Conflicts:
	components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/MonitoringManagerImpl.java
revert-70aa11f8
Dilshan Edirisuriya 9 years ago
commit 3c444f6102

@ -43,7 +43,7 @@ public class Operation implements Serializable {
private String createdTimeStamp; private String createdTimeStamp;
private boolean isEnabled; private boolean isEnabled;
private Object payLoad; private Object payLoad;
private Object operationResponse; private String operationResponse;
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
@ -183,11 +183,11 @@ public class Operation implements Serializable {
this.payLoad = payLoad; this.payLoad = payLoad;
} }
public Object getOperationResponse() { public String getOperationResponse() {
return operationResponse; return operationResponse;
} }
public void setOperationResponse(Object operationResponse) { public void setOperationResponse(String operationResponse) {
this.operationResponse = operationResponse; this.operationResponse = operationResponse;
} }

@ -61,6 +61,7 @@
org.osgi.service.component, org.osgi.service.component,
org.apache.commons.logging, org.apache.commons.logging,
javax.sql, javax.sql,
javax.cache,
javax.naming, javax.naming,
javax.xml.bind.*, javax.xml.bind.*,
javax.xml.parsers.*, javax.xml.parsers.*,

@ -0,0 +1,59 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.mgt.core.cache;
public class PolicyCacheException extends Exception {
private static final long serialVersionUID = -4234546127441192907L;
private String errorMessage;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public PolicyCacheException(String msg, Exception nestedEx) {
super(msg, nestedEx);
setErrorMessage(msg);
}
public PolicyCacheException(String message, Throwable cause) {
super(message, cause);
setErrorMessage(message);
}
public PolicyCacheException(String msg) {
super(msg);
setErrorMessage(msg);
}
public PolicyCacheException() {
super();
}
public PolicyCacheException(Throwable cause) {
super(cause);
}
}

@ -0,0 +1,49 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.mgt.core.cache;
import org.wso2.carbon.device.mgt.core.policy.mgt.policy.Policy;
import java.util.List;
public interface PolicyCacheManager {
void addAllPolicies(List<Policy> policies);
void updateAllPolicies(List<Policy> policies);
List<Policy> getAllPolicies();
void removeAllPolicies();
void addPolicy(Policy policy);
void updatePolicy(Policy policy);
void removePolicy(int policyId);
Policy getPolicy(int policyId);
void addPolicyToDevice(int deviceId, int policyId);
List<Integer> getPolicyAppliedDeviceIds(int policyId);
int getPolicyIdOfDevice(int deviceId);
}

@ -0,0 +1,83 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.policy.mgt.core.cache.impl;
import org.wso2.carbon.device.mgt.core.policy.mgt.policy.Policy;
import org.wso2.carbon.policy.mgt.core.cache.PolicyCacheManager;
import java.util.List;
public class PolicyCacheManagerImpl implements PolicyCacheManager {
@Override
public void addAllPolicies(List<Policy> policies) {
}
@Override
public void updateAllPolicies(List<Policy> policies) {
}
@Override
public List<Policy> getAllPolicies() {
return null;
}
@Override
public void removeAllPolicies() {
}
@Override
public void addPolicy(Policy policy) {
}
@Override
public void updatePolicy(Policy policy) {
}
@Override
public void removePolicy(int policyId) {
}
@Override
public Policy getPolicy(int policyId) {
return null;
}
@Override
public void addPolicyToDevice(int deviceId, int policyId) {
}
@Override
public List<Integer> getPolicyAppliedDeviceIds(int policyId) {
return null;
}
@Override
public int getPolicyIdOfDevice(int deviceId) {
return 0;
}
}

@ -21,6 +21,7 @@ package org.wso2.carbon.policy.mgt.core.dao.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.policy.mgt.common.Profile; import org.wso2.carbon.policy.mgt.common.Profile;
import org.wso2.carbon.policy.mgt.common.ProfileFeature; import org.wso2.carbon.policy.mgt.common.ProfileFeature;
@ -140,7 +141,8 @@ public class FeatureDAOImpl implements FeatureDAO {
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating feature " + feature.getName() + " (Feature Name) to the database."; String msg = "Error occurred while updating feature " + feature.getName() + " (Feature Name) to the
database.";
log.error(msg, e); log.error(msg, e);
throw new FeatureManagerDAOException(msg, e); throw new FeatureManagerDAOException(msg, e);
} finally { } finally {
@ -156,32 +158,36 @@ public class FeatureDAOImpl implements FeatureDAO {
} }
@Override @Override
public ProfileFeature updateProfileFeature(ProfileFeature feature, int profileId) throws FeatureManagerDAOException { public ProfileFeature updateProfileFeature(ProfileFeature feature, int profileId) throws
FeatureManagerDAOException {
return null; return null;
} }
@Override @Override
public List<ProfileFeature> addProfileFeatures(List<ProfileFeature> features, int profileId) throws FeatureManagerDAOException { public List<ProfileFeature> addProfileFeatures(List<ProfileFeature> features, int profileId) throws
FeatureManagerDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet generatedKeys = null; ResultSet generatedKeys = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_PROFILE_FEATURES (PROFILE_ID, FEATURE_CODE, DEVICE_TYPE_ID, CONTENT) " + String query = "INSERT INTO DM_PROFILE_FEATURES (PROFILE_ID, FEATURE_CODE, DEVICE_TYPE_ID, CONTENT, " +
"VALUES (?, ?, ?, ?)"; "TENANT_ID) VALUES (?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS); stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
for (ProfileFeature feature : features) { for (ProfileFeature feature : features) {
stmt.setInt(1, profileId); stmt.setInt(1, profileId);
stmt.setString(2, feature.getFeatureCode()); stmt.setString(2, feature.getFeatureCode());
stmt.setInt(3, feature.getDeviceTypeId()); stmt.setInt(3, feature.getDeviceTypeId());
if (conn.getMetaData().getDriverName().contains("H2")) { // if (conn.getMetaData().getDriverName().contains("H2")) {
stmt.setBytes(4, PolicyManagerUtil.getBytes(feature.getContent())); // stmt.setBytes(4, PolicyManagerUtil.getBytes(feature.getContent()));
} else { // } else {
stmt.setBytes(4, PolicyManagerUtil.getBytes(feature.getContent())); stmt.setBytes(4, PolicyManagerUtil.getBytes(feature.getContent()));
} //}
stmt.setInt(5, tenantId);
stmt.addBatch(); stmt.addBatch();
//Not adding the logic to check the size of the stmt and execute if the size records added is over 1000 //Not adding the logic to check the size of the stmt and execute if the size records added is over 1000
} }
@ -210,14 +216,17 @@ public class FeatureDAOImpl implements FeatureDAO {
} }
@Override @Override
public List<ProfileFeature> updateProfileFeatures(List<ProfileFeature> features, int profileId) throws FeatureManagerDAOException { public List<ProfileFeature> updateProfileFeatures(List<ProfileFeature> features, int profileId) throws
FeatureManagerDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "UPDATE DM_PROFILE_FEATURES SET CONTENT = ? WHERE PROFILE_ID = ?, FEATURE_CODE = ?"; String query = "UPDATE DM_PROFILE_FEATURES SET CONTENT = ? WHERE PROFILE_ID = ? AND FEATURE_CODE = ? AND" +
" TENANT_ID = ?";
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS); stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
for (ProfileFeature feature : features) { for (ProfileFeature feature : features) {
@ -228,6 +237,7 @@ public class FeatureDAOImpl implements FeatureDAO {
} }
stmt.setInt(2, profileId); stmt.setInt(2, profileId);
stmt.setString(3, feature.getFeatureCode()); stmt.setString(3, feature.getFeatureCode());
stmt.setInt(4, tenantId);
stmt.addBatch(); stmt.addBatch();
//Not adding the logic to check the size of the stmt and execute if the size records added is over 1000 //Not adding the logic to check the size of the stmt and execute if the size records added is over 1000
} }
@ -252,12 +262,14 @@ public class FeatureDAOImpl implements FeatureDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "DELETE FROM DM_PROFILE_FEATURES WHERE PROFILE_ID = ?"; String query = "DELETE FROM DM_PROFILE_FEATURES WHERE PROFILE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, profile.getProfileId()); stmt.setInt(1, profile.getProfileId());
stmt.setInt(2, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
return true; return true;
@ -272,14 +284,16 @@ public class FeatureDAOImpl implements FeatureDAO {
@Override @Override
public boolean deleteFeaturesOfProfile(int profileId) throws FeatureManagerDAOException { public boolean deleteFeaturesOfProfile(int profileId) throws FeatureManagerDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "DELETE FROM DM_PROFILE_FEATURES WHERE PROFILE_ID = ?"; String query = "DELETE FROM DM_PROFILE_FEATURES WHERE PROFILE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, profileId); stmt.setInt(1, profileId);
stmt.setInt(2, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
return true; return true;
@ -300,11 +314,14 @@ public class FeatureDAOImpl implements FeatureDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
List<ProfileFeature> featureList = new ArrayList<ProfileFeature>(); List<ProfileFeature> featureList = new ArrayList<ProfileFeature>();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT ID, PROFILE_ID, FEATURE_CODE, DEVICE_TYPE_ID, CONTENT FROM DM_PROFILE_FEATURES"; String query = "SELECT ID, PROFILE_ID, FEATURE_CODE, DEVICE_TYPE_ID, CONTENT FROM DM_PROFILE_FEATURES " +
"WHERE TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -406,13 +423,15 @@ public class FeatureDAOImpl implements FeatureDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
List<ProfileFeature> featureList = new ArrayList<ProfileFeature>(); List<ProfileFeature> featureList = new ArrayList<ProfileFeature>();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT ID, FEATURE_CODE, DEVICE_TYPE_ID, CONTENT FROM DM_PROFILE_FEATURES " + String query = "SELECT ID, FEATURE_CODE, DEVICE_TYPE_ID, CONTENT FROM DM_PROFILE_FEATURES " +
"WHERE PROFILE_ID = ?"; "WHERE PROFILE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, profileId); stmt.setInt(1, profileId);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -473,12 +492,14 @@ public class FeatureDAOImpl implements FeatureDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "DELETE FROM DM_FEATURES WHERE ID = ?"; String query = "DELETE FROM DM_FEATURES WHERE ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, featureId); stmt.setInt(1, featureId);
stmt.setInt(2, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
return true; return true;

@ -21,6 +21,7 @@ package org.wso2.carbon.policy.mgt.core.dao.impl;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceData;
import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature; import org.wso2.carbon.policy.mgt.common.monitor.ComplianceFeature;
import org.wso2.carbon.policy.mgt.core.dao.MonitoringDAO; import org.wso2.carbon.policy.mgt.core.dao.MonitoringDAO;
@ -39,20 +40,23 @@ public class MonitoringDAOImpl implements MonitoringDAO {
@Override @Override
public int addComplianceDetails(int deviceId, int policyId) throws MonitoringDAOException { public int addComplianceDetails(int deviceId, int policyId) throws MonitoringDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet generatedKeys = null; ResultSet generatedKeys = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_POLICY_COMPLIANCE_STATUS (DEVICE_ID, POLICY_ID, STATUS, ATTEMPTS, " + String query = "INSERT INTO DM_POLICY_COMPLIANCE_STATUS (DEVICE_ID, POLICY_ID, STATUS, ATTEMPTS, " +
"LAST_REQUESTED_TIME) VALUES (?, ?, ?,?, ?) "; "LAST_REQUESTED_TIME, TENANT_ID) VALUES (?, ?, ?,?, ?, ?) ";
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS); stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, policyId); stmt.setInt(2, policyId);
stmt.setInt(3, 1); stmt.setInt(3, 1);
stmt.setInt(4, 1); stmt.setInt(4, 1);
stmt.setTimestamp(5, currentTimestamp); stmt.setTimestamp(5, currentTimestamp);
stmt.setInt(6, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
generatedKeys = stmt.getGeneratedKeys(); generatedKeys = stmt.getGeneratedKeys();
@ -74,10 +78,13 @@ public class MonitoringDAOImpl implements MonitoringDAO {
@Override @Override
public void addComplianceDetails(Map<Integer, Integer> devicePolicyMap) throws MonitoringDAOException { public void addComplianceDetails(Map<Integer, Integer> devicePolicyMap) throws MonitoringDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet generatedKeys = null; ResultSet generatedKeys = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Adding the compliance details for devices and policies"); log.debug("Adding the compliance details for devices and policies");
for (Map.Entry<Integer, Integer> map : devicePolicyMap.entrySet()) { for (Map.Entry<Integer, Integer> map : devicePolicyMap.entrySet()) {
@ -88,7 +95,7 @@ public class MonitoringDAOImpl implements MonitoringDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_POLICY_COMPLIANCE_STATUS (DEVICE_ID, POLICY_ID, STATUS, ATTEMPTS, " + String query = "INSERT INTO DM_POLICY_COMPLIANCE_STATUS (DEVICE_ID, POLICY_ID, STATUS, ATTEMPTS, " +
"LAST_REQUESTED_TIME) VALUES (?, ?, ?,?, ?) "; "LAST_REQUESTED_TIME, TENANT_ID) VALUES (?, ?, ?,?, ?, ?) ";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
for (Map.Entry<Integer, Integer> map : devicePolicyMap.entrySet()) { for (Map.Entry<Integer, Integer> map : devicePolicyMap.entrySet()) {
stmt.setInt(1, map.getKey()); stmt.setInt(1, map.getKey());
@ -96,6 +103,7 @@ public class MonitoringDAOImpl implements MonitoringDAO {
stmt.setInt(3, 1); stmt.setInt(3, 1);
stmt.setInt(4, 1); stmt.setInt(4, 1);
stmt.setTimestamp(5, currentTimestamp); stmt.setTimestamp(5, currentTimestamp);
stmt.setInt(6, tenantId);
stmt.addBatch(); stmt.addBatch();
} }
stmt.executeBatch(); stmt.executeBatch();
@ -118,18 +126,20 @@ public class MonitoringDAOImpl implements MonitoringDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet generatedKeys = null; ResultSet generatedKeys = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET STATUS = 0, LAST_FAILED_TIME = ?, POLICY_ID = ?," + String query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET STATUS = 0, LAST_FAILED_TIME = ?, POLICY_ID = ?," +
" ATTEMPTS=0 WHERE DEVICE_ID = ?"; " ATTEMPTS=0 WHERE DEVICE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setTimestamp(1, currentTimestamp); stmt.setTimestamp(1, currentTimestamp);
stmt.setInt(2, policyId); stmt.setInt(2, policyId);
stmt.setInt(3, deviceId); stmt.setInt(3, deviceId);
stmt.setInt(4, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while updating the none compliance to the database."; String msg = "Error occurred while updating the none compliance to the database.";
log.error(msg, e); log.error(msg, e);
@ -147,15 +157,17 @@ public class MonitoringDAOImpl implements MonitoringDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet generatedKeys = null; ResultSet generatedKeys = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET STATUS = ?, ATTEMPTS=0, LAST_SUCCESS_TIME = ?" + String query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET STATUS = ?, ATTEMPTS=0, LAST_SUCCESS_TIME = ?" +
" WHERE DEVICE_ID = ?"; " WHERE DEVICE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, 1); stmt.setInt(1, 1);
stmt.setTimestamp(2, currentTimestamp); stmt.setTimestamp(2, currentTimestamp);
stmt.setInt(3, deviceId); stmt.setInt(3, deviceId);
stmt.setInt(4, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
// generatedKeys = stmt.getGeneratedKeys(); // generatedKeys = stmt.getGeneratedKeys();
@ -180,10 +192,12 @@ public class MonitoringDAOImpl implements MonitoringDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_POLICY_COMPLIANCE_FEATURES (COMPLIANCE_STATUS_ID, FEATURE_CODE, STATUS) " + String query = "INSERT INTO DM_POLICY_COMPLIANCE_FEATURES (COMPLIANCE_STATUS_ID, FEATURE_CODE, STATUS, " +
"VALUES (?, ?, ?) "; "TENANT_ID) VALUES (?, ?, ?, ?) ";
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS); stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
for (ComplianceFeature feature : complianceFeatures) { for (ComplianceFeature feature : complianceFeatures) {
@ -194,6 +208,7 @@ public class MonitoringDAOImpl implements MonitoringDAO {
} else { } else {
stmt.setInt(3, 0); stmt.setInt(3, 0);
} }
stmt.setInt(4, tenantId);
stmt.addBatch(); stmt.addBatch();
} }
stmt.executeBatch(); stmt.executeBatch();
@ -214,11 +229,14 @@ public class MonitoringDAOImpl implements MonitoringDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
ComplianceData complianceData = new ComplianceData(); ComplianceData complianceData = new ComplianceData();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_POLICY_COMPLIANCE_STATUS WHERE DEVICE_ID = ?"; String query = "SELECT * FROM DM_POLICY_COMPLIANCE_STATUS WHERE DEVICE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
@ -246,16 +264,19 @@ public class MonitoringDAOImpl implements MonitoringDAO {
@Override @Override
public List<ComplianceData> getCompliance(List<Integer> deviceIds) throws MonitoringDAOException { public List<ComplianceData> getCompliance(List<Integer> deviceIds) throws MonitoringDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
List<ComplianceData> complianceDataList = new ArrayList<>(); List<ComplianceData> complianceDataList = new ArrayList<>();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_POLICY_COMPLIANCE_STATUS WHERE DEVICE_ID IN (?)"; String query = "SELECT * FROM DM_POLICY_COMPLIANCE_STATUS WHERE TENANT_ID = ? AND DEVICE_ID IN (?)";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setString(1, PolicyManagerUtil.makeString(deviceIds)); stmt.setInt(1, tenantId);
stmt.setString(2, PolicyManagerUtil.makeString(deviceIds));
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
@ -294,11 +315,14 @@ public class MonitoringDAOImpl implements MonitoringDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>(); List<ComplianceFeature> complianceFeatures = new ArrayList<ComplianceFeature>();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_POLICY_COMPLIANCE_FEATURES WHERE COMPLIANCE_STATUS_ID = ?"; String query = "SELECT * FROM DM_POLICY_COMPLIANCE_FEATURES WHERE COMPLIANCE_STATUS_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, policyComplianceStatusId); stmt.setInt(1, policyComplianceStatusId);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
@ -326,11 +350,14 @@ public class MonitoringDAOImpl implements MonitoringDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "DELETE FROM DM_POLICY_COMPLIANCE_FEATURES WHERE COMPLIANCE_STATUS_ID = ?"; String query = "DELETE FROM DM_POLICY_COMPLIANCE_FEATURES WHERE COMPLIANCE_STATUS_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, policyComplianceStatusId); stmt.setInt(1, policyComplianceStatusId);
stmt.setInt(2, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
@ -345,23 +372,27 @@ public class MonitoringDAOImpl implements MonitoringDAO {
@Override @Override
public void updateAttempts(int deviceId, boolean reset) throws MonitoringDAOException { public void updateAttempts(int deviceId, boolean reset) throws MonitoringDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = ""; String query = "";
if (reset) { if (reset) {
query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = 0, LAST_REQUESTED_TIME = ? " + query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = 0, LAST_REQUESTED_TIME = ? " +
"WHERE DEVICE_ID = ?"; "WHERE DEVICE_ID = ? AND TENANT_ID = ?";
} else { } else {
query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = ATTEMPTS + 1, LAST_REQUESTED_TIME = ? " + query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = ATTEMPTS + 1, LAST_REQUESTED_TIME = ? " +
"WHERE DEVICE_ID = ?"; "WHERE DEVICE_ID = ? AND TENANT_ID = ?";
} }
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setTimestamp(1, currentTimestamp); stmt.setTimestamp(1, currentTimestamp);
stmt.setInt(2, deviceId); stmt.setInt(2, deviceId);
stmt.setInt(3, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
@ -376,24 +407,28 @@ public class MonitoringDAOImpl implements MonitoringDAO {
@Override @Override
public void updateAttempts(List<Integer> deviceIds, boolean reset) throws MonitoringDAOException { public void updateAttempts(List<Integer> deviceIds, boolean reset) throws MonitoringDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = ""; String query = "";
if (reset) { if (reset) {
query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = 0, LAST_REQUESTED_TIME = ? " + query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = 0, LAST_REQUESTED_TIME = ? " +
"WHERE DEVICE_ID = ?"; "WHERE DEVICE_ID = ? AND TENANT_ID = ?";
} else { } else {
query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = ATTEMPTS + 1, LAST_REQUESTED_TIME = ? " + query = "UPDATE DM_POLICY_COMPLIANCE_STATUS SET ATTEMPTS = ATTEMPTS + 1, LAST_REQUESTED_TIME = ? " +
"WHERE DEVICE_ID = ?"; "WHERE DEVICE_ID = ? AND TENANT_ID = ?";
} }
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
for (int deviceId : deviceIds) { for (int deviceId : deviceIds) {
stmt.setTimestamp(1, currentTimestamp); stmt.setTimestamp(1, currentTimestamp);
stmt.setInt(2, deviceId); stmt.setInt(2, deviceId);
stmt.setInt(3, tenantId);
stmt.addBatch(); stmt.addBatch();
} }
stmt.executeBatch(); stmt.executeBatch();

@ -54,6 +54,7 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_DEVICE_TYPE_POLICY (DEVICE_TYPE_ID, POLICY_ID) VALUES (?, ?)"; String query = "INSERT INTO DM_DEVICE_TYPE_POLICY (DEVICE_TYPE_ID, POLICY_ID) VALUES (?, ?)";
@ -78,6 +79,7 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_ROLE_POLICY (ROLE_NAME, POLICY_ID) VALUES (?, ?)"; String query = "INSERT INTO DM_ROLE_POLICY (ROLE_NAME, POLICY_ID) VALUES (?, ?)";
@ -104,6 +106,7 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_USER_POLICY (POLICY_ID, USERNAME) VALUES (?, ?)"; String query = "INSERT INTO DM_USER_POLICY (POLICY_ID, USERNAME) VALUES (?, ?)";
@ -130,6 +133,7 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_DEVICE_POLICY (DEVICE_ID, POLICY_ID) VALUES (?, ?)"; String query = "INSERT INTO DM_DEVICE_POLICY (DEVICE_ID, POLICY_ID) VALUES (?, ?)";
@ -155,14 +159,17 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "UPDATE DM_POLICY SET PRIORITY = ? WHERE ID = ?"; String query = "UPDATE DM_POLICY SET PRIORITY = ? WHERE ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
for (Policy policy : policies) { for (Policy policy : policies) {
stmt.setInt(1, policy.getPriorityId()); stmt.setInt(1, policy.getPriorityId());
stmt.setInt(2, policy.getId()); stmt.setInt(2, policy.getId());
stmt.setInt(3, tenantId);
stmt.addBatch(); stmt.addBatch();
} }
stmt.executeBatch(); stmt.executeBatch();
@ -184,8 +191,8 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet generatedKeys; ResultSet generatedKeys;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_CRITERIA (TENANT_ID, NAME) VALUES (?, ?)"; String query = "INSERT INTO DM_CRITERIA (TENANT_ID, NAME) VALUES (?, ?)";
@ -216,13 +223,14 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "UPDATE DM_CRITERIA SET TENANT_ID = ?, NAME = ? WHERE ID = ?"; String query = "UPDATE DM_CRITERIA SET NAME = ? WHERE ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, tenantId); stmt.setString(1, criteria.getName());
stmt.setString(2, criteria.getName()); stmt.setInt(2, criteria.getId());
stmt.setInt(3, criteria.getId()); stmt.setInt(3, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
@ -242,12 +250,14 @@ public class PolicyDAOImpl implements PolicyDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
Criterion criterion = new Criterion(); Criterion criterion = new Criterion();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_CRITERIA WHERE ID= ?"; String query = "SELECT * FROM DM_CRITERIA WHERE ID= ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, id); stmt.setInt(1, id);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -273,12 +283,14 @@ public class PolicyDAOImpl implements PolicyDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
Criterion criterion = new Criterion(); Criterion criterion = new Criterion();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_CRITERIA WHERE NAME= ?"; String query = "SELECT * FROM DM_CRITERIA WHERE NAME= ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setString(1, name); stmt.setString(1, name);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -303,13 +315,15 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
boolean exist = false; boolean exist = false;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_CRITERIA WHERE NAME = ?"; String query = "SELECT * FROM DM_CRITERIA WHERE NAME = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setString(1, name); stmt.setString(1, name);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
exist = resultSet.next(); exist = resultSet.next();
@ -357,11 +371,13 @@ public class PolicyDAOImpl implements PolicyDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
List<Criterion> criteria = new ArrayList<Criterion>(); List<Criterion> criteria = new ArrayList<Criterion>();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_CRITERIA"; String query = "SELECT * FROM DM_CRITERIA WHERE TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -523,17 +539,19 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
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= ?, PROFILE_ID = ?, PRIORITY = ?, COMPLIANCE = ?" +
" WHERE ID = ?"; " WHERE ID = ? AND TENANT_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.getProfile().getProfileId());
stmt.setInt(3, policy.getProfile().getProfileId()); stmt.setInt(3, policy.getPriorityId());
stmt.setInt(4, policy.getPriorityId()); stmt.setString(4, policy.getCompliance());
stmt.setString(5, policy.getCompliance()); stmt.setInt(5, policy.getId());
stmt.setInt(6, policy.getId()); stmt.setInt(6, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
@ -553,11 +571,14 @@ public class PolicyDAOImpl implements PolicyDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
Policy policy = new Policy(); Policy policy = new Policy();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_POLICY WHERE ID= ?"; String query = "SELECT * FROM DM_POLICY WHERE ID= ? AND TENANT_ID = ? ";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, policyId); stmt.setInt(1, policyId);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -576,6 +597,7 @@ public class PolicyDAOImpl implements PolicyDAO {
throw new PolicyManagerDAOException(msg, e); throw new PolicyManagerDAOException(msg, e);
} finally { } finally {
PolicyManagementDAOUtil.cleanupResources(stmt, resultSet); PolicyManagementDAOUtil.cleanupResources(stmt, resultSet);
this.closeConnection();
} }
} }
@ -587,11 +609,14 @@ public class PolicyDAOImpl implements PolicyDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
Policy policy = new Policy(); Policy policy = new Policy();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_POLICY WHERE PROFILE_ID= ?"; String query = "SELECT * FROM DM_POLICY WHERE PROFILE_ID= ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, profileId); stmt.setInt(1, profileId);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -621,10 +646,13 @@ public class PolicyDAOImpl implements PolicyDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
List<Policy> policies = new ArrayList<Policy>(); List<Policy> policies = new ArrayList<Policy>();
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_POLICY"; String query = "SELECT * FROM DM_POLICY WHERE TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -633,7 +661,7 @@ public class PolicyDAOImpl implements PolicyDAO {
policy.setId(resultSet.getInt("ID")); policy.setId(resultSet.getInt("ID"));
policy.setProfileId(resultSet.getInt("PROFILE_ID")); policy.setProfileId(resultSet.getInt("PROFILE_ID"));
policy.setPolicyName(resultSet.getString("NAME")); policy.setPolicyName(resultSet.getString("NAME"));
policy.setTenantId(resultSet.getInt("TENANT_ID")); policy.setTenantId(tenantId);
policy.setPriorityId(resultSet.getInt("PRIORITY")); policy.setPriorityId(resultSet.getInt("PRIORITY"));
policy.setCompliance(resultSet.getString("COMPLIANCE")); policy.setCompliance(resultSet.getString("COMPLIANCE"));
policy.setOwnershipType(resultSet.getString("OWNERSHIP_TYPE")); policy.setOwnershipType(resultSet.getString("OWNERSHIP_TYPE"));
@ -750,13 +778,13 @@ public class PolicyDAOImpl implements PolicyDAO {
@Override @Override
public void addEffectivePolicyToDevice(int deviceId, Policy policy) public void addEffectivePolicyToDevice(int deviceId, Policy policy) throws PolicyManagerDAOException {
throws PolicyManagerDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "INSERT INTO DM_DEVICE_POLICY_APPLIED (DEVICE_ID, POLICY_ID, POLICY_CONTENT, " + String query = "INSERT INTO DM_DEVICE_POLICY_APPLIED (DEVICE_ID, POLICY_ID, POLICY_CONTENT, " +
@ -791,13 +819,17 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "UPDATE DM_DEVICE_POLICY_APPLIED SET APPLIED_TIME = ?, APPLIED = ? WHERE DEVICE_ID = ? "; String query = "UPDATE DM_DEVICE_POLICY_APPLIED SET APPLIED_TIME = ?, APPLIED = ? WHERE DEVICE_ID = ? AND" +
" TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setTimestamp(1, currentTimestamp); stmt.setTimestamp(1, currentTimestamp);
stmt.setBoolean(2, true); stmt.setBoolean(2, true);
stmt.setInt(3, deviceId); stmt.setInt(3, deviceId);
stmt.setInt(4, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
@ -818,16 +850,19 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime());
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
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 = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, policy.getId()); stmt.setInt(1, policy.getId());
stmt.setBytes(2, PolicyManagerUtil.getBytes(policy)); stmt.setBytes(2, PolicyManagerUtil.getBytes(policy));
stmt.setTimestamp(3, currentTimestamp); stmt.setTimestamp(3, currentTimestamp);
stmt.setBoolean(4, false); stmt.setBoolean(4, false);
stmt.setInt(5, deviceId); stmt.setInt(5, deviceId);
stmt.setInt(6, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
} catch (SQLException e) { } catch (SQLException e) {
@ -846,16 +881,19 @@ public class PolicyDAOImpl implements PolicyDAO {
@Override @Override
public boolean checkPolicyAvailable(int deviceId) throws PolicyManagerDAOException { public boolean checkPolicyAvailable(int deviceId) throws PolicyManagerDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
boolean exist = false; boolean exist = false;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ?"; String query = "SELECT * FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
exist = resultSet.next(); exist = resultSet.next();
@ -965,12 +1003,14 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "DELETE FROM DM_POLICY WHERE ID = ?"; String query = "DELETE FROM DM_POLICY WHERE ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, policy.getId()); stmt.setInt(1, policy.getId());
stmt.setInt(2, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -988,14 +1028,17 @@ public class PolicyDAOImpl implements PolicyDAO {
@Override @Override
public boolean deletePolicy(int policyId) throws PolicyManagerDAOException { public boolean deletePolicy(int policyId) throws PolicyManagerDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "DELETE FROM DM_POLICY WHERE ID = ?"; String query = "DELETE FROM DM_POLICY WHERE ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, policyId); stmt.setInt(1, policyId);
stmt.setInt(2, tenantId);
stmt.executeUpdate(); stmt.executeUpdate();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -1158,11 +1201,13 @@ public class PolicyDAOImpl implements PolicyDAO {
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
int priority = 0; int priority = 0;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT MAX(PRIORITY) PRIORITY FROM DM_POLICY;"; String query = "SELECT MAX(PRIORITY) PRIORITY FROM DM_POLICY WHERE TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -1188,11 +1233,14 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
int policyCount = 0; int policyCount = 0;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT COUNT(ID) AS POLICY_COUNT FROM DM_POLICY"; String query = "SELECT COUNT(ID) AS POLICY_COUNT FROM DM_POLICY WHERE TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -1216,12 +1264,14 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ?"; String query = "SELECT * FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
@ -1246,21 +1296,16 @@ public class PolicyDAOImpl implements PolicyDAO {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
Policy policy = null; Policy policy = null;
try { try {
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ?"; String query = "SELECT * FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ? AND TENANT_ID = ?";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);
stmt.setInt(1, deviceId); stmt.setInt(1, deviceId);
stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
// log.debug("Logging the statement................." + stmt.toString());
// log.debug("+++++++++++++++++++++++++++++");
// log.debug(conn.toString());
// log.debug("+++++++++++++++++++++++++++++");
while (resultSet.next()) { while (resultSet.next()) {
ByteArrayInputStream bais = null; ByteArrayInputStream bais = null;
@ -1320,6 +1365,7 @@ public class PolicyDAOImpl implements PolicyDAO {
@Override @Override
public HashMap<Integer, Integer> getAppliedPolicyIds(List<Integer> deviceIds) throws PolicyManagerDAOException { public HashMap<Integer, Integer> getAppliedPolicyIds(List<Integer> deviceIds) throws PolicyManagerDAOException {
Connection conn; Connection conn;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet resultSet = null; ResultSet resultSet = null;

@ -225,6 +225,7 @@ public class ProfileDAOImpl implements ProfileDAO {
List<Profile> profileList = new ArrayList<Profile>(); List<Profile> profileList = new ArrayList<Profile>();
try { try {
//TODO : Fix with TenantID.
conn = this.getConnection(); conn = this.getConnection();
String query = "SELECT * FROM DM_PROFILE"; String query = "SELECT * FROM DM_PROFILE";
stmt = conn.prepareStatement(query); stmt = conn.prepareStatement(query);

@ -140,17 +140,24 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
} }
} else { } else {
List<ComplianceFeature> noneComplianceFeatures = complianceData.getComplianceFeatures(); List<ComplianceFeature> noneComplianceFeatures = complianceData.getComplianceFeatures();
List<ProfileFeature> effectiveFeatures = policy.getProfile().getProfileFeaturesList();
for (ComplianceFeature feature : noneComplianceFeatures) { for (ComplianceFeature feature : noneComplianceFeatures) {
for (ProfileFeature pf : effectiveFeatures) {
if (pf.getFeatureCode().equalsIgnoreCase(feature.getFeatureCode())) {
ProfileOperation profileOperation = new ProfileOperation(); ProfileOperation profileOperation = new ProfileOperation();
profileOperation.setCode(feature.getFeatureCode()); profileOperation.setCode(feature.getFeatureCode());
profileOperation.setEnabled(true); profileOperation.setEnabled(true);
profileOperation.setStatus(Operation.Status.PENDING); profileOperation.setStatus(Operation.Status.PENDING);
profileOperation.setType(Operation.Type.PROFILE); profileOperation.setType(Operation.Type.PROFILE);
profileOperation.setPayLoad(feature.getFeature().getContent()); profileOperation.setPayLoad(pf.getContent());
profileOperationList.add(profileOperation); profileOperationList.add(profileOperation);
} }
} }
}
}
policyOperation.setProfileOperations(profileOperationList); policyOperation.setProfileOperations(profileOperationList);
policyOperation.setPayLoad(policyOperation.getProfileOperations()); policyOperation.setPayLoad(policyOperation.getProfileOperations());
PolicyManagementDataHolder.getInstance().getDeviceManagementService(). PolicyManagementDataHolder.getInstance().getDeviceManagementService().

@ -58,22 +58,22 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
@Override @Override
public Policy addPolicy(Policy policy) throws PolicyManagementException { public Policy addPolicy(Policy policy) throws PolicyManagementException {
Policy resultantPolicy = policyManager.addPolicy(policy); Policy resultantPolicy = policyManager.addPolicy(policy);
try { // try {
delegator.delegate(resultantPolicy, resultantPolicy.getDevices()); // delegator.delegate(resultantPolicy, resultantPolicy.getDevices());
} catch (PolicyDelegationException e) { // } catch (PolicyDelegationException e) {
throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e); // throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e);
} // }
return resultantPolicy; return resultantPolicy;
} }
@Override @Override
public Policy updatePolicy(Policy policy) throws PolicyManagementException { public Policy updatePolicy(Policy policy) throws PolicyManagementException {
Policy resultantPolicy = policyManager.updatePolicy(policy); Policy resultantPolicy = policyManager.updatePolicy(policy);
try { // try {
delegator.delegate(resultantPolicy, resultantPolicy.getDevices()); // delegator.delegate(resultantPolicy, resultantPolicy.getDevices());
} catch (PolicyDelegationException e) { // } catch (PolicyDelegationException e) {
throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e); // throw new PolicyManagementException("Error occurred while delegating policy operation to the devices", e);
} // }
return resultantPolicy; return resultantPolicy;
} }

@ -89,13 +89,19 @@ public class PolicyFilterImpl implements PolicyFilter {
List<Policy> temp = new ArrayList<Policy>(); List<Policy> temp = new ArrayList<Policy>();
for (Policy policy : policies) { for (Policy policy : policies) {
List<String> users = policy.getUsers(); List<String> users = policy.getUsers();
if(users.contains(PolicyManagementConstants.ANY)) {
if (users.isEmpty()) {
temp.add(policy);
continue;
}
if (users.contains(PolicyManagementConstants.ANY)) {
temp.add(policy); temp.add(policy);
continue; continue;
} }
for (String user : users) { for (String user : users) {
if(username.equalsIgnoreCase(user)) { if (username.equalsIgnoreCase(user)) {
temp.add(policy); temp.add(policy);
} }
} }

@ -304,7 +304,7 @@ public class MonitoringManagerImpl implements MonitoringManager {
if (!deviceIdsWithExistingOperation.isEmpty()) { if (!deviceIdsWithExistingOperation.isEmpty()) {
monitoringDAO.updateAttempts(new ArrayList<>(deviceIdsWithExistingOperation.keySet()), false); monitoringDAO.updateAttempts(new ArrayList<>(deviceIdsWithExistingOperation.keySet()), false);
//TODO uncomment with proper fix //TODO: Add attempts. This has to be fixed in the get pending operation tables too. This will be
// decisionPoint.setDevicesAsUnreachable(this.getDeviceIdentifiersFromDevices( // decisionPoint.setDevicesAsUnreachable(this.getDeviceIdentifiersFromDevices(
// new ArrayList<>(deviceIdsWithExistingOperation.values()))); // new ArrayList<>(deviceIdsWithExistingOperation.values())));
} }

@ -291,8 +291,9 @@ public class PolicyManagerImpl implements PolicyManager {
public boolean deletePolicy(int policyId) throws PolicyManagementException { public boolean deletePolicy(int policyId) throws PolicyManagementException {
try { try {
PolicyManagementDAOFactory.beginTransaction();
Policy policy = policyDAO.getPolicy(policyId); Policy policy = policyDAO.getPolicy(policyId);
PolicyManagementDAOFactory.beginTransaction();
policyDAO.deleteAllPolicyRelatedConfigs(policyId); policyDAO.deleteAllPolicyRelatedConfigs(policyId);
policyDAO.deletePolicy(policyId); policyDAO.deletePolicy(policyId);

@ -37,4 +37,9 @@ public final class PolicyManagementConstants {
public static final String TASK_CLAZZ = "org.wso2.carbon.policy.mgt.core.task.MonitoringTask"; public static final String TASK_CLAZZ = "org.wso2.carbon.policy.mgt.core.task.MonitoringTask";
public static final String DM_CACHE_MANAGER = "DM_CACHE_MANAGER";
public static final String DM_CACHE = "DM_CACHE";
} }

@ -31,6 +31,9 @@ import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig;
import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition; import org.wso2.carbon.policy.mgt.core.config.datasource.JNDILookupDefinition;
import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil; import org.wso2.carbon.policy.mgt.core.dao.util.PolicyManagementDAOUtil;
import javax.cache.Cache;
import javax.cache.CacheManager;
import javax.cache.Caching;
import javax.sql.DataSource; import javax.sql.DataSource;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
@ -136,4 +139,10 @@ public class PolicyManagerUtil {
byte[] data = bos.toByteArray(); byte[] data = bos.toByteArray();
return data; return data;
} }
public static Cache getCacheManagerImpl(){
return Caching.getCacheManagerFactory()
.getCacheManager(PolicyManagementConstants.DM_CACHE_MANAGER).getCache(PolicyManagementConstants.DM_CACHE);
}
} }

@ -31,6 +31,7 @@ import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import org.wso2.carbon.policy.mgt.common.*; import org.wso2.carbon.policy.mgt.common.*;
import org.wso2.carbon.policy.mgt.core.impl.PolicyAdministratorPointImpl; import org.wso2.carbon.policy.mgt.core.impl.PolicyAdministratorPointImpl;
import org.wso2.carbon.policy.mgt.core.internal.PolicyManagementDataHolder;
import org.wso2.carbon.policy.mgt.core.mgt.FeatureManager; import org.wso2.carbon.policy.mgt.core.mgt.FeatureManager;
import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager; import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager;
import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager; import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager;
@ -97,6 +98,8 @@ public class PolicyDAOTestCase extends BasePolicyManagementDAOTest {
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl(); DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
PolicyManagementDataHolder.getInstance().setDeviceManagementService(service);
log.debug("Printing device taken by calling the service layer with device type."); log.debug("Printing device taken by calling the service layer with device type.");
List<Device> devices3 = service.getAllDevices("android"); List<Device> devices3 = service.getAllDevices("android");

@ -37,7 +37,7 @@ public class PolicyCreator {
List<String> users = new ArrayList<String>(); List<String> users = new ArrayList<String>();
users.add("Dilshan"); users.add("Dilshan");
policy.setUsers(users); policy.setUsers(users);
policy.setCompliance("ENFORCE"); policy.setCompliance("NOTIFY");
policy.setOwnershipType("COPE"); policy.setOwnershipType("COPE");
return policy; return policy;
@ -52,7 +52,7 @@ public class PolicyCreator {
policy.setProfile(profile); policy.setProfile(profile);
policy.setDevices(DeviceCreator.getDeviceList(DeviceTypeCreator.getDeviceType())); policy.setDevices(DeviceCreator.getDeviceList(DeviceTypeCreator.getDeviceType()));
policy.setCompliance("NOTIFY"); policy.setCompliance("ENFORCE");
List<String> roles = new ArrayList<String>(); List<String> roles = new ArrayList<String>();
roles.add("Role_01"); roles.add("Role_01");

@ -201,6 +201,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
PROFILE_ID INT(11) NOT NULL, PROFILE_ID INT(11) NOT NULL,
FEATURE_CODE VARCHAR(30) NOT NULL, FEATURE_CODE VARCHAR(30) NOT NULL,
DEVICE_TYPE_ID INT NOT NULL, DEVICE_TYPE_ID INT NOT NULL,
TENANT_ID INT(11) NOT NULL ,
CONTENT BLOB NULL DEFAULT NULL, CONTENT BLOB NULL DEFAULT NULL,
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES
@ -314,6 +315,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
DEVICE_ID INT NOT NULL, DEVICE_ID INT NOT NULL,
POLICY_ID INT NOT NULL, POLICY_ID INT NOT NULL,
TENANT_ID INT NOT NULL,
STATUS INT NULL, STATUS INT NULL,
LAST_SUCCESS_TIME TIMESTAMP NULL, LAST_SUCCESS_TIME TIMESTAMP NULL,
LAST_REQUESTED_TIME TIMESTAMP NULL, LAST_REQUESTED_TIME TIMESTAMP NULL,
@ -332,6 +334,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
COMPLIANCE_STATUS_ID INT NOT NULL, COMPLIANCE_STATUS_ID INT NOT NULL,
TENANT_ID INT NOT NULL,
FEATURE_CODE VARCHAR(15) NOT NULL, FEATURE_CODE VARCHAR(15) NOT NULL,
STATUS INT NULL, STATUS INT NULL,
PRIMARY KEY (ID), PRIMARY KEY (ID),

@ -191,6 +191,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
PROFILE_ID INT(11) NOT NULL, PROFILE_ID INT(11) NOT NULL,
FEATURE_CODE VARCHAR(30) NOT NULL, FEATURE_CODE VARCHAR(30) NOT NULL,
DEVICE_TYPE_ID INT NOT NULL, DEVICE_TYPE_ID INT NOT NULL,
TENANT_ID INT(11) NOT NULL ,
CONTENT BLOB NULL DEFAULT NULL, CONTENT BLOB NULL DEFAULT NULL,
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES
@ -300,6 +301,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
DEVICE_ID INT NOT NULL, DEVICE_ID INT NOT NULL,
POLICY_ID INT NOT NULL, POLICY_ID INT NOT NULL,
TENANT_ID INT NOT NULL,
STATUS INT NULL, STATUS INT NULL,
LAST_SUCCESS_TIME TIMESTAMP NULL, LAST_SUCCESS_TIME TIMESTAMP NULL,
LAST_REQUESTED_TIME TIMESTAMP NULL, LAST_REQUESTED_TIME TIMESTAMP NULL,
@ -318,6 +320,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS (
CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_FEATURES (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
COMPLIANCE_STATUS_ID INT NOT NULL, COMPLIANCE_STATUS_ID INT NOT NULL,
TENANT_ID INT NOT NULL,
FEATURE_CODE VARCHAR(15) NOT NULL, FEATURE_CODE VARCHAR(15) NOT NULL,
STATUS INT NULL, STATUS INT NULL,
PRIMARY KEY (ID), PRIMARY KEY (ID),

@ -414,10 +414,10 @@
<groupId>org.eclipse.equinox</groupId> <groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.http.helper</artifactId> <artifactId>org.eclipse.equinox.http.helper</artifactId>
</exclusion> </exclusion>
<exclusion> <!--<exclusion>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>javax.cache.wso2</artifactId> <artifactId>javax.cache.wso2</artifactId>
</exclusion> </exclusion>-->
<exclusion> <exclusion>
<groupId>org.wso2.carbon</groupId> <groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.core</artifactId> <artifactId>org.wso2.carbon.registry.core</artifactId>

Loading…
Cancel
Save