Expresso 5-6

com.jcorporate.expresso.ext.dbobj
Class ReverseLookupDomains

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.BaseDataObject
      extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
          extended bycom.jcorporate.expresso.core.dbobj.DBObject
              extended bycom.jcorporate.expresso.core.dbobj.SecuredDBObject
                  extended bycom.jcorporate.expresso.ext.dbobj.ISOCountryCodes
                      extended bycom.jcorporate.expresso.ext.dbobj.ReverseLookupDomains
All Implemented Interfaces:
Cacheable, ContextNested, DataObject, LookupInterface, Securable, Serializable

public class ReverseLookupDomains
extends ISOCountryCodes

Class that maintains a database of all known top level domain codes. Useful for testing whether a particular domain should be denied or not. See RestrictedCountries for sample usage.

This class derives from ISOCountryCodes since most top level domain names are simply the ISO country codes. However, an additional table is necessary for all the additions such as .com, .biz, .uk, etc.

The domain information was from http://www.iana.org/

Since:
Expresso 5.0
Author:
Michael Rimov
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.jcorporate.expresso.core.dbobj.DBObject
DBObject.FieldError, DBObject.FieldUpdate
 
Field Summary
static String FLD_DESCRIPTION
           
static String FLD_DOMAINCODE
           
static String FLD_NOTES
           
 
Fields inherited from class com.jcorporate.expresso.ext.dbobj.ISOCountryCodes
compiler, countryCodeLock, countryCodes, FLD_COUNTRY, FLD_ISOCODE, FLD_POSTALREGEXP, matcher, regExpCache, TABLE
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
ADD, ALL_FUNCTIONS, CACHE_NAME, CACHE_TTY, DELETE, SEARCH, SYSTEM_ACCOUNT, SYSTEM_ACCOUNT_NAME, UPDATE
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.DBObject
ATTRIBUTE_ERROR, ATTRIBUTE_ERROR_MESSAGE, ATTRIBUTE_PAGE_LIMIT, BIG_DECIMAL_ZERO, EMAIL_MASK, EVENT_ADD, EVENT_DELETE, EVENT_UPDATE, FLOAT_MASK, INT_MASK, IS_CHECK_RELATIONAL_INTEGRITY, UPDATE_CHANGED_ONLY, WHERE_KEYWORD
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
anyFieldsDistinct, anyFieldsToRetrieve, appendCustomWhere, caseSensitiveQuery, customWhereClause, dbKey, distinctFields, localConnection, LONGBINARY_READ_DEFAULT_SIZE, maxRecords, myClassName, myUpdates, offsetRecord, recordSet, retrieveFields, sMetadataMap, sortKeys
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
currentStatus, globalMask
 
Fields inherited from interface com.jcorporate.expresso.core.dataobjects.DataObject
STATUS_CURRENT, STATUS_DELETED, STATUS_NEW, STATUS_UPDATED
 
Constructor Summary
ReverseLookupDomains()
          Constructor
ReverseLookupDomains(DBConnection myConnection)
          Constructor
ReverseLookupDomains(int uid)
          Use over (String) constructor.
ReverseLookupDomains(RequestContext request)
          For using DBObjects within Controllers.
 
Method Summary
 String getDomainId(String ipAddress)
          Use this function to lookup any domain names given the InetAddress
 int getExpectedDefaultPopulation()
          Useful method for unit testing to make sure that everything got added during setup as expected.
protected  String[][] getInternetCodes()
           
 DBObject getThisDBObj()
          This will return a new object of the type of the subclass.
 Vector getValues()
          Method to return a Vector of ValidValue Template method--not implemented in this superclass.
 void populateDefaultValues()
          This function populates the table with the current listing of ISO country codes
protected  void setupFields()
          Sets up the fields for use in this database
 
Methods inherited from class com.jcorporate.expresso.ext.dbobj.ISOCountryCodes
checkPostalCode, getCountryCodes
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
add, canRequesterAdd, canRequesterDelete, canRequesterRead, canRequesterUpdate, checkAllowed, copyAttributes, count, createSecurityCache, delete, deleteAll, find, getRequestingUid, getString, getString, getString, getString, getString, getString, getSystemUid, instantiate, isAllowed, retrieve, search, searchAndRetrieveList, searchAndRetrieveList, setRequestingUid, update
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.DBObject
addDetail, addField, addField, addFieldError, addFoundKeys, addIfNeeded, addIndex, addKey, addOrUpdate, addSortKey, addTransition, addVirtualField, addVirtualField, addVirtualField, addVirtualField, average, basicAdd, cacheIsChangedComparison, checkAllReferredToBy, checkAllRefs, checkAllRefsPublic, checkDeleteDetailPerm, checkField, checkRef, checkRef, clear, clearDistinctFields, clearError, clearFieldsToRetrieve, clearSortKeys, containsWildCards, delete, deleteAll, deleteDetails, denotesRange, equals, forKey, formatDateTime, get, getAllAttributes, getAttribute, getAttributesIterator, getBooleanFieldValue, getCacheSize, getCacheStatsMap, getCacheUtil, getCheckZeroUpdate, getCustomWhereClause, getDataContext, getDataField, getDataTransferObject, getDBName, getDetails, getDistinctFieldCount, getDistinctFields, getField, getFieldBigDecimal, getFieldBoolean, getFieldByte, getFieldByteArray, getFieldData, getFieldDate, getFieldDecimalFormatted, getFieldDouble, getFieldErrorMessage, getFieldFloat, getFieldInt, getFieldLong, getFieldMetaData, getFieldShort, getFieldsToRetrieveCount, getFilterClass, getFoundCount, getFoundKeysArray, getIndexArray, getISOValuesDefault, getISOValuesDefault, getISOValuesDefault, getKey, getKeyFieldListIterator, getLength, getLengthInt, getLocalConnection, getLocale, getLogger, getLookupObject, getMax, getMax, getMaxRecords, getMyKeys, getMyUpdatesArray, getOffsetRecord, getPatternMatcher, getPrecision, getSerializedForm, getStringFilter, getThisDBbj, getValidValueDescrip, getValidValues, getValidValuesList, getValuesDefault, getValuesDefault, getValuesDefault, hasError, hasErrors, haveAllKeys, initialize, isCached, isChanged, isDistinct, isEmpty, isFieldDistinct, isFieldNull, isFieldsToRetrieve, isFieldToRetrieve, isMultiValued, isReadOnly, isSecret, isVirtual, loadFromConnection, logChange, max, min, newInstance, noNewLine, noQuotes, notifyListeners, referredToBy, removeAttribute, removeFromCache, retrieveFromCache, saveBinaryField, search, set, setAttribute, setCacheSize, setCharset, setCheckZeroUpdate, setConnection, setConnection, setCustomWhereClause, setCustomWhereClause, setDataContext, setDataField, setDataTransferObject, setDefaultValue, setDescription, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setFieldData, setFieldData, setFieldDistinct, setFieldsToRetrieve, setFilterClass, setFilterClass, setKeys, setLocale, setLookupField, setLookupObject, setMask, setMaxRecords, setMultiValued, setName, setOffsetRecord, setReadOnly, setSchema, setSecret, setSortKey, setStringFilter, setStringFiltersOnAll, setTargetDbSchema, setTargetTable, sqlAggrFunction, sum, toDebugString, update, updateAll, updateAll, verify
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
addInParam, addOutParam, buildWhereClause, buildWhereClauseBuffer, checkZeroUpdate, constructNewMetaData, createAndExecuteSearch, createAndRunStoreProcedure, getConnectionPool, getCustomStringFieldValue, getDef, getDistinctFieldArrayList, getExecutor, getFieldsToRetrieveIterator, getJDBCMetaData, getJDBCUtil, getMappedDataContext, getMetaData, getQueryInterface, getSerialForm, loadFromConnection, makeLimitationStub, quoteIfNeeded, runStoredProcedure, runStoredProcedureAndRetrieveList, selectFieldString, setCaseSensitiveQuery, setDBConnectionPool, setDBName, setMappedDataContext, setOriginalDBName, setTargetStoreProcedure
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
getGlobalMask, getStatus, isGlobalMasked, setFieldsWithDefaults, setGlobalMask, setStatus
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FLD_DOMAINCODE

public static final String FLD_DOMAINCODE
See Also:
Constant Field Values

FLD_DESCRIPTION

public static final String FLD_DESCRIPTION
See Also:
Constant Field Values

FLD_NOTES

public static final String FLD_NOTES
See Also:
Constant Field Values
Constructor Detail

ReverseLookupDomains

public ReverseLookupDomains()
                     throws DBException
Constructor

Throws:
DBException - if there's an initialization problem

ReverseLookupDomains

public ReverseLookupDomains(DBConnection myConnection)
                     throws DBException
Constructor

Parameters:
myConnection - database connection for transactions
Throws:
DBException - if there's an initialization problem

ReverseLookupDomains

public ReverseLookupDomains(int uid)
                     throws DBException
Use over (String) constructor. Initializes the object in the context of the user who's uid belongs to the parameter.

Parameters:
uid - the Uid of the user context
Throws:
DBException - if there's an initialization problem

ReverseLookupDomains

public ReverseLookupDomains(RequestContext request)
                     throws DBException
For using DBObjects within Controllers. Initializes based upon the current user and the requested db. [Of course this can be modified later]

Parameters:
request - - The controller request handed to you by the framework.
Throws:
DBException - if there's an initialization problem
Method Detail

populateDefaultValues

public void populateDefaultValues()
                           throws DBException
This function populates the table with the current listing of ISO country codes

Overrides:
populateDefaultValues in class ISOCountryCodes
Throws:
DBException - if an error occurs while populating the table.
See Also:
DBObject.populateDefaultValues()

getExpectedDefaultPopulation

public int getExpectedDefaultPopulation()
Useful method for unit testing to make sure that everything got added during setup as expected.

Overrides:
getExpectedDefaultPopulation in class ISOCountryCodes
Returns:
the length o

getValues

public Vector getValues()
                 throws DBException
Description copied from class: DBObject
Method to return a Vector of ValidValue Template method--not implemented in this superclass. This method may be implemented by objects that want to provide a list of valid values for other DB objects. It is strongly recommended that the valid value list be cached (via the CacheManager) for performance. The naming convention used in Expresso is to store the ValidValue list with a cache name the same as the db objects class name with ".validValues" appended TODO: This should be converted to array List versions

Specified by:
getValues in interface LookupInterface
Overrides:
getValues in class ISOCountryCodes
Returns:
Vector of ValidValue Value/Description pairs for ISO Country Codes
Throws:
DBException - If the values cannot be retrieved

getThisDBObj

public DBObject getThisDBObj()
                      throws DBException
Description copied from class: DBObject
This will return a new object of the type of the subclass.

OVERRIDE this method with implentation like

return new MyObject()

if you want greatest efficiency. For example: A DBObject called "Customer" should return a new "Customer" object.

the implementation in DBObject uses getClass().newInstance(), which seems to be about 50% slower than "new MyObject()" calls on JDK 1.4

Note that this method should never be called directly. It should only be called by newInstance()

Overrides:
getThisDBObj in class DBObject
Returns:
instantiated DBObject
Throws:
DBException - if an error occurs while instantiating the object
See Also:
DBObject.getThisDBObj()

setupFields

protected void setupFields()
                    throws DBException
Sets up the fields for use in this database

Overrides:
setupFields in class ISOCountryCodes
Throws:
DBException - if an error occurs while instantiating the object

getInternetCodes

protected String[][] getInternetCodes()

getDomainId

public String getDomainId(String ipAddress)
                   throws DBException
Use this function to lookup any domain names given the InetAddress

Parameters:
ipAddress - the address to check
Returns:
String: ex 'uk' or 'gov' or 'com'
Throws:
DBException - if an error occurs

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.