org.opencms.util
Class CmsResourceUtil

java.lang.Object
  extended byorg.opencms.util.CmsResourceUtil

public final class CmsResourceUtil
extends java.lang.Object

Provides CmsResource utility functions.

This class provides in java all resource information used by the explorer view, mostly generated in javascript (see explorer.js)

Since:
6.0.0
Version:
$Revision$
Author:
Michael Moossen

Constructor Summary
CmsResourceUtil(CmsObject cms)
          Creates a new CmsRequestUtil object.
CmsResourceUtil(CmsObject cms, CmsResource resource)
          Creates a new CmsRequestUtil object.
CmsResourceUtil(CmsResource resource)
          Creates a new CmsRequestUtil object.
 
Method Summary
 CmsObject getCms()
          Returns the cms context.
 java.lang.String getIconPathExplorer()
          Returns the resource icon path displayed in the explorer view for the given resource.
 java.lang.String getIconPathLock()
          Returns the lock icon path for the given resource.
 java.lang.String getIconPathProjectState()
          Returns the project state icon path for the given resource.
 java.lang.String getIconPathResourceType()
          Returns the resource type icon path for the given resource.
 CmsLock getLock()
          Returns the the lock for the given resource.
 java.lang.String getLockedByName()
          Returns the user name who owns the lock for the given resource.
 int getLockedInProjectId()
          Returns the id of the project in which the given resource is locked.
 java.lang.String getLockedInProjectName()
          Returns the project name that locked the current resource's.
 java.lang.String getPermissions()
          Returns the permissions string for the given resource.
 int getProjectId()
          Returns the id of the project which the resource belongs to.
 java.lang.Boolean getProjectState()
          Returns the project state of the given resource.
 CmsProject getReferenceProject()
          Returns the project to use to check project state.
 CmsResource getResource()
          Returns the resource.
 I_CmsResourceType getResourceType()
          Returns the resource type for the given resource.
 int getResourceTypeId()
          Returns the resource type id for the given resource.
 java.lang.String getResourceTypeName()
          Returns the resource type name for the given resource.
 java.lang.String getSizeString()
          Returns the size of the given resource as a String.
 char getStateAbbreviation()
          Returns resource state abbreviation.
static char getStateAbbreviation(int state)
          Returns resource state abbreviation.
 java.lang.String getStateName()
          Returns the state name for a resource.
 java.lang.String getStyleClassName()
          Returns the style class to use for the given resource.
 java.lang.String getStyleRange()
          Returns additional style sheets depending on publication constraints.
 java.lang.String getStyleSiblings()
          Returns additional style sheets for the resource type icon depending on siblings.
 java.lang.String getTitle()
          Returns the title of a resource.
 java.lang.String getUserCreated()
          Returns the name of the user who created the given resource.
 java.lang.String getUserLastModified()
          Returns the name of the user who last modified the given resource.
 boolean isEditable()
          Returns true if the given resource is editable by the current user.
 boolean isExpired()
          Returns true if the given resource has expired.
 boolean isInRange()
          Returns true if the given resource has been released and has not expired.
 boolean isInsideProject()
          Returns true if the given resource is in the reference project.
 boolean isReleased()
          Returns true if the given resource has been released.
 void setCms(CmsObject cms)
          Sets the cms context.
 void setReferenceProject(CmsProject project)
          Sets the project to use to check project state.
 void setResource(CmsResource resource)
          Sets the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsResourceUtil

public CmsResourceUtil(CmsObject cms)
Creates a new CmsRequestUtil object.

Parameters:
cms - the cms context

CmsResourceUtil

public CmsResourceUtil(CmsObject cms,
                       CmsResource resource)
Creates a new CmsRequestUtil object.

Parameters:
cms - the cms context
resource - the resource

CmsResourceUtil

public CmsResourceUtil(CmsResource resource)
Creates a new CmsRequestUtil object.

Parameters:
resource - the resource
Method Detail

getStateAbbreviation

public static char getStateAbbreviation(int state)
Returns resource state abbreviation.

Parameters:
state - the resource state
Returns:
resource state abbreviation

getCms

public CmsObject getCms()
Returns the cms context.

Returns:
the cms context

getIconPathExplorer

public java.lang.String getIconPathExplorer()
Returns the resource icon path displayed in the explorer view for the given resource.

Relative to /system/workplace/resources/.

If the resource has no sibling it is the same as getIconPathResourceType().

Returns:
the resource icon path displayed in the explorer view for the given resource
See Also:
getStyleSiblings()

getIconPathLock

public java.lang.String getIconPathLock()
Returns the lock icon path for the given resource.

Relative to /system/workplace/resources/.

Returns explorer/project_none.gif if request context is null.

Returns:
the lock icon path for the given resource

getIconPathProjectState

public java.lang.String getIconPathProjectState()
Returns the project state icon path for the given resource.

Relative to /system/workplace/resources/.

Returns:
the project state icon path for the given resource

getIconPathResourceType

public java.lang.String getIconPathResourceType()
Returns the resource type icon path for the given resource.

Relative to /system/workplace/resources/.

Returns:
the resource type icon path for the given resource

getLock

public CmsLock getLock()
Returns the the lock for the given resource.

Returns:
the lock the given resource

getLockedByName

public java.lang.String getLockedByName()
Returns the user name who owns the lock for the given resource.

Returns:
the user name who owns the lock for the given resource

getLockedInProjectId

public int getLockedInProjectId()
Returns the id of the project in which the given resource is locked.

Returns:
the id of the project in which the given resource is locked

getLockedInProjectName

public java.lang.String getLockedInProjectName()
Returns the project name that locked the current resource's.

Returns:
the the project name that locked the current resource's

getPermissions

public java.lang.String getPermissions()
Returns the permissions string for the given resource.

Returns:
the permissions string for the given resource

getProjectId

public int getProjectId()
Returns the id of the project which the resource belongs to.

Returns:
the id of the project which the resource belongs to

getProjectState

public java.lang.Boolean getProjectState()
Returns the project state of the given resource.

Returns:
the project state of the given resource

getReferenceProject

public CmsProject getReferenceProject()
Returns the project to use to check project state.

Returns:
the project to use to check project state

getResource

public CmsResource getResource()
Returns the resource.

Returns:
the resource

getResourceType

public I_CmsResourceType getResourceType()
Returns the resource type for the given resource.

Returns:
the resource type for the given resource

getResourceTypeId

public int getResourceTypeId()
Returns the resource type id for the given resource.

Returns:
the resource type id for the given resource

getResourceTypeName

public java.lang.String getResourceTypeName()
Returns the resource type name for the given resource.

Returns:
the resource type name for the given resource

getSizeString

public java.lang.String getSizeString()
Returns the size of the given resource as a String.

For directories it returns #SIZE_DIR.

Returns:
the size of the given resource as a String

getStateAbbreviation

public char getStateAbbreviation()
Returns resource state abbreviation.

Returns:
resource state abbreviation

getStateName

public java.lang.String getStateName()
Returns the state name for a resource.

Uses default locale if request context is null.

Returns:
the state name for that resource

getStyleClassName

public java.lang.String getStyleClassName()
Returns the style class to use for the given resource.

Returns:
style class name
See Also:
CmsListExplorerColumn.getExplorerStyleDef()

getStyleRange

public java.lang.String getStyleRange()
Returns additional style sheets depending on publication constraints.

That is, depending on CmsResource.getDateReleased() and CmsResource.getDateExpired().

Returns:
additional style sheets depending on publication constraints

getStyleSiblings

public java.lang.String getStyleSiblings()
Returns additional style sheets for the resource type icon depending on siblings.

That is, depending on CmsResource.getSiblingCount() Use it with the getIconPathExplorer() method.

Returns:
additional style sheets depending on siblings

getTitle

public java.lang.String getTitle()
Returns the title of a resource.

Returns:
the title for that resource

getUserCreated

public java.lang.String getUserCreated()
Returns the name of the user who created the given resource.

Returns:
the name of the user who created the given resource

getUserLastModified

public java.lang.String getUserLastModified()
Returns the name of the user who last modified the given resource.

Returns:
the name of the user who last modified the given resource

isEditable

public boolean isEditable()
Returns true if the given resource is editable by the current user.

Retuns false if no request context is set.

Returns:
true if the given resource is editable by the current user

isExpired

public boolean isExpired()
Returns true if the given resource has expired.

Retuns true if no request context is set.

Returns:
true if the given resource has expired

isInRange

public boolean isInRange()
Returns true if the given resource has been released and has not expired.

Retuns false if no request context is set.

Returns:
true if the given resource has been released and has not expired

isInsideProject

public boolean isInsideProject()
Returns true if the given resource is in the reference project.

Returns false if the request context is null.

Returns:
true if the given resource is in the reference project
See Also:
getReferenceProject()

isReleased

public boolean isReleased()
Returns true if the given resource has been released.

Returns:
true if the given resource has been released

setCms

public void setCms(CmsObject cms)
Sets the cms context.

Parameters:
cms - the cms context to set

setReferenceProject

public void setReferenceProject(CmsProject project)
Sets the project to use to check project state.

Parameters:
project - the project to set

setResource

public void setResource(CmsResource resource)
Sets the resource.

Parameters:
resource - the resource to set