diff options
author | Adam Young <ayoung@redhat.com> | 2011-11-18 14:39:59 -0500 |
---|---|---|
committer | Adam Young <ayoung@redhat.com> | 2012-01-04 11:24:45 -0500 |
commit | 9c3c8ee12bfc4b0bd3a6a57382f90d7c0ff8abbb (patch) | |
tree | d7f2dc5b6a4e01493428d487b9491aed2e7b461f /pki/base | |
parent | e06776464042c557f2a66cbca874507e2be521a8 (diff) | |
download | pki-9c3c8ee12bfc4b0bd3a6a57382f90d7c0ff8abbb.tar.gz pki-9c3c8ee12bfc4b0bd3a6a57382f90d7c0ff8abbb.tar.xz pki-9c3c8ee12bfc4b0bd3a6a57382f90d7c0ff8abbb.zip |
typesafety db and logging
Diffstat (limited to 'pki/base')
13 files changed, 102 insertions, 99 deletions
diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/IDBVirtualList.java b/pki/base/common/src/com/netscape/certsrv/dbs/IDBVirtualList.java index 8e627520c..7d175c452 100644 --- a/pki/base/common/src/com/netscape/certsrv/dbs/IDBVirtualList.java +++ b/pki/base/common/src/com/netscape/certsrv/dbs/IDBVirtualList.java @@ -27,7 +27,7 @@ import com.netscape.certsrv.base.EBaseException; * * @version $Revision$, $Date$ */ -public interface IDBVirtualList { +public interface IDBVirtualList<E> { /** * Sets the paging size of this virtual list. @@ -107,7 +107,7 @@ public interface IDBVirtualList { * * @param index the index of the element to fetch */ - public Object getElementAt(int index); + public E getElementAt(int index); /** * Retrieves and jumps to element in the given position. @@ -115,7 +115,7 @@ public interface IDBVirtualList { * @param i position * @return object */ - public Object getJumpToElementAt(int i); + public E getJumpToElementAt(int i); /** * Processes elements as soon as it arrives. It is diff --git a/pki/base/common/src/com/netscape/certsrv/dbs/certdb/ICertRecordList.java b/pki/base/common/src/com/netscape/certsrv/dbs/certdb/ICertRecordList.java index a77458880..616bd5db1 100644 --- a/pki/base/common/src/com/netscape/certsrv/dbs/certdb/ICertRecordList.java +++ b/pki/base/common/src/com/netscape/certsrv/dbs/certdb/ICertRecordList.java @@ -91,6 +91,6 @@ public interface ICertRecordList { * @return object * @exception EBaseException failed to retrieve */ - public Object getCertRecord(int index) + public ICertRecord getCertRecord(int index) throws EBaseException; } diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ConsoleLog.java b/pki/base/common/src/com/netscape/certsrv/logging/ConsoleLog.java index c18b062c2..8dee67ef8 100644 --- a/pki/base/common/src/com/netscape/certsrv/logging/ConsoleLog.java +++ b/pki/base/common/src/com/netscape/certsrv/logging/ConsoleLog.java @@ -88,7 +88,7 @@ public class ConsoleLog implements ILogEventListener { * @exception IOException * @exception EBaseException */ - public synchronized NameValuePairs retrieveLogContent(Hashtable req) throws ServletException, + public synchronized NameValuePairs retrieveLogContent(Hashtable<String, String> req) throws ServletException, IOException, EBaseException { return null; } @@ -97,7 +97,7 @@ public class ConsoleLog implements ILogEventListener { * Retrieve log file list. * <br> unimplemented */ - public synchronized NameValuePairs retrieveLogList(Hashtable req) throws ServletException, + public synchronized NameValuePairs retrieveLogList(Hashtable<String, String> req) throws ServletException, IOException, EBaseException { return null; } @@ -110,14 +110,14 @@ public class ConsoleLog implements ILogEventListener { return "ConsoleLog"; } - public Vector getDefaultParams() { - Vector v = new Vector(); + public Vector<String> getDefaultParams() { + Vector<String> v = new Vector<String>(); return v; } - public Vector getInstanceParams() { - Vector v = new Vector(); + public Vector<String> getInstanceParams() { + Vector<String> v = new Vector<String>(); return v; } diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ILogEventListener.java b/pki/base/common/src/com/netscape/certsrv/logging/ILogEventListener.java index 12c09b0bc..80953ead6 100644 --- a/pki/base/common/src/com/netscape/certsrv/logging/ILogEventListener.java +++ b/pki/base/common/src/com/netscape/certsrv/logging/ILogEventListener.java @@ -95,14 +95,14 @@ public interface ILogEventListener extends EventListener { * @exception IOException For input/output problems. * @exception EBaseException For other problems. */ - public NameValuePairs retrieveLogContent(Hashtable req) throws ServletException, + public NameValuePairs retrieveLogContent(Hashtable<String, String> req) throws ServletException, IOException, EBaseException; /** * Retrieve list of log files. * */ - public NameValuePairs retrieveLogList(Hashtable req) throws ServletException, + public NameValuePairs retrieveLogList(Hashtable<String, String> req) throws ServletException, IOException, EBaseException; /** @@ -121,11 +121,11 @@ public interface ILogEventListener extends EventListener { * Return list of default config parameters for this log event listener. * @return Vector of default parameters. */ - public Vector getDefaultParams(); + public Vector<String> getDefaultParams(); /** * Return list of instance config parameters for this log event listener. * @return Vector of instance parameters. */ - public Vector getInstanceParams(); + public Vector<String> getInstanceParams(); } diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ILogSubsystem.java b/pki/base/common/src/com/netscape/certsrv/logging/ILogSubsystem.java index 438c42508..2bdba0abf 100644 --- a/pki/base/common/src/com/netscape/certsrv/logging/ILogSubsystem.java +++ b/pki/base/common/src/com/netscape/certsrv/logging/ILogSubsystem.java @@ -65,7 +65,7 @@ public interface ILogSubsystem extends ISubsystem { * Hashtable contains the name/value pair of pluginName/LogPlugin * @see LogPlugin */ - public Hashtable getLogPlugins(); + public Hashtable<String, LogPlugin> getLogPlugins(); /** * get the list of log instances that are available @@ -73,7 +73,7 @@ public interface ILogSubsystem extends ISubsystem { * Hashtable contains the name/value pair of instName/ILogEventListener * @see LogPlugin */ - public Hashtable getLogInsts(); + public Hashtable<String, ILogEventListener> getLogInsts(); /** * Get the default configuration parameter names associated with a @@ -87,7 +87,7 @@ public interface ILogSubsystem extends ISubsystem { * @exception ELogException when instantiation of the plugin * implementation fails. */ - public Vector getLogDefaultParams(String implName) throws + public Vector<String> getLogDefaultParams(String implName) throws ELogException; /** @@ -99,6 +99,6 @@ public interface ILogSubsystem extends ISubsystem { * @return a Vector of default configuration paramter names * associated with this log instance. */ - public Vector getLogInstanceParams(String insName) + public Vector<String> getLogInstanceParams(String insName) throws ELogException; } diff --git a/pki/base/common/src/com/netscape/cms/logging/LogFile.java b/pki/base/common/src/com/netscape/cms/logging/LogFile.java index 284ff02d7..c2dd7b332 100644 --- a/pki/base/common/src/com/netscape/cms/logging/LogFile.java +++ b/pki/base/common/src/com/netscape/cms/logging/LogFile.java @@ -193,7 +193,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { * The selected log event types */ protected String mSelectedEventsList = null; - protected Vector mSelectedEvents = null; + protected Vector<String> mSelectedEvents = null; /** * The eventType that this log is triggered @@ -297,8 +297,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * turns a comma-separated String into a Vector */ - protected Vector string2Vector(String theString) { - Vector theVector = new Vector(); + protected Vector<String> string2Vector(String theString) { + Vector<String> theVector = new Vector<String>(); if (theString == null) { return theVector; } @@ -337,7 +337,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { * @param events comma-separated event list */ public void replaceEvents(String events) { - Vector v = string2Vector(events); + Vector<String> v = string2Vector(events); mSelectedEvents.removeAllElements(); mSelectedEvents = v; } @@ -1145,8 +1145,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { * @param fName The log file name to be read. If it's null, read the current * log file */ - public Vector readEntry(int maxLine, int lowLevel, int source, String fName) { - Vector mEntries = new Vector(); + public Vector<LogEntry> readEntry(int maxLine, int lowLevel, int source, String fName) { + Vector<LogEntry> mEntries = new Vector<LogEntry>(); String fileName = mFileName; BufferedReader fBuffer; int lineNo = 0; // lineNo of the current entry in the log file @@ -1319,12 +1319,12 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { * and from source "source". If the parameter is omitted. All entries * are sent back. */ - public synchronized NameValuePairs retrieveLogContent(Hashtable req) throws ServletException, + public synchronized NameValuePairs retrieveLogContent(Hashtable<String, String> req) throws ServletException, IOException, EBaseException { NameValuePairs params = new NameValuePairs(); String tmp, fName = null; int maxLine = -1, level = -1, source = -1; - Vector entries = null; + Vector<LogEntry> entries = null; if ((tmp = (String)req.get(Constants.PR_LOG_ENTRY)) != null) { maxLine = Integer.parseInt(tmp); @@ -1359,7 +1359,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Retrieve log file list. */ - public synchronized NameValuePairs retrieveLogList(Hashtable req) throws ServletException, + public synchronized NameValuePairs retrieveLogList(Hashtable<String, String> req) throws ServletException, IOException, EBaseException { return null; } @@ -1372,8 +1372,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { return "LogFile"; } - public Vector getDefaultParams() { - Vector v = new Vector(); + public Vector<String> getDefaultParams() { + Vector<String> v = new Vector<String>(); v.addElement(PROP_TYPE + "="); v.addElement(PROP_ON + "="); @@ -1394,8 +1394,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { return v; } - public Vector getInstanceParams() { - Vector v = new Vector(); + public Vector<String> getInstanceParams() { + Vector<String> v = new Vector<String>(); try { diff --git a/pki/base/common/src/com/netscape/cms/logging/RollingLogFile.java b/pki/base/common/src/com/netscape/cms/logging/RollingLogFile.java index 2f97dcaac..d2dab3950 100644 --- a/pki/base/common/src/com/netscape/cms/logging/RollingLogFile.java +++ b/pki/base/common/src/com/netscape/cms/logging/RollingLogFile.java @@ -519,7 +519,7 @@ public class RollingLogFile extends LogFile { /** * Retrieve log file list. */ - public synchronized NameValuePairs retrieveLogList(Hashtable req + public synchronized NameValuePairs retrieveLogList(Hashtable<String, String> req ) throws ServletException, IOException, EBaseException { NameValuePairs params = new NameValuePairs(); @@ -584,8 +584,8 @@ public class RollingLogFile extends LogFile { return "RollingLogFile"; } - public Vector getDefaultParams() { - Vector v = super.getDefaultParams(); + public Vector<String> getDefaultParams() { + Vector<String> v = super.getDefaultParams(); v.addElement(PROP_MAX_FILE_SIZE + "="); v.addElement(PROP_ROLLOVER_INTERVAL + "="); @@ -593,8 +593,8 @@ public class RollingLogFile extends LogFile { return v; } - public Vector getInstanceParams() { - Vector v = super.getInstanceParams(); + public Vector<String> getInstanceParams() { + Vector<String> v = super.getInstanceParams(); try { v.addElement(PROP_MAX_FILE_SIZE + "=" + mMaxFileSize / 1024); @@ -617,7 +617,7 @@ public class RollingLogFile extends LogFile { public String[] getExtendedPluginInfo(Locale locale) { String[] p = super.getExtendedPluginInfo(locale); - Vector info = new Vector(); + Vector<String> info = new Vector<String>(); for (int i = 0; i < p.length; i++) { if (!p[i].startsWith(IExtendedPluginInfo.HELP_TOKEN) && !p[i].startsWith(IExtendedPluginInfo.HELP_TEXT)) diff --git a/pki/base/common/src/com/netscape/cms/servlet/admin/LogAdminServlet.java b/pki/base/common/src/com/netscape/cms/servlet/admin/LogAdminServlet.java index 358553074..08d6fcf56 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/admin/LogAdminServlet.java +++ b/pki/base/common/src/com/netscape/cms/servlet/admin/LogAdminServlet.java @@ -83,9 +83,9 @@ public class LogAdminServlet extends AdminServlet { super(); } - public static Hashtable toHashtable(HttpServletRequest req) { - Hashtable httpReqHash = new Hashtable(); - Enumeration names = req.getParameterNames(); + public static Hashtable<String, String> toHashtable(HttpServletRequest req) { + Hashtable<String, String> httpReqHash = new Hashtable<String, String>(); + Enumeration<?> names = req.getParameterNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); @@ -342,7 +342,7 @@ public class LogAdminServlet extends AdminServlet { NameValuePairs params = new NameValuePairs(); String insts = null; - Enumeration e = mSys.getLogInsts().keys(); + Enumeration<String> e = mSys.getLogInsts().keys(); for (; e.hasMoreElements();) { String name = (String) e.nextElement(); @@ -422,7 +422,8 @@ public class LogAdminServlet extends AdminServlet { * @exception IOException an input/output error has occurred * @exception EBaseException an error has occurred */ - private synchronized void addLogPlugin(HttpServletRequest req, + @SuppressWarnings("unchecked") + private synchronized void addLogPlugin(HttpServletRequest req, HttpServletResponse resp, String scope) throws ServletException, IOException, EBaseException { String auditMessage = null; @@ -507,10 +508,10 @@ public class LogAdminServlet extends AdminServlet { destStore.getSubStore("impl"); // Does the class exist? - Class newImpl = null; + Class<ILogEventListener> newImpl = null; try { - newImpl = Class.forName(classPath); + newImpl = (Class<ILogEventListener>) Class.forName(classPath); } catch (ClassNotFoundException e) { // store a message in the signed audit log file if (logType.equals(SIGNED_AUDIT_LOG_TYPE)) { @@ -810,7 +811,7 @@ public class LogAdminServlet extends AdminServlet { return; } - Vector configParams = mSys.getLogDefaultParams(implname); + Vector<String> configParams = mSys.getLogDefaultParams(implname); IConfigStore destStore = mConfig.getSubStore("log"); @@ -1029,7 +1030,7 @@ public class LogAdminServlet extends AdminServlet { HttpServletResponse resp) throws ServletException, IOException, EBaseException { NameValuePairs params = new NameValuePairs(); - Enumeration e = mSys.getLogPlugins().keys(); + Enumeration<String> e = mSys.getLogPlugins().keys(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); @@ -1304,7 +1305,7 @@ public class LogAdminServlet extends AdminServlet { // first check if any instances from this log // DON'T remove log if any instance - for (Enumeration e = mSys.getLogInsts().keys(); + for (Enumeration<String> e = mSys.getLogInsts().keys(); e.hasMoreElements();) { String name = (String) e.nextElement(); ILogEventListener log = mSys.getLogInstance(name); @@ -1559,7 +1560,7 @@ public class LogAdminServlet extends AdminServlet { ILogEventListener oldinst = (ILogEventListener) mSys.getLogInstance(id); - Vector oldConfigParms = oldinst.getInstanceParams(); + Vector<String> oldConfigParms = oldinst.getInstanceParams(); NameValuePairs saveParams = new NameValuePairs(); // implName is always required so always include it it. @@ -1585,7 +1586,7 @@ public class LogAdminServlet extends AdminServlet { // create new substore. - Vector configParams = mSys.getLogInstanceParams(id); + Vector<String> configParams = mSys.getLogInstanceParams(id); //instancesConfig.removeSubStore(id); @@ -2204,7 +2205,7 @@ public class LogAdminServlet extends AdminServlet { return; } - Vector configParams = mSys.getLogDefaultParams(implname); + Vector<String> configParams = mSys.getLogDefaultParams(implname); NameValuePairs params = new NameValuePairs(); // implName is always required so always send it. @@ -2250,7 +2251,7 @@ public class LogAdminServlet extends AdminServlet { ILogEventListener logInst = (ILogEventListener) mSys.getLogInstance(id); - Vector configParams = logInst.getInstanceParams(); + Vector<String> configParams = logInst.getInstanceParams(); NameValuePairs params = new NameValuePairs(); params.add(Constants.PR_LOG_IMPL_NAME, @@ -2276,7 +2277,7 @@ public class LogAdminServlet extends AdminServlet { store.removeSubStore(id); IConfigStore rstore = store.makeSubStore(id); - Enumeration keys = saveParams.getNames(); + Enumeration<String> keys = saveParams.getNames(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); @@ -2329,11 +2330,12 @@ public class LogAdminServlet extends AdminServlet { HttpServletResponse resp) throws ServletException, IOException, EBaseException { - Enumeration enum1 = req.getParameterNames(); + @SuppressWarnings("unchecked") + Enumeration<String> enum1 = req.getParameterNames(); boolean restart = false; while (enum1.hasMoreElements()) { - String key = (String) enum1.nextElement(); + String key = enum1.nextElement(); String value = req.getParameter(key); if (key.equals(Constants.PR_DEBUG_LOG_ENABLE)) { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordList.java b/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordList.java index e8d7df9c8..3477360e0 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordList.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CertRecordList.java @@ -24,6 +24,7 @@ import java.util.Vector; import com.netscape.certsrv.base.EBaseException; import com.netscape.certsrv.dbs.IDBVirtualList; import com.netscape.certsrv.dbs.IElementProcessor; +import com.netscape.certsrv.dbs.certdb.ICertRecord; import com.netscape.certsrv.dbs.certdb.ICertRecordList; @@ -36,12 +37,12 @@ import com.netscape.certsrv.dbs.certdb.ICertRecordList; */ public class CertRecordList implements ICertRecordList { - private IDBVirtualList mVlist = null; + private IDBVirtualList<ICertRecord> mVlist = null; /** * Constructs a request list. */ - public CertRecordList(IDBVirtualList vlist) { + public CertRecordList(IDBVirtualList<ICertRecord> vlist) { mVlist = vlist; } @@ -89,12 +90,12 @@ public class CertRecordList implements ICertRecordList { * It's no good to call this if you didnt check * if the startidx, endidx are valid. */ - public Enumeration getCertRecords(int startidx, int endidx) + public Enumeration<ICertRecord> getCertRecords(int startidx, int endidx) throws EBaseException { - Vector entries = new Vector(); + Vector<ICertRecord> entries = new Vector<ICertRecord>(); for (int i = startidx; i <= endidx; i++) { - Object element = mVlist.getElementAt(i); + ICertRecord element = mVlist.getElementAt(i); // CMS.debug("gerCertRecords[" + i + "] element: " + element); if (element != null) { @@ -104,12 +105,11 @@ public class CertRecordList implements ICertRecordList { return entries.elements(); } - public Object getCertRecord(int index) + public ICertRecord getCertRecord(int index) throws EBaseException { - Object element = mVlist.getElementAt(index); + return mVlist.getElementAt(index); - return element; } diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java b/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java index 740948712..93f9f35c0 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/CertificateRepository.java @@ -77,7 +77,7 @@ public class CertificateRepository extends Repository private boolean mSkipIfInconsistent = false; private int mCertStatusUpdateInterval = 0; - private Hashtable mCRLIssuingPoints = new Hashtable(); + private Hashtable<String, ICRLIssuingPoint> mCRLIssuingPoints = new Hashtable<String, ICRLIssuingPoint>(); private int mTransitMaxRecords = 1000000; private int mTransitRecordPageSize = 200; @@ -134,7 +134,6 @@ public class CertificateRepository extends Repository } int ltSize = recList.getSizeBeforeJumpTo(); - Vector cList = new Vector(ltSize); CMS.debug("CertificateRepository:getLastSerialNumberInRange: ltSize " + ltSize); @@ -183,7 +182,7 @@ public class CertificateRepository extends Repository ICertRecordList list =findCertRecordsInList(filter, null, "serialno", 10); int size = list.getSize(); - Enumeration e = list.getCertRecords(0, size - 1); + Enumeration<ICertRecord> e = list.getCertRecords(0, size - 1); while (e.hasMoreElements()) { CertRecord rec = (CertRecord) e.nextElement(); BigInteger cur = rec.getSerialNumber(); @@ -425,7 +424,7 @@ public class CertificateRepository extends Repository CertRecord curRec = null; int i; - Object obj = null; + ICertRecord obj = null; for (i = 0; i < ltSize; i++) { obj = recList.getCertRecord(i); @@ -891,7 +890,7 @@ public class CertificateRepository extends Repository CertRecordList list = null; try { - DBVirtualList vlist = (DBVirtualList) s.createVirtualList(getDN(), filter, attrs, + DBVirtualList<ICertRecord> vlist = (DBVirtualList<ICertRecord>) s.createVirtualList(getDN(), filter, attrs, sortKey, pageSize); list = new CertRecordList(vlist); diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java b/pki/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java index adbae506c..65b1039d4 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java @@ -57,11 +57,11 @@ import com.netscape.certsrv.logging.ILogger; public class DBRegistry implements IDBRegistry, ISubsystem { private IConfigStore mConfig = null; - private Hashtable mOCclassNames = new Hashtable(); - private Hashtable mOCldapNames = new Hashtable(); - private Hashtable mAttrufNames = new Hashtable(); + private Hashtable<String, String[]> mOCclassNames = new Hashtable<String, String[]>(); + private Hashtable<String, NameAndObject> mOCldapNames = new Hashtable<String, NameAndObject>(); + private Hashtable<String, IDBAttrMapper> mAttrufNames = new Hashtable<String, IDBAttrMapper>(); private IFilterConverter mConverter = null; - private Vector mDynAttrMappers = new Vector(); + private Vector<IDBDynAttrMapper> mDynAttrMappers = new Vector<IDBDynAttrMapper>(); private ILogger mLogger = CMS.getLogger(); @@ -130,7 +130,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { public void registerObjectClass(String className, String ldapNames[]) throws EDBException { try { - Class c = Class.forName(className); + Class<?> c = Class.forName(className); mOCclassNames.put(className, ldapNames); mOCldapNames.put(sortAndConcate( @@ -244,7 +244,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { int level = 0; int start = 0; int end = 0; - Vector v = new Vector(); + Vector<String> v = new Vector<String>(); for (int i = 0; i < f.length(); i++) { if (f.charAt(i) == '(') { @@ -364,7 +364,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { if (attrs == null) return null; - Vector v = new Vector(); + Vector<String> v = new Vector<String>(); for (int i = 0; i < attrs.length; i++) { @@ -379,7 +379,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { if (mapper == null) { throw new EDBException(CMS.getUserMessage("CMS_DBS_INVALID_ATTRS")); } - Enumeration e = mapper.getSupportedLDAPAttributeNames(); + Enumeration<String> e = mapper.getSupportedLDAPAttributeNames(); while (e.hasMoreElements()) { String s = (String) e.nextElement(); @@ -391,7 +391,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { } else { IDBDynAttrMapper matchingDynAttrMapper = null; // check if a dynamic mapper can handle the attribute - for (Iterator dynMapperIter = mDynAttrMappers.iterator(); + for (Iterator<IDBDynAttrMapper> dynMapperIter = mDynAttrMappers.iterator(); dynMapperIter.hasNext();) { IDBDynAttrMapper dynAttrMapper = (IDBDynAttrMapper)dynMapperIter.next(); @@ -429,7 +429,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { */ public LDAPAttributeSet createLDAPAttributeSet(IDBObj obj) throws EBaseException { - Enumeration e = obj.getSerializableAttrNames(); + Enumeration<String> e = obj.getSerializableAttrNames(); LDAPAttributeSet attrs = new LDAPAttributeSet(); // add object class to attribute set @@ -462,8 +462,9 @@ public class DBRegistry implements IDBRegistry, ISubsystem { attrs.remove("objectclass"); // sort the object class values - Enumeration vals = attr.getStringValues(); - Vector v = new Vector(); + @SuppressWarnings("unchecked") + Enumeration<String> vals = attr.getStringValues(); + Vector<String> v = new Vector<String>(); while (vals.hasMoreElements()) { v.addElement(vals.nextElement()); @@ -478,11 +479,11 @@ public class DBRegistry implements IDBRegistry, ISubsystem { throw new EDBException( CMS.getUserMessage("CMS_DBS_INVALID_CLASS_NAME", sorted)); } - Class c = (Class) no.getObject(); + Class<?> c = (Class<?>) no.getObject(); try { IDBObj obj = (IDBObj) c.newInstance(); - Enumeration ee = obj.getSerializableAttrNames(); + Enumeration<String> ee = obj.getSerializableAttrNames(); while (ee.hasMoreElements()) { String oname = (String) ee.nextElement(); @@ -516,7 +517,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem { * Sorts and concate given strings. */ private String sortAndConcate(String s[]) { - Vector v = new Vector(); + Vector<String> v = new Vector<String>(); // sort it first for (int i = 0; i < s.length; i++) { diff --git a/pki/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java b/pki/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java index e5fc8c7bb..ddec63cef 100644 --- a/pki/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java +++ b/pki/base/common/src/com/netscape/cmscore/dbs/DBVirtualList.java @@ -47,7 +47,7 @@ import com.netscape.certsrv.logging.ILogger; * @author mzhao * @version $Revision$, $Date$ */ -public class DBVirtualList implements IDBVirtualList { +public class DBVirtualList<E> implements IDBVirtualList<E> { private IDBRegistry mRegistry = null; private LDAPConnection mConn = null; @@ -57,7 +57,7 @@ public class DBVirtualList implements IDBVirtualList { // virtual list size private int mSize = -1; - private Vector mEntries = new Vector(); + private Vector<E> mEntries = new Vector<E>(); // mSize is get or not? private boolean mInitialized = false; private LDAPSortKey[] mKeys; @@ -460,7 +460,8 @@ public class DBVirtualList implements IDBVirtualList { try { //maintain mEntries as vector of LDAPEntry - Object o = mRegistry.createObject(entry.getAttributeSet()); + @SuppressWarnings("unchecked") + E o = (E)mRegistry.createObject(entry.getAttributeSet()); mEntries.addElement(o); } catch (Exception e) { @@ -631,7 +632,7 @@ public class DBVirtualList implements IDBVirtualList { * * @param index the index of the element to fetch */ - public Object getElementAt(int index) { + public E getElementAt(int index) { /* mSize may not be init at this time! Bad ! * the caller should really check the index is within bound before this @@ -715,12 +716,12 @@ public class DBVirtualList implements IDBVirtualList { if ((offset < 0) || (offset >= mEntries.size())) //XXX - return ("No entry at " + index); + return null; //("No entry at " + index); else return mEntries.elementAt(offset); } - public Object getJumpToElementAt(int i) { + public E getJumpToElementAt(int i) { return mEntries.elementAt(i); } diff --git a/pki/base/common/src/com/netscape/cmscore/logging/LogSubsystem.java b/pki/base/common/src/com/netscape/cmscore/logging/LogSubsystem.java index eeae860c2..05e4e91ff 100644 --- a/pki/base/common/src/com/netscape/cmscore/logging/LogSubsystem.java +++ b/pki/base/common/src/com/netscape/cmscore/logging/LogSubsystem.java @@ -57,8 +57,8 @@ public class LogSubsystem implements ILogSubsystem { public static final String PROP_PLUGIN = "pluginName"; public static final String PROP_INSTANCE = "instance"; - public Hashtable mLogPlugins = new Hashtable(); - public Hashtable mLogInsts = new Hashtable(); + public Hashtable<String, LogPlugin> mLogPlugins = new Hashtable<String, LogPlugin>(); + public Hashtable<String, ILogEventListener> mLogInsts = new Hashtable<String, ILogEventListener>(); /** * Constructs a log subsystem. @@ -88,7 +88,7 @@ public class LogSubsystem implements ILogSubsystem { // load log plugin implementation IConfigStore c = config.getSubStore(PROP_IMPL); - Enumeration mImpls = c.getSubStoreNames(); + Enumeration<String> mImpls = c.getSubStoreNames(); while (mImpls.hasMoreElements()) { String id = (String) mImpls.nextElement(); @@ -102,7 +102,7 @@ public class LogSubsystem implements ILogSubsystem { // load log instances c = config.getSubStore(PROP_INSTANCE); - Enumeration instances = c.getSubStoreNames(); + Enumeration<String> instances = c.getSubStoreNames(); while (instances.hasMoreElements()) { String insName = (String) instances.nextElement(); @@ -158,7 +158,7 @@ public class LogSubsystem implements ILogSubsystem { public void startup() throws EBaseException { Debug.trace("entering LogSubsystem.startup()"); - Enumeration enum1 = mLogInsts.keys(); + Enumeration<String> enum1 = mLogInsts.keys(); while (enum1.hasMoreElements()) { String instName = (String) enum1.nextElement(); @@ -220,15 +220,15 @@ public class LogSubsystem implements ILogSubsystem { return (ILogEventListener) mLogInsts.get(insName); } - public Hashtable getLogPlugins() { + public Hashtable<String, LogPlugin> getLogPlugins() { return mLogPlugins; } - public Hashtable getLogInsts() { + public Hashtable<String, ILogEventListener> getLogInsts() { return mLogInsts; } - public Vector getLogDefaultParams(String implName) throws + public Vector<String> getLogDefaultParams(String implName) throws ELogException { // is this a registered implname? LogPlugin plugin = (LogPlugin) @@ -245,7 +245,7 @@ public class LogSubsystem implements ILogSubsystem { try { LogInst = (ILogEventListener) Class.forName(className).newInstance(); - Vector v = LogInst.getDefaultParams(); + Vector<String> v = LogInst.getDefaultParams(); return v; } catch (InstantiationException e) { @@ -260,14 +260,14 @@ public class LogSubsystem implements ILogSubsystem { } } - public Vector getLogInstanceParams(String insName) throws + public Vector<String> getLogInstanceParams(String insName) throws ELogException { ILogEventListener logInst = getLogInstance(insName); if (logInst == null) { return null; } - Vector v = logInst.getInstanceParams(); + Vector<String> v = logInst.getInstanceParams(); return v; } |