From 948bfab248d4cb1faf00c5999f8a55580e89999f Mon Sep 17 00:00:00 2001 From: Adam Young Date: Mon, 5 Dec 2011 17:15:56 -0500 Subject: TreeSet ArraySet and AttributeNameEnumeration both were not updated to handfle Generics. Neither are really needed, and are likely to introduce errors. ArraySet can be safely replaced by TreeSet. TreeSet provides a stricter ordering constraint than ArraySet did. This will not hurt anything, and may actually be closer to the desired behavior AttributeNameEnumeration was a thin wrapper around Vector. It has been replaced with Vector In addition, this patch cleans up the Type safety in of the collections used in the related files. removed files from cmake Removed custom collection files Supressed watnings generated by the clone method. --- .../src/com/netscape/cmscore/ldap/LdapRule.java | 20 ++--- .../netscape/cmscore/ldap/PublisherProcessor.java | 92 +++++++++++----------- 2 files changed, 55 insertions(+), 57 deletions(-) (limited to 'pki/base/common/src/com/netscape/cmscore') diff --git a/pki/base/common/src/com/netscape/cmscore/ldap/LdapRule.java b/pki/base/common/src/com/netscape/cmscore/ldap/LdapRule.java index 16bc7f02b..233cbf871 100644 --- a/pki/base/common/src/com/netscape/cmscore/ldap/LdapRule.java +++ b/pki/base/common/src/com/netscape/cmscore/ldap/LdapRule.java @@ -66,20 +66,20 @@ public class LdapRule implements ILdapRule, IExtendedPluginInfo { mConfig = config; mProcessor = processor; - Enumeration mappers = mProcessor.getMapperInsts().keys(); - Enumeration publishers = mProcessor.getPublisherInsts().keys(); + Enumeration mappers = mProcessor.getMapperInsts().keys(); + Enumeration publishers = mProcessor.getPublisherInsts().keys(); String map = NOMAPPER; for (; mappers.hasMoreElements();) { - String name = (String) mappers.nextElement(); + String name = mappers.nextElement(); map = map + "," + name; } String publish = ""; for (; publishers.hasMoreElements();) { - String name = (String) publishers.nextElement(); + String name = publishers.nextElement(); publish = publish + "," + name; } @@ -168,11 +168,11 @@ public class LdapRule implements ILdapRule, IExtendedPluginInfo { /** * Returns the current instance parameters. */ - public Vector getInstanceParams() { + public Vector getInstanceParams() { //if (mProcessor == null) System.out.println("xxxxnull"); //dont know why the processor was null in getExtendedPluginInfo() - Enumeration mappers = mProcessor.getMapperInsts().keys(); - Enumeration publishers = mProcessor.getPublisherInsts().keys(); + Enumeration mappers = mProcessor.getMapperInsts().keys(); + Enumeration publishers = mProcessor.getPublisherInsts().keys(); String map = NOMAPPER; for (; mappers.hasMoreElements();) { @@ -197,7 +197,7 @@ public class LdapRule implements ILdapRule, IExtendedPluginInfo { mExtendedPluginInfo.add("predicate","string;"); */ - Vector v = new Vector(); + Vector v = new Vector(); try { v.addElement(IPublisherProcessor.PROP_TYPE + "=" + @@ -288,8 +288,8 @@ public class LdapRule implements ILdapRule, IExtendedPluginInfo { /** * Returns the initial default parameters. */ - public Vector getDefaultParams() { - Vector v = new Vector(); + public Vector getDefaultParams() { + Vector v = new Vector(); v.addElement(IPublisherProcessor.PROP_TYPE + "="); v.addElement(IPublisherProcessor.PROP_PREDICATE + "="); diff --git a/pki/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java b/pki/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java index a1e45a58a..1477e57b0 100644 --- a/pki/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java +++ b/pki/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java @@ -65,12 +65,12 @@ import com.netscape.cmscore.util.Debug; public class PublisherProcessor implements IPublisherProcessor, IXcertPublisherProcessor { - public Hashtable mPublisherPlugins = new Hashtable(); - public Hashtable mPublisherInsts = new Hashtable(); - public Hashtable mMapperPlugins = new Hashtable(); - public Hashtable mMapperInsts = new Hashtable(); - public Hashtable mRulePlugins = new Hashtable(); - public Hashtable mRuleInsts = new Hashtable(); + public Hashtable mPublisherPlugins = new Hashtable(); + public Hashtable mPublisherInsts = new Hashtable(); + public Hashtable mMapperPlugins = new Hashtable(); + public Hashtable mMapperInsts = new Hashtable(); + public Hashtable mRulePlugins = new Hashtable(); + public Hashtable mRuleInsts = new Hashtable(); /** protected PublishRuleSet mRuleSet = null; @@ -112,7 +112,7 @@ public class PublisherProcessor implements IConfigStore publisherConfig = config.getSubStore("publisher"); IConfigStore c = publisherConfig.getSubStore(PROP_IMPL); mCreateOwnDNEntry = mConfig.getBoolean("createOwnDNEntry", false); - Enumeration mImpls = c.getSubStoreNames(); + Enumeration mImpls = c.getSubStoreNames(); while (mImpls.hasMoreElements()) { String id = (String) mImpls.nextElement(); @@ -126,7 +126,7 @@ public class PublisherProcessor implements // load publisher instances c = publisherConfig.getSubStore(PROP_INSTANCE); - Enumeration instances = c.getSubStoreNames(); + Enumeration instances = c.getSubStoreNames(); while (instances.hasMoreElements()) { String insName = (String) instances.nextElement(); @@ -460,35 +460,35 @@ public class PublisherProcessor implements } } - public Hashtable getRulePlugins() { + public Hashtable getRulePlugins() { return mRulePlugins; } - public Hashtable getRuleInsts() { + public Hashtable getRuleInsts() { return mRuleInsts; } - public Hashtable getMapperPlugins() { + public Hashtable getMapperPlugins() { return mMapperPlugins; } - public Hashtable getPublisherPlugins() { + public Hashtable getPublisherPlugins() { return mPublisherPlugins; } - public Hashtable getMapperInsts() { + public Hashtable getMapperInsts() { return mMapperInsts; } - public Hashtable getPublisherInsts() { + public Hashtable getPublisherInsts() { return mPublisherInsts; } //certType can be client,server,ca,crl,smime //XXXshould make it static to make it faster - public Enumeration getRules(String publishingType) { - Vector rules = new Vector(); - Enumeration e = mRuleInsts.keys(); + public Enumeration getRules(String publishingType) { + Vector rules = new Vector(); + Enumeration e = mRuleInsts.keys(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); @@ -525,13 +525,13 @@ public class PublisherProcessor implements return rules.elements(); } - public Enumeration getRules(String publishingType, IRequest req) { + public Enumeration getRules(String publishingType, IRequest req) { if (req == null) { return getRules(publishingType); } - Vector rules = new Vector(); - Enumeration e = mRuleInsts.keys(); + Vector rules = new Vector(); + Enumeration e = mRuleInsts.keys(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); @@ -575,11 +575,10 @@ public class PublisherProcessor implements } **/ - public Vector getMapperDefaultParams(String implName) throws + public Vector getMapperDefaultParams(String implName) throws ELdapException { // is this a registered implname? - MapperPlugin plugin = (MapperPlugin) - mMapperPlugins.get(implName); + MapperPlugin plugin = mMapperPlugins.get(implName); if (plugin == null) { log(ILogger.LL_FAILURE, @@ -597,7 +596,7 @@ public class PublisherProcessor implements try { mapperInst = (ILdapMapper) Class.forName(className).newInstance(); - Vector v = mapperInst.getDefaultParams(); + Vector v = mapperInst.getDefaultParams(); return v; } catch (InstantiationException e) { @@ -612,7 +611,7 @@ public class PublisherProcessor implements } } - public Vector getMapperInstanceParams(String insName) throws + public Vector getMapperInstanceParams(String insName) throws ELdapException { ILdapMapper mapperInst = null; MapperProxy proxy = (MapperProxy) mMapperInsts.get(insName); @@ -624,12 +623,12 @@ public class PublisherProcessor implements if (mapperInst == null) { return null; } - Vector v = mapperInst.getInstanceParams(); + Vector v = mapperInst.getInstanceParams(); return v; } - public Vector getPublisherDefaultParams(String implName) throws + public Vector getPublisherDefaultParams(String implName) throws ELdapException { // is this a registered implname? PublisherPlugin plugin = (PublisherPlugin) @@ -651,7 +650,7 @@ public class PublisherProcessor implements try { publisherInst = (ILdapPublisher) Class.forName(className).newInstance(); - Vector v = publisherInst.getDefaultParams(); + Vector v = publisherInst.getDefaultParams(); return v; } catch (InstantiationException e) { @@ -728,23 +727,22 @@ public class PublisherProcessor implements return proxy.getPublisher(); } - public Vector getPublisherInstanceParams(String insName) throws + public Vector getPublisherInstanceParams(String insName) throws ELdapException { ILdapPublisher publisherInst = getPublisherInstance(insName); if (publisherInst == null) { return null; } - Vector v = publisherInst.getInstanceParams(); + Vector v = publisherInst.getInstanceParams(); return v; } - public Vector getRuleDefaultParams(String implName) throws + public Vector getRuleDefaultParams(String implName) throws ELdapException { // is this a registered implname? - RulePlugin plugin = (RulePlugin) - mRulePlugins.get(implName); + RulePlugin plugin = mRulePlugins.get(implName); if (plugin == null) { log(ILogger.LL_FAILURE, @@ -763,7 +761,7 @@ public class PublisherProcessor implements ruleInst = (ILdapRule) Class.forName(className).newInstance(); - Vector v = ruleInst.getDefaultParams(); + Vector v = ruleInst.getDefaultParams(); return v; } catch (InstantiationException e) { @@ -778,11 +776,10 @@ public class PublisherProcessor implements } } - public Vector getRuleInstanceParams(String implName) throws + public Vector getRuleInstanceParams(String implName) throws ELdapException { // is this a registered implname? - RulePlugin plugin = (RulePlugin) - mRulePlugins.get(implName); + RulePlugin plugin = mRulePlugins.get(implName); if (plugin == null) { log(ILogger.LL_FAILURE, @@ -800,7 +797,7 @@ public class PublisherProcessor implements try { ruleInst = (ILdapRule) Class.forName(className).newInstance(); - Vector v = ruleInst.getInstanceParams(); + Vector v = ruleInst.getInstanceParams(); IConfigStore rc = ruleInst.getConfigStore(); return v; @@ -864,7 +861,7 @@ public class PublisherProcessor implements CMS.debug("PublishProcessor::publishCACert"); // get mapper and publisher for cert type. - Enumeration rules = getRules(PROP_LOCAL_CA); + Enumeration rules = getRules(PROP_LOCAL_CA); if (rules == null || !rules.hasMoreElements()) { if (isClone()) { @@ -934,7 +931,7 @@ public class PublisherProcessor implements return; // get mapper and publisher for cert type. - Enumeration rules = getRules(PROP_LOCAL_CA); + Enumeration rules = getRules(PROP_LOCAL_CA); if (rules == null || !rules.hasMoreElements()) { if (isClone()) { @@ -1001,7 +998,7 @@ public class PublisherProcessor implements CMS.debug("PublisherProcessor: in publishXCertPair()"); // get mapper and publisher for cert type. - Enumeration rules = getRules(PROP_XCERT); + Enumeration rules = getRules(PROP_XCERT); if (rules == null || !rules.hasMoreElements()) { if (isClone()) { @@ -1063,7 +1060,7 @@ public class PublisherProcessor implements return; // get mapper and publisher for cert type. - Enumeration rules = getRules("certs", req); + Enumeration rules = getRules("certs", req); // Bugscape #52306 - Remove superfluous log messages on failure if (rules == null || !rules.hasMoreElements()) { @@ -1120,7 +1117,7 @@ public class PublisherProcessor implements return; // get mapper and publisher for cert type. - Enumeration rules = getRules("certs", req); + Enumeration rules = getRules("certs", req); if (rules == null || !rules.hasMoreElements()) { log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_LDAP_NO_UNPUBLISHING_RULE_FOUND_FOR_REQUEST", "certs", req.getRequestId().toString())); @@ -1189,7 +1186,7 @@ public class PublisherProcessor implements ILdapPublisher publisher = null; // get mapper and publisher for cert type. - Enumeration rules = getRules(PROP_LOCAL_CRL); + Enumeration rules = getRules(PROP_LOCAL_CRL); if (rules == null || !rules.hasMoreElements()) { log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_LDAP_NO_RULE_FOR_CRL")); @@ -1279,7 +1276,7 @@ public class PublisherProcessor implements if (!enabled()) return; // get mapper and publisher for cert type. - Enumeration rules = getRules(PROP_LOCAL_CRL); + Enumeration rules = getRules(PROP_LOCAL_CRL); if (rules == null || !rules.hasMoreElements()) { log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_LDAP_NO_RULE_FOR_CRL")); @@ -1364,9 +1361,10 @@ public class PublisherProcessor implements try { if (dirdn instanceof Vector) { - int n = ((Vector)dirdn).size(); + Vector dirdnVector = (Vector)dirdn; + int n = dirdnVector.size(); for (int i = 0; i < n; i++) { - publisher.publish(conn, (String)(((Vector)dirdn).elementAt(i)), cert); + publisher.publish(conn, (String)dirdnVector.elementAt(i), cert); } } else if (dirdn instanceof String || publisher instanceof com.netscape.cms.publish.publishers.FileBasedPublisher) { -- cgit