## com.arsdigita.docmgr
Class ResourceImpl

    java.lang.Object
      com.arsdigita.domain.DomainObject
          com.arsdigita.domain.ObservableDomainObject
              com.arsdigita.kernel.ACSObject
                  com.arsdigita.versioning.VersionedACSObject
                      com.arsdigita.docmgr.ResourceImpl

All Implemented Interfaces:
  com.arsdigita.auditing.Audited, Constants, Resource

Direct Known Subclasses:
  File, Folder

public abstract class ResourceImpl
extends com.arsdigita.versioning.VersionedACSObject
implements Resource, Constants

This class is the abstract parent class of `File` and `Folder`. It provides an implementation of the `Resource` interface for a database-backed virtual filesystem. This implementation stores file in Oracle exclusively. All versioning API is by inheritance from VersionedACSObject (which will eventually also include access logging - so wait for VersionedACSObject)

Version:
  $Revision: #13 $ $Date: 2003/07/11 $ $Author: jparsons $
Author:
  Stefan Deusch (stefan@arsdigita.com), Ron Henderson (ron@arsdigita.com)

Field Summary
`static String` `BASE_DATA_OBJECT_TYPE`
`static String` `PARENT`
`protected static org.apache.log4j.Logger` `s_log`
`static String` `versionId`

Fields inherited from class com.arsdigita.versioning.VersionedACSObject
`IS_DELETED, MASTER`

Fields inherited from class com.arsdigita.kernel.ACSObject
`CONTAINER, DEFAULT_DOMAIN_CLASS, DISPLAY_NAME, ID, OBJECT_TYPE`

Fields inherited from interface com.arsdigita.docmgr.Resource
`SEPARATOR, SEPARATOR_CHAR`

Fields inherited from interface com.arsdigita.docmgr.Constants
`ACTION, CONTENT, DESCRIPTION, DURATION, FOLDER_ID, IS_FOLDER, LAST_MODIFIED_DATE, MIME_TYPE_LABEL, NAME, OBJECT_ID, PARTY_ID, PATH, REPOSITORIES_MOUNTED, SIZE, TEXT_HTML, TEXT_PLAIN, TYPE, USER_ID`

Constructor Summary
`protected` `ResourceImpl()` Default constructor.
`protected` `ResourceImpl(BigDecimal id)` Creates a resource given the ID
`protected` `ResourceImpl(com.arsdigita.persistence.DataObject dataObject)` Creates a new resource.
`protected` `ResourceImpl(com.arsdigita.persistence.metadata.ObjectType type)` Constructor.
`protected` `ResourceImpl(com.arsdigita.persistence.OID oid)` Creates a resource given the OID
`protected` `ResourceImpl(String typeName)` Constructor.
`protected` `ResourceImpl(String type, ResourceImpl parent)` Creates an empty resource with the given parent.
`protected` `ResourceImpl(String type, String name, String description)` Creates a named resource of the specified type.
`protected` `ResourceImpl(String type, String name, String description, ResourceImpl parent)` Creates a named resource of the specified type with a given parent.

Method Summary
`protected void` `afterSave()`
`protected void` `beforeSave()`
`protected static void` `copy(ResourceImpl src, ResourceImpl dest)` Copy the generic properties of a Resource.
`Resource` `copyTo(Resource parent)` Copies the resource into another location.
`Resource` `copyTo(String name)` Copies the resource into the same location (same parent) with a new name.
`abstract Resource` `copyTo(String name, Resource parent)` Copies the resource into another location with a new name.
`void` `delete()` Deletes a resource.
`protected String` `getBaseDataObjectType()`
`static String` `getCanonicalPath(String path)` Returns a canonical path by removing leading or trailing separator characters as needed.
`Date` `getCreationDate()`
`String` `getCreationIP()`
`com.arsdigita.kernel.User` `getCreationUser()`
`String` `getDescription()` Returns a description of the resource, or null if no description has been provided.
`Date` `getLastModifiedDate()`
`String` `getLastModifiedIP()`
`com.arsdigita.kernel.User` `getLastModifiedUser()`
`String` `getName()` Returns the name of the file or folder corresponding to this resource.
`Resource` `getParent()` Returns the path name of this resource's parent, or null if this resource does not have a parent.
`protected BigDecimal` `getParentResourceID()`
`String` `getPath()` Converts this resource into a pathname string.
`protected Vector` `getPropertyNames()` Return the list of declared property names for a Resource.
`BigDecimal` `getResourceID()`
`BigDecimal` `getResourceID(String path)` Retrieve the ID of a child resource using a relative path.
`protected static boolean` `isAbsolutePath(String path)` Verifies that the given string corresponds to a valid absolute path name.
`abstract boolean` `isFile()` Tests whether this resource is a file.
`abstract boolean` `isFolder()` Tests whether this resource is a folder.
`boolean` `isRoot()`
`protected static int` `isValidName(String name)` Verifies that the string only contains valid characters for resource names.
`protected static int` `isValidPath(String path)` Verifies that the given string corresponds to a valid relative path name.
`protected static String` `retrievePath(BigDecimal id)` Retrieves the path corresponding to a given resource.
`void` `setCreationDate(Date date)`
`void` `setCreationIP()`
`void` `setCreationUser(com.arsdigita.kernel.User user)`
`void` `setDescription(String description)`
`void` `setLastModifiedDate(Date date)`
`void` `setLastModifiedIP()`
`void` `setLastModifiedUser(com.arsdigita.kernel.User user)`
`void` `setName(String name)`
`void` `setParent(Resource parent)` Set the parent of this resource.
`URL` `toURL()` Returns the URL corresponding to this resource.

Methods inherited from class com.arsdigita.versioning.VersionedACSObject
`applyTag, applyUniqueTag, autoPropagateMaster, getMaster, getRolledBackTo, getTransactions, getTransactions, isMaster, isRolledBack, isSubtype, permanentlyDelete, propagateMaster, recordAttributeChange, rollBackTo, rollBackTo, rollForward, save, setMaster, trackChanges`

Methods inherited from class com.arsdigita.kernel.ACSObject
`assertPrivilege, checkPrivilege, doCreateCheck, doWriteCheck, getContainer, getDefaultDomainClass, getDisplayName, getID, getSpecificObjectType, getSpecificOID, gimmeContainer, initialize, isContainerModified, setID, setID`

Methods inherited from class com.arsdigita.domain.ObservableDomainObject
`addObserver, getObservers`

Methods inherited from class com.arsdigita.domain.DomainObject
`add, add, addToAssociation, afterDelete, beforeDelete, clear, disconnect, equals, get, getObjectType, getOID, getSession, hashCode, isDeleted, isDisconnected, isModified, isNew, isPropertyModified, isValid, remove, remove, remove, removeFromAssociation, save, set, setAssociation, setAssociation, specializeDataObject, specializeDataObject, toString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.arsdigita.docmgr.Resource
`getID, toString`

Field Detail

### versionId

    public static final String versionId

See Also:
  Constant Field Values

### BASE_DATA_OBJECT_TYPE

    public static final String BASE_DATA_OBJECT_TYPE

See Also:
  Constant Field Values

### PARENT

    public static final String PARENT

See Also:
  Constant Field Values

### s_log

    protected static org.apache.log4j.Logger s_log

Constructor Detail

### ResourceImpl

    protected ResourceImpl()

  Default constructor. The contained `DataObject` is initialized with a new `DataObject` with an `ObjectType` of BASE_DATA_OBJECT_TYPE.

See Also:
  `DomainObject.DomainObject(String)`, `ObjectType`

### ResourceImpl

    protected ResourceImpl(String typeName)

  Constructor. The contained `DataObject` is initialized with a new `DataObject` with an `ObjectType` specified by the string typeName.

Parameters:
  `typeName` - The name of the `ObjectType` of the contained `DataObject`.
See Also:
  `DomainObject.DomainObject(String)`, `DataObject`, `ObjectType`

### ResourceImpl

    protected ResourceImpl(com.arsdigita.persistence.metadata.ObjectType type)

  Constructor. The contained `DataObject` is initialized with a new `DataObject` with an `ObjectType` specified by type.

Parameters:
  `type` - The `ObjectType` of the contained `DataObject`.
See Also:
  `DomainObject.DomainObject(ObjectType)`, `DataObject`, `ObjectType`

### ResourceImpl

    protected ResourceImpl(com.arsdigita.persistence.DataObject dataObject)

  Creates a new resource. Properties of this object are not made persistent until the `save()` method is called.

### ResourceImpl

    protected ResourceImpl(BigDecimal id)
                    throws com.arsdigita.domain.DataObjectNotFoundException

  Creates a resource given the ID

Parameters:
  `id` - the BigDecimal ID

### ResourceImpl

    protected ResourceImpl(com.arsdigita.persistence.OID oid)
                    throws com.arsdigita.domain.DataObjectNotFoundException

  Creates a resource given the OID

Parameters:
  `oid` - the Object OID

### ResourceImpl

    protected ResourceImpl(String type,
                           String name,
                           String description)

  Creates a named resource of the specified type.

### ResourceImpl

    protected ResourceImpl(String type,
                           String name,
                           String description,
                           ResourceImpl parent)

  Creates a named resource of the specified type with a given parent.

### ResourceImpl

    protected ResourceImpl(String type,
                           ResourceImpl parent)

  Creates an empty resource with the given parent.

Method Detail

### getBaseDataObjectType

    protected String getBaseDataObjectType()

### beforeSave

    protected void beforeSave()

### afterSave

    protected void afterSave()

### delete

    public void delete()
                throws ResourceNotEmptyException

  Deletes a resource. Throws a `ResourceNotEmptyException` if the resource still contains children.

  Throws:
    `ResourceNotEmptyException`

### getName

    public String getName()

  Description copied from interface: `Resource`
  Returns the name of the file or folder corresponding to this resource.

  Specified by:
    `getName` in interface `Resource`

### setName

    public void setName(String name)

### getDescription

    public String getDescription()

  Description copied from interface: `Resource`
  Returns a description of the resource, or null if no description has been provided.

  Specified by:
    `getDescription` in interface `Resource`

### setDescription

    public void setDescription(String description)

### getParent

    public Resource getParent()

  Description copied from interface: `Resource`
  Returns the path name of this resource's parent, or null if this resource does not have a parent.

  Specified by:
    `getParent` in interface `Resource`

### setParent

    public void setParent(Resource parent)

  Set the parent of this resource.

  Parameters:
    `parent` - the parent of this resource

### getParentResourceID

    protected BigDecimal getParentResourceID()

### isRoot

    public boolean isRoot()

### getPath

    public String getPath()

  Description copied from interface: `Resource`
  Converts this resource into a pathname string.

  Specified by:
    `getPath` in interface `Resource`

### isFolder

    public abstract boolean isFolder()

  Description copied from interface: `Resource`
  Tests whether this resource is a folder.

  Specified by:
    `isFolder` in interface `Resource`

### isFile

    public abstract boolean isFile()

  Description copied from interface: `Resource`
  Tests whether this resource is a file.

  Specified by:
    `isFile` in interface `Resource`

### toURL

    public URL toURL()

  Description copied from interface: `Resource`
  Returns the URL corresponding to this resource.

  Specified by:
    `toURL` in interface `Resource`

### retrievePath

    protected static String retrievePath(BigDecimal id)

  Retrieves the path corresponding to a given resource.

### isValidPath

    protected static int isValidPath(String path)

  Verifies that the given string corresponds to a valid relative path name.

  Returns:
    0 for a system-valid parthname, otherwise error codes defined in InvalidNameException.
  See Also:
    `InvalidNameException`

### isAbsolutePath

    protected static boolean isAbsolutePath(String path)

  Verifies that the given string corresponds to a valid absolute path name.

### isValidName

    protected static int isValidName(String name)

  Verifies that the string only contains valid characters for resource names. The following are allowed: [a-z][A-Z][0-9][-., ] In addition, names cannot begin with ".", i.e. we do NOT support file names like ".profile" at the moment. The current implementation does not allow international characters for resource names.

  Returns:
    0 for a system-valid resource name, otherwise error codes defined in InvalidNameException.
  See Also:
    `InvalidNameException`

### getCanonicalPath

    public static String getCanonicalPath(String path)
                                   throws InvalidNameException

  Returns a canonical path by removing leading or trailing separator characters as needed.

  Throws:
    `InvalidNameException`

### getResourceID

    public BigDecimal getResourceID()

### getResourceID

    public BigDecimal getResourceID(String path)
                             throws com.arsdigita.domain.DataObjectNotFoundException,
                                    InvalidNameException

  Retrieve the ID of a child resource using a relative path. This method is useful for checking the existence of a named child without the overhead of instantiating that child.

  Returns:
    the BigDecimal ID of the resource with the specified relative path
  Throws:
    `com.arsdigita.domain.DataObjectNotFoundException`
    `InvalidNameException`

### getPropertyNames

    protected Vector getPropertyNames()

  Return the list of declared property names for a Resource. This list only includes the properties that should be duplicated during a copy operation.

### getLastModifiedDate

    public Date getLastModifiedDate()

  Specified by:
    `getLastModifiedDate` in interface `com.arsdigita.auditing.Audited`

### setLastModifiedDate

    public void setLastModifiedDate(Date date)

### getCreationDate

    public Date getCreationDate()

  Specified by:
    `getCreationDate` in interface `com.arsdigita.auditing.Audited`

### setCreationDate

    public void setCreationDate(Date date)

### getCreationUser

    public com.arsdigita.kernel.User getCreationUser()

  Specified by:
    `getCreationUser` in interface `com.arsdigita.auditing.Audited`

### setCreationUser

    public void setCreationUser(com.arsdigita.kernel.User user)

### getLastModifiedUser

    public com.arsdigita.kernel.User getLastModifiedUser()

  Specified by:
    `getLastModifiedUser` in interface `com.arsdigita.auditing.Audited`

### setLastModifiedUser

    public void setLastModifiedUser(com.arsdigita.kernel.User user)

### getCreationIP

    public String getCreationIP()

  Specified by:
    `getCreationIP` in interface `com.arsdigita.auditing.Audited`

### setCreationIP

    public void setCreationIP()

### getLastModifiedIP

    public String getLastModifiedIP()

  Specified by:
    `getLastModifiedIP` in interface `com.arsdigita.auditing.Audited`

### setLastModifiedIP

    public void setLastModifiedIP()

### copy

    protected static void copy(ResourceImpl src,
                               ResourceImpl dest)

  Copy the generic properties of a Resource. Uses an explicit list of properties to copy as determined by `getPropertyNames`.

### copyTo

    public Resource copyTo(Resource parent)

  Description copied from interface: `Resource`
  Copies the resource into another location. Preserves the original name of the resource but places the copy inside a new parent resource.

  Specified by:
    `copyTo` in interface `Resource`
  Parameters:
    `parent` - the parent of the copy
  Returns:
    a copy of the original resource

### copyTo

    public Resource copyTo(String name)

  Description copied from interface: `Resource`
  Copies the resource into the same location (same parent) with a new name.

  Specified by:
    `copyTo` in interface `Resource`
  Parameters:
    `name` - the name of the copy
  Returns:
    a copy of the original resource.

### copyTo

    public abstract Resource copyTo(String name,
                                    Resource parent)

  Description copied from interface: `Resource`
  Copies the resource into another location with a new name.

  Specified by:
    `copyTo` in interface `Resource`
  Parameters:
    `name` - the name of the copy
    `parent` - the parent of the copy
  Returns:
    a copy of the original resource.

Copyright (c) 2006 Red Hat, Inc. Corporation. All Rights Reserved. Generated at June 1 2006:1113 UTC