From 3e37b73360b6b138c851e1b0df899b16ff74d685 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Fri, 22 May 2015 01:17:20 +0530 Subject: [PATCH] Removing unnessaccery code blocks --- .../core/impl/PolicyInformationPointImpl.java | 44 ++++--------------- 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java index 2addda1a81..ef537bbc1c 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyInformationPointImpl.java @@ -88,47 +88,19 @@ public class PolicyInformationPointImpl implements PolicyInformationPoint { @Override public List getRelatedPolicies(PIPDevice pipDevice) throws PolicyManagementException { -// List> policies = new ArrayList>(); - List policies = new ArrayList(); - try { - // Get the device type related policies -// policies.add(policyManager.getPoliciesOfDeviceType(pipDevice.getDeviceType().getName())); - - - // Commented out because these are already taken when device type based policies retrieved - -// // Get the roles related policies -// for (String role : pipDevice.getRoles()) { -// policies.add(policyManager.getPoliciesOfRole(role)); -// } -// // Get policy related to the device -// policies.add(policyManager.getPoliciesOfDevice(pipDevice.getDeviceIdentifier())); + List policies = policyManager.getPoliciesOfDeviceType(pipDevice.getDeviceType().getName()); + PolicyFilter policyFilter = new PolicyFilterImpl(); + policyFilter.filterDeviceTypeBasedPolicies(pipDevice.getDeviceType().getName(), policies); + policyFilter.filterOwnershipTypeBasedPolicies(pipDevice.getOwnershipType(), policies); + policyFilter.filterRolesBasedPolicies(pipDevice.getRoles(), policies); - policies = policyManager.getPoliciesOfDeviceType(pipDevice.getDeviceType().getName()); - - PolicyFilter policyFilter = new PolicyFilterImpl(); - policyFilter.filterDeviceTypeBasedPolicies(pipDevice.getDeviceType().getName(), policies); - policyFilter.filterOwnershipTypeBasedPolicies(pipDevice.getOwnershipType(), policies); - policyFilter.filterRolesBasedPolicies(pipDevice.getRoles(), policies); - - return policies; - } catch (PolicyManagementException e) { - String msg = "Error occurred when retrieving related to given device " + - pipDevice.getDeviceIdentifier().getId() + " " + pipDevice.getDeviceIdentifier().getType() + "."; - log.error(msg, e); - throw new PolicyManagementException(msg, e); - } + return policies; } @Override public List getRelatedFeatures(String deviceType) throws FeatureManagementException { - try { - return featureManager.getAllFeatures(deviceType); - } catch (FeatureManagementException e) { - String msg = "Error occurred when retrieving features related to device type."; - log.error(msg, e); - throw new FeatureManagementException(msg, e); - } + return featureManager.getAllFeatures(deviceType); + } private String[] getRoleOfDevice(Device device) throws PolicyManagementException {