mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Cleaning up the unused methods on the operation mgmt.
This commit is contained in:
parent
1b5bd81a6d
commit
9f502c022f
@ -63,7 +63,8 @@ public interface OperationManager {
|
||||
* @throws OperationManagementException If some unusual behaviour is observed while fetching the
|
||||
* operation list.
|
||||
*/
|
||||
PaginationResult getOperations(DeviceIdentifier deviceId, PaginationRequest request) throws OperationManagementException;
|
||||
PaginationResult getOperations(DeviceIdentifier deviceId, PaginationRequest request)
|
||||
throws OperationManagementException;
|
||||
|
||||
/**
|
||||
* Method to retrieve the list of available operations to a device.
|
||||
@ -73,15 +74,12 @@ public interface OperationManager {
|
||||
* @throws OperationManagementException If some unusual behaviour is observed while fetching the
|
||||
* operation list.
|
||||
*/
|
||||
List<? extends Operation> getPendingOperations(
|
||||
DeviceIdentifier deviceId) throws OperationManagementException;
|
||||
List<? extends Operation> getPendingOperations(DeviceIdentifier deviceId) throws OperationManagementException;
|
||||
|
||||
Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException;
|
||||
|
||||
void updateOperation(DeviceIdentifier deviceId, Operation operation) throws OperationManagementException;
|
||||
|
||||
void deleteOperation(int operationId) throws OperationManagementException;
|
||||
|
||||
Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, int operationId)
|
||||
throws OperationManagementException;
|
||||
|
||||
@ -93,9 +91,8 @@ public interface OperationManager {
|
||||
|
||||
Activity getOperationByActivityId(String activity) throws OperationManagementException;
|
||||
|
||||
Activity getOperationByActivityIdAndDevice(String activity, DeviceIdentifier deviceId) throws OperationManagementException;
|
||||
|
||||
List<Operation> getOperationUpdatedAfter(long timestamp) throws OperationManagementException;
|
||||
Activity getOperationByActivityIdAndDevice(String activity, DeviceIdentifier deviceId)
|
||||
throws OperationManagementException;
|
||||
|
||||
List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementException;
|
||||
|
||||
@ -103,12 +100,6 @@ public interface OperationManager {
|
||||
|
||||
int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementException;
|
||||
|
||||
/**
|
||||
* Operation manger implementation can have a push notification stratergy
|
||||
* @param notificationStrategy eg: mqtt/xmpp
|
||||
*/
|
||||
void setNotificationStrategy(NotificationStrategy notificationStrategy);
|
||||
|
||||
/**
|
||||
* retrive the push notification strategy.
|
||||
* @return NotificationStrategy
|
||||
|
||||
@ -105,10 +105,6 @@ public class OperationManagerImpl implements OperationManager {
|
||||
return notificationStrategy;
|
||||
}
|
||||
|
||||
public void setNotificationStrategy(NotificationStrategy notificationStrategy) {
|
||||
this.notificationStrategy = notificationStrategy;
|
||||
}
|
||||
|
||||
public OperationManagerImpl(String deviceType, NotificationStrategy notificationStrategy) {
|
||||
this(deviceType);
|
||||
this.notificationStrategy = notificationStrategy;
|
||||
@ -557,27 +553,6 @@ public class OperationManagerImpl implements OperationManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOperation(int operationId) throws OperationManagementException {
|
||||
try {
|
||||
OperationManagementDAOFactory.beginTransaction();
|
||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operation =
|
||||
operationDAO.getOperation(operationId);
|
||||
if (operation == null) {
|
||||
throw new OperationManagementException("Operation not found for operation id : " + operationId);
|
||||
}
|
||||
lookupOperationDAO(operation).deleteOperation(operationId);
|
||||
OperationManagementDAOFactory.commitTransaction();
|
||||
} catch (OperationManagementDAOException e) {
|
||||
OperationManagementDAOFactory.rollbackTransaction();
|
||||
throw new OperationManagementException("Error occurred while deleting the operation: " + operationId, e);
|
||||
} catch (TransactionManagementException e) {
|
||||
throw new OperationManagementException("Error occurred while initiating a transaction", e);
|
||||
} finally {
|
||||
OperationManagementDAOFactory.closeConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, int operationId)
|
||||
throws OperationManagementException {
|
||||
@ -738,62 +713,6 @@ public class OperationManagerImpl implements OperationManager {
|
||||
return operation;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Operation getOperationByActivityId(String activity) throws OperationManagementException {
|
||||
// // This parses the operation id from activity id (ex : ACTIVITY_23) and converts to the integer.
|
||||
// Operation operation;
|
||||
// int enrollmentOpMappingId = Integer.parseInt(
|
||||
// activity.replace(DeviceManagementConstants.OperationAttributes.ACTIVITY, ""));
|
||||
// if (enrollmentOpMappingId == 0) {
|
||||
// throw new IllegalArgumentException("Operation ID cannot be null or zero (0).");
|
||||
// }
|
||||
// try {
|
||||
// OperationManagementDAOFactory.openConnection();
|
||||
// org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation dtoOperation =
|
||||
// operationDAO.getOperationFromEnrollment(enrollmentOpMappingId);
|
||||
//
|
||||
// if (dtoOperation == null) {
|
||||
// throw new OperationManagementException("Operation not found for given activity Id:" + activity);
|
||||
// }
|
||||
// org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status status = dtoOperation.getStatus();
|
||||
// if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.COMMAND)) {
|
||||
// org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation commandOperation;
|
||||
// commandOperation =
|
||||
// (org.wso2.carbon.device.mgt.core.dto.operation.mgt.CommandOperation) commandOperationDAO.
|
||||
// getOperation(dtoOperation.getId());
|
||||
// dtoOperation.setEnabled(commandOperation.isEnabled());
|
||||
// } else if (dtoOperation.getType().
|
||||
// equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.CONFIG)) {
|
||||
// dtoOperation = configOperationDAO.getOperation(dtoOperation.getId());
|
||||
// } else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.
|
||||
// PROFILE)) {
|
||||
// dtoOperation = profileOperationDAO.getOperation(dtoOperation.getId());
|
||||
// } else if (dtoOperation.getType().equals(org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Type.
|
||||
// POLICY)) {
|
||||
// dtoOperation = policyOperationDAO.getOperation(dtoOperation.getId());
|
||||
// }
|
||||
// operation = OperationDAOUtil.convertOperation(dtoOperation);
|
||||
// int enrolmentId = operationDAO.getEnrolmentIdFromMappingId(enrollmentOpMappingId);
|
||||
// if (enrolmentId != 0) {
|
||||
// operation.setResponses(operationDAO.getOperationResponses(enrolmentId, operation.getId()));
|
||||
// }
|
||||
//
|
||||
// operation.setStatus(Operation.Status.valueOf(status.toString()));
|
||||
// operation.setActivityId(activity);
|
||||
//
|
||||
// } catch (SQLException e) {
|
||||
// throw new OperationManagementException("Error occurred while opening a connection to the data source", e);
|
||||
// } catch (OperationManagementDAOException e) {
|
||||
// throw new OperationManagementException("Error occurred while retrieving the operation with activity Id '" +
|
||||
// activity, e);
|
||||
// } finally {
|
||||
// OperationManagementDAOFactory.closeConnection();
|
||||
// }
|
||||
//
|
||||
// // return this.getOperation(operationId);
|
||||
// return operation;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Activity getOperationByActivityId(String activity) throws OperationManagementException {
|
||||
// This parses the operation id from activity id (ex : ACTIVITY_23) and converts to the integer.
|
||||
@ -837,11 +756,6 @@ public class OperationManagerImpl implements OperationManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Operation> getOperationUpdatedAfter(long timestamp) throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementException {
|
||||
try {
|
||||
|
||||
@ -33,12 +33,8 @@ public interface OperationDAO {
|
||||
|
||||
void updateOperation(Operation operation) throws OperationManagementDAOException;
|
||||
|
||||
void deleteOperation(int operationId) throws OperationManagementDAOException;
|
||||
|
||||
Operation getOperation(int operationId) throws OperationManagementDAOException;
|
||||
|
||||
Operation getOperationFromEnrollment(int enrollmentOpMappingId) throws OperationManagementDAOException;
|
||||
|
||||
Operation getOperationByDeviceAndId(int enrolmentId, int operationId) throws OperationManagementDAOException;
|
||||
|
||||
List<? extends Operation> getOperationsByDeviceAndStatus(int enrolmentId, Operation.Status status)
|
||||
@ -66,24 +62,16 @@ public interface OperationDAO {
|
||||
void addOperationResponse(int enrolmentId, int operationId, Object operationResponse)
|
||||
throws OperationManagementDAOException;
|
||||
|
||||
List<OperationResponse> getOperationResponses(int enrolmentId, int operationId) throws OperationManagementDAOException;
|
||||
|
||||
Activity getActivity(int operationId) throws OperationManagementDAOException;
|
||||
|
||||
Activity getActivityByDevice(int operationId, int deviceId) throws OperationManagementDAOException;
|
||||
|
||||
int getEnrolmentIdFromMappingId(int enrollmentOpMappingId) throws OperationManagementDAOException;
|
||||
|
||||
List<Operation> getOperationsUpdatedAfter(long timestamp) throws OperationManagementDAOException;
|
||||
|
||||
List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementDAOException;
|
||||
|
||||
List<Activity> getActivitiesUpdatedAfter(long timestamp, int limit, int offset) throws OperationManagementDAOException;
|
||||
|
||||
int getActivityCountUpdatedAfter(long timestamp) throws OperationManagementDAOException;
|
||||
|
||||
boolean resetAttemptCount(int enrolmentId) throws OperationManagementDAOException;
|
||||
|
||||
/**
|
||||
* This method provides operation mappings for given status
|
||||
* @param opStatus Operation status
|
||||
|
||||
@ -70,22 +70,6 @@ public class CommandOperationDAOImpl extends GenericOperationDAOImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOperation(int id) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
Connection connection = OperationManagementDAOFactory.getConnection();
|
||||
stmt = connection.prepareStatement("DELETE FROM DM_COMMAND_OPERATION WHERE OPERATION_ID = ?");
|
||||
stmt.setInt(1, id);
|
||||
stmt.executeUpdate();
|
||||
super.deleteOperation(id);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while deleting operation metadata", e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
public CommandOperation getOperation(int id) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
@ -58,22 +58,6 @@ public class ConfigOperationDAOImpl extends GenericOperationDAOImpl {
|
||||
return operationId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOperation(int id) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
Connection connection = OperationManagementDAOFactory.getConnection();
|
||||
stmt = connection.prepareStatement("DELETE FROM DM_CONFIG_OPERATION WHERE OPERATION_ID = ?") ;
|
||||
stmt.setInt(1, id);
|
||||
stmt.executeUpdate();
|
||||
super.deleteOperation(id);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while deleting operation metadata", e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateOperation(Operation operation) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
@ -249,68 +249,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OperationResponse> getOperationResponses(int enrolmentId, int operationId) throws
|
||||
OperationManagementDAOException {
|
||||
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
List<OperationResponse> responces = new ArrayList<>();
|
||||
try {
|
||||
Connection conn = OperationManagementDAOFactory.getConnection();
|
||||
String sql = "SELECT * FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ? AND OPERATION_ID = ?";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, enrolmentId);
|
||||
stmt.setInt(2, operationId);
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
OperationResponse response = new OperationResponse();
|
||||
response.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
|
||||
ByteArrayInputStream bais = null;
|
||||
ObjectInputStream ois = null;
|
||||
byte[] contentBytes;
|
||||
try {
|
||||
contentBytes = (byte[]) rs.getBytes("OPERATION_RESPONSE");
|
||||
bais = new ByteArrayInputStream(contentBytes);
|
||||
ois = new ObjectInputStream(bais);
|
||||
response.setResponse(ois.readObject().toString());
|
||||
|
||||
} finally {
|
||||
if (bais != null) {
|
||||
try {
|
||||
bais.close();
|
||||
} catch (IOException e) {
|
||||
log.warn("Error occurred while closing ByteArrayOutputStream", e);
|
||||
}
|
||||
}
|
||||
if (ois != null) {
|
||||
try {
|
||||
ois.close();
|
||||
} catch (IOException e) {
|
||||
log.warn("Error occurred while closing ObjectOutputStream", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
responces.add(response);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("SQL Error occurred while retrieving the operation responses for " +
|
||||
"operation id " + operationId + " and enrolment id " + enrolmentId, e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while converting the operation responses to string" +
|
||||
" for operation id " + operationId + " and enrolment id " + enrolmentId, e);
|
||||
} catch (IOException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while converting the operation responses to string" +
|
||||
" for operation id " + operationId + " and enrolment id " + enrolmentId, e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
|
||||
return responces;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getActivity(int operationId) throws OperationManagementDAOException {
|
||||
|
||||
@ -674,80 +612,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnrolmentIdFromMappingId(int enrollmentOpMappingId) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
Connection conn = OperationManagementDAOFactory.getConnection();
|
||||
String sql = "SELECT * FROM DM_ENROLMENT_OP_MAPPING WHERE ID = ?";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, enrollmentOpMappingId);
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
if (rs.next()) {
|
||||
return rs.getInt("ENROLMENT_ID");
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("SQL Error occurred while retrieving the enrolment id " +
|
||||
" for the mapping id '" + enrollmentOpMappingId, e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Operation> getOperationsUpdatedAfter(long timestamp) throws OperationManagementDAOException {
|
||||
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
List<Operation> operations = new ArrayList<>();
|
||||
try {
|
||||
Connection conn = OperationManagementDAOFactory.getConnection();
|
||||
String sql = "SELECT o.ID, o.TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, OPERATION_CODE " +
|
||||
"FROM DM_OPERATION AS o \n" +
|
||||
"INNER JOIN DM_ENROLMENT_OP_MAPPING AS eom ON eom.OPERATION_ID=o.ID WHERE eom.UPDATED_TIMESTAMP = ?";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setLong(1, timestamp);
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
if (rs.next()) {
|
||||
Operation operation = new Operation();
|
||||
operation.setId(rs.getInt("ID"));
|
||||
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
||||
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
||||
operation.setCode(rs.getString("OPERATION_CODE"));
|
||||
|
||||
operations.add(operation);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while retrieving the operations updated " +
|
||||
"after a given time", e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return operations;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteOperation(int id) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
Connection connection = OperationManagementDAOFactory.getConnection();
|
||||
stmt = connection.prepareStatement("DELETE FROM DM_OPERATION WHERE ID = ?");
|
||||
stmt.setInt(1, id);
|
||||
stmt.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while deleting operation metadata", e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperation(int id) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
@ -783,49 +647,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
||||
return operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperationFromEnrollment(int enrollmentOpMappingId) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
Operation operation = null;
|
||||
try {
|
||||
Connection conn = OperationManagementDAOFactory.getConnection();
|
||||
String sql = "SELECT o.ID, TYPE, o.CREATED_TIMESTAMP, o.RECEIVED_TIMESTAMP, OPERATION_CODE, \n" +
|
||||
" om.STATUS, om.UPDATED_TIMESTAMP FROM DM_OPERATION o \n" +
|
||||
"INNER JOIN (SELECT * FROM DM_ENROLMENT_OP_MAPPING dm WHERE dm.ID = ? ) om \n" +
|
||||
"ON o.ID = om.OPERATION_ID ORDER BY o.CREATED_TIMESTAMP DESC ";
|
||||
stmt = conn.prepareStatement(sql);
|
||||
stmt.setInt(1, enrollmentOpMappingId);
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
if (rs.next()) {
|
||||
operation = new Operation();
|
||||
operation.setId(rs.getInt("ID"));
|
||||
operation.setType(Operation.Type.valueOf(rs.getString("TYPE")));
|
||||
operation.setCreatedTimeStamp(rs.getTimestamp("CREATED_TIMESTAMP").toString());
|
||||
// if (rs.getTimestamp("RECEIVED_TIMESTAMP") == null) {
|
||||
// operation.setReceivedTimeStamp("");
|
||||
// } else {
|
||||
// operation.setReceivedTimeStamp(rs.getTimestamp("RECEIVED_TIMESTAMP").toString());
|
||||
// }
|
||||
if (rs.getLong("UPDATED_TIMESTAMP") == 0) {
|
||||
operation.setReceivedTimeStamp("");
|
||||
} else {
|
||||
operation.setReceivedTimeStamp(
|
||||
new java.sql.Timestamp((rs.getLong("UPDATED_TIMESTAMP") * 1000)).toString());
|
||||
}
|
||||
operation.setCode(rs.getString("OPERATION_CODE"));
|
||||
operation.setStatus(Operation.Status.valueOf(rs.getString("STATUS")));
|
||||
OperationDAOUtil.setActivityId(operation, rs.getInt("ID"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("SQL error occurred while retrieving the operation .", e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt, rs);
|
||||
}
|
||||
return operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperationByDeviceAndId(int enrolmentId, int operationId) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
@ -1177,31 +998,6 @@ public class GenericOperationDAOImpl implements OperationDAO {
|
||||
return operations;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resetAttemptCount(int enrolmentId) throws OperationManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn;
|
||||
PreparedStatement stmt = null;
|
||||
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
try {
|
||||
conn = OperationManagementDAOFactory.getConnection();
|
||||
String query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = 0, LAST_REQUESTED_TIME = ? " +
|
||||
"WHERE ENROLMENT_ID = ? AND TENANT_ID = ?";
|
||||
stmt = conn.prepareStatement(query);
|
||||
stmt.setTimestamp(1, currentTimestamp);
|
||||
stmt.setInt(2, enrolmentId);
|
||||
stmt.setInt(3, tenantId);
|
||||
stmt.executeUpdate();
|
||||
status = true;
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("Unable to reset the attempt count in database.", e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<OperationMapping>> getOperationMappingsByStatus(Operation.Status opStatus, Operation.PushNotificationStatus pushNotificationStatus,
|
||||
int limit) throws OperationManagementDAOException {
|
||||
|
||||
@ -122,22 +122,6 @@ public class PolicyOperationDAOImpl extends GenericOperationDAOImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOperation(int operationId) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
Connection connection = OperationManagementDAOFactory.getConnection();
|
||||
stmt = connection.prepareStatement("DELETE FROM DM_POLICY_OPERATION WHERE OPERATION_ID=?");
|
||||
stmt.setInt(1, operationId);
|
||||
stmt.executeUpdate();
|
||||
super.deleteOperation(operationId);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while deleting operation metadata", e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperation(int operationId) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
@ -123,22 +123,6 @@ public class ProfileOperationDAOImpl extends GenericOperationDAOImpl {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOperation(int id) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
Connection connection = OperationManagementDAOFactory.getConnection();
|
||||
stmt = connection.prepareStatement("DELETE FROM DM_PROFILE_OPERATION WHERE OPERATION_ID=?");
|
||||
stmt.setInt(1, id);
|
||||
stmt.executeUpdate();
|
||||
super.deleteOperation(id);
|
||||
} catch (SQLException e) {
|
||||
throw new OperationManagementDAOException("Error occurred while deleting operation metadata", e);
|
||||
} finally {
|
||||
OperationManagementDAOUtil.cleanupResources(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
public Operation getOperation(int id) throws OperationManagementDAOException {
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
@ -83,11 +83,6 @@ public class PushNotificationBasedOperationManager implements OperationManager {
|
||||
this.operationManager.updateOperation(deviceId, operation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOperation(int operationId) throws OperationManagementException {
|
||||
this.operationManager.deleteOperation(operationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperationByDeviceAndOperationId(
|
||||
DeviceIdentifier deviceId, int operationId) throws OperationManagementException {
|
||||
@ -121,11 +116,6 @@ public class PushNotificationBasedOperationManager implements OperationManager {
|
||||
return this.operationManager.getOperationByActivityIdAndDevice(activity, deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Operation> getOperationUpdatedAfter(long timestamp) throws OperationManagementException {
|
||||
return this.operationManager.getOperationUpdatedAfter(timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Activity> getActivitiesUpdatedAfter(long timestamp) throws OperationManagementException {
|
||||
return this.operationManager.getActivitiesUpdatedAfter(timestamp);
|
||||
@ -141,11 +131,6 @@ public class PushNotificationBasedOperationManager implements OperationManager {
|
||||
return this.operationManager.getActivityCountUpdatedAfter(timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNotificationStrategy(NotificationStrategy notificationStrategy) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NotificationStrategy getNotificationStrategy() {
|
||||
return notificationProvider;
|
||||
|
||||
@ -553,8 +553,6 @@ public interface DeviceManagementProviderService {
|
||||
|
||||
void updateOperation(DeviceIdentifier deviceId, Operation operation) throws OperationManagementException;
|
||||
|
||||
void deleteOperation(String type, int operationId) throws OperationManagementException;
|
||||
|
||||
Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, int operationId)
|
||||
throws OperationManagementException;
|
||||
|
||||
|
||||
@ -1429,11 +1429,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
||||
.updateOperation(deviceId, operation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteOperation(String type, int operationId) throws OperationManagementException {
|
||||
pluginRepository.getOperationManager(type, this.getTenantId()).deleteOperation(operationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId,
|
||||
int operationId) throws OperationManagementException {
|
||||
|
||||
@ -240,18 +240,6 @@ public class OperationManagementTests {
|
||||
Assert.assertTrue(operation.getType().equals(Operation.Type.POLICY));
|
||||
}
|
||||
|
||||
|
||||
@Test(dependsOnMethods = "getNextPendingOperation", enabled = false)
|
||||
public void deleteOperation() throws OperationManagementException {
|
||||
//TODO: Verify the operation management service operations.
|
||||
DeviceIdentifier deviceIdentifier = this.deviceIds.get(0);
|
||||
Operation operation = this.operationMgtService.getNextPendingOperation(deviceIdentifier);
|
||||
this.operationMgtService.deleteOperation(operation.getId());
|
||||
Operation operationAfterDeletion = this.operationMgtService.getNextPendingOperation(deviceIdentifier);
|
||||
Assert.assertTrue(operation.getId() != operation.getId());
|
||||
Assert.assertTrue(operationAfterDeletion.getType().equals(Operation.Type.POLICY));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "getNextPendingOperation")
|
||||
public void getOperationByDeviceAndOperationId() throws OperationManagementException {
|
||||
DeviceIdentifier deviceIdentifier = this.deviceIds.get(0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user