|
|
@ -416,7 +416,7 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String msg = "Error occurred while inserting the criterion to policy (" + policy.getPolicyName() + ") " +
|
|
|
|
String msg = "Error occurred while inserting the criterion to policy (" + policy.getPolicyName() + ") " +
|
|
|
|
"to database.";
|
|
|
|
"to database.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new PolicyManagerDAOException(msg, e);
|
|
|
|
throw new PolicyManagerDAOException(msg, e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
@ -436,7 +436,7 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String query = "INSERT INTO DM_POLICY_CRITERIA_PROPERTIES (POLICY_CRITERION_ID, PROP_KEY, PROP_VALUE, " +
|
|
|
|
String query = "INSERT INTO DM_POLICY_CRITERIA_PROPERTIES (POLICY_CRITERION_ID, PROP_KEY, PROP_VALUE, " +
|
|
|
|
"CONTENT) VALUES (?, ?, ?, ?)";
|
|
|
|
"CONTENT) VALUES (?, ?, ?, ?)";
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
|
|
|
|
|
|
|
|
for (PolicyCriterion criterion : policyCriteria) {
|
|
|
|
for (PolicyCriterion criterion : policyCriteria) {
|
|
|
@ -477,9 +477,9 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String query = "SELECT DPC.ID, DPC.CRITERIA_ID, DPCP.PROP_KEY, DPCP.PROP_VALUE, DPCP.CONTENT FROM " +
|
|
|
|
String query = "SELECT DPC.ID, DPC.CRITERIA_ID, DPCP.PROP_KEY, DPCP.PROP_VALUE, DPCP.CONTENT FROM " +
|
|
|
|
"DM_POLICY_CRITERIA DPC LEFT JOIN DM_POLICY_CRITERIA_PROPERTIES DPCP " +
|
|
|
|
"DM_POLICY_CRITERIA DPC LEFT JOIN DM_POLICY_CRITERIA_PROPERTIES DPCP " +
|
|
|
|
"ON DPCP.POLICY_CRITERION_ID = DPC.ID RIGHT JOIN DM_CRITERIA DC " +
|
|
|
|
"ON DPCP.POLICY_CRITERION_ID = DPC.ID RIGHT JOIN DM_CRITERIA DC " +
|
|
|
|
"ON DC.ID=DPC.CRITERIA_ID WHERE DPC.POLICY_ID = ?";
|
|
|
|
"ON DC.ID=DPC.CRITERIA_ID WHERE DPC.POLICY_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
stmt.setInt(1, policyId);
|
|
|
|
stmt.setInt(1, policyId);
|
|
|
|
resultSet = stmt.executeQuery();
|
|
|
|
resultSet = stmt.executeQuery();
|
|
|
@ -525,7 +525,7 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String query = "UPDATE DM_POLICY SET NAME= ?, TENANT_ID = ?, PROFILE_ID = ?, PRIORITY = ?, COMPLIANCE = ?" +
|
|
|
|
String query = "UPDATE DM_POLICY SET NAME= ?, TENANT_ID = ?, PROFILE_ID = ?, PRIORITY = ?, COMPLIANCE = ?" +
|
|
|
|
" WHERE ID = ?";
|
|
|
|
" WHERE ID = ?";
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
stmt.setString(1, policy.getPolicyName());
|
|
|
|
stmt.setString(1, policy.getPolicyName());
|
|
|
|
stmt.setInt(2, policy.getTenantId());
|
|
|
|
stmt.setInt(2, policy.getTenantId());
|
|
|
@ -758,7 +758,7 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String query = "INSERT INTO DM_DEVICE_POLICY_APPLIED " +
|
|
|
|
String query = "INSERT INTO DM_DEVICE_POLICY_APPLIED " +
|
|
|
|
"(DEVICE_ID, POLICY_ID, POLICY_CONTENT, CREATED_TIME, UPDATED_TIME) VALUES (?, ?, ?, ?, ?)";
|
|
|
|
"(DEVICE_ID, POLICY_ID, POLICY_CONTENT, CREATED_TIME, UPDATED_TIME) VALUES (?, ?, ?, ?, ?)";
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
stmt.setInt(1, deviceId);
|
|
|
|
stmt.setInt(1, deviceId);
|
|
|
|
stmt.setInt(2, policyId);
|
|
|
|
stmt.setInt(2, policyId);
|
|
|
@ -814,7 +814,7 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String query = "UPDATE DM_DEVICE_POLICY_APPLIED SET POLICY_ID = ?, POLICY_CONTENT = ?, UPDATED_TIME = ?, " +
|
|
|
|
String query = "UPDATE DM_DEVICE_POLICY_APPLIED SET POLICY_ID = ?, POLICY_CONTENT = ?, UPDATED_TIME = ?, " +
|
|
|
|
"APPLIED = ? WHERE DEVICE_ID = ?";
|
|
|
|
"APPLIED = ? WHERE DEVICE_ID = ?";
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
stmt = conn.prepareStatement(query);
|
|
|
|
stmt.setInt(1, policyId);
|
|
|
|
stmt.setInt(1, policyId);
|
|
|
|
stmt.setObject(2, profileFeatures);
|
|
|
|
stmt.setObject(2, profileFeatures);
|
|
|
@ -1068,7 +1068,7 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getConnection();
|
|
|
|
conn = this.getConnection();
|
|
|
|
String query = "INSERT INTO DM_POLICY (NAME, PROFILE_ID, TENANT_ID, PRIORITY, COMPLIANCE, OWNERSHIP_TYPE)" +
|
|
|
|
String query = "INSERT INTO DM_POLICY (NAME, PROFILE_ID, TENANT_ID, PRIORITY, COMPLIANCE, OWNERSHIP_TYPE)" +
|
|
|
|
" VALUES (?, ?, ?, ?, ?, ?)";
|
|
|
|
" VALUES (?, ?, ?, ?, ?, ?)";
|
|
|
|
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
|
|
|
|
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
|
|
|
|
|
|
|
|
|
|
|
|
stmt.setString(1, policy.getPolicyName());
|
|
|
|
stmt.setString(1, policy.getPolicyName());
|
|
|
@ -1245,28 +1245,30 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|
|
|
stmt.setInt(1, deviceId);
|
|
|
|
stmt.setInt(1, deviceId);
|
|
|
|
resultSet = stmt.executeQuery();
|
|
|
|
resultSet = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ByteArrayInputStream bais = null;
|
|
|
|
ByteArrayInputStream bais = null;
|
|
|
|
ObjectInputStream ois = null;
|
|
|
|
ObjectInputStream ois = null;
|
|
|
|
byte[] contentBytes;
|
|
|
|
byte[] contentBytes;
|
|
|
|
try {
|
|
|
|
|
|
|
|
contentBytes = (byte[]) resultSet.getBytes("POLICY_CONTENT");
|
|
|
|
while (resultSet.next()) {
|
|
|
|
bais = new ByteArrayInputStream(contentBytes);
|
|
|
|
try {
|
|
|
|
ois = new ObjectInputStream(bais);
|
|
|
|
contentBytes = (byte[]) resultSet.getBytes("POLICY_CONTENT");
|
|
|
|
policy = (Policy) ois.readObject();
|
|
|
|
bais = new ByteArrayInputStream(contentBytes);
|
|
|
|
} finally {
|
|
|
|
ois = new ObjectInputStream(bais);
|
|
|
|
if (bais != null) {
|
|
|
|
policy = (Policy) ois.readObject();
|
|
|
|
try {
|
|
|
|
} finally {
|
|
|
|
bais.close();
|
|
|
|
if (bais != null) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
try {
|
|
|
|
log.warn("Error occurred while closing ByteArrayOutputStream", e);
|
|
|
|
bais.close();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
log.warn("Error occurred while closing ByteArrayOutputStream", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ois != null) {
|
|
|
|
if (ois != null) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
ois.close();
|
|
|
|
ois.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
log.warn("Error occurred while closing ObjectOutputStream", e);
|
|
|
|
log.warn("Error occurred while closing ObjectOutputStream", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|