Fixes to the timestamp and filters

revert-70aa11f8
Dulitha Wijewantha 10 years ago
parent c8affcf836
commit 341abb47ab

@ -60,13 +60,13 @@ public class PolicyFilterImpl implements PolicyFilter {
@Override @Override
public void filterOwnershipTypeBasedPolicies(String ownershipType, List<Policy> policies) { public void filterOwnershipTypeBasedPolicies(String ownershipType, List<Policy> policies) {
List<Policy> temp = new ArrayList<Policy>(); // List<Policy> temp = new ArrayList<Policy>();
for (Policy policy : policies) { // for (Policy policy : policies) {
if (ownershipType.equalsIgnoreCase(policy.getOwnershipType())) { // if (ownershipType.equalsIgnoreCase(policy.getOwnershipType())) {
temp.add(policy); // temp.add(policy);
} // }
} // }
policies = temp; // policies = temp;
} }
@Override @Override

@ -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.PolicyManager;
import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager; import org.wso2.carbon.policy.mgt.core.mgt.ProfileManager;
import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.List; import java.util.List;
public class PolicyManagerImpl implements PolicyManager { public class PolicyManagerImpl implements PolicyManager {
@ -58,9 +60,15 @@ public class PolicyManagerImpl implements PolicyManager {
try { try {
PolicyManagementDAOFactory.beginTransaction(); PolicyManagementDAOFactory.beginTransaction();
if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) { if (policy.getProfile() != null && policy.getProfile().getProfileId() == 0) {
profileDAO.addProfile(policy.getProfile()); Profile profile = policy.getProfile();
featureDAO.addProfileFeatures(policy.getProfile().getProfileFeaturesList(),
policy.getProfile().getProfileId()); 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); policy = policyDAO.addPolicy(policy);

Loading…
Cancel
Save