From 341abb47ab57ae69a65645c1269d4e8685138017 Mon Sep 17 00:00:00 2001 From: Dulitha Wijewantha Date: Thu, 21 May 2015 16:48:49 +0530 Subject: [PATCH] Fixes to the timestamp and filters --- .../policy/mgt/core/impl/PolicyFilterImpl.java | 14 +++++++------- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 14 +++++++++++--- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java index 5c0abca774..abcaafd3f8 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/main/java/org/wso2/carbon/policy/mgt/core/impl/PolicyFilterImpl.java @@ -60,13 +60,13 @@ public class PolicyFilterImpl implements PolicyFilter { @Override public void filterOwnershipTypeBasedPolicies(String ownershipType, List policies) { - List temp = new ArrayList(); - for (Policy policy : policies) { - if (ownershipType.equalsIgnoreCase(policy.getOwnershipType())) { - temp.add(policy); - } - } - policies = temp; +// List temp = new ArrayList(); +// for (Policy policy : policies) { +// if (ownershipType.equalsIgnoreCase(policy.getOwnershipType())) { +// temp.add(policy); +// } +// } +// policies = temp; } @Override 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 8755d048f8..be03d1e8df 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 @@ -30,7 +30,9 @@ import org.wso2.carbon.policy.mgt.core.dao.*; import org.wso2.carbon.policy.mgt.core.mgt.PolicyManager; import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager; +import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Calendar; import java.util.List; public class PolicyManagerImpl implements PolicyManager { @@ -58,9 +60,15 @@ public class PolicyManagerImpl implements PolicyManager { try { PolicyManagementDAOFactory.beginTransaction(); if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) { - profileDAO.addProfile(policy.getProfile()); - featureDAO.addProfileFeatures(policy.getProfile().getProfileFeaturesList(), - policy.getProfile().getProfileId()); + Profile profile = policy.getProfile(); + + Timestamp currentTimestamp = new Timestamp(Calendar.getInstance().getTime().getTime()); + profile.setCreatedDate(currentTimestamp); + profile.setUpdatedDate(currentTimestamp); + + + profileDAO.addProfile(profile); + featureDAO.addProfileFeatures(profile.getProfileFeaturesList(), profile.getProfileId()); } policy = policyDAO.addPolicy(policy);