org.hd.d.pg2k.svrCore.props
Class GenProps

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.props.GenProps
All Implemented Interfaces:
java.io.ObjectInputValidation, java.io.Serializable

public final class GenProps
extends java.lang.Object
implements java.io.Serializable, java.io.ObjectInputValidation

This holds run-time settable properties for the master and mirrors. It is immutable, and can be persisted or sent over RMI-IIOP.

All values are accessed through getXXX() methods (this object can be used as a bean) to allow us to always constrain values to sensible limits (and, for example, to patch up up any values that have `gone funny' in serialization because (say) because the class version changed and fields were added) and to allow for local overrides from properties. This means that some of the getXXXX() methods have to be synchronized.

We also extensively check object state at construction and deserialisation; and we try to impose explicit or implicit limits on the amount of space that an instance of this object can consume, especially because at a transition between an old version and a new one there may be multiple instances floating about in memory.

We don't retain the original raw properties internally, but parse them at construction time, to do most of the expensive work once if possible, and to keep the serialised form of the object small. Defaults are set at parse/constuction time, whereas limits are imposed at getXXX() time which makes for a lot of robustness if the object is damaged in transit or if the class details change slightly.

The version manufactured with a default contructor has a zero timestamp.

See Also:
Serialized Form

Nested Class Summary
static class GenProps.AuthData
          Class holding details of one author; immutable, serialisable.
static class GenProps.ClassifiedAd
          Class holding details of one classified advertisement; immutable, serialisable.
private static class GenProps.SimpleAd
          Class holding details of one simple banner advertisement; immutable, serialisable.
 
Field Summary
private  java.util.regex.Pattern _masterClassifiedMatchPattern
          Overall URI regex to check for match against any classified ad; null iff no classified ads.
static java.util.Set<java.lang.String> AD_BANNER_RND_TOKENS
          Immutable Set of String tokens to replace with random values in banner HTML.
private  java.util.SortedMap<java.lang.String,GenProps.AuthData> authDB
          Immutable SortedMap of author details, no empty or duplicate slots; non-zero length, or null if none.
private  GenProps.ClassifiedAd[] classifiedAds
          Array of classified ads, no empty slots or duplicates, non-zero length; or null if no classified ads.
private  java.util.Set<java.lang.String> DNSBLs
          Immutable Set of DNS BLs (normalised DNS zone names); can be null for no such hosts.
private  java.util.Map<java.lang.String,java.lang.String> gen
          The (immutable) generic properties map; never null.
static java.lang.String GEN_PREFIX
          Prefix for general properties in file (not needed on lookup).
private  java.util.Set<java.lang.String> hotLinkAllowHosts
          Immutable Set of "allow" hotlink hosts (normalised host names); can be null for no such hosts.
private  java.util.regex.Pattern hotLinkAllowHostsRegex
          Immutable compiled case-insensitive regex pattern for hotlink allow hosts not in literal list; can be null if no such "regex-match" hosts.
private  java.util.Set<java.lang.String> hotLinkDisallowHosts
          Immutable Set of "disallow" hotlink hosts (normalised/stripped/lower-cased host names); can be null for no such hosts.
private  java.util.regex.Pattern hotLinkDisallowHostsRegex
          Immutable compiled case-insensitive regex pattern for hotlink disallow hosts not in literal list; can be null if no such "regex-match" hosts.
static int MAX_ALLOW_DISALLOW_HOTLINK_HOSTS
          Maximum number of allow/disallow hotlink hosts that may be specified.
static int MAX_AUTH_ENTRIES
          The maximum number of author database entries.
static int MAX_CLASSIFIED_ADS
          The maximum number of classified ads that we will entertain at once.
static int MAX_DNSBLS
          Maximum number of DNSBLs that may be specified.
static int MAX_GEN_LEN
          Maximum length of general property key or value (chars).
static int MAX_GEN_PROPS
          Maximum number of general properties.
static int MAX_POPWT_ENTRIES
          The maximum number of static "goodness"/popularity database entries.
static byte MAX_POPWT_VAL
          The maximum allowed "goodness"/popularity weight (maximally good); strictly negative.
static int MAX_SIMPLE_ADS
          The maximum number of simple ads that we will entertain at once.
static byte MIN_POPWT_VAL
          The minimum allowed "goodness"/popularity weight (maximally bad); strictly negative.
static java.lang.String PCOMP_POPWR_BYATTR
          Goodness subcomponent by attribute; includes trailing dot.
static java.lang.String PCOMP_POPWR_BYAUTH
          Goodness subcomponent by author; includes trailing dot.
static java.lang.String PCOMP_POPWR_BYTYPE
          Goodness subcomponent by type/extension; includes trailing dot.
static java.lang.String PNAME_WEBSVR_BG_IMAGE
          Name of JPEG exhibit to use as a background image (null if none).
static java.lang.String PNAME_WEBSVR_BW_LIMITER
          Name of Web server precacheing bandwidth-limiter value (max fraction of available bandwidth used on precacheing).
static java.lang.String PNAME_WEBSVR_CLASSIFIEDAD_PREFIX
          Name of prefix for classified ad code.
static java.lang.String PNAME_WEBSVR_DNSBLs
          Name of Web server DNSRBLs set.
static java.lang.String PNAME_WEBSVR_EX_HOTLINK_DIVERT_URL
          Name of Web server hotlinked-download-limiter divert graphic URL value.
static java.lang.String PNAME_WEBSVR_EX_HOTLINK_LIMITER
          Name of Web server hotlinked-download-limiter value (as percentange of all exhibit downloads).
static java.lang.String PNAME_WEBSVR_EX_HOTLINK_LIMITER_ALLOW
          Name of Web server hotlinked-download-host-allow set.
static java.lang.String PNAME_WEBSVR_EX_HOTLINK_LIMITER_DISALLOW
          Name of Web server hotlinked-download-host-disallow set.
static java.lang.String PNAME_WEBSVR_MAX_CACHEABLE_EX_BYTES
          Name of Web server maximum-cached-exhibit-prefix-size (bytes) property.
static java.lang.String PNAME_WEBSVR_MAX_EX_BYTES
          Name of Web server maximum exhibit size (32-bit value, bytes).
static java.lang.String PNAME_WEBSVR_META_DESCRIPTION
          Name of description for HTML meta header ("" if none; not null).
static java.lang.String PNAME_WEBSVR_META_KEYWORDS
          Name of keywords list for HTML meta header ("" if none; not null).
static java.lang.String PNAME_WEBSVR_MIN_EX_IMATTR_RECHECK_MS
          Name of Web server minimum exhibit-immutable-attributes check interval (ms) property.
static java.lang.String PNAME_WEBSVR_SIMPLEAD_ALLOW
          Name of on/off switch for simple and classified ad code, enabled by default.
static java.lang.String PNAME_WEBSVR_SIMPLEAD_PREFIX
          Name of prefix for simple banner ad code.
static java.lang.String PNAME_WEBSVR_SYSPROPS_RECHECK_MS
          Name of Web server sysprops check interval (ms) property.
static java.lang.String PNAME_WEBSVR_TN_CACHEPC
          Name of Web server persistent thumbnail cache size limit as percentage of exhibit cache limit value.
private  java.util.Map<java.lang.String,java.lang.Byte> popWeights
          Map from String token to Byte ([-100,+100]) weighting.
static java.lang.String PPREFIX_AUTH_DETAILS
          Property name prefix for author details.
static java.lang.String PPREFIX_POPWT_DETAILS
          Prefix for static "goodness"/popularity weighting values.
private static long serialVersionUID
          Our serialisation version.
private  GenProps.SimpleAd[] simpleAds
          Sorted array of simple ads, no empty slots, non-zero length; or null if no simple ads.
 long timestamp
          Timestamp of this properties set; zero for default/empty set.
private  int totalSimpleAdWeight
          Total weight of all simple ads; non-negative.
private  java.lang.CharSequence WEBSVR_BG_IMAGE
          JPEG exhibit to use as a background image (null if none).
private  int WEBSVR_BW_LIMITER
          Web server precacheing bandwidth-limiter value (max fraction of available bandwidth used on precacheing).
private  java.lang.String WEBSVR_EX_HOTLINK_DIVERT_URL
          Web server hotlinked-download-limiter divert graphic URL value.
private  byte WEBSVR_EX_HOTLINK_LIMITER
          Web server hotlinked-download-limiter value (as percentange of all exhibit downloads).
private  int WEBSVR_MAX_CACHEABLE_EX_BYTES
          Web server maximum-cached-exhibit-prefix-size (bytes).
private  int WEBSVR_MAX_EX_BYTES
          Web server maximum exhibit size (32-bit value, bytes).
private  java.lang.String WEBSVR_META_DESCRIPTION
          Description for HTML meta header ("" if none; not null).
private  java.lang.String WEBSVR_META_KEYWORDS
          Keywords list for HTML meta header ("" if none; not null).
private  int WEBSVR_MIN_EX_IMATTR_RECHECK_MS
          Web server minimum exhibit-immutable-attributes check interval (ms).
private  boolean WEBSVR_SIMPLEAD_ALLOW
          On/off switch for simple banner ad code, enabled by default.
private  int WEBSVR_SYSPROPS_RECHECK_MS
          Web server sysprops (ie most property files including GenProps) (re)check interval (ms).
private  int WEBSVR_TN_CACHEPC
          Web server persistent thumbnail cache size limit as percentage of exhibit cache limit value.
 
Constructor Summary
GenProps()
          Construct a default, zero-timestamp set of generic properties.
GenProps(java.util.Properties props, long _timestamp)
          Construct a new, immutable, properties set.
GenProps(java.util.Properties props, long _timestamp, SimpleLoggerIF logger)
          Construct a new, immutable, properties set.
 
Method Summary
private static int _compute_totalSimpleAdWeight(GenProps.SimpleAd[] _simpleAds)
          Recompute totalSimpleAdWeight; zero if arg is null.
private static java.util.regex.Pattern _makeResidualRegexHostMatch(java.util.Set<java.lang.String> rawNames, SimpleLoggerIF logger)
          Make single compiled pattern from all regex-match hostname expressions; null if no such expressions.
private static boolean _mayBeRegexHostname(java.lang.String n)
          Returns true if this may be a regex (ie contains non-DNS-safe chars).
private static java.util.Set<java.lang.String> _normaliseHostList(java.util.Set<java.lang.String> rawNames, int maxSize)
          Normalise Set of normalised host names; result is immutable and not empty, or is null.
private  java.util.Set<java.lang.String> _parseHostList(java.lang.String hostList)
          Parse set of (space-separated) hostnames; returns null for an empty list.
 GenProps.AuthData getAuthData(java.lang.CharSequence auth)
          Get AuthData for specified author, or null if none.
 java.util.List<GenProps.ClassifiedAd> getClassifieds(java.net.URI uri, java.util.Locale locale, java.net.InetAddress addr)
          Returns List of possible classifieds that match the filters; null if no such ads.
 java.util.Set<java.lang.String> getDNSBLs()
          Get immutable Set of DNSBLs (normalised DNS zone names); never null.
 java.util.Map<java.lang.String,java.lang.String> getGen()
          Get the immutable generic properties; never null.
 java.util.Set<java.lang.String> getHotLinkAllowHosts()
          Get immutable Set of "allow" hotlink hosts (normalised host names); never null.
 java.util.regex.Pattern getHotLinkAllowHostsRegex()
          Get immutable compiled case-insensitive regex pattern for hotlink allow hosts not in literal list; can be null if no such "regex-match" hosts.
 java.util.Set<java.lang.String> getHotLinkDisallowHosts()
          Get immutable Set of "disallow" hotlink hosts (normalised host names); never null.
 java.util.regex.Pattern getHotLinkDisallowHostsRegex()
          Get immutable compiled case-insensitive regex pattern for hotlink disallow hosts not in literal list; can be null if no such "regex-match" hosts.
 java.lang.Byte getPopWeightForAttr(java.lang.String attrWord)
          Get weighting by attribute word in range ([-100,+100]); null if no weighting for specified attribute.
 java.lang.Byte getPopWeightForAuth(java.lang.CharSequence auth)
          Get weighting by author in range ([-100,+100]); null if no weighting for specified author.
 java.lang.Byte getPopWeightForType(java.lang.CharSequence type)
          Get weighting by type/extension in range ([-100,+100]); null if no weighting for specified type.
 java.lang.String getSimpleAd()
          Get HTML code for a simple ad at random; null if none available.
 Name.ExhibitFull getWEBSVR_BG_IMAGE()
          Get the JPEG exhibit to use as a background image (null if none).
 int getWEBSVR_BW_LIMITER()
          Web server precacheing bandwidth-limiter value (max fraction of available bandwidth used on precacheing).
 java.lang.String getWEBSVR_EX_HOTLINK_DIVERT_URL()
          Web server hotlinked-download-limiter value divert graphic URL value, or null if none.
 int getWEBSVR_EX_HOTLINK_LIMITER()
          Web server hotlinked-download-limiter value (as percentange of all exhibit downloads).
 int getWEBSVR_MAX_CACHEABLE_EX_BYTES()
          Get the Web server maximum-cached-exhibit-prefix-size (bytes).
 int getWEBSVR_MAX_EX_BYTES()
          Get the Web server maximum exhibit size (32-bit value, bytes).
 java.lang.String getWEBSVR_META_DESCRIPTION()
          Get the description list for HTML meta header ("" if none; not null).
 java.lang.String getWEBSVR_META_KEYWORDS()
          Get the keywords list for HTML meta header ("" if none; never null).
 int getWEBSVR_MIN_EX_IMATTR_RECHECK_MS()
          Get the Web server minimum exhibit-immutable-attributes check interval (ms).
 boolean getWEBSVR_SIMPLEAD_ALLOW()
          Get on/off switch for simple banner ad code, enabled by default.
 int getWEBSVR_SYSPROPS_RECHECK_MS()
          Get the Web server sysprops check interval (ms).
 int getWEBSVR_TN_CACHEPC()
          Web server persistent thumbnail cache size limit as percentage of exhibit cache limit value.
private static boolean isSafeGenPropValue(java.lang.String s)
          Check if String is save as generic property key or value.
private static boolean isSafeHTMLMetaHeaderChar(char c)
          Check that character is safe for an HTML meta-header; return false if not.
private static boolean isSafeHTMLMetaHeaderString(java.lang.String s)
          Check if String is safe to use as HTML meta-header; return false if not.
private static long parseUTCyyyymmdd(java.lang.String property)
          Parse UTC YYYYMMDD date, or zero if absent (null).
private  void readObject(java.io.ObjectInputStream in)
          Deserialise.
 void validateObject()
          Validate fields/state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Our serialisation version.

See Also:
Constant Field Values

timestamp

public final long timestamp
Timestamp of this properties set; zero for default/empty set.


MAX_GEN_PROPS

public static final int MAX_GEN_PROPS
Maximum number of general properties.

See Also:
Constant Field Values

MAX_GEN_LEN

public static final int MAX_GEN_LEN
Maximum length of general property key or value (chars).

See Also:
Constant Field Values

GEN_PREFIX

public static final java.lang.String GEN_PREFIX
Prefix for general properties in file (not needed on lookup).

See Also:
Constant Field Values

gen

private java.util.Map<java.lang.String,java.lang.String> gen
The (immutable) generic properties map; never null.


PNAME_WEBSVR_MIN_EX_IMATTR_RECHECK_MS

public static final java.lang.String PNAME_WEBSVR_MIN_EX_IMATTR_RECHECK_MS
Name of Web server minimum exhibit-immutable-attributes check interval (ms) property.

See Also:
Constant Field Values

WEBSVR_MIN_EX_IMATTR_RECHECK_MS

private final int WEBSVR_MIN_EX_IMATTR_RECHECK_MS
Web server minimum exhibit-immutable-attributes check interval (ms).


PNAME_WEBSVR_SYSPROPS_RECHECK_MS

public static final java.lang.String PNAME_WEBSVR_SYSPROPS_RECHECK_MS
Name of Web server sysprops check interval (ms) property.

See Also:
Constant Field Values

WEBSVR_SYSPROPS_RECHECK_MS

private final int WEBSVR_SYSPROPS_RECHECK_MS
Web server sysprops (ie most property files including GenProps) (re)check interval (ms).


PNAME_WEBSVR_MAX_CACHEABLE_EX_BYTES

public static final java.lang.String PNAME_WEBSVR_MAX_CACHEABLE_EX_BYTES
Name of Web server maximum-cached-exhibit-prefix-size (bytes) property.

See Also:
Constant Field Values

WEBSVR_MAX_CACHEABLE_EX_BYTES

private final int WEBSVR_MAX_CACHEABLE_EX_BYTES
Web server maximum-cached-exhibit-prefix-size (bytes).


PNAME_WEBSVR_TN_CACHEPC

public static final java.lang.String PNAME_WEBSVR_TN_CACHEPC
Name of Web server persistent thumbnail cache size limit as percentage of exhibit cache limit value.

See Also:
Constant Field Values

WEBSVR_TN_CACHEPC

private final int WEBSVR_TN_CACHEPC
Web server persistent thumbnail cache size limit as percentage of exhibit cache limit value.


PNAME_WEBSVR_BW_LIMITER

public static final java.lang.String PNAME_WEBSVR_BW_LIMITER
Name of Web server precacheing bandwidth-limiter value (max fraction of available bandwidth used on precacheing).

See Also:
Constant Field Values

WEBSVR_BW_LIMITER

private final int WEBSVR_BW_LIMITER
Web server precacheing bandwidth-limiter value (max fraction of available bandwidth used on precacheing).


PNAME_WEBSVR_MAX_EX_BYTES

public static final java.lang.String PNAME_WEBSVR_MAX_EX_BYTES
Name of Web server maximum exhibit size (32-bit value, bytes).

See Also:
Constant Field Values

WEBSVR_MAX_EX_BYTES

private final int WEBSVR_MAX_EX_BYTES
Web server maximum exhibit size (32-bit value, bytes).


PNAME_WEBSVR_META_KEYWORDS

public static final java.lang.String PNAME_WEBSVR_META_KEYWORDS
Name of keywords list for HTML meta header ("" if none; not null).

See Also:
Constant Field Values

WEBSVR_META_KEYWORDS

private final java.lang.String WEBSVR_META_KEYWORDS
Keywords list for HTML meta header ("" if none; not null).


PNAME_WEBSVR_META_DESCRIPTION

public static final java.lang.String PNAME_WEBSVR_META_DESCRIPTION
Name of description for HTML meta header ("" if none; not null).

See Also:
Constant Field Values

WEBSVR_META_DESCRIPTION

private final java.lang.String WEBSVR_META_DESCRIPTION
Description for HTML meta header ("" if none; not null).


PNAME_WEBSVR_BG_IMAGE

public static final java.lang.String PNAME_WEBSVR_BG_IMAGE
Name of JPEG exhibit to use as a background image (null if none).

See Also:
Constant Field Values

WEBSVR_BG_IMAGE

private final java.lang.CharSequence WEBSVR_BG_IMAGE
JPEG exhibit to use as a background image (null if none). Should be Name.ExhibitFull but could be String from deserialising old format.


AD_BANNER_RND_TOKENS

public static final java.util.Set<java.lang.String> AD_BANNER_RND_TOKENS
Immutable Set of String tokens to replace with random values in banner HTML. These tokens, when encountered in HTML banner ad text, are replaced with random (positive, decimal) integers. These are to help with "cache-busting".

These tokens must be chosen so as to be very unlikely to appear where they are not intended for replacement.

This set may become replaceable at run-time in future.


PNAME_WEBSVR_SIMPLEAD_PREFIX

public static final java.lang.String PNAME_WEBSVR_SIMPLEAD_PREFIX
Name of prefix for simple banner ad code. There is one sub-property ({prefix}.allow, either "true" or "false") that allows or disallows all simple ads at once.

Then for N starting at 1, and stopping at the first gap, there must be a non-empty {prefix}.{N}.HTML containing non-empty, pure-printable 7-bit ASCII (32--126, +CRLF) HTML ad code. There may be an optional {prefix}.{N}.wt strictly-positive integer relative weighting (default 100) of this ad to others, the higher the weighting the more of the available space taken.

See Also:
Constant Field Values

PNAME_WEBSVR_SIMPLEAD_ALLOW

public static final java.lang.String PNAME_WEBSVR_SIMPLEAD_ALLOW
Name of on/off switch for simple and classified ad code, enabled by default.

See Also:
Constant Field Values

WEBSVR_SIMPLEAD_ALLOW

private final boolean WEBSVR_SIMPLEAD_ALLOW
On/off switch for simple banner ad code, enabled by default.


totalSimpleAdWeight

private final int totalSimpleAdWeight
Total weight of all simple ads; non-negative. Strictly positive if there are some simple ads.


simpleAds

private GenProps.SimpleAd[] simpleAds
Sorted array of simple ads, no empty slots, non-zero length; or null if no simple ads.


MAX_SIMPLE_ADS

public static final int MAX_SIMPLE_ADS
The maximum number of simple ads that we will entertain at once.

See Also:
Constant Field Values

PNAME_WEBSVR_CLASSIFIEDAD_PREFIX

public static final java.lang.String PNAME_WEBSVR_CLASSIFIEDAD_PREFIX
Name of prefix for classified ad code.

See Also:
Constant Field Values

classifiedAds

private GenProps.ClassifiedAd[] classifiedAds
Array of classified ads, no empty slots or duplicates, non-zero length; or null if no classified ads.


MAX_CLASSIFIED_ADS

public static final int MAX_CLASSIFIED_ADS
The maximum number of classified ads that we will entertain at once.

See Also:
Constant Field Values

_masterClassifiedMatchPattern

private transient volatile java.util.regex.Pattern _masterClassifiedMatchPattern
Overall URI regex to check for match against any classified ad; null iff no classified ads. Not serialised; created on first use. Never set null once non-null.

Marked volatile for thread-safe lock-free access.


PPREFIX_AUTH_DETAILS

public static final java.lang.String PPREFIX_AUTH_DETAILS
Property name prefix for author details.

See Also:
Constant Field Values

authDB

private java.util.SortedMap<java.lang.String,GenProps.AuthData> authDB
Immutable SortedMap of author details, no empty or duplicate slots; non-zero length, or null if none.


MAX_AUTH_ENTRIES

public static final int MAX_AUTH_ENTRIES
The maximum number of author database entries.

See Also:
Constant Field Values

PPREFIX_POPWT_DETAILS

public static final java.lang.String PPREFIX_POPWT_DETAILS
Prefix for static "goodness"/popularity weighting values.

See Also:
Constant Field Values

PCOMP_POPWR_BYAUTH

public static final java.lang.String PCOMP_POPWR_BYAUTH
Goodness subcomponent by author; includes trailing dot.

See Also:
Constant Field Values

PCOMP_POPWR_BYTYPE

public static final java.lang.String PCOMP_POPWR_BYTYPE
Goodness subcomponent by type/extension; includes trailing dot.

See Also:
Constant Field Values

PCOMP_POPWR_BYATTR

public static final java.lang.String PCOMP_POPWR_BYATTR
Goodness subcomponent by attribute; includes trailing dot.

See Also:
Constant Field Values

MAX_POPWT_ENTRIES

public static final int MAX_POPWT_ENTRIES
The maximum number of static "goodness"/popularity database entries.

See Also:
Constant Field Values

MAX_POPWT_VAL

public static final byte MAX_POPWT_VAL
The maximum allowed "goodness"/popularity weight (maximally good); strictly negative.

See Also:
Constant Field Values

MIN_POPWT_VAL

public static final byte MIN_POPWT_VAL
The minimum allowed "goodness"/popularity weight (maximally bad); strictly negative.

See Also:
Constant Field Values

popWeights

private java.util.Map<java.lang.String,java.lang.Byte> popWeights
Map from String token to Byte ([-100,+100]) weighting. We cheat and assume the that sets of author, attribute words and extensions are disjoint, and so we keep all the mappings in a single table!


PNAME_WEBSVR_EX_HOTLINK_LIMITER

public static final java.lang.String PNAME_WEBSVR_EX_HOTLINK_LIMITER
Name of Web server hotlinked-download-limiter value (as percentange of all exhibit downloads).

See Also:
Constant Field Values

WEBSVR_EX_HOTLINK_LIMITER

private final byte WEBSVR_EX_HOTLINK_LIMITER
Web server hotlinked-download-limiter value (as percentange of all exhibit downloads).


PNAME_WEBSVR_EX_HOTLINK_DIVERT_URL

public static final java.lang.String PNAME_WEBSVR_EX_HOTLINK_DIVERT_URL
Name of Web server hotlinked-download-limiter divert graphic URL value.

See Also:
Constant Field Values

WEBSVR_EX_HOTLINK_DIVERT_URL

private final java.lang.String WEBSVR_EX_HOTLINK_DIVERT_URL
Web server hotlinked-download-limiter divert graphic URL value.


MAX_ALLOW_DISALLOW_HOTLINK_HOSTS

public static final int MAX_ALLOW_DISALLOW_HOTLINK_HOSTS
Maximum number of allow/disallow hotlink hosts that may be specified.

See Also:
Constant Field Values

PNAME_WEBSVR_EX_HOTLINK_LIMITER_ALLOW

public static final java.lang.String PNAME_WEBSVR_EX_HOTLINK_LIMITER_ALLOW
Name of Web server hotlinked-download-host-allow set.

See Also:
Constant Field Values

PNAME_WEBSVR_EX_HOTLINK_LIMITER_DISALLOW

public static final java.lang.String PNAME_WEBSVR_EX_HOTLINK_LIMITER_DISALLOW
Name of Web server hotlinked-download-host-disallow set.

See Also:
Constant Field Values

hotLinkAllowHosts

private java.util.Set<java.lang.String> hotLinkAllowHosts
Immutable Set of "allow" hotlink hosts (normalised host names); can be null for no such hosts.


hotLinkAllowHostsRegex

private final java.util.regex.Pattern hotLinkAllowHostsRegex
Immutable compiled case-insensitive regex pattern for hotlink allow hosts not in literal list; can be null if no such "regex-match" hosts.


hotLinkDisallowHosts

private java.util.Set<java.lang.String> hotLinkDisallowHosts
Immutable Set of "disallow" hotlink hosts (normalised/stripped/lower-cased host names); can be null for no such hosts.


hotLinkDisallowHostsRegex

private final java.util.regex.Pattern hotLinkDisallowHostsRegex
Immutable compiled case-insensitive regex pattern for hotlink disallow hosts not in literal list; can be null if no such "regex-match" hosts.


MAX_DNSBLS

public static final int MAX_DNSBLS
Maximum number of DNSBLs that may be specified.

See Also:
Constant Field Values

PNAME_WEBSVR_DNSBLs

public static final java.lang.String PNAME_WEBSVR_DNSBLs
Name of Web server DNSRBLs set.

See Also:
Constant Field Values

DNSBLs

private java.util.Set<java.lang.String> DNSBLs
Immutable Set of DNS BLs (normalised DNS zone names); can be null for no such hosts.

Constructor Detail

GenProps

public GenProps()
Construct a default, zero-timestamp set of generic properties.


GenProps

public GenProps(java.util.Properties props,
                long _timestamp)
Construct a new, immutable, properties set. The properties must be non-null and the timestamp must be non-negative.

Minor problems with the properties themselves will be silently ignored or logged, and defaults substituted for broken or missing values.


GenProps

public GenProps(java.util.Properties props,
                long _timestamp,
                SimpleLoggerIF logger)
Construct a new, immutable, properties set. The properties must be non-null and the timestamp must be non-negative.

Minor problems with the properties themselves will be silently ignored or logged, and defaults substituted for broken or missing values.

Parameters:
logger - if non-null than non-fatal problems will be logged here
Method Detail

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Deserialise.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

validateObject

public void validateObject()
                    throws java.io.InvalidObjectException
Validate fields/state. Called in the constructor and possibly after de-serialising.

Barf if something bad is found. (Maybe allow some extra info in debug version.)

Specified by:
validateObject in interface java.io.ObjectInputValidation
Throws:
java.io.InvalidObjectException

isSafeGenPropValue

private static final boolean isSafeGenPropValue(java.lang.String s)
Check if String is save as generic property key or value. Null and zero-length values are not permitted.

Only ASCII values in the range 32 to 126 are allowed.

Parameters:
s - the putative generic property key or value
Returns:
true iff the argument is a non-null, non-empty, not-too-long pure-ASCII value

isSafeHTMLMetaHeaderString

private static final boolean isSafeHTMLMetaHeaderString(java.lang.String s)
Check if String is safe to use as HTML meta-header; return false if not. Null is treated as OK.


isSafeHTMLMetaHeaderChar

private static final boolean isSafeHTMLMetaHeaderChar(char c)
Check that character is safe for an HTML meta-header; return false if not. Basically such a character must be printable ASCII, and one of:


parseUTCyyyymmdd

private static long parseUTCyyyymmdd(java.lang.String property)
Parse UTC YYYYMMDD date, or zero if absent (null).


getGen

public java.util.Map<java.lang.String,java.lang.String> getGen()
Get the immutable generic properties; never null. The keys in this Map here are stripped of the initial GEN_PREFIX that appears in the properties file.


getWEBSVR_MIN_EX_IMATTR_RECHECK_MS

public final int getWEBSVR_MIN_EX_IMATTR_RECHECK_MS()
Get the Web server minimum exhibit-immutable-attributes check interval (ms). Constrained to the range approx 1s to 6h, default approx 2m.


getWEBSVR_SYSPROPS_RECHECK_MS

public final int getWEBSVR_SYSPROPS_RECHECK_MS()
Get the Web server sysprops check interval (ms). Constrained to the range approx 1s to 1h, default approx 10s (which applies until first props set is fetched).


getWEBSVR_MAX_CACHEABLE_EX_BYTES

public final int getWEBSVR_MAX_CACHEABLE_EX_BYTES()
Get the Web server maximum-cached-exhibit-prefix-size (bytes). Constrained to the range approx 64kB to 1GB, default approx 2MB.


getWEBSVR_TN_CACHEPC

public final int getWEBSVR_TN_CACHEPC()
Web server persistent thumbnail cache size limit as percentage of exhibit cache limit value. Constrained to the range 0 to 100, default approx 10.

A value of zero disables the persistent cache (though in-memory cacheing may continue).

Any additional cache of generated thumbnails (exhibit samples) is limited to a size at most this many percent of the exhibit cache size. This cache is managed separately from this exhibit cache, but yoking the values together makes for simpler system management.


getWEBSVR_BW_LIMITER

public final int getWEBSVR_BW_LIMITER()
Web server precacheing bandwidth-limiter value (max fraction of available bandwidth used on precacheing). Constrained to the range approx 1 to 1000, default approx 10.

If any precacheing operation takes N milliseconds the next one will not be started until at least N times this value later.

The effect is to limit resource consumption to at most about 1/N of the most constrained of slave and master resources (typically CPU and/or bandwidth).


getWEBSVR_MAX_EX_BYTES

public final int getWEBSVR_MAX_EX_BYTES()
Get the Web server maximum exhibit size (32-bit value, bytes). Constrained to the range approx 1B to 1GB, default approx 1GB.


getWEBSVR_META_KEYWORDS

public final java.lang.String getWEBSVR_META_KEYWORDS()
Get the keywords list for HTML meta header ("" if none; never null). May be trimmed of excess whitespace and canonicalised; "" if none.

Guaranteed only to contain characters safe to put directly into an HTML description meta-header attribute value.

In particular this result contains no quote marks (" or ') nor ampersand nor angle-brackets, though may contain whitespace, so should be quoted.


getWEBSVR_META_DESCRIPTION

public final java.lang.String getWEBSVR_META_DESCRIPTION()
Get the description list for HTML meta header ("" if none; not null). May be trimmed of excess whitespace; "" if none.


getWEBSVR_BG_IMAGE

public final Name.ExhibitFull getWEBSVR_BG_IMAGE()
Get the JPEG exhibit to use as a background image (null if none). Is a syntactically-valid JPEG exhibit name (or null).


getWEBSVR_SIMPLEAD_ALLOW

public final boolean getWEBSVR_SIMPLEAD_ALLOW()
Get on/off switch for simple banner ad code, enabled by default.


getSimpleAd

public final java.lang.String getSimpleAd()
Get HTML code for a simple ad at random; null if none available. This returns ads with frequencies in proportion to their weightings.

This will always return null if getWEBSVR_SIMPLEAD_ALLOW() returns false.

This algorithm will take O(n) time to return one of n available ads.

Will be faster when ads are unevenly weigted.

This will automatically do substitution of random "cache-buster" tokens if required. (Any of the recognised tokens will be substituted with a random (positive decimal) integer value, different each time, with all occurrences of any one token the same in any one call.)


_compute_totalSimpleAdWeight

private static int _compute_totalSimpleAdWeight(GenProps.SimpleAd[] _simpleAds)
Recompute totalSimpleAdWeight; zero if arg is null.

Throws:
java.lang.IllegalArgumentException - if sum of weights would exceed Integer.MAX_VALUE.

getClassifieds

public java.util.List<GenProps.ClassifiedAd> getClassifieds(java.net.URI uri,
                                                            java.util.Locale locale,
                                                            java.net.InetAddress addr)
Returns List of possible classifieds that match the filters; null if no such ads. The URI passed should usually be absolute, ie starting with '/'.

This inspects and filters by:

It may be desirable to shuffle the result to avoid any unwanted bias/ordering and to minimise ad-blindness.

Parameters:
uri - the display URI; must be non-null
locale - if non-null then ads are filtered by the ad language, if null then we do not filter by locale/language
addr - if non-null then ads are filtered by the country indicated by this client IP address, if null then we do not filter by country
Returns:
undefined-order non-empty List of possible matching classifieds, else null.

getAuthData

public GenProps.AuthData getAuthData(java.lang.CharSequence auth)
Get AuthData for specified author, or null if none.

Parameters:
auth - author initials of desired data.

getPopWeightForAuth

public java.lang.Byte getPopWeightForAuth(java.lang.CharSequence auth)
Get weighting by author in range ([-100,+100]); null if no weighting for specified author. Author initials specified must be syntactically valid.

Note that this should be treated as if a value of +1.0 with a correlation of the returned value divided by MAX_POPWT_VAL.


getPopWeightForType

public java.lang.Byte getPopWeightForType(java.lang.CharSequence type)
Get weighting by type/extension in range ([-100,+100]); null if no weighting for specified type. Extension/type specified must be syntactically valid and known to the system.

Note that this should be treated as if a value of +1.0 with a correlation of the returned value divided by MAX_POPWT_VAL.


getPopWeightForAttr

public java.lang.Byte getPopWeightForAttr(java.lang.String attrWord)
Get weighting by attribute word in range ([-100,+100]); null if no weighting for specified attribute. Attribute word specified must be syntactically valid and known to the system.

Note that this should be treated as if a value of +1.0 with a correlation of the returned value divided by MAX_POPWT_VAL.


getWEBSVR_EX_HOTLINK_LIMITER

public final int getWEBSVR_EX_HOTLINK_LIMITER()
Web server hotlinked-download-limiter value (as percentange of all exhibit downloads). Constrained to the range approx 0 to 255, default 0.

This limit is too prevent too much (lazy or bandwidth-theft) direct hot-linking to exhibits (and/or thumbnails) by external Web sites.

There are bona fide reasons for some direct hotlinks, eg:


getWEBSVR_EX_HOTLINK_DIVERT_URL

public final java.lang.String getWEBSVR_EX_HOTLINK_DIVERT_URL()
Web server hotlinked-download-limiter value divert graphic URL value, or null if none. Absolute URL of an alternate graphic to divert a user's brower to when they have been hotlinked to one of our exhibits, or null if the user is simply to get a 5XX error.

Preferably a small image with a long cache time.


getHotLinkAllowHosts

public final java.util.Set<java.lang.String> getHotLinkAllowHosts()
Get immutable Set of "allow" hotlink hosts (normalised host names); never null.


getHotLinkAllowHostsRegex

public final java.util.regex.Pattern getHotLinkAllowHostsRegex()
Get immutable compiled case-insensitive regex pattern for hotlink allow hosts not in literal list; can be null if no such "regex-match" hosts.


getHotLinkDisallowHosts

public final java.util.Set<java.lang.String> getHotLinkDisallowHosts()
Get immutable Set of "disallow" hotlink hosts (normalised host names); never null.


getHotLinkDisallowHostsRegex

public final java.util.regex.Pattern getHotLinkDisallowHostsRegex()
Get immutable compiled case-insensitive regex pattern for hotlink disallow hosts not in literal list; can be null if no such "regex-match" hosts.


_mayBeRegexHostname

private static boolean _mayBeRegexHostname(java.lang.String n)
Returns true if this may be a regex (ie contains non-DNS-safe chars). If a user-specified hostname contains characters other than [-a-zA-Z0-9.] then we assume that it may be intended as a regex.

Parameters:
n - non-null non-empty user-specified non-normalised hostname

_makeResidualRegexHostMatch

private static java.util.regex.Pattern _makeResidualRegexHostMatch(java.util.Set<java.lang.String> rawNames,
                                                                   SimpleLoggerIF logger)
Make single compiled pattern from all regex-match hostname expressions; null if no such expressions. The pattern will match if any of the sub-patterns match.

This will whinge about and drop any indiviual non-compilable patterns. No whingeing is done, however, if the passed log is null!


_normaliseHostList

private static java.util.Set<java.lang.String> _normaliseHostList(java.util.Set<java.lang.String> rawNames,
                                                                  int maxSize)
Normalise Set of normalised host names; result is immutable and not empty, or is null. Normalises the set of names provided, discarding any that seem to be invalid, and stopping when/if we reach the size limit specified.

This skips any that seem to be regexes.

Parameters:
rawNames - set of raw host names; if null then null is returned
maxSize - maximum size of result set; strictly positive

_parseHostList

private java.util.Set<java.lang.String> _parseHostList(java.lang.String hostList)
Parse set of (space-separated) hostnames; returns null for an empty list. This does not validate or normalise the names supplied.

Parameters:
hostList - space-separate list of hostnames (or null for none)

getDNSBLs

public final java.util.Set<java.lang.String> getDNSBLs()
Get immutable Set of DNSBLs (normalised DNS zone names); never null.


DHD Multimedia Gallery V1.53.0

Copyright (c) 1996-2009, Damon Hart-Davis. All rights reserved.