org.starhope.appius.sys.admin
Class Domain

java.lang.Object
  extended by BaseDatum
      extended by org.starhope.appius.sys.admin.Domain

public class Domain
extends BaseDatum

Author:
brpocock

Field Summary
private  String code
          This code (or identifier) is a four-character string which uniquely represents this Domain among all Star-Hope game domains.
private  com.sun.sgs.app.ManagedReference<Filter> filter
           
private  String resourceBase
          This is the URL base under which game resources for this domain are found.
private static long serialVersionUID
           
static long TEST_DOMAIN
           For unit testing, we want to perform our testing in a "safe" database environment.
private  String title
          This is the user-visible title of this domain.
 
Constructor Summary
Domain()
          Instantiate a new "null" domain object
 
Method Summary
static Domain get(org.json.JSONObject object)
          Instantiate a Domain object based upon the supplied JSON data
static Domain get(String id)
           
static Domain getByIdentifier(String domainIdentifier)
           
 String getCode()
           
 Filter getFilter()
           
 String getResourceBase()
          Gets the URI under which resources for this domain should be fetched.
 String getTitle()
          Gets the (user-visible) title of this Domain
 void set(org.json.JSONObject o)
           
 void setCode(String newCode)
           
 void setFilter(Filter filter)
           Get the filter which applies to global actions in this domain.
 void setResourceBase(String newResourceBase)
           
 void setTitle(String newTitle)
          Set the user-visible title of this domain
 org.json.JSONObject toJSON()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEST_DOMAIN

public static final long TEST_DOMAIN

For unit testing, we want to perform our testing in a "safe" database environment. To that ends, we provide a "magic" domain identified as TEST_DOMAIN. Instantiating a Domain object with this as its ID will perform database tests more-or-less out of the way. Note, however, that database testing should still occur only in a "safe" test database schema in the QA or UAT server(s).

Finally, note that since TEST_DOMAIN is a negative value, it will never conflict with any valid Domain ID. (It's -277, which are my initials on a telephone keypad, BRP)

See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

code

private String code
This code (or identifier) is a four-character string which uniquely represents this Domain among all Star-Hope game domains.


filter

private com.sun.sgs.app.ManagedReference<Filter> filter

resourceBase

private String resourceBase
This is the URL base under which game resources for this domain are found.


title

private String title
This is the user-visible title of this domain.

Constructor Detail

Domain

public Domain()
Instantiate a new "null" domain object

Method Detail

get

public static Domain get(org.json.JSONObject object)
                  throws NotFoundException,
                         RuntimeException,
                         org.json.JSONException
Instantiate a Domain object based upon the supplied JSON data

Parameters:
object - the JSON data
Returns:
the Domain object in question
Throws:
org.json.JSONException - if the JSON data is badly-formed
RuntimeException - if something really bad happened
NotFoundException - if the ID is specified, and it isn't found in the database

get

public static Domain get(String id)
                  throws RuntimeException,
                         NotFoundException
Parameters:
id - database ID
Returns:
Domain object referenced by that ID
Throws:
NotFoundException - if the ID doesn't exist in the database
RuntimeException - if the ID is out of the valid range, or some other stupid thing

getByIdentifier

public static Domain getByIdentifier(String domainIdentifier)
                              throws NotFoundException
Parameters:
domainIdentifier - the 4-character identifier code for this domain
Returns:
a (potentially new) Domain object
Throws:
NotFoundException - if the domain can't be found by the given identifier

getCode

public String getCode()
Returns:
a 4-character code representing this domain uniquely within the sysplex

getFilter

public Filter getFilter()
Returns:
get the default filter for this domain

getResourceBase

public String getResourceBase()
Gets the URI under which resources for this domain should be fetched.

Returns:
The URI prefix/base for resources.

getTitle

public String getTitle()
Gets the (user-visible) title of this Domain

Returns:
The title string

set

public void set(org.json.JSONObject o)
See Also:
CastsToJSON.set(org.json.JSONObject)

setCode

public void setCode(String newCode)
             throws DataException
Parameters:
newCode - the new identifier code (4 characters) for this domain
Throws:
DataException - if the identifier attempted isn't 4 uppercase characters

setFilter

public void setFilter(Filter filter)

Get the filter which applies to global actions in this domain.

In particular, this is the filter which applies when registering a user name, to prevent stuff like User.setLogin ("fucktard")

For in-game zones, filters are per-zone.

Parameters:
filter - the new default filter for this domain

setResourceBase

public void setResourceBase(String newResourceBase)
Parameters:
newResourceBase - The URI prefix/base for resources

setTitle

public void setTitle(String newTitle)
              throws DataException
Set the user-visible title of this domain

Parameters:
newTitle - the new title for this Domain
Throws:
DataException - if the title is over 64 characters or blank

toJSON

public org.json.JSONObject toJSON()
See Also:
org.starhope.appius.util.BaseDatum#toJSON()