From 6a24b83277be10ba4c40f1e62747beb4fd12f717 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Wed, 11 Sep 2013 15:08:18 -0400
Subject: [PATCH] Fixed dependency issue on ProfilePolicy.

The ProfilePolicy is in the server package but it's used by IProfile
interface in the base package. The interface have been modified to use
IProfilePolicy instead.
---
 .../src/com/netscape/certsrv/profile/IProfile.java |  3 +-
 .../netscape/cms/profile/common/BasicProfile.java  | 40 +++++++++++-----------
 .../cms/servlet/admin/ProfileAdminServlet.java     |  3 +-
 .../cms/servlet/cert/RequestProcessor.java         |  7 ++--
 4 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/base/common/src/com/netscape/certsrv/profile/IProfile.java b/base/common/src/com/netscape/certsrv/profile/IProfile.java
index 1a2b7aa68b05fcc668229d13801d897ba8a3637f..b4605cf303563860c699612df4011e458ccc3f0b 100644
--- a/base/common/src/com/netscape/certsrv/profile/IProfile.java
+++ b/base/common/src/com/netscape/certsrv/profile/IProfile.java
@@ -26,7 +26,6 @@ import com.netscape.certsrv.base.IConfigStore;
 import com.netscape.certsrv.common.NameValuePairs;
 import com.netscape.certsrv.request.IRequest;
 import com.netscape.certsrv.request.IRequestQueue;
-import com.netscape.cms.profile.common.ProfilePolicy;
 
 /**
  * This interface represents a profile. A profile contains
@@ -361,7 +360,7 @@ public interface IProfile {
      * @param setId set id
      * @return a list of policies
      */
-    public Enumeration<ProfilePolicy> getProfilePolicies(String setId);
+    public Enumeration<IProfilePolicy> getProfilePolicies(String setId);
 
     /**
      * Creates one or more requests. Normally, only one request will
diff --git a/base/common/src/com/netscape/cms/profile/common/BasicProfile.java b/base/common/src/com/netscape/cms/profile/common/BasicProfile.java
index c3f6b327deb49ee10597678887bc8bffd94ff4e5..ea5108445356e848ecb9520c7147a75181c11c51 100644
--- a/base/common/src/com/netscape/cms/profile/common/BasicProfile.java
+++ b/base/common/src/com/netscape/cms/profile/common/BasicProfile.java
@@ -94,7 +94,7 @@ public abstract class BasicProfile implements IProfile {
     protected String mId = null;
     protected String mAuthzAcl = "";
 
-    protected Hashtable<String, Vector<ProfilePolicy>> mPolicySet = new Hashtable<String, Vector<ProfilePolicy>>();
+    protected Hashtable<String, Vector<IProfilePolicy>> mPolicySet = new Hashtable<String, Vector<IProfilePolicy>>();
 
     protected ILogger mSignedAuditLogger = CMS.getSignedAuditLogger();
 
@@ -406,7 +406,7 @@ public abstract class BasicProfile implements IProfile {
 
     public void deleteProfilePolicy(String setId, String policyId)
             throws EProfileException {
-        Vector<ProfilePolicy> policies = mPolicySet.get(setId);
+        Vector<IProfilePolicy> policies = mPolicySet.get(setId);
 
         if (policies == null) {
             return;
@@ -440,7 +440,7 @@ public abstract class BasicProfile implements IProfile {
             int size = policies.size();
 
             for (int i = 0; i < size; i++) {
-                ProfilePolicy policy = policies.elementAt(i);
+                IProfilePolicy policy = policies.elementAt(i);
                 String id = policy.getId();
 
                 if (id.equals(policyId)) {
@@ -474,10 +474,10 @@ public abstract class BasicProfile implements IProfile {
     }
 
     public void deleteAllProfilePolicies() throws EProfileException {
-        for (Map.Entry<String, Vector<ProfilePolicy>> entry : mPolicySet.entrySet()) {
+        for (Map.Entry<String, Vector<IProfilePolicy>> entry : mPolicySet.entrySet()) {
             String setId = entry.getKey();
-            Vector<ProfilePolicy> pList = new Vector<ProfilePolicy>(entry.getValue());
-            for (ProfilePolicy policy: pList) {
+            Vector<IProfilePolicy> pList = new Vector<IProfilePolicy>(entry.getValue());
+            for (IProfilePolicy policy: pList) {
                 deleteProfilePolicy(setId, policy.getId());
             }
         }
@@ -789,11 +789,11 @@ public abstract class BasicProfile implements IProfile {
         // String constraintClassId : if of the constraint plugin ex: basicConstraintsExtConstraintImpl
         // boolean createConfig : true : being called from the console. false: being called from server startup code
 
-        Vector<ProfilePolicy> policies = mPolicySet.get(setId);
+        Vector<IProfilePolicy> policies = mPolicySet.get(setId);
 
         IConfigStore policyStore = mConfig.getSubStore("policyset." + setId);
         if (policies == null) {
-            policies = new Vector<ProfilePolicy>();
+            policies = new Vector<IProfilePolicy>();
             mPolicySet.put(setId, policies);
             if (createConfig) {
                 // re-create policyset.list
@@ -1002,13 +1002,13 @@ public abstract class BasicProfile implements IProfile {
     }
 
     public IProfilePolicy getProfilePolicy(String setId, String id) {
-        Vector<ProfilePolicy> policies = mPolicySet.get(setId);
+        Vector<IProfilePolicy> policies = mPolicySet.get(setId);
 
         if (policies == null)
             return null;
 
         for (int i = 0; i < policies.size(); i++) {
-            ProfilePolicy policy = policies.elementAt(i);
+            IProfilePolicy policy = policies.elementAt(i);
 
             if (policy.getId().equals(id)) {
                 return policy;
@@ -1079,8 +1079,8 @@ public abstract class BasicProfile implements IProfile {
         }
     }
 
-    public Vector<ProfilePolicy> getPolicies(String setId) {
-        Vector<ProfilePolicy> policies = mPolicySet.get(setId);
+    public Vector<IProfilePolicy> getPolicies(String setId) {
+        Vector<IProfilePolicy> policies = mPolicySet.get(setId);
 
         return policies;
     }
@@ -1092,11 +1092,11 @@ public abstract class BasicProfile implements IProfile {
     public void populate(IRequest request)
             throws EProfileException {
         String setId = getPolicySetId(request);
-        Vector<ProfilePolicy> policies = getPolicies(setId);
+        Vector<IProfilePolicy> policies = getPolicies(setId);
         CMS.debug("BasicProfile: populate() policy setid =" + setId);
 
         for (int i = 0; i < policies.size(); i++) {
-            ProfilePolicy policy = policies.elementAt(i);
+            IProfilePolicy policy = policies.elementAt(i);
 
             policy.getDefault().populate(request);
         }
@@ -1110,10 +1110,10 @@ public abstract class BasicProfile implements IProfile {
             throws ERejectException {
         String setId = getPolicySetId(request);
         CMS.debug("BasicProfile: validate start on setId=" + setId);
-        Vector<ProfilePolicy> policies = getPolicies(setId);
+        Vector<IProfilePolicy> policies = getPolicies(setId);
 
         for (int i = 0; i < policies.size(); i++) {
-            ProfilePolicy policy = policies.elementAt(i);
+            IProfilePolicy policy = policies.elementAt(i);
 
             policy.getConstraint().validate(request);
         }
@@ -1122,8 +1122,8 @@ public abstract class BasicProfile implements IProfile {
         CMS.debug("BasicProfile: validate end");
     }
 
-    public Enumeration<ProfilePolicy> getProfilePolicies(String setId) {
-        Vector<ProfilePolicy> policies = mPolicySet.get(setId);
+    public Enumeration<IProfilePolicy> getProfilePolicies(String setId) {
+        Vector<IProfilePolicy> policies = mPolicySet.get(setId);
 
         if (policies == null)
             return null;
@@ -1131,7 +1131,7 @@ public abstract class BasicProfile implements IProfile {
     }
 
     public Enumeration<String> getProfilePolicyIds(String setId) {
-        Vector<ProfilePolicy> policies = mPolicySet.get(setId);
+        Vector<IProfilePolicy> policies = mPolicySet.get(setId);
 
         if (policies == null)
             return null;
@@ -1139,7 +1139,7 @@ public abstract class BasicProfile implements IProfile {
         Vector<String> v = new Vector<String>();
 
         for (int i = 0; i < policies.size(); i++) {
-            ProfilePolicy policy = policies.elementAt(i);
+            IProfilePolicy policy = policies.elementAt(i);
 
             v.addElement(policy.getId());
         }
diff --git a/base/common/src/com/netscape/cms/servlet/admin/ProfileAdminServlet.java b/base/common/src/com/netscape/cms/servlet/admin/ProfileAdminServlet.java
index 57489c1245245a1c516e9298a919a8ed98c02496..3d25b8b71bc7f71a7d579aa6d27bcdc623e49e28 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/ProfileAdminServlet.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/ProfileAdminServlet.java
@@ -49,7 +49,6 @@ import com.netscape.certsrv.property.EPropertyException;
 import com.netscape.certsrv.property.IDescriptor;
 import com.netscape.certsrv.registry.IPluginInfo;
 import com.netscape.certsrv.registry.IPluginRegistry;
-import com.netscape.cms.profile.common.ProfilePolicy;
 
 /**
  * This class is an administration servlet for policy management.
@@ -2039,7 +2038,7 @@ public class ProfileAdminServlet extends AdminServlet {
         }
         while (setIds.hasMoreElements()) {
             String setId = setIds.nextElement();
-            Enumeration<ProfilePolicy> policies = profile.getProfilePolicies(setId);
+            Enumeration<IProfilePolicy> policies = profile.getProfilePolicies(setId);
 
             while (policies.hasMoreElements()) {
                 IProfilePolicy policy = policies.nextElement();
diff --git a/base/common/src/com/netscape/cms/servlet/cert/RequestProcessor.java b/base/common/src/com/netscape/cms/servlet/cert/RequestProcessor.java
index fbfe9ceda8d5a08c6e5f16cbb904753ab89fffce..2826f477e358a5e16657e985d7f13079cdb14a33 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/RequestProcessor.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/RequestProcessor.java
@@ -55,7 +55,6 @@ import com.netscape.certsrv.property.EPropertyException;
 import com.netscape.certsrv.request.IRequest;
 import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.request.RequestStatus;
-import com.netscape.cms.profile.common.ProfilePolicy;
 import com.netscape.cms.servlet.common.CMSRequest;
 import com.netscape.cms.servlet.profile.ProfileOutputFactory;
 
@@ -413,11 +412,11 @@ public class RequestProcessor extends CertProcessor {
 
         String profileSetId = req.getExtDataInString("profileSetId");
 
-        Enumeration<ProfilePolicy> policies = profile.getProfilePolicies(profileSetId);
+        Enumeration<IProfilePolicy> policies = profile.getProfilePolicies(profileSetId);
         int count = 0;
 
         while (policies.hasMoreElements()) {
-            ProfilePolicy policy = policies.nextElement();
+            IProfilePolicy policy = policies.nextElement();
 
             setValue(locale, count, policy, req, policyData);
             count++;
@@ -426,7 +425,7 @@ public class RequestProcessor extends CertProcessor {
         policies = profile.getProfilePolicies(profileSetId);
         count = 0;
         while (policies.hasMoreElements()) {
-            ProfilePolicy policy = policies.nextElement();
+            IProfilePolicy policy = policies.nextElement();
 
             validate(count, policy, req);
             count++;
-- 
1.8.1.4

