Package org.opencms.xml.containerpage
Class CmsLazyFolder
- java.lang.Object
-
- org.opencms.xml.containerpage.CmsLazyFolder
-
public class CmsLazyFolder extends java.lang.Object
Helper class for creating a folder if it doesn'T already exist.- Since:
- 8.0.0
-
-
Constructor Summary
Constructors Constructor Description CmsLazyFolder(java.lang.String path)
Initializes this object with a path at which the folder should be created.CmsLazyFolder(CmsResource folder)
Initializes this object with an existing folder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CmsResource
createFolder(CmsObject cms)
Creates the folder with the given name if it doesn't already exist, and returns it.CmsResource
getFolder(CmsObject cms)
Returns the folder if it already exists, or null if it doesn't.CmsResource
getOrCreateFolder(CmsObject cms)
Returns the folder if it already exists, or creates and returns it if it doesn't.CmsResource
getPermissionCheckFolder(CmsObject cms)
Returns the folder to check for permissions, which is either the folder itself if it already exists, or the parent folder if it doesn't.java.lang.String
getSitePath(CmsObject cms)
Computes the site path of the folder, which is either the original path constructor argument, or the site path of the original resource constructor argument.
-
-
-
Constructor Detail
-
CmsLazyFolder
public CmsLazyFolder(CmsResource folder)
Initializes this object with an existing folder.- Parameters:
folder
- the existing folder
-
CmsLazyFolder
public CmsLazyFolder(java.lang.String path)
Initializes this object with a path at which the folder should be created.- Parameters:
path
- the path at which the folder should be created
-
-
Method Detail
-
createFolder
public CmsResource createFolder(CmsObject cms) throws CmsException
Creates the folder with the given name if it doesn't already exist, and returns it.- Parameters:
cms
- the current CMS context- Returns:
- the created folder or the already existing folder
- Throws:
CmsException
- if something goes wrong
-
getFolder
public CmsResource getFolder(CmsObject cms) throws CmsException
Returns the folder if it already exists, or null if it doesn't.- Parameters:
cms
- the current CMS context- Returns:
- the folder if it exists, else null
- Throws:
CmsException
- if something goes wrong
-
getOrCreateFolder
public CmsResource getOrCreateFolder(CmsObject cms) throws CmsException
Returns the folder if it already exists, or creates and returns it if it doesn't.- Parameters:
cms
- the current CMS context- Returns:
- the folder
- Throws:
CmsException
- if something goes wrong
-
getPermissionCheckFolder
public CmsResource getPermissionCheckFolder(CmsObject cms) throws CmsException
Returns the folder to check for permissions, which is either the folder itself if it already exists, or the parent folder if it doesn't.- Parameters:
cms
- the current CMS context- Returns:
- the folder to check for permissions
- Throws:
CmsException
- if something goes wrong
-
getSitePath
public java.lang.String getSitePath(CmsObject cms)
Computes the site path of the folder, which is either the original path constructor argument, or the site path of the original resource constructor argument.- Parameters:
cms
- the current CMS context- Returns:
- the site path of the lazy folder
-
-