com.opencms.file
Class CmsResource

java.lang.Object
  |
  +--com.opencms.file.CmsResource
All Implemented Interfaces:
Cloneable, I_CmsConstants, Serializable
Direct Known Subclasses:
CmsBackupResource, CmsFile, CmsFolder

public class CmsResource
extends Object
implements I_CmsConstants, Cloneable, Serializable

Describes a resource in the Cms. This resource can be a A_CmsFile or a A_CmsFolder.

Version:
$Revision: 1.44 $ $Date: 2003/04/01 15:20:18 $
Author:
Michael Emmerich
See Also:
Serialized Form

Field Summary
protected  int m_size
          The size of the file content.
 
Fields inherited from interface com.opencms.core.I_CmsConstants
C_ACCESS_DEFAULT_FLAGS, C_ACCESS_GROUP, C_ACCESS_GROUP_READ, C_ACCESS_GROUP_VISIBLE, C_ACCESS_GROUP_WRITE, C_ACCESS_INTERNAL_READ, C_ACCESS_OWNER, C_ACCESS_OWNER_READ, C_ACCESS_OWNER_VISIBLE, C_ACCESS_OWNER_WRITE, C_ACCESS_PUBLIC, C_ACCESS_PUBLIC_READ, C_ACCESS_PUBLIC_VISIBLE, C_ACCESS_PUBLIC_WRITE, C_ACCESS_READ, C_ACCESS_VISIBLE, C_ACCESS_WRITE, C_ADDITIONAL_INFO_EXPLORERSETTINGS, C_ADDITIONAL_INFO_PREFERENCES, C_ADDITIONAL_INFO_STARTSETTINGS, C_ADDITIONAL_INFO_TASKSETTINGS, C_ADDITIONAL_INFO_TOWN, C_ADDITIONAL_INFO_ZIPCODE, C_AT_LEAST_ONCE, C_CLUSTERURL, C_CONFIGURATION_CACHE, C_CONFIGURATION_CLASS, C_CONFIGURATION_REGISTRY, C_CONFIGURATION_RESOURCEBROKER, C_COPYRIGHT, C_DEFAULT_SITE, C_DELETE_HISTORY, C_ENABLE_HISTORY, C_ERRPREFIX, C_ERRSPERATOR, C_EXPORT_TAG_ACCESS, C_EXPORT_TAG_ADDRESS, C_EXPORT_TAG_CREATOR, C_EXPORT_TAG_DATE, C_EXPORT_TAG_DEFAULTGROUP, C_EXPORT_TAG_DESCRIPTION, C_EXPORT_TAG_DESTINATION, C_EXPORT_TAG_EMAIL, C_EXPORT_TAG_EXPORT, C_EXPORT_TAG_FILE, C_EXPORT_TAG_FIRSTNAME, C_EXPORT_TAG_FLAGS, C_EXPORT_TAG_GROUP, C_EXPORT_TAG_GROUPDATA, C_EXPORT_TAG_GROUPNAME, C_EXPORT_TAG_INFO, C_EXPORT_TAG_LASTMODIFIED, C_EXPORT_TAG_LASTNAME, C_EXPORT_TAG_LAUNCHER_START_CLASS, C_EXPORT_TAG_MODULEXPORT, C_EXPORT_TAG_NAME, C_EXPORT_TAG_OC_VERSION, C_EXPORT_TAG_PARENTGROUP, C_EXPORT_TAG_PASSWORD, C_EXPORT_TAG_PROJECT, C_EXPORT_TAG_PROPERTIES, C_EXPORT_TAG_PROPERTY, C_EXPORT_TAG_RECOVERYPASSWORD, C_EXPORT_TAG_SECTION, C_EXPORT_TAG_SOURCE, C_EXPORT_TAG_TYPE, C_EXPORT_TAG_USER, C_EXPORT_TAG_USERDATA, C_EXPORT_TAG_USERGROUPDATA, C_EXPORT_TAG_USERGROUPS, C_EXPORT_TAG_USERINFO, C_EXPORT_TAG_VALUE, C_EXPORT_TAG_VERSION, C_EXPORT_VERSION, C_EXPORT_XMLFILENAME, C_EXPORTONLYFILES, C_EXPORTONLYUSERS, C_EXPORTPOINT, C_EXPORTPOINT_PATH, C_EXPORTUSERSFILES, C_FCONTENT, C_FELEMENT, C_FILE, C_FILECONTENT, C_FILES_IMPORTED, C_FLAG_DISABLED, C_FLAG_ENABLED, C_FLAG_GROUP_PROJECTCOWORKER, C_FLAG_GROUP_PROJECTMANAGER, C_FLAG_GROUP_ROLE, C_FOLDER, C_FOLDER_SEPARATOR, C_GROUP, C_GROUP_ADMIN, C_GROUP_GUEST, C_GROUP_PROJECTLEADER, C_GROUP_USERS, C_LINKCHECKTABLE_DATE, C_MAX_LENGTH_RESOURCE_NAME, C_MODULE_PROPERTY_ADDITIONAL_RESOURCES, C_MODULE_PROPERTY_ADDITIONAL_RESOURCES_SEPARATOR, C_MODUS_AUTO, C_MODUS_EXPORT, C_MODUS_EXTERN, C_MODUS_OFFLINE, C_MODUS_ONLINE, C_MOUNTPOINT_FILESYSTEM, C_MOUNTPOINT_MYSQL, C_NEVER, C_NO_FILES_IMPORTED, C_ORDER_AGENTUSER, C_ORDER_ENDTIME, C_ORDER_ID, C_ORDER_INITIATORUSER, C_ORDER_NAME, C_ORDER_ORIGINALUSER, C_ORDER_PERCENTAGE, C_ORDER_PRIORITY, C_ORDER_ROLE, C_ORDER_STARTTIME, C_ORDER_STATE, C_ORDER_TASKTYPE, C_ORDER_TIMEOUT, C_ORDER_WAKEUPTIME, C_PASSWORD_MINIMUMSIZE, C_PROJECT_ONLINE, C_PROJECT_ONLINE_ID, C_PROJECT_STATE_ARCHIVE, C_PROJECT_STATE_INVISIBLE, C_PROJECT_STATE_LOCKED, C_PROJECT_STATE_UNLOCKED, C_PROJECT_TYPE_INVISIBLE, C_PROJECT_TYPE_NORMAL, C_PROJECT_TYPE_TEMPORARY, C_PROPERTY_ACTIV, C_PROPERTY_CHANNELID, C_PROPERTY_CONTENT_ENCODING, C_PROPERTY_DEFAULT_FILE, C_PROPERTY_DESCRIPTION, C_PROPERTY_EXPORT, C_PROPERTY_EXPORTNAME, C_PROPERTY_KEYWORDS, C_PROPERTY_NAVPOS, C_PROPERTY_NAVTEXT, C_PROPERTY_RELATIVEROOT, C_PROPERTY_TEMPLATETYPE, C_PROPERTY_TITLE, C_PROPERTY_VISIBLE, C_PUBLISH_METHOD_LINK, C_REGISTRY_DESTINATION, C_REGISTRY_HISTORY, C_REGISTRY_KNOWNLAUNCHERS, C_REGISTRY_LAUNCHER, C_REGISTRY_SOURCE, C_REQUEST_CONSOLE, C_REQUEST_HTTP, C_RESPONSE_CONSOLE, C_RESPONSE_HTTP, C_ROOT, C_ROOT_TEMPLATE_NAME, C_ROOTNAME_COS, C_ROOTNAME_VFS, C_SESSION_ADMIN_POS, C_SESSION_BROADCASTMESSAGE, C_SESSION_CONTENT_ENCODING, C_SESSION_CURRENTGROUP, C_SESSION_DATA, C_SESSION_IS_DIRTY, C_SESSION_MESSAGEPENDING, C_SESSION_MODULE_VECTOR, C_SESSION_PROJECT, C_SESSION_THREAD_ERROR, C_SESSION_USERNAME, C_SORT_ASC, C_SORT_DESC, C_START_ACCESSFLAGS, C_START_DEFAULTGROUP, C_START_LANGUAGE, C_START_LOCKDIALOG, C_START_PROJECT, C_START_VIEW, C_STATE_CHANGED, C_STATE_DELETED, C_STATE_NEW, C_STATE_UNCHANGED, C_STATICEXPORT_PATH, C_STATICEXPORT_START, C_SYNCHRONISATION_PATH, C_SYNCHRONISATION_PROJECT, C_SYNCHRONISATION_RESOURCE, C_SYNCHRONISATION_RESOURCETAG, C_SYSTEMPROPERTY_CRONTABLE, C_SYSTEMPROPERTY_EXPORTPATH, C_SYSTEMPROPERTY_EXTENSIONS, C_SYSTEMPROPERTY_LINKCHECKTABLE, C_SYSTEMPROPERTY_MIMETYPES, C_SYSTEMPROPERTY_MOUNTPOINT, C_SYSTEMPROPERTY_RESOURCE_TYPE, C_TABLE_CHANNELID, C_TASK_FILTER, C_TASK_MESSAGES, C_TASK_MESSAGES_ACCEPTED, C_TASK_MESSAGES_COMPLETED, C_TASK_MESSAGES_FORWARDED, C_TASK_MESSAGES_MEMBERS, C_TASK_ORDER_BY_DATE, C_TASK_ORDER_BY_NAME, C_TASK_PRIORITY_HIGH, C_TASK_PRIORITY_LOW, C_TASK_PRIORITY_NORMAL, C_TASK_STATE_ENDED, C_TASK_STATE_HALTED, C_TASK_STATE_NOTENDED, C_TASK_STATE_PREPARE, C_TASK_STATE_START, C_TASK_STATE_STARTED, C_TASK_VIEW_ALL, C_TASKLOG_SYSTEM, C_TASKLOG_USER, C_TASKORDER_NONE, C_TASKORDER_STARTDATE, C_TASKORDER_TIMEOUT, C_TASKS_ACTIVE, C_TASKS_ALL, C_TASKS_DONE, C_TASKS_NEW, C_TASKS_OPEN, C_TASKSORDER_TASKNAME, C_TEMP_PREFIX, C_TFACCESS, C_TFGROUP, C_TFILEOBJ, C_TFILES, C_TFNAME, C_TFPROPERTYINFO, C_TFPROPERTYNAME, C_TFPROPERTYTYPE, C_TFPROPERTYVALUE, C_TFTYPE, C_TFTYPENAME, C_TFUSER, C_TGDESC, C_TGFLAG, C_TGNAME, C_TGPARENTGROUP, C_TGROUPOBJ, C_TGROUPS, C_TGROUPUSERS, C_TGUSER, C_TUADDINFO, C_TUDESC, C_TUDGROUP, C_TUDISABLED, C_TUEMAIL, C_TUFIRSTNAME, C_TUFLAG, C_TUGROUP, C_TUINFOKEY, C_TUINFOVALUE, C_TULOGIN, C_TUNAME, C_TUPASSWD, C_TUSERGROUPS, C_TUSEROBJ, C_TUSERS, C_TYPE_BODY_NAME, C_TYPE_COMPATIBLEPLAIN_NAME, C_TYPE_FOLDER, C_TYPE_FOLDER_NAME, C_TYPE_IMAGE_NAME, C_TYPE_LAST_INDEX, C_TYPE_PAGE_NAME, C_TYPE_PLAIN_NAME, C_UNKNOWN_ID, C_UNKNOWN_INT, C_UNKNOWN_LAUNCHER, C_UNKNOWN_LAUNCHER_ID, C_UNKNOWN_LONG, C_URL_PREFIX_EXPORT, C_URL_PREFIX_HTTP, C_URL_PREFIX_HTTPS, C_URL_PREFIX_SERVERNAME, C_USER, C_USER_ADMIN, C_USER_GUEST, C_USER_TYPE_SYSTEMANDWEBUSER, C_USER_TYPE_SYSTEMUSER, C_USER_TYPE_WEBUSER, C_WEB_APP_REPLACE_KEY, C_WEEKS_HISTORY, C_WHATEVER, C_XML_BODY_ELEMENT
 
Constructor Summary
CmsResource(int resourceId, int parentId, int fileId, String resourceName, int resourceType, int resourceFlags, int user, int group, int projectId, int accessFlags, int state, int lockedBy, int launcherType, String launcherClassname, long dateCreated, long dateLastModified, int resourceLastModifiedBy, int size, int lockedInProject)
          Constructor, creates a new CmsRecource object.
 
Method Summary
 Object clone()
          Clones the CmsResource by creating a new CmsObject.
 boolean equals(Object obj)
          Compares the overgiven object with this object.
 String getAbsolutePath()
          Returns the absolute path of this resource, e.g.
static String getAbsolutePath(String resourceName)
          Returns the absolute path of the provided resource, e.g.
 int getAccessFlags()
          Returns the accessflags of this resource.
 long getDateCreated()
          Returns the date of the creation for this resource.
 long getDateLastModified()
          Returns the date of the last modification for this resource.
 int getFileId()
          Gets the File id for this resource.
 int getFlags()
          Returns the flags of this resource ( not used yet; the Accessflags are served in getAccessFlags).
 String getFlagString()
          Creates a Unix-Style string of access rights from the access right flag of a CmsResource
 int getGroupId()
          Returns the groupid of this resource.
 String getLauncherClassname()
          Gets the launcher classname for this resource.
 int getLauncherType()
          Gets the launcher type id for this resource.
 int getLength()
          Gets the length of the content (filesize).
 int getLockedInProject()
          Gets the project id of the project that has locked this resource.
 String getName()
          Returns the name of this resource.
 int getOwnerId()
          Returns the userid of the resource owner.
 String getParent()
          Returns the absolute parent folder name of this resource.
static String getParent(String resource)
          Returns the absolute parent folder name of a resource.
 int getParentId()
          Gets the Parent database id for this resource.
 String getPath()
          Returns the folder path of this resource, if the resource is a folder, the complete path of the folder is returned (not the parent folder path).
static String getPath(String resource)
          Returns the folder path of the resource with the given name, if the resource is a folder (i.e. ends with a "/"), the complete path of the folder is returned (not the parent folder path).
static int getPathLevel(String resource)
          Returns the directory level of a resource.
static String getPathPart(String resource, int level)
          Returns the name of a parent folder of the given resource, that is either minus levels up from the current folder, or that is plus levels down from the root folder.
 int getProjectId()
          Returns the project id for this resource.
 int getResourceId()
          Gets the database id for this resource.
 int getResourceLastModifiedBy()
          Gets the userId from the user who made the last change.
 String getResourceName()
          Returns the resource name of this resource, e.g.
 String getRootName()
          Returns the root name of this resource, e.g.
 int getState()
          Returns the state of this resource.
 int getType()
          Gets the type id for this resource.
 boolean inProject(CmsProject project)
          Checks if a resource belongs to a project.
 boolean isFile()
          Determines, if this resource is a file.
 boolean isFolder()
          Determines, if this resource is a folder.
 boolean isLocked()
          Determines, if this resource is locked by a user.
 int isLockedBy()
          Returns the user idthat locked this resource.
 boolean isTouched()
          Returns the isTouched.
 void setAccessFlags(int flags)
          Sets the accessflags of this resource.
 void setDateLastModified(long time)
          Sets the date of the last modification for this resource.
 void setFileId(int fileId)
          Sets the File id for this resource.
 void setGroupId(int group)
          Sets the groupId of this resource.
 void setLauncherType(int type)
          Sets launcher the type id for this resource.
 void setLocked(int id)
          Sets the the user id that locked this resource.
 void setLockedInProject(int project)
          Sets the projectId in which this resource is locked.
 void setParentId(int parentId)
          Sets the parent database id for this resource.
 void setProjectId(int project)
          Sets the projectId of this resource.
 void setState(int state)
          Sets the state of this resource.
 void setType(int type)
          Sets the type id for this resource.
 void setUserId(int user)
          Sets the userId of this resource.
 String toString()
          Returns a string-representation for this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_size

protected int m_size
The size of the file content.

Constructor Detail

CmsResource

public CmsResource(int resourceId,
                   int parentId,
                   int fileId,
                   String resourceName,
                   int resourceType,
                   int resourceFlags,
                   int user,
                   int group,
                   int projectId,
                   int accessFlags,
                   int state,
                   int lockedBy,
                   int launcherType,
                   String launcherClassname,
                   long dateCreated,
                   long dateLastModified,
                   int resourceLastModifiedBy,
                   int size,
                   int lockedInProject)
Constructor, creates a new CmsRecource object.

Parameters:
resourceId - The database Id.
parentId - The database Id of the parent folder.
fileId - The id of the content.
resourceName - The name (including complete path) of the resouce.
resourceType - The type of this resource.
projectId - The project id this resource belongs to.
accessFlags - The access flags of this resource.
state - The state of this resource.
lockedBy - The user id of the user who has locked this resource.
launcherType - The launcher that is require to process this recource.
launcherClassname - The name of the Java class invoked by the launcher.
dateCreated - The creation date of this resource.
dateLastModified - The date of the last modification of the resource.
resourceLastModifiedBy - The user who changed the file.
Method Detail

clone

public Object clone()
Clones the CmsResource by creating a new CmsObject.

Overrides:
clone in class Object
Returns:
Cloned CmsObject.

equals

public boolean equals(Object obj)
Compares the overgiven object with this object.

Overrides:
equals in class Object
Returns:
true, if the object is identically else it returns false.

getAbsolutePath

public String getAbsolutePath()
Returns the absolute path of this resource, e.g. /system/workplace/action/index.html

Returns:
the absolute path for this resource

getAbsolutePath

public static String getAbsolutePath(String resourceName)
Returns the absolute path of the provided resource, e.g. /system/workplace/action/index.html

Returns:
the absolute path of the provided resource

getRootName

public String getRootName()
Returns the root name of this resource, e.g. /default/vfs

Returns:
the root name for this resource

getResourceName

public String getResourceName()
Returns the resource name of this resource, e.g. /default/vfs/system/workplace/action/index.html

Returns:
the resource name for this resource.

getAccessFlags

public int getAccessFlags()
Returns the accessflags of this resource.

Returns:
the accessflags of this resource.

getDateCreated

public long getDateCreated()
Returns the date of the creation for this resource.

Returns:
the date of the creation for this resource.

getDateLastModified

public long getDateLastModified()
Returns the date of the last modification for this resource.

Returns:
the date of the last modification for this resource.

setDateLastModified

public void setDateLastModified(long time)
Sets the date of the last modification for this resource.


getFileId

public int getFileId()
Gets the File id for this resource.

Returns:
the File id of this resource.

getFlags

public int getFlags()
Returns the flags of this resource ( not used yet; the Accessflags are served in getAccessFlags).

Returns:
the flags of this resource (this are not the AccessFlags!!).

getFlagString

public String getFlagString()
Creates a Unix-Style string of access rights from the access right flag of a CmsResource

Returns:
String of access rights

getGroupId

public int getGroupId()
Returns the groupid of this resource.

Returns:
the groupid of this resource.

getLauncherClassname

public String getLauncherClassname()
Gets the launcher classname for this resource.

Returns:
the launcher classname for this resource.

getLauncherType

public int getLauncherType()
Gets the launcher type id for this resource.

Returns:
the launcher type id of this resource.

getLength

public int getLength()
Gets the length of the content (filesize).

Returns:
the length of the content.

getName

public String getName()
Returns the name of this resource.
Example: retuns language.cms for the resource /system/def/language.cms

Returns:
the name of this resource.

getOwnerId

public int getOwnerId()
Returns the userid of the resource owner.

Returns:
the userid of the resource owner.

getParent

public String getParent()
Returns the absolute parent folder name of this resource.

The parent resource of a file is the folder of the file. The parent resource of a folder is the parent folder. The parent resource of the root folder is null.

Example: /system/workplace/ has the parent /system/.

Returns:
the calculated parent absolute folder path, or null for the root folder

getParent

public static String getParent(String resource)
Returns the absolute parent folder name of a resource.

The parent resource of a file is the folder of the file. The parent resource of a folder is the parent folder. The parent resource of the root folder is null.

Example: /system/workplace/ has the parent /system/.

Parameters:
resource - the resource to find the parent folder for
Returns:
the calculated parent absolute folder path, or null for the root folder

getPath

public String getPath()
Returns the folder path of this resource, if the resource is a folder, the complete path of the folder is returned (not the parent folder path).

Example: Returns /system/def/ for the resource /system/def/file.html and /system/def/ for the (folder) resource /system/def/. Does not append the repository information to the result, i.e. /system/def/ will be returned, not /default/vfs/system/def/.

Returns:
the folder of this resource

getPath

public static String getPath(String resource)
Returns the folder path of the resource with the given name, if the resource is a folder (i.e. ends with a "/"), the complete path of the folder is returned (not the parent folder path).

This is achived by just cutting of everthing behind the last occurence of a "/" character in the String, no check if performed if the resource exists or not in the VFS, only resources that end with a "/" are considered to be folders. Example: Returns /system/def/ for the resource /system/def/file.html and /system/def/ for the (folder) resource /system/def/..

Parameters:
resource - the name of a resource
Returns:
the folder of the given resource

getPathPart

public static String getPathPart(String resource,
                                 int level)
Returns the name of a parent folder of the given resource, that is either minus levels up from the current folder, or that is plus levels down from the root folder.

Parameters:
resource - the name of a resource
Returns:
the name of a parent folder of the given resource, that is either minus levels up from the current folder, or that is plus levels down from the root folder

getPathLevel

public static int getPathLevel(String resource)
Returns the directory level of a resource.

The root folder "/" has level 0, a folder "/foo/" would have level 1, a folfer "/foo/bar/" level 2 etc.

Returns:
the directory level of a resource

getParentId

public int getParentId()
Gets the Parent database id for this resource.

Returns:
the Parent database id of this resource.

getProjectId

public int getProjectId()
Returns the project id for this resource.

Returns:
the project id for this resource.

getResourceId

public int getResourceId()
Gets the database id for this resource.

Returns:
the database id of this resource.

getResourceLastModifiedBy

public int getResourceLastModifiedBy()
Gets the userId from the user who made the last change.

Returns:
the userId from the user who made the last change.

getState

public int getState()
Returns the state of this resource.
This may be C_STATE_UNCHANGED, C_STATE_CHANGED, C_STATE_NEW or C_STATE_DELETED.

Returns:
the state of this resource.

getType

public int getType()
Gets the type id for this resource.

Returns:
the type id of this resource.

getLockedInProject

public int getLockedInProject()
Gets the project id of the project that has locked this resource.

Returns:
the project id.

inProject

public boolean inProject(CmsProject project)
Checks if a resource belongs to a project.

Parameters:
project - The project which the resources is checked about.
Returns:
true if the resource is in the project, false otherwise.

isFile

public boolean isFile()
Determines, if this resource is a file.

Returns:
true, if this resource is a file, else it returns false.

isFolder

public boolean isFolder()
Determines, if this resource is a folder.

Returns:
true, if this resource is a folder, else it returns false.

isLocked

public boolean isLocked()
Determines, if this resource is locked by a user.

Returns:
true, if this resource is locked by a user, else it returns false.

isLockedBy

public int isLockedBy()
Returns the user idthat locked this resource.

Returns:
the user id that locked this resource. If this resource is free it returns the unknown user id.

setAccessFlags

public void setAccessFlags(int flags)
Sets the accessflags of this resource.


setFileId

public void setFileId(int fileId)
Sets the File id for this resource.


setGroupId

public void setGroupId(int group)
Sets the groupId of this resource.


setLauncherType

public void setLauncherType(int type)
Sets launcher the type id for this resource.


setLocked

public void setLocked(int id)
Sets the the user id that locked this resource.


setParentId

public void setParentId(int parentId)
Sets the parent database id for this resource.


setState

public void setState(int state)
Sets the state of this resource.


setType

public void setType(int type)
Sets the type id for this resource.


setUserId

public void setUserId(int user)
Sets the userId of this resource.


setProjectId

public void setProjectId(int project)
Sets the projectId of this resource.


setLockedInProject

public void setLockedInProject(int project)
Sets the projectId in which this resource is locked.


toString

public String toString()
Returns a string-representation for this object. This can be used for debugging.

Overrides:
toString in class Object
Returns:
string-representation for this object.

isTouched

public boolean isTouched()
Returns the isTouched.

Returns:
boolean