Code revie fixes

revert-70aa11f8
Geeth Munasinghe 10 years ago
parent 2c1178011b
commit a872caeefc

@ -27,17 +27,18 @@ import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
//TODO :
public class PIPDevice {
Device device;
DeviceType deviceType;
DeviceIdentifier deviceIdentifier;
String ownershipType;
List<String> userIds;
String roles [];
String altitude;
String longitude;
Timestamp timestamp;
private Device device;
private DeviceType deviceType;
private DeviceIdentifier deviceIdentifier;
private String ownershipType;
private List<String> userIds;
private String roles[];
private String altitude;
private String longitude;
private Timestamp timestamp;
/*This will be used to record attributes to which would come from other PDPs*/
Map<String, Object> attributes;

@ -34,7 +34,7 @@ public interface PolicyEvaluationPoint {
* @param deviceIdentifier device information.
* @return returns the effective policy.
*/
Policy getEffectivePolicies(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException;
Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException;
/**

@ -124,7 +124,7 @@ CREATE TABLE IF NOT EXISTS `WSO2CDM`.`DM_FEATURES` (
`NAME` VARCHAR(256) NOT NULL ,
`CODE` VARCHAR(45) NULL DEFAULT NULL ,
`DESCRIPTION` TEXT NULL DEFAULT NULL ,
`EVALUVATION_RULE` VARCHAR(60) NOT NULL ,
`EVALUATION_RULE` VARCHAR(60) NOT NULL ,
PRIMARY KEY (`ID`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = latin1;

@ -77,7 +77,7 @@ public class PolicyManagerServiceImpl implements PolicyManagerService {
public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyManagementException {
try {
return PolicyManagementDataHolder.getInstance().getPolicyEvaluationPoint().
getEffectivePolicies(deviceIdentifier);
getEffectivePolicy(deviceIdentifier);
} catch (PolicyEvaluationException e) {
String msg = "Error occurred while getting the effective policies from the PEP service for device " +
deviceIdentifier.getId() + " - " + deviceIdentifier.getType();

@ -38,9 +38,11 @@ public interface FeatureDAO {
ProfileFeature updateProfileFeature(ProfileFeature feature, int profileId) throws FeatureManagerDAOException;
List<ProfileFeature> addProfileFeatures(List<ProfileFeature> features, int profileId) throws FeatureManagerDAOException;
List<ProfileFeature> addProfileFeatures(List<ProfileFeature> features, int profileId) throws
FeatureManagerDAOException;
List<ProfileFeature> updateProfileFeatures(List<ProfileFeature> features, int profileId) throws FeatureManagerDAOException;
List<ProfileFeature> updateProfileFeatures(List<ProfileFeature> features, int profileId) throws
FeatureManagerDAOException;
List<Feature> getAllFeatures() throws FeatureManagerDAOException;

@ -50,7 +50,7 @@ public class FeatureDAOImpl implements FeatureDAO {
try {
conn = this.getConnection();
String query = "INSERT INTO DM_FEATURES (NAME, CODE, DESCRIPTION, EVALUVATION_RULE, DEVICE_TYPE_ID) VALUES (?, ?, ?, ?, ?)";
String query = "INSERT INTO DM_FEATURES (NAME, CODE, DESCRIPTION, EVALUATION_RULE, DEVICE_TYPE_ID) VALUES (?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
stmt.setString(1, feature.getName());
stmt.setString(2, feature.getCode());
@ -88,7 +88,7 @@ public class FeatureDAOImpl implements FeatureDAO {
try {
conn = this.getConnection();
String query = "INSERT INTO DM_FEATURES (NAME, CODE, DESCRIPTION, EVALUVATION_RULE, DEVICE_TYPE_ID) VALUES (?, ?, ?, ?, ?)";
String query = "INSERT INTO DM_FEATURES (NAME, CODE, DESCRIPTION, EVALUATION_RULE, DEVICE_TYPE_ID) VALUES (?, ?, ?, ?, ?)";
stmt = conn.prepareStatement(query, PreparedStatement.RETURN_GENERATED_KEYS);
for (Feature feature : features) {
@ -133,7 +133,7 @@ public class FeatureDAOImpl implements FeatureDAO {
try {
conn = this.getConnection();
String query = "UPDATE DM_FEATURES SET NAME = ?, CODE = ?, DESCRIPTION = ?, EVALUVATION_RULE = ? WHERE ID = ?";
String query = "UPDATE DM_FEATURES SET NAME = ?, CODE = ?, DESCRIPTION = ?, EVALUATION_RULE = ? WHERE ID = ?";
stmt = conn.prepareStatement(query);
stmt.setString(1, feature.getName());
stmt.setString(2, feature.getCode());
@ -266,7 +266,7 @@ public class FeatureDAOImpl implements FeatureDAO {
try {
conn = this.getConnection();
String query = "SELECT ID, NAME, CODE, DEVICE_TYPE_ID, EVALUVATION_RULE FROM DM_FEATURES";
String query = "SELECT ID, NAME, CODE, DEVICE_TYPE_ID, EVALUATION_RULE FROM DM_FEATURES";
stmt = conn.prepareStatement(query);
resultSet = stmt.executeQuery();
@ -277,7 +277,7 @@ public class FeatureDAOImpl implements FeatureDAO {
feature.setCode(resultSet.getString("CODE"));
feature.setName(resultSet.getString("NAME"));
feature.setDeviceTypeId(resultSet.getInt("DEVICE_TYPE_ID"));
feature.setRuleValue(resultSet.getString("EVALUVATION_RULE"));
feature.setRuleValue(resultSet.getString("EVALUATION_RULE"));
featureList.add(feature);
}
@ -303,7 +303,7 @@ public class FeatureDAOImpl implements FeatureDAO {
try {
conn = this.getConnection();
String query = "SELECT PF.ID AS ID, PF.FEATURE_ID FEATURE_ID, F.NAME NAME, F.CODE CODE, " +
"F.EVALUVATION_RULE RULE, F.CONTENT AS CONTENT FROM DM_PROFILE_FEATURES AS PF " +
"F.EVALUATION_RULE RULE, F.CONTENT AS CONTENT FROM DM_PROFILE_FEATURES AS PF " +
"JOIN DM_FEATURES AS F ON F.ID = PF.FEATURE_ID";
stmt = conn.prepareStatement(query);
resultSet = stmt.executeQuery();
@ -345,7 +345,7 @@ public class FeatureDAOImpl implements FeatureDAO {
try {
conn = this.getConnection();
String query = "SELECT f.ID ID, f.NAME NAME, f.CODE CODE, f.DEVICE_TYPE_ID DEVICE_TYPE_ID," +
" f.EVALUVATION_RULE EVALUVATION_RULE FROM DM_FEATURES f INNER JOIN DM_DEVICE_TYPE d " +
" f.EVALUATION_RULE EVALUATION_RULE FROM DM_FEATURES f INNER JOIN DM_DEVICE_TYPE d " +
"ON d.ID=f.DEVICE_TYPE_ID WHERE d.NAME = ?";
stmt = conn.prepareStatement(query);
stmt.setString(1, deviceType);
@ -358,7 +358,7 @@ public class FeatureDAOImpl implements FeatureDAO {
feature.setCode(resultSet.getString("CODE"));
feature.setName(resultSet.getString("NAME"));
feature.setDeviceTypeId(resultSet.getInt("DEVICE_TYPE_ID"));
feature.setRuleValue(resultSet.getString("EVALUVATION_RULE"));
feature.setRuleValue(resultSet.getString("EVALUATION_RULE"));
featureList.add(feature);
}
@ -384,7 +384,7 @@ public class FeatureDAOImpl implements FeatureDAO {
try {
conn = this.getConnection();
String query = "SELECT PF.ID AS ID, PF.FEATURE_ID FEATURE_ID, F.NAME NAME, F.CODE CODE, " +
"F.EVALUVATION_RULE RULE, F.CONTENT AS CONTENT FROM DM_PROFILE_FEATURES AS PF " +
"F.EVALUATION_RULE RULE, F.CONTENT AS CONTENT FROM DM_PROFILE_FEATURES AS PF " +
"JOIN DM_FEATURES AS F ON F.ID = PF.FEATURE_ID WHERE PROFILE_ID=?";
stmt = conn.prepareStatement(query);
stmt.setInt(1, profileId);

@ -20,13 +20,8 @@ package org.wso2.carbon.policy.mgt.core.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.core.dto.Device;
import org.wso2.carbon.policy.mgt.common.Policy;
import org.wso2.carbon.policy.mgt.common.PolicyDates;
import org.wso2.carbon.policy.mgt.common.PolicyLocations;
import org.wso2.carbon.policy.mgt.common.PolicyTimes;
import org.wso2.carbon.policy.mgt.common.ProfileFeature;
import org.wso2.carbon.policy.mgt.common.*;
import org.wso2.carbon.policy.mgt.core.dao.PolicyDAO;
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagementDAOFactory;
import org.wso2.carbon.policy.mgt.core.dao.PolicyManagerDAOException;

@ -53,7 +53,7 @@ import org.wso2.carbon.user.core.service.RealmService;
* bind="setDeviceManagementService"
* unbind="unsetDeviceManagementService"
*/
@SuppressWarnings("unused")
public class PolicyManagementServiceComponent {
private static Log log = LogFactory.getLog(PolicyManagementServiceComponent.class);
@ -70,8 +70,7 @@ public class PolicyManagementServiceComponent {
PolicyManagerService.class.getName(), new PolicyManagementService(), null);
} catch (Throwable t) {
String msg = "Error occurred while initializing the Policy management core.";
log.error(msg, t);
log.error("Error occurred while initializing the Policy management core.", t);
}
}

@ -142,7 +142,7 @@ CREATE TABLE IF NOT EXISTS DM_FEATURES (
CODE VARCHAR(45) NULL DEFAULT NULL ,
DEVICE_TYPE_ID INT NOT NULL ,
DESCRIPTION TEXT NULL DEFAULT NULL ,
EVALUVATION_RULE VARCHAR(60) NOT NULL ,
EVALUATION_RULE VARCHAR(60) NOT NULL ,
PRIMARY KEY (ID) ,
CONSTRAINT DM_FEATURES_DEVICE_TYPE
FOREIGN KEY (DEVICE_TYPE_ID )

@ -154,7 +154,7 @@ CREATE TABLE IF NOT EXISTS `WSO2CDM`.`DM_FEATURES` (
`CODE` VARCHAR(45) NULL DEFAULT NULL ,
`DEVICE_TYPE_ID` INT NOT NULL ,
`DESCRIPTION` TEXT NULL DEFAULT NULL ,
`EVALUVATION_RULE` VARCHAR(60) NOT NULL ,
`EVALUATION_RULE` VARCHAR(60) NOT NULL ,
PRIMARY KEY (`ID`) ,
INDEX `DM_FEATURES_DEVICE_TYPE` (`DEVICE_TYPE_ID` ASC) ,
CONSTRAINT `DM_FEATURES_DEVICE_TYPE`
@ -286,6 +286,36 @@ CREATE TABLE IF NOT EXISTS `WSO2CDM`.`DM_USER_POLICY` (
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `WSO2CDM`.`DM_DEVICE_POLICY_APPLIED`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `WSO2CDM`.`DM_DEVICE_POLICY_APPLIED` ;
CREATE TABLE IF NOT EXISTS `WSO2CDM`.`DM_DEVICE_POLICY_APPLIED` (
`ID` INT NOT NULL AUTO_INCREMENT ,
`DEVICE_ID` INT NOT NULL ,
`POLICY_ID` INT NOT NULL ,
`POLICY_CONTENT` BLOB NULL ,
`APPLIED` TINYINT(1) NULL ,
`CREATED_TIME` TIMESTAMP NULL ,
`UPDATED_TIME` TIMESTAMP NULL ,
`APPLIED_TIME` TIMESTAMP NULL ,
PRIMARY KEY (`ID`) ,
INDEX `FK_DM_POLICY_DEVCIE_APPLIED` (`DEVICE_ID` ASC) ,
INDEX `FK_DM_POLICY_DEVICE_APPLIED_POLICY` (`POLICY_ID` ASC) ,
CONSTRAINT `FK_DM_POLICY_DEVCIE_APPLIED`
FOREIGN KEY (`DEVICE_ID` )
REFERENCES `WSO2CDM`.`DM_DEVICE` (`ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `FK_DM_POLICY_DEVICE_APPLIED_POLICY`
FOREIGN KEY (`POLICY_ID` )
REFERENCES `WSO2CDM`.`DM_POLICY` (`ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;

@ -35,7 +35,7 @@ public class PolicyEvaluationServiceImpl implements PolicyEvaluationPoint {
}
@Override
public Policy getEffectivePolicies(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException {
public Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException {
return evaluation.getEffectivePolicy(deviceIdentifier);
}

@ -25,7 +25,7 @@ import org.wso2.carbon.policy.mgt.common.PolicyEvaluationException;
public interface SimpleEvaluation {
void sortPolicy() throws PolicyEvaluationException;
void sortPolicies() throws PolicyEvaluationException;
Policy getEffectivePolicy(DeviceIdentifier deviceIdentifier) throws PolicyEvaluationException;

@ -25,14 +25,16 @@ import org.wso2.carbon.policy.mgt.common.*;
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
import org.wso2.carbon.simple.policy.decision.point.internal.PolicyDecisionPointDataHolder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class SimpleEvaluationImpl implements SimpleEvaluation {
private static final Log log = LogFactory.getLog(SimpleEvaluationImpl.class);
//TODO : to revove the stale reference
private PolicyManagerService policyManagerService;
private List<Policy> policyList;
private List<Policy> policyList = new ArrayList<Policy>();
public SimpleEvaluationImpl() {
policyManagerService = PolicyDecisionPointDataHolder.getInstance().getPolicyManagerService();
@ -45,13 +47,13 @@ public class SimpleEvaluationImpl implements SimpleEvaluation {
PolicyInformationPoint policyInformationPoint;
try {
if (policyManagerService != null && policyList == null) {
if (policyManagerService != null) {
policyInformationPoint = policyManagerService.getPIP();
PIPDevice pipDevice = policyInformationPoint.getDeviceData(deviceIdentifier);
policyList = policyInformationPoint.getRelatedPolicies(pipDevice);
sortPolicy();
sortPolicies();
policy = policyList.get(0);
policyAdministratorPoint = policyManagerService.getPAP();
@ -69,7 +71,7 @@ public class SimpleEvaluationImpl implements SimpleEvaluation {
@Override
public void sortPolicy() throws PolicyEvaluationException {
public void sortPolicies() throws PolicyEvaluationException {
Collections.sort(policyList);
}
}

Loading…
Cancel
Save