org.liquidsite.core.content
Class Domain

java.lang.Object
  extended byorg.liquidsite.core.content.PersistentObject
      extended byorg.liquidsite.core.content.Domain
All Implemented Interfaces:
java.lang.Comparable

public class Domain
extends PersistentObject
implements java.lang.Comparable

A resource and user domain.


Field Summary
static java.lang.String HOST_NAME_CHARS
          The permitted host name characters.
static java.lang.String NAME_CHARS
          The permitted domain name characters.
 
Fields inherited from class org.liquidsite.core.content.PersistentObject
BINDERS, LOWER_CASE, NUMBERS, UPPER_CASE
 
Constructor Summary
Domain(ContentManager manager, java.lang.String name)
          Creates a new domain with default values.
 
Method Summary
 void addHost(java.lang.String name, java.lang.String description)
          Adds or overwrites a host in the domain.
 int compareTo(Domain domain)
          Compares this object with the specified domain for order.
 int compareTo(java.lang.Object obj)
          Compares this object with the specified object for order.
protected  void doDelete(DataSource src, User user)
          Deletes the object data from the database.
protected  void doInsert(DataSource src, User user, boolean restore)
          Inserts the object data into the database.
protected  void doUpdate(DataSource src, User user)
          Updates the object data in the database.
protected  void doValidate()
          Validates the object data before writing to the database.
 boolean equals(java.lang.Object obj)
          Checks if this domain equals another object.
 java.util.Date getCreatedDate()
          Returns the domain creation date.
 java.lang.String getDescription()
          Returns the domain description.
 java.io.File getDirectory()
          Returns the domain file directory.
 java.util.ArrayList getHosts()
          Returns the hosts belonging to this domain.
 java.lang.String getMailFrom()
          Returns the mail sender address.
 java.util.Date getModifiedDate()
          Returns the domain last modification date.
 java.lang.String getName()
          Returns the unique domain name.
 PermissionList getPermissions()
          Returns the permission list applicable to this domain object.
 java.util.ArrayList getSize()
          Calculates the approximate size of a domain per category.
 void removeAllHosts()
          Removes all hosts belonging to the domain.
 void removeHost(java.lang.String name)
          Removes a host belonging to the domain.
 void setDescription(java.lang.String description)
          Sets the domain description.
 void setMailFrom(java.lang.String address)
          Sets the mail sender address.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class org.liquidsite.core.content.PersistentObject
decodeMap, delete, delete, encodeMap, getContentManager, hasAdminAccess, hasPublishAccess, hasReadAccess, hasWriteAccess, isPersistent, restore, restore, save, save, validateChars, validateSize
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NAME_CHARS

public static final java.lang.String NAME_CHARS
The permitted domain name characters.

See Also:
Constant Field Values

HOST_NAME_CHARS

public static final java.lang.String HOST_NAME_CHARS
The permitted host name characters.

See Also:
Constant Field Values
Constructor Detail

Domain

public Domain(ContentManager manager,
              java.lang.String name)
Creates a new domain with default values.

Parameters:
manager - the content manager to use
name - the domain name
Method Detail

equals

public boolean equals(java.lang.Object obj)
Checks if this domain equals another object. This method will only return true if the other object is a domain with the same name.

Parameters:
obj - the object to compare with
Returns:
true if the other object is an identical domain, or false otherwise

compareTo

public int compareTo(java.lang.Object obj)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the object to compare to
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
Throws:
java.lang.ClassCastException - if the object isn't a Domain object

compareTo

public int compareTo(Domain domain)
Compares this object with the specified domain for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The ordering is based on domain name.

Parameters:
domain - the domain to compare to
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object

toString

public java.lang.String toString()
Returns a string representation of this object.

Returns:
a string representation of this object

getName

public java.lang.String getName()
Returns the unique domain name.

Returns:
the unique domain name

getDescription

public java.lang.String getDescription()
Returns the domain description.

Returns:
the domain description

setDescription

public void setDescription(java.lang.String description)
Sets the domain description.

Parameters:
description - the new description

getCreatedDate

public java.util.Date getCreatedDate()
Returns the domain creation date.

Returns:
the domain creation date

getModifiedDate

public java.util.Date getModifiedDate()
Returns the domain last modification date.

Returns:
the domain last modification date

getMailFrom

public java.lang.String getMailFrom()
Returns the mail sender address. This address will be used for all mails sent from the domain. If this address is not set, the server default address should be used.

Returns:
the mail sender address, or null for none

setMailFrom

public void setMailFrom(java.lang.String address)
Sets the mail sender address. This address will be used for all mails sent from the domain. If this address is not set, the server default address should be used. The address should be formatted as a correct internet mail address, optionally containing both the name and email address.

Parameters:
address - the new address, or null to remove
See Also:
InternetAddress

getPermissions

public PermissionList getPermissions()
                              throws ContentException
Returns the permission list applicable to this domain object. If the object has no permissions an empty permission list will be returned.

Returns:
the permission list for this object
Throws:
ContentException - if the database couldn't be accessed properly

getHosts

public java.util.ArrayList getHosts()
Returns the hosts belonging to this domain. The returned list can be modified freely, as it is only a copy of the actual host data.

Returns:
an array of hosts in this domain
See Also:
DomainHost

addHost

public void addHost(java.lang.String name,
                    java.lang.String description)
Adds or overwrites a host in the domain.

Parameters:
name - the host name
description - the host description

removeHost

public void removeHost(java.lang.String name)
Removes a host belonging to the domain.

Parameters:
name - the host name

removeAllHosts

public void removeAllHosts()
Removes all hosts belonging to the domain.


getDirectory

public java.io.File getDirectory()
                          throws ContentException
Returns the domain file directory. This directory is composed of the application file directory and the domain name. Note that this method will create the domain directory if it does not already exist.

Returns:
the domain file directory
Throws:
ContentException - if the domain file directory wasn't found or couldn't be created

getSize

public java.util.ArrayList getSize()
                            throws ContentException
Calculates the approximate size of a domain per category. This calculation will sum the the size of all files in the domain with an approximate lower estimate for the size of all content in the domain. All values are calculated per content category.

Returns:
a list with domain size objects
Throws:
ContentException - if the database couldn't be accessed properly
See Also:
DomainSize

doValidate

protected void doValidate()
                   throws ContentException
Validates the object data before writing to the database.

Specified by:
doValidate in class PersistentObject
Throws:
ContentException - if the object data wasn't valid

doInsert

protected void doInsert(DataSource src,
                        User user,
                        boolean restore)
                 throws ContentException
Inserts the object data into the database. If the restore flag is set, no automatic changes should be made to the data before writing to the database.

Specified by:
doInsert in class PersistentObject
Parameters:
src - the data source to use
user - the user performing the operation
restore - the restore flag
Throws:
ContentException - if the database couldn't be accessed properly

doUpdate

protected void doUpdate(DataSource src,
                        User user)
                 throws ContentException
Updates the object data in the database.

Specified by:
doUpdate in class PersistentObject
Parameters:
src - the data source to use
user - the user performing the operation
Throws:
ContentException - if the database couldn't be accessed properly

doDelete

protected void doDelete(DataSource src,
                        User user)
                 throws ContentException
Deletes the object data from the database.

Specified by:
doDelete in class PersistentObject
Parameters:
src - the data source to use
user - the user performing the operation
Throws:
ContentException - if the database couldn't be accessed properly