diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index cd777fb7b8..19658c340f 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -455,14 +455,17 @@ public class PolicyManagerImpl implements PolicyManager { @Override public List getPolicies() throws PolicyManagementException { - List policyList; - + List profileList; + try { + profileList = profileManager.getAllProfiles(); + } catch (ProfileManagementException e) { + throw new PolicyManagementException("Error occurred while getting all the profiles.", e); + } try { PolicyManagementDAOFactory.openConnection(); policyList = policyDAO.getAllPolicies(); // List profileList = profileDAO.getAllProfiles(); - List profileList = profileManager.getAllProfiles(); for (Policy policy : policyList) { for (Profile profile : profileList) { @@ -481,8 +484,6 @@ public class PolicyManagerImpl implements PolicyManager { Collections.sort(policyList); } catch (PolicyManagerDAOException e) { throw new PolicyManagementException("Error occurred while getting all the policies.", e); - } catch (ProfileManagementException e) { - throw new PolicyManagementException("Error occurred while getting all the profiles.", e); } catch (SQLException e) { throw new PolicyManagementException("Error occurred while opening a connection to the data source", e); } finally {