org.hd.d.pg2k.svrCore
Class HostUtils

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.HostUtils

public final class HostUtils
extends java.lang.Object

Some simple common host-name utilities.


Constructor Summary
private HostUtils()
          Prevent construction of an instance.
 
Method Summary
static GeoUtils.CCTLD getMirrorCC(java.lang.String name)
          Extract country code from mirror URL/prefix; null if none.
static java.lang.String getMirrorTag(java.lang.String name)
          Extract mirror tag from mirror URL/prefix; null if none.
static boolean isMasterName(java.lang.String name)
          Returns true if this looks like a "master" server domain-name.
static boolean isMirrorName(java.lang.String name)
          Returns true if this looks like a mirror domain-name.
static boolean isPrimaryMirrorName(java.lang.String name)
          Returns true if this appears to be the domain-name of a primary local mirror.
static boolean isPrimaryMirrorTag(java.lang.String tag)
          Returns true if this tag (initial domain-name component) appears to for a primary local mirror.
static boolean isSpecialName(java.lang.String name)
          Returns true if this looks like a special (mirror or master) domain-name.
static java.lang.String makeMirrorNameGeneric(java.lang.String tag)
          Make mirror version of standard "generic" domain-name; never null.
static java.lang.String normaliseVirtualHostName(java.lang.String name)
          Normalise host (Web server) name (ours or a third-party one).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HostUtils

private HostUtils()
Prevent construction of an instance.

Method Detail

normaliseVirtualHostName

public static java.lang.String normaliseVirtualHostName(java.lang.String name)
Normalise host (Web server) name (ours or a third-party one). This converts the host name to lower-case and strips any "www." or "mirror-CC-name." prefix and/or "." suffix.

If the name is already normalised, it is returned unchanged.

Throws:
java.lang.IllegalArgumentException - if arguments are malformed

isMirrorName

public static boolean isMirrorName(java.lang.String name)
Returns true if this looks like a mirror domain-name. This is a canonical name prefixed with something of the form: mirror-cc-x." where "cc" is the two-letter country code where the mirror is hosted (eg uk or us or fr) and "x" is a descriptive short tag to indicate which mirror instance.

Parameters:
name - host name, must be lower-case and non-null

isPrimaryMirrorName

public static boolean isPrimaryMirrorName(java.lang.String name)
Returns true if this appears to be the domain-name of a primary local mirror. This mirror will be assumed to be the primary mirror in its geographical area (and thus worth allowing to be spidered by SEs) iff its name ends with a '1', so, 'mirror-uk-ww1.something' is a primary mirror and 'mirror-uk-ww2.something' is not.

(Thus 'mirror-uk-ww11.something' would also be primary, but we don't care yet.)

This returns true for the full domain name iff isPrimaryMirrorTag() would return true for the embedded mirror tag.

Parameters:
name - host name, must be lower-case and non-null

isPrimaryMirrorTag

public static boolean isPrimaryMirrorTag(java.lang.String tag)
Returns true if this tag (initial domain-name component) appears to for a primary local mirror. A mirror with this tag will be assumed to be the primary mirror in its geographical area (and thus worth allowing to be spidered by SEs) iff its name ends with a '1', so, 'mirror-uk-ww1' is a primary mirror and 'mirror-uk-ww2' is not.

(Thus 'mirror-uk-ww11' would also be primary, but we don't care yet.)

This returns true for the tag iff isPrimaryMirrorName() would return true for the whole name, though a null tag will cause this routine to return false for simplicity.

Parameters:
mirror - tag, must be lower-case

getMirrorTag

public static java.lang.String getMirrorTag(java.lang.String name)
Extract mirror tag from mirror URL/prefix; null if none. The mirror tag extracted should be of the form returned by LocalProps.getMirrorTag() for a well-formed server name.


getMirrorCC

public static GeoUtils.CCTLD getMirrorCC(java.lang.String name)
Extract country code from mirror URL/prefix; null if none.


isMasterName

public static boolean isMasterName(java.lang.String name)
Returns true if this looks like a "master" server domain-name. This is a canonical name prefixed with "master." and indicates a central server, eg on which uploads are permitted.

Parameters:
name - host name, must be lower-case and non-null

isSpecialName

public static boolean isSpecialName(java.lang.String name)
Returns true if this looks like a special (mirror or master) domain-name.

Parameters:
name - host name, must be lower-case and non-null

makeMirrorNameGeneric

public static java.lang.String makeMirrorNameGeneric(java.lang.String tag)
Make mirror version of standard "generic" domain-name; never null. Generates hostname of form "mirror-tag.gallery.hd.org".

Parameters:
tag - valid non-null mirror tag

DHD Multimedia Gallery V1.60.69

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