mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Added operation persistance logic & refactored the code
This commit is contained in:
parent
dd9bfdb6a7
commit
193eca9e2d
@ -48,20 +48,20 @@ public interface FeaturePropertyDAO {
|
||||
/**
|
||||
* Delete a given feature property from feature property table.
|
||||
*
|
||||
* @param propertyId Id of the feature property to be deleted.
|
||||
* @param property Property of the feature property to be deleted.
|
||||
* @return The status of the operation. If the operationId was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteFeatureProperty(int propertyId) throws MobileDeviceManagementDAOException;
|
||||
boolean deleteFeatureProperty(String property) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given feature property from feature property table.
|
||||
*
|
||||
* @param propertyId Id 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.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
FeatureProperty getFeatureProperty(int propertyId) throws MobileDeviceManagementDAOException;
|
||||
FeatureProperty getFeatureProperty(String property) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a list of feature property corresponds to a feature id .
|
||||
|
||||
@ -25,14 +25,14 @@ import java.util.List;
|
||||
*/
|
||||
public interface MobileDeviceDAO {
|
||||
|
||||
MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException;
|
||||
MobileDevice getMobileDevice(String deviceId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
boolean addDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
|
||||
boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
|
||||
|
||||
boolean updateDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
|
||||
boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
|
||||
|
||||
boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException;
|
||||
boolean deleteMobileDevice(String deviceId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
List<MobileDevice> getAllDevices() throws MobileDeviceManagementDAOException;
|
||||
List<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException;
|
||||
|
||||
}
|
||||
|
||||
@ -53,16 +53,16 @@ public class MobileDeviceManagementDAOFactory implements DataSourceListener {
|
||||
return new MobileDeviceDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static OperationDAO getOperationDAO() {
|
||||
return new OperationDAOImpl(dataSource);
|
||||
public static MobileOperationDAO getMobileOperationDAO() {
|
||||
return new MobileOperationDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static OperationPropertyDAO geOperationPropertyDAO() {
|
||||
return new OperationPropertyDAOImpl(dataSource);
|
||||
public static MobileOperationPropertyDAO getMobileOperationPropertyDAO() {
|
||||
return new MobileOperationPropertyDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static DeviceOperationDAO getDeviceOperationDAO() {
|
||||
return new DeviceOperationDAOImpl(dataSource);
|
||||
public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() {
|
||||
return new MobileDeviceOperationDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static FeatureDAO getFeatureDAO() {
|
||||
|
||||
@ -16,14 +16,14 @@
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents the mapping between device and operations.
|
||||
*/
|
||||
public interface DeviceOperationDAO {
|
||||
public interface MobileDeviceOperationDAO {
|
||||
/**
|
||||
* Add a new mapping to plugin device_operation table.
|
||||
*
|
||||
@ -32,7 +32,7 @@ public interface DeviceOperationDAO {
|
||||
* @return The status of the operation. If the insert was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean addDeviceOperation(DeviceOperation deviceOperation)
|
||||
boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -42,7 +42,7 @@ public interface DeviceOperationDAO {
|
||||
* @return The status of the operation. If the update was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean updateDeviceOperation(DeviceOperation deviceOperation)
|
||||
boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -53,7 +53,7 @@ public interface DeviceOperationDAO {
|
||||
* @return The status of the operation. If the deletion was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteDeviceOperation(String deviceId, int operationId)
|
||||
boolean deleteMobileDeviceOperation(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -65,7 +65,7 @@ public interface DeviceOperationDAO {
|
||||
* deviceId and operationId.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
DeviceOperation getDeviceOperation(String deviceId, int operationId)
|
||||
MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -74,6 +74,6 @@ public interface DeviceOperationDAO {
|
||||
* @return Device operation mapping object list.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
List<DeviceOperation> getAllDeviceOperationOfDevice(String deviceId)
|
||||
List<MobileDeviceOperation> getAllMobileDeviceOperationsOfDevice(String deviceId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
}
|
||||
@ -16,46 +16,44 @@
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
|
||||
|
||||
import java.util.List;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
|
||||
/**
|
||||
* This class represents the key operations associated with persisting operation related
|
||||
* information.
|
||||
*/
|
||||
public interface OperationDAO {
|
||||
public interface MobileOperationDAO {
|
||||
|
||||
/**
|
||||
* Add a new operation to plugin operation table.
|
||||
* Add a new Mobile operation to plugin operation table.
|
||||
* @param operation Operation object that holds data related to the operation to be inserted.
|
||||
* @return The last inserted Id is returned, if the insertion was unsuccessful -1 is returned.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
int addOperation(Operation operation) throws MobileDeviceManagementDAOException;
|
||||
int addMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Update a operation in the operation table.
|
||||
* Update a Mobile operation in the operation table.
|
||||
* @param operation Operation object that holds data has to be updated.
|
||||
* @return The status of the operation. If the update was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean updateOperation(Operation operation) throws MobileDeviceManagementDAOException;
|
||||
boolean updateMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Delete a given operation from plugin database.
|
||||
* Delete a given Mobile operation from plugin database.
|
||||
* @param operationId Operation code of the operation to be deleted.
|
||||
* @return The status of the operation. If the operationId was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
boolean deleteMobileOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given operation from plugin database.
|
||||
* Retrieve a given Mobile operation from plugin database.
|
||||
* @param operationId Operation id of the operation to be retrieved.
|
||||
* @return Operation object that holds data of the feature represented by operationId.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
Operation getOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
MobileOperation getMobileOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -24,15 +24,16 @@ import java.util.List;
|
||||
* This class represents the key operations associated with persisting operation property related
|
||||
* information.
|
||||
*/
|
||||
public interface OperationPropertyDAO {
|
||||
public interface MobileOperationPropertyDAO {
|
||||
/**
|
||||
* Add a new mapping to plugin operation property table.
|
||||
*
|
||||
* @param operationProperty OperationProperty object that holds data related to the operation property to be inserted.
|
||||
* @param operationProperty OperationProperty object that holds data related to the operation
|
||||
* property to be inserted.
|
||||
* @return The status of the operation. If the insert was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean addOperationProperty(OperationProperty operationProperty)
|
||||
boolean addMobileOperationProperty(MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -42,36 +43,38 @@ public interface OperationPropertyDAO {
|
||||
* @return The status of the operation. If the update was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean updateOperationProperty(OperationProperty operationProperty)
|
||||
boolean updateMobileOperationProperty(MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Delete a given device operation from plugin database.
|
||||
* Deletes mobile operation properties of a given operation id from the plugin database.
|
||||
*
|
||||
* @param operationPropertyId Device id of the mapping to be deleted.
|
||||
* @param operationId Operation id of the mapping to be deleted.
|
||||
* @return The status of the operation. If the deletion was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteOperationProperty(int operationPropertyId)
|
||||
boolean deleteMobileOperationProperties(int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given device operation from plugin database.
|
||||
* Retrieve a given mobile operation property from plugin database.
|
||||
*
|
||||
* @param deviceId Device id of the mapping to be retrieved.
|
||||
* @param operationId Operation id of the mapping to be retrieved.
|
||||
* @return DeviceOperation object that holds data of the device operation mapping represented by deviceId and operationId.
|
||||
* @param property Property of the mapping to be retrieved.
|
||||
* @return DeviceOperation object that holds data of the device operation mapping represented by
|
||||
* deviceId and operationId.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
OperationProperty getOperationProperty(String deviceId, int operationId)
|
||||
MobileOperationProperty getMobileOperationProperty(int operationId, String property)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve all the device operation mapping from plugin database.
|
||||
* Retrieve all the mobile operation properties related to the a operation id.
|
||||
*
|
||||
* @param operationId Operation id of the mapping to be retrieved.
|
||||
* @return Device operation mapping object list.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
List<OperationProperty> getAllDeviceOperationOfDevice(String deviceId)
|
||||
List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
}
|
||||
@ -32,7 +32,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of FeatureDAO
|
||||
* Implementation of FeatureDAO.
|
||||
*/
|
||||
public class FeatureDAOImpl implements FeatureDAO {
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of FeaturePropertyDAO
|
||||
* Implementation of FeaturePropertyDAO.
|
||||
*/
|
||||
public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
|
||||
@ -81,18 +81,17 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String updateDBQuery =
|
||||
"UPDATE MBL_FEATURE_PROPERTY SET PROPERTY = ?, FEATURE_ID = ? WHERE PROPERTY_ID = ?";
|
||||
"UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?";
|
||||
stmt = conn.prepareStatement(updateDBQuery);
|
||||
stmt.setString(1, featureProperty.getProperty());
|
||||
stmt.setString(2, featureProperty.getFeatureID());
|
||||
stmt.setInt(3, featureProperty.getPropertyId());
|
||||
stmt.setString(1, featureProperty.getFeatureID());
|
||||
stmt.setString(2, featureProperty.getProperty());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while updating the feature property with property id - '" +
|
||||
featureProperty.getPropertyId() + "'";
|
||||
String msg = "Error occurred while updating the feature property with property - '" +
|
||||
featureProperty.getProperty() + "'";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -102,7 +101,7 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteFeatureProperty(int propertyId)
|
||||
public boolean deleteFeatureProperty(String property)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -110,16 +109,16 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String deleteDBQuery =
|
||||
"DELETE FROM MBL_FEATURE_PROPERTY WHERE PROPERTY_ID = ?";
|
||||
"DELETE FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?";
|
||||
stmt = conn.prepareStatement(deleteDBQuery);
|
||||
stmt.setInt(1, propertyId);
|
||||
stmt.setString(1, property);
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while deleting feature property with property Id - " +
|
||||
propertyId;
|
||||
String msg = "Error occurred while deleting feature property with property - " +
|
||||
property;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -129,7 +128,7 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureProperty getFeatureProperty(int propertyId)
|
||||
public FeatureProperty getFeatureProperty(String property)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
@ -137,9 +136,9 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY_ID = ?";
|
||||
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setInt(1, propertyId);
|
||||
stmt.setString(1, property);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
featureProperty = new FeatureProperty();
|
||||
@ -148,8 +147,8 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while fetching property Id - '" +
|
||||
propertyId + "'";
|
||||
String msg = "Error occurred while fetching property - '" +
|
||||
property + "'";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -168,15 +167,14 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT PROPERTY_ID,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.setString(1, featureId);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
featureProperty = new FeatureProperty();
|
||||
featureProperty.setPropertyId(resultSet.getInt(1));
|
||||
featureProperty.setProperty(resultSet.getString(2));
|
||||
featureProperty.setFeatureID(resultSet.getString(3));
|
||||
featureProperty.setProperty(resultSet.getString(1));
|
||||
featureProperty.setFeatureID(resultSet.getString(2));
|
||||
FeatureProperties.add(featureProperty);
|
||||
}
|
||||
return FeatureProperties;
|
||||
|
||||
@ -44,7 +44,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
||||
public MobileDevice getMobileDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
MobileDevice mobileDevice = null;
|
||||
@ -80,7 +80,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDevice(MobileDevice mobileDevice)
|
||||
public boolean addMobileDevice(MobileDevice mobileDevice)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -106,8 +106,8 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while enrolling mobile device '" +
|
||||
mobileDevice.getMobileDeviceId() + "'";
|
||||
String msg = "Error occurred while adding the mobile device '" +
|
||||
mobileDevice.getMobileDeviceId() + "' to the mobile db.";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -117,7 +117,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDevice(MobileDevice mobileDevice)
|
||||
public boolean updateMobileDevice(MobileDevice mobileDevice)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -153,7 +153,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
||||
public boolean deleteMobileDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
@ -178,7 +178,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobileDevice> getAllDevices() throws MobileDeviceManagementDAOException {
|
||||
public List<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
MobileDevice mobileDevice;
|
||||
|
||||
@ -18,10 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.DeviceOperationDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceOperationDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
@ -32,19 +32,19 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of DeviceOperationDAO
|
||||
* Implementation of MobileDeviceOperationDAO.
|
||||
*/
|
||||
public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO {
|
||||
|
||||
private DataSource dataSource;
|
||||
private static final Log log = LogFactory.getLog(DeviceOperationDAOImpl.class);
|
||||
private static final Log log = LogFactory.getLog(MobileDeviceOperationDAOImpl.class);
|
||||
|
||||
public DeviceOperationDAOImpl(DataSource dataSource) {
|
||||
public MobileDeviceOperationDAOImpl(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDeviceOperation(DeviceOperation deviceOperation)
|
||||
public boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -66,7 +66,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while adding device id - '" +
|
||||
deviceOperation.getDeviceId() + " and operation id - " +
|
||||
deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";
|
||||
deviceOperation.getOperationId() +
|
||||
" to mapping table MBL_DEVICE_OPERATION";
|
||||
;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -77,7 +78,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDeviceOperation(DeviceOperation deviceOperation)
|
||||
public boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -85,7 +86,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String updateDBQuery =
|
||||
"UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? and OPERATION_ID=?";
|
||||
"UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||
stmt = conn.prepareStatement(updateDBQuery);
|
||||
stmt.setLong(1, deviceOperation.getSentDate());
|
||||
stmt.setLong(2, deviceOperation.getReceivedDate());
|
||||
@ -98,7 +99,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while updating device id - '" +
|
||||
deviceOperation.getDeviceId() + " and operation id - " +
|
||||
deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";
|
||||
deviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -108,7 +109,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDeviceOperation(String deviceId, int operationId)
|
||||
public boolean deleteMobileDeviceOperation(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -116,7 +117,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String deleteDBQuery =
|
||||
"DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? and OPERATION_ID=?";
|
||||
"DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||
stmt = conn.prepareStatement(deleteDBQuery);
|
||||
stmt.setString(1, deviceId);
|
||||
stmt.setInt(2, operationId);
|
||||
@ -126,7 +127,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while deleting mapping table MBL_DEVICE_OPERATION with device id - '" +
|
||||
"Error occurred while deleting the table entry MBL_DEVICE_OPERATION with device id - '" +
|
||||
deviceId + " and operation id - " + operationId;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -137,21 +138,21 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceOperation getDeviceOperation(String deviceId, int operationId)
|
||||
public MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
DeviceOperation deviceOperation = null;
|
||||
MobileDeviceOperation deviceOperation = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? and OPERATION_ID=?";
|
||||
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setString(1, deviceId);
|
||||
stmt.setInt(2, operationId);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
deviceOperation = new DeviceOperation();
|
||||
deviceOperation = new MobileDeviceOperation();
|
||||
deviceOperation.setDeviceId(resultSet.getString(1));
|
||||
deviceOperation.setOperationId(resultSet.getInt(2));
|
||||
deviceOperation.setSentDate(resultSet.getInt(3));
|
||||
@ -160,7 +161,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while fetching mapping 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;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -171,12 +172,12 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceOperation> getAllDeviceOperationOfDevice(String deviceId)
|
||||
public List<MobileDeviceOperation> getAllMobileDeviceOperationsOfDevice(String deviceId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
DeviceOperation deviceOperation = null;
|
||||
List<DeviceOperation> deviceOperations = new ArrayList<DeviceOperation>();
|
||||
MobileDeviceOperation deviceOperation = null;
|
||||
List<MobileDeviceOperation> deviceOperations = new ArrayList<MobileDeviceOperation>();
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
@ -185,17 +186,16 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
stmt.setString(1, deviceId);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
deviceOperation = new DeviceOperation();
|
||||
deviceOperation = new MobileDeviceOperation();
|
||||
deviceOperation.setDeviceId(resultSet.getString(1));
|
||||
deviceOperation.setOperationId(resultSet.getInt(2));
|
||||
deviceOperation.setSentDate(resultSet.getInt(3));
|
||||
deviceOperation.setReceivedDate(resultSet.getInt(4));
|
||||
deviceOperations.add(deviceOperation);
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" +
|
||||
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of device id - '" +
|
||||
deviceId;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -19,9 +19,9 @@ package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.OperationDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileOperationDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
@ -30,19 +30,19 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Implementation of OperationDAO
|
||||
* Implementation of MobileOperationDAO.
|
||||
*/
|
||||
public class OperationDAOImpl implements OperationDAO {
|
||||
public class MobileOperationDAOImpl implements MobileOperationDAO {
|
||||
|
||||
private DataSource dataSource;
|
||||
private static final Log log = LogFactory.getLog(OperationDAOImpl.class);
|
||||
private static final Log log = LogFactory.getLog(MobileOperationDAOImpl.class);
|
||||
|
||||
public OperationDAOImpl(DataSource dataSource) {
|
||||
public MobileOperationDAOImpl(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addOperation(Operation operation)
|
||||
public int addMobileOperation(MobileOperation operation)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
int status = -1;
|
||||
Connection conn = null;
|
||||
@ -51,7 +51,6 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
conn = this.getConnection();
|
||||
String createDBQuery =
|
||||
"INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)";
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery, new String[] { "OPERATION_ID" });
|
||||
stmt.setString(1, operation.getFeatureCode());
|
||||
stmt.setLong(2, operation.getCreatedDate());
|
||||
@ -63,8 +62,8 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while adding feature code - '" +
|
||||
operation.getFeatureCode() + "' to operations table";
|
||||
String msg = "Error occurred while adding the operation - '" +
|
||||
operation.getFeatureCode() + "' to MBL_OPERATION table";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -74,7 +73,7 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateOperation(Operation operation)
|
||||
public boolean updateMobileOperation(MobileOperation operation)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -92,7 +91,7 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while updating the operation with operation id - '" +
|
||||
String msg = "Error occurred while updating the MBL_OPERATION table entry with operation id - '" +
|
||||
operation.getOperationId() + "'";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -103,7 +102,7 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteOperation(int operationId)
|
||||
public boolean deleteMobileOperation(int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -119,7 +118,7 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while deleting operation with operation Id - ";
|
||||
String msg = "Error occurred while deleting MBL_OPERATION entry with operation Id - ";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -129,11 +128,11 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperation(int operationId)
|
||||
public MobileOperation getMobileOperation(int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
Operation operation = null;
|
||||
MobileOperation operation = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
@ -142,13 +141,13 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
stmt.setInt(1, operation.getOperationId());
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
operation = new Operation();
|
||||
operation = new MobileOperation();
|
||||
operation.setOperationId(resultSet.getInt(1));
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while fetching operationId - '" +
|
||||
operationId + "'";
|
||||
operationId + "' from MBL_OPERATION";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* 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.dao.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
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.util.MobileDeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of MobileOperationPropertyDAO.
|
||||
*/
|
||||
public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDAO {
|
||||
|
||||
private DataSource dataSource;
|
||||
private static final Log log = LogFactory.getLog(MobileOperationPropertyDAOImpl.class);
|
||||
|
||||
public MobileOperationPropertyDAOImpl(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addMobileOperationProperty(MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String createDBQuery =
|
||||
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) VALUES ( ?, ?, ?)";
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setInt(1, operationProperty.getOperationId());
|
||||
stmt.setString(2, operationProperty.getProperty());
|
||||
stmt.setString(3, operationProperty.getValue());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while adding mobile operation property to MBL_OPERATION_PROPERTY table";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateMobileOperationProperty(
|
||||
MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String createDBQuery =
|
||||
"UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND PROPERTY = ?";
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setString(1, operationProperty.getValue());
|
||||
stmt.setInt(2, operationProperty.getOperationId());
|
||||
stmt.setString(3, operationProperty.getProperty());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while updating the mobile operation property in MBL_OPERATION_PROPERTY table.";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteMobileOperationProperties(int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String deleteDBQuery =
|
||||
"DELETE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
|
||||
stmt = conn.prepareStatement(deleteDBQuery);
|
||||
stmt.setInt(1, operationId);
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while deleting MBL_OPERATION_PROPERTY entry with operation Id - ";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MobileOperationProperty getMobileOperationProperty(int operationId,
|
||||
String property)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
MobileOperationProperty mobileOperationProperty = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ? AND PROPERTY = ?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setInt(1, operationId);
|
||||
stmt.setString(2, property);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
mobileOperationProperty = new MobileOperationProperty();
|
||||
mobileOperationProperty.setOperationId(resultSet.getInt(1));
|
||||
mobileOperationProperty.setProperty(resultSet.getString(2));
|
||||
mobileOperationProperty.setValue(resultSet.getString(3));
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while fetching the mobile operation property of Operation_id : " +
|
||||
operationId + " and Property : " + property;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return mobileOperationProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(
|
||||
int operationId) throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
MobileOperationProperty mobileOperationProperty = null;
|
||||
List<MobileOperationProperty> properties = new ArrayList<MobileOperationProperty>();
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setInt(1, operationId);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
mobileOperationProperty = new MobileOperationProperty();
|
||||
mobileOperationProperty.setOperationId(resultSet.getInt(1));
|
||||
mobileOperationProperty.setProperty(resultSet.getString(2));
|
||||
mobileOperationProperty.setValue(resultSet.getString(3));
|
||||
properties.add(mobileOperationProperty);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while fetching the mobile operation properties of Operation_id " +
|
||||
operationId;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
private Connection getConnection() throws MobileDeviceManagementDAOException {
|
||||
try {
|
||||
return dataSource.getConnection();
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while obtaining a connection from the mobile device " +
|
||||
"management metadata repository datasource.";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* 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.dao.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.OperationPropertyDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of OperationPropertyDAO
|
||||
*/
|
||||
public class OperationPropertyDAOImpl implements OperationPropertyDAO {
|
||||
|
||||
private DataSource dataSource;
|
||||
private static final Log log = LogFactory.getLog(OperationPropertyDAOImpl.class);
|
||||
|
||||
public OperationPropertyDAOImpl(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addOperationProperty(OperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String createDBQuery =
|
||||
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY_ID, VALUE) VALUES ( ?, ?, ?)";
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setInt(1, operationProperty.getOperationId());
|
||||
stmt.setInt(2, operationProperty.getPropertyId());
|
||||
stmt.setString(3, operationProperty.getValue());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while adding feature property to operation property table";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override public boolean updateOperationProperty(OperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean deleteOperationProperty(int operationPropertyId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public OperationProperty getOperationProperty(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public List<OperationProperty> getAllDeviceOperationOfDevice(String deviceId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Connection getConnection() throws MobileDeviceManagementDAOException {
|
||||
try {
|
||||
return dataSource.getConnection();
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while obtaining a connection from the mobile device " +
|
||||
"management metadata repository datasource.";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
*/
|
||||
public class FeatureProperty {
|
||||
|
||||
private int propertyId;
|
||||
private String property;
|
||||
private String featureID;
|
||||
|
||||
@ -33,14 +32,6 @@ public class FeatureProperty {
|
||||
this.featureID = featureID;
|
||||
}
|
||||
|
||||
public int getPropertyId() {
|
||||
return propertyId;
|
||||
}
|
||||
|
||||
public void setPropertyId(int propertyId) {
|
||||
this.propertyId = propertyId;
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
@ -17,9 +17,9 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
|
||||
/**
|
||||
* DTO of Operations.
|
||||
* DTO of Mobile Device Operations.
|
||||
*/
|
||||
public class DeviceOperation {
|
||||
public class MobileDeviceOperation {
|
||||
|
||||
private String deviceId;
|
||||
private int operationId;
|
||||
@ -19,14 +19,14 @@ package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DTO of operation.
|
||||
* DTO of MobileOperation.
|
||||
*/
|
||||
public class Operation {
|
||||
public class MobileOperation {
|
||||
|
||||
private int operationId;
|
||||
private String featureCode;
|
||||
private long createdDate;
|
||||
private List<OperationProperty> properties;
|
||||
private List<MobileOperationProperty> properties;
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
@ -36,11 +36,11 @@ public class Operation {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public List<OperationProperty> getProperties() {
|
||||
public List<MobileOperationProperty> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<OperationProperty> properties) {
|
||||
public void setProperties(List<MobileOperationProperty> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@ -17,13 +17,12 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
|
||||
/**
|
||||
* DTO of operation property.
|
||||
* DTO of Mobile Operation property.
|
||||
*/
|
||||
public class OperationProperty {
|
||||
public class MobileOperationProperty {
|
||||
|
||||
private int operationPropertyId;
|
||||
private int operationId;
|
||||
private int propertyId;
|
||||
private String property;
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
@ -34,14 +33,6 @@ public class OperationProperty {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getOperationPropertyId() {
|
||||
return operationPropertyId;
|
||||
}
|
||||
|
||||
public void setOperationPropertyId(int operationPropertyId) {
|
||||
this.operationPropertyId = operationPropertyId;
|
||||
}
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
}
|
||||
@ -50,12 +41,12 @@ public class OperationProperty {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public int getPropertyId() {
|
||||
return propertyId;
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setPropertyId(int propertyId) {
|
||||
this.propertyId = propertyId;
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
}
|
||||
@ -50,7 +50,8 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
boolean status;
|
||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||
try {
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addDevice(mobileDevice);
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
|
||||
mobileDevice);
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while enrolling the Android device : " +
|
||||
device.getDeviceIdentifier();
|
||||
@ -66,7 +67,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||
try {
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||
.updateDevice(mobileDevice);
|
||||
.updateMobileDevice(mobileDevice);
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while updating the enrollment of the Android device : " +
|
||||
device.getDeviceIdentifier();
|
||||
@ -81,7 +82,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
boolean status;
|
||||
try {
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||
.deleteDevice(deviceId.getId());
|
||||
.deleteMobileDevice(deviceId.getId());
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while removing the Android device : " + deviceId.getId();
|
||||
log.error(msg, e);
|
||||
@ -95,7 +96,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
boolean isEnrolled = false;
|
||||
try {
|
||||
MobileDevice mobileDevice =
|
||||
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getDevice(
|
||||
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
|
||||
deviceId.getId());
|
||||
if (mobileDevice != null) {
|
||||
isEnrolled = true;
|
||||
@ -125,7 +126,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
Device device;
|
||||
try {
|
||||
MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
||||
getDevice(deviceId.getId());
|
||||
getMobileDevice(deviceId.getId());
|
||||
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while fetching the Android device : " + deviceId.getId();
|
||||
@ -147,7 +148,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||
try {
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||
.updateDevice(mobileDevice);
|
||||
.updateMobileDevice(mobileDevice);
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while updating the Android device : " + device.getDeviceIdentifier();
|
||||
log.error(msg, e);
|
||||
@ -162,7 +163,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
try {
|
||||
List<MobileDevice> mobileDevices =
|
||||
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
||||
getAllDevices();
|
||||
getAllMobileDevices();
|
||||
if (mobileDevices != null) {
|
||||
devices = new ArrayList<Device>();
|
||||
for (MobileDevice mobileDevice : mobileDevices) {
|
||||
|
||||
@ -18,15 +18,17 @@ package org.wso2.carbon.device.mgt.mobile.impl.android;
|
||||
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.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.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.DeviceOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
||||
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.List;
|
||||
|
||||
public class AndroidMobileOperationManager extends AbstractMobileOperationManager {
|
||||
@ -36,26 +38,67 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
||||
@Override
|
||||
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
|
||||
OperationManagementException {
|
||||
boolean status = false;
|
||||
try {
|
||||
MobileDeviceManagementDAOFactory.getOperationDAO().addOperation(
|
||||
new org.wso2.carbon.device.mgt.mobile.dto.Operation());
|
||||
MobileDeviceManagementDAOFactory.geOperationPropertyDAO()
|
||||
.addOperationProperty(new OperationProperty());
|
||||
MobileDeviceManagementDAOFactory.getDeviceOperationDAO()
|
||||
.addDeviceOperation(new DeviceOperation());
|
||||
MobileDeviceOperation mobileDeviceOperation = null;
|
||||
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) {
|
||||
mobileDeviceOperation = new MobileDeviceOperation();
|
||||
mobileDeviceOperation.setOperationId(operationId);
|
||||
mobileDeviceOperation.setDeviceId(deviceIdentifier.getId());
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||
.addMobileDeviceOperation(
|
||||
new MobileDeviceOperation());
|
||||
}
|
||||
}
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while updating the enrollment of the Android device : " +
|
||||
devices.get(0).getId();
|
||||
String msg =
|
||||
"Error while adding an operation " + operation.getCode() + "to Android devices";
|
||||
log.error(msg, e);
|
||||
throw new OperationManagementException(msg, e);
|
||||
}
|
||||
return false;
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
|
||||
throws OperationManagementException {
|
||||
return null;
|
||||
List<Operation> operations = new ArrayList<Operation>();
|
||||
List<MobileDeviceOperation> mobileDeviceOperations = null;
|
||||
MobileOperation mobileOperation = null;
|
||||
try {
|
||||
mobileDeviceOperations = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||
.getAllMobileDeviceOperationsOfDevice(
|
||||
deviceIdentifier
|
||||
.getId());
|
||||
if (mobileDeviceOperations.size() > 0) {
|
||||
List<Integer> operationIds = MobileDeviceManagementUtil
|
||||
.getMobileOperationIdsFromMobileDeviceOperations(mobileDeviceOperations);
|
||||
for (Integer operationId : operationIds) {
|
||||
mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
|
||||
.getMobileOperation(
|
||||
operationId);
|
||||
operations.add(MobileDeviceManagementUtil
|
||||
.convertMobileOperationToOperation(mobileOperation));
|
||||
}
|
||||
}
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg =
|
||||
"Error while fetching the operations for the android device " +
|
||||
deviceIdentifier.getId();
|
||||
log.error(msg, e);
|
||||
throw new OperationManagementException(msg, e);
|
||||
}
|
||||
return operations;
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,9 +21,11 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.Operation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
@ -69,7 +71,7 @@ public class MobileDeviceManagementUtil {
|
||||
|
||||
private static Device.Property getProperty(String property, String value) {
|
||||
Device.Property prop = null;
|
||||
if(property != null){
|
||||
if (property != null) {
|
||||
prop = new Device.Property();
|
||||
prop.setName(property);
|
||||
prop.setValue(value);
|
||||
@ -89,40 +91,66 @@ public class MobileDeviceManagementUtil {
|
||||
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
|
||||
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
|
||||
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
|
||||
mobileDevice.setLatitude(getPropertyValue(device,MOBILE_DEVICE_LATITUDE));
|
||||
mobileDevice.setLongitude(getPropertyValue(device,MOBILE_DEVICE_LONGITUDE));
|
||||
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
|
||||
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
|
||||
}
|
||||
return mobileDevice;
|
||||
}
|
||||
|
||||
public static Device convertToDevice(MobileDevice mobileDevice) {
|
||||
Device device = null;
|
||||
if(mobileDevice!=null){
|
||||
if (mobileDevice != null) {
|
||||
device = new Device();
|
||||
List<Device.Property> propertyList = new ArrayList<Device.Property>();
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_IMEI,mobileDevice.getImei()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_IMSI,mobileDevice.getImsi()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_REG_ID,mobileDevice.getRegId()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_MODEL,mobileDevice.getModel()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION,mobileDevice.getOsVersion()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR,mobileDevice.getVendor()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE,mobileDevice.getLatitude()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE,mobileDevice.getLongitude()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_REG_ID, mobileDevice.getRegId()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude()));
|
||||
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
|
||||
device.setProperties(propertyList);
|
||||
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
public static Operation convertToOperation(org.wso2.carbon.device.mgt.common.Operation operation){
|
||||
Operation mobileOperation = new Operation();
|
||||
List<OperationProperty> properties = new LinkedList<OperationProperty>();
|
||||
public static MobileOperation convertToMobileOperation(
|
||||
org.wso2.carbon.device.mgt.common.Operation operation) {
|
||||
MobileOperation mobileOperation = new MobileOperation();
|
||||
MobileOperationProperty operationProperty = null;
|
||||
List<MobileOperationProperty> properties = new LinkedList<MobileOperationProperty>();
|
||||
mobileOperation.setFeatureCode(operation.getCode());
|
||||
mobileOperation.setCreatedDate(new Date().getTime());
|
||||
Properties operationProperties = operation.getProperties();
|
||||
for(String key : operationProperties.stringPropertyNames()) {
|
||||
String value = operationProperties.getProperty(key);
|
||||
for (String key : operationProperties.stringPropertyNames()) {
|
||||
operationProperty = new MobileOperationProperty();
|
||||
operationProperty.setProperty(key);
|
||||
operationProperty.setValue(operationProperties.getProperty(key));
|
||||
properties.add(operationProperty);
|
||||
}
|
||||
mobileOperation.setProperties(properties);
|
||||
return mobileOperation;
|
||||
}
|
||||
|
||||
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
|
||||
List<MobileDeviceOperation> mobileDeviceOperations) {
|
||||
List<Integer> mobileOperationIds = new ArrayList<Integer>();
|
||||
for(MobileDeviceOperation mobileDeviceOperation:mobileDeviceOperations){
|
||||
mobileOperationIds.add(mobileDeviceOperation.getOperationId());
|
||||
}
|
||||
return mobileOperationIds;
|
||||
}
|
||||
|
||||
public static Operation convertMobileOperationToOperation(MobileOperation mobileOperation){
|
||||
Operation operation = new Operation();
|
||||
Properties properties = new Properties();
|
||||
operation.setCode(mobileOperation.getFeatureCode());
|
||||
for(MobileOperationProperty mobileOperationProperty:mobileOperation.getProperties()){
|
||||
properties.put(mobileOperationProperty.getProperty(),mobileOperationProperty.getValue());
|
||||
}
|
||||
operation.setProperties(properties);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`CODE` VARCHAR(45) NULL ,
|
||||
`CODE` VARCHAR(45) NOT NULL ,
|
||||
`NAME` VARCHAR(100) NULL ,
|
||||
`DESCRIPTION` VARCHAR(200) NULL ,
|
||||
PRIMARY KEY (`FEATURE_ID`) );
|
||||
@ -30,7 +30,7 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`FEATURE_CODE` VARCHAR(45) NULL ,
|
||||
`FEATURE_CODE` VARCHAR(45) NOT NULL ,
|
||||
`CREATED_DATE` INT NULL ,
|
||||
PRIMARY KEY (`OPERATION_ID`) ,
|
||||
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
|
||||
@ -40,9 +40,9 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||
ON UPDATE NO ACTION);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_DEVICE_OPERATION_MAPING`
|
||||
-- Table `MBL_DEVICE_OPERATION_MAPPING`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
|
||||
`DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||
`OPERATION_ID` INT NOT NULL ,
|
||||
`SENT_DATE` INT NULL ,
|
||||
@ -63,11 +63,10 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
|
||||
-- Table `MBL_OPERATION_PROPERTY`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
||||
`OPERATION_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`OPERATION_ID` INT NULL ,
|
||||
`PROPERTY_ID` INT NULL ,
|
||||
`OPERATION_ID` INT NOT NULL ,
|
||||
`PROPERTY` VARCHAR(45) NOT NULL ,
|
||||
`VALUE` TEXT NULL ,
|
||||
PRIMARY KEY (`OPERATION_PROPERTY_ID`) ,
|
||||
PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) ,
|
||||
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
|
||||
FOREIGN KEY (`OPERATION_ID` )
|
||||
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
|
||||
@ -78,13 +77,11 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
||||
-- Table `MBL_FEATURE_PROPERTY`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
|
||||
`PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`PROPERTY` VARCHAR(100) NULL ,
|
||||
`FEATURE_ID` VARCHAR(45) NULL ,
|
||||
PRIMARY KEY (`PROPERTY_ID`) ,
|
||||
`PROPERTY` VARCHAR(45) NOT NULL ,
|
||||
`FEATURE_ID` VARCHAR(45) NOT NULL ,
|
||||
PRIMARY KEY (`PROPERTY`) ,
|
||||
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
|
||||
FOREIGN KEY (`FEATURE_ID` )
|
||||
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION);
|
||||
|
||||
|
||||
@ -3,12 +3,14 @@
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
||||
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL,
|
||||
`REG_ID` VARCHAR(45) NULL,
|
||||
`IMEI` VARCHAR(45) NULL,
|
||||
`IMSI` VARCHAR(45) NULL,
|
||||
`OS_VERSION` VARCHAR(45) NULL,
|
||||
`DEVICE_MODEL` VARCHAR(45) NULL,
|
||||
`VENDOR` VARCHAR(45) NULL,
|
||||
`REG_ID` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`IMEI` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`IMSI` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`VENDOR` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`MOBILE_DEVICE_ID`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
@ -16,50 +18,44 @@ ENGINE = InnoDB;
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_FEATURE`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`CODE` VARCHAR(45) NULL ,
|
||||
`NAME` VARCHAR(100) NULL ,
|
||||
`DESCRIPTION` VARCHAR(200) NULL ,
|
||||
PRIMARY KEY (`FEATURE_ID`) )
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT,
|
||||
`CODE` VARCHAR(45) NULL,
|
||||
`NAME` VARCHAR(100) NULL,
|
||||
`DESCRIPTION` VARCHAR(200) NULL,
|
||||
PRIMARY KEY (`FEATURE_ID`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_OPERATION`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`FEATURE_CODE` VARCHAR(45) NULL ,
|
||||
`CREATED_DATE` INT NULL ,
|
||||
PRIMARY KEY (`OPERATION_ID`) ,
|
||||
INDEX `fk_MBL_OPERATION_MBL_FEATURES1_idx` (`FEATURE_CODE` ASC) ,
|
||||
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
|
||||
FOREIGN KEY (`FEATURE_CODE` )
|
||||
REFERENCES `MBL_FEATURE` (`CODE` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT,
|
||||
`FEATURE_CODE` VARCHAR(45) NULL,
|
||||
`CREATED_DATE` INT NULL,
|
||||
PRIMARY KEY (`OPERATION_ID`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_DEVICE_OPERATION_MAPING`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
|
||||
`DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||
`OPERATION_ID` INT NOT NULL ,
|
||||
`SENT_DATE` INT NULL ,
|
||||
`RECEIVED_DATE` INT NULL ,
|
||||
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`) ,
|
||||
INDEX `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1_idx` (`OPERATION_ID` ASC) ,
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
|
||||
`DEVICE_ID` VARCHAR(45) NOT NULL,
|
||||
`OPERATION_ID` INT NOT NULL,
|
||||
`SENT_DATE` INT NULL,
|
||||
`RECEIVED_DATE` INT NULL,
|
||||
PRIMARY KEY (`DEVICE_ID`, `OPERATION_ID`),
|
||||
INDEX `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1_idx` (`OPERATION_ID` ASC),
|
||||
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_DEVICE`
|
||||
FOREIGN KEY (`DEVICE_ID` )
|
||||
REFERENCES `MBL_DEVICE` (`MOBILE_DEVICE_ID` )
|
||||
FOREIGN KEY (`DEVICE_ID`)
|
||||
REFERENCES `MBL_DEVICE` (`MOBILE_DEVICE_ID`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION,
|
||||
CONSTRAINT `fk_MBL_DEVICE_OPERATION_MBL_OPERATION1`
|
||||
FOREIGN KEY (`OPERATION_ID` )
|
||||
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
|
||||
FOREIGN KEY (`OPERATION_ID`)
|
||||
REFERENCES `MBL_OPERATION` (`OPERATION_ID`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
@ -68,16 +64,16 @@ ENGINE = InnoDB;
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_OPERATION_PROPERTY`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
||||
`OPERATION_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`OPERATION_ID` INT NULL ,
|
||||
`PROPERTY_ID` INT NULL ,
|
||||
`VALUE` TEXT NULL ,
|
||||
PRIMARY KEY (`OPERATION_PROPERTY_ID`) ,
|
||||
INDEX `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1_idx` (`OPERATION_ID` ASC) ,
|
||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
||||
`OPERATION_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT,
|
||||
`OPERATION_ID` INT NULL,
|
||||
`PROPERTY_ID` INT NULL,
|
||||
`VALUE` TEXT NULL,
|
||||
PRIMARY KEY (`OPERATION_PROPERTY_ID`),
|
||||
INDEX `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1_idx` (`OPERATION_ID` ASC),
|
||||
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
|
||||
FOREIGN KEY (`OPERATION_ID` )
|
||||
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
|
||||
FOREIGN KEY (`OPERATION_ID`)
|
||||
REFERENCES `MBL_OPERATION` (`OPERATION_ID`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
@ -86,15 +82,15 @@ ENGINE = InnoDB;
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_FEATURE_PROPERTY`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
|
||||
`PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`PROPERTY` VARCHAR(100) NULL ,
|
||||
`FEATURE_ID` VARCHAR(45) NULL ,
|
||||
PRIMARY KEY (`PROPERTY_ID`) ,
|
||||
INDEX `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1_idx` (`FEATURE_ID` ASC) ,
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
|
||||
`PROPERTY_ID` INT NOT NULL AUTO_INCREMENT,
|
||||
`PROPERTY` VARCHAR(100) NULL,
|
||||
`FEATURE_ID` VARCHAR(45) NULL,
|
||||
PRIMARY KEY (`PROPERTY_ID`),
|
||||
INDEX `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1_idx` (`FEATURE_ID` ASC),
|
||||
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
|
||||
FOREIGN KEY (`FEATURE_ID` )
|
||||
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
|
||||
FOREIGN KEY (`FEATURE_ID`)
|
||||
REFERENCES `MBL_FEATURE` (`FEATURE_ID`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB;
|
||||
|
||||
@ -36,81 +36,73 @@ import java.util.List;
|
||||
@Consumes({ "application/json", "application/xml" })
|
||||
public class Operation {
|
||||
|
||||
private static Log log = LogFactory.getLog(Operation.class);
|
||||
private static Log log = LogFactory.getLog(Operation.class);
|
||||
|
||||
@GET
|
||||
@Path("{id}")
|
||||
public List<org.wso2.carbon.device.mgt.common.Operation> getAllOperations(@PathParam("id") String id)
|
||||
throws AndroidAgentException {
|
||||
@GET
|
||||
@Path("{id}")
|
||||
public List<org.wso2.carbon.device.mgt.common.Operation> getAllOperations(
|
||||
@PathParam("id") String id)
|
||||
throws AndroidAgentException {
|
||||
|
||||
List<org.wso2.carbon.device.mgt.common.Operation> operations;
|
||||
String msg;
|
||||
DeviceManagementService dmService;
|
||||
List<org.wso2.carbon.device.mgt.common.Operation> operations;
|
||||
String msg;
|
||||
DeviceManagementService dmService;
|
||||
|
||||
try {
|
||||
dmService = AndroidAPIUtils.getDeviceManagementService();
|
||||
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
||||
msg = "Device management service error";
|
||||
log.error(msg, deviceMgtServiceEx);
|
||||
throw new AndroidAgentException(msg, deviceMgtServiceEx);
|
||||
}
|
||||
try {
|
||||
dmService = AndroidAPIUtils.getDeviceManagementService();
|
||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||
operations = dmService.getOperationManager(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID)
|
||||
.getOperations(deviceIdentifier);
|
||||
Response.status(HttpStatus.SC_OK);
|
||||
return operations;
|
||||
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
||||
msg = "Device management service error";
|
||||
log.error(msg, deviceMgtServiceEx);
|
||||
throw new AndroidAgentException(msg, deviceMgtServiceEx);
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while fetching the operation manager for the device type.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
} catch (OperationManagementException e) {
|
||||
msg = "Error occurred while fetching the operation list for the device.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||
operations = dmService.getOperationManager(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID)
|
||||
.getOperations(deviceIdentifier);
|
||||
Response.status(HttpStatus.SC_OK);
|
||||
return operations;
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while fetching the operation manager for the device type.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
} catch (OperationManagementException e) {
|
||||
msg = "Error occurred while fetching the operation list for the device.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@PUT
|
||||
public Message updateOperation() throws AndroidAgentException {
|
||||
|
||||
String msg;
|
||||
DeviceManagementService dmService;
|
||||
Message responseMsg = new Message();
|
||||
|
||||
try {
|
||||
dmService = AndroidAPIUtils.getDeviceManagementService();
|
||||
|
||||
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
||||
msg = "Device management service error";
|
||||
log.error(msg, deviceMgtServiceEx);
|
||||
throw new AndroidAgentException(msg, deviceMgtServiceEx);
|
||||
}
|
||||
|
||||
try {
|
||||
boolean result = dmService.getOperationManager("").addOperation(null, null);
|
||||
if (result) {
|
||||
Response.status(HttpStatus.SC_OK);
|
||||
responseMsg.setResponseMessage("Device has already enrolled");
|
||||
} else {
|
||||
Response.status(HttpStatus.SC_NOT_FOUND);
|
||||
responseMsg.setResponseMessage("Operation not found");
|
||||
}
|
||||
return responseMsg;
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while fetching the operation manager for the device type.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
} catch (OperationManagementException e) {
|
||||
msg = "Error occurred while updating the operation status for the device.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
}
|
||||
@PUT
|
||||
public Message updateOperation() throws AndroidAgentException {
|
||||
String msg;
|
||||
DeviceManagementService dmService;
|
||||
Message responseMsg = new Message();
|
||||
try {
|
||||
dmService = AndroidAPIUtils.getDeviceManagementService();
|
||||
boolean result = dmService.getOperationManager("").addOperation(null, null);
|
||||
if (result) {
|
||||
Response.status(HttpStatus.SC_OK);
|
||||
responseMsg.setResponseMessage("Device has already enrolled");
|
||||
} else {
|
||||
Response.status(HttpStatus.SC_NOT_FOUND);
|
||||
responseMsg.setResponseMessage("Operation not found");
|
||||
}
|
||||
return responseMsg;
|
||||
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
||||
msg = "Device management service error";
|
||||
log.error(msg, deviceMgtServiceEx);
|
||||
throw new AndroidAgentException(msg, deviceMgtServiceEx);
|
||||
} catch (DeviceManagementException e) {
|
||||
msg = "Error occurred while fetching the operation manager for the device type.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
} catch (OperationManagementException e) {
|
||||
msg = "Error occurred while updating the operation status for the device.";
|
||||
log.error(msg, e);
|
||||
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||
throw new AndroidAgentException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50,16 +50,13 @@ public class Operation {
|
||||
OperationManager operationManager;
|
||||
try {
|
||||
dmService = CDMAPIUtils.getDeviceManagementService();
|
||||
operationManager = dmService.getOperationManager(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
operations = operationManager.getOperations(null);
|
||||
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
||||
String errorMsg = "Device management service error";
|
||||
log.error(errorMsg, deviceServiceMgtEx);
|
||||
throw new CDMAPIException(errorMsg, deviceServiceMgtEx);
|
||||
}
|
||||
|
||||
try {
|
||||
operationManager = dmService.getOperationManager(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
operations = operationManager.getOperations(null);
|
||||
} catch (DeviceManagementException deviceMgtEx) {
|
||||
String errorMsg = "Error occurred while fetching the operation manager.";
|
||||
log.error(errorMsg, deviceMgtEx);
|
||||
@ -79,13 +76,6 @@ public class Operation {
|
||||
Message responseMsg = new Message();
|
||||
try {
|
||||
dmService = CDMAPIUtils.getDeviceManagementService();
|
||||
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
||||
String errorMsg = "Device management service error";
|
||||
log.error(errorMsg, deviceServiceMgtEx);
|
||||
throw new CDMAPIException(errorMsg, deviceServiceMgtEx);
|
||||
}
|
||||
|
||||
try {
|
||||
operationManager = dmService.getOperationManager(
|
||||
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
|
||||
boolean status = operationManager.addOperation(operationContext.getOperation(),
|
||||
@ -98,6 +88,10 @@ public class Operation {
|
||||
responseMsg.setResponseMessage("Failure in adding the Operation.");
|
||||
}
|
||||
return responseMsg;
|
||||
} catch (DeviceManagementServiceException deviceServiceMgtEx) {
|
||||
String errorMsg = "Device management service error";
|
||||
log.error(errorMsg, deviceServiceMgtEx);
|
||||
throw new CDMAPIException(errorMsg, deviceServiceMgtEx);
|
||||
} catch (DeviceManagementException deviceMgtEx) {
|
||||
String errorMsg = "Error occurred while adding the operation";
|
||||
log.error(errorMsg, deviceMgtEx);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user