Package org.opencms.repository
Class CmsRepositorySession
java.lang.Object
org.opencms.repository.A_CmsRepositorySession
org.opencms.repository.CmsRepositorySession
- All Implemented Interfaces:
I_CmsRepositorySession
This is the session class to work with the
CmsRepository.
You can get an instance of this class by calling
CmsRepository.login(String, String).
This class provides basic file and folder operations on the resources in the VFS of OpenCms.
- Since:
- 6.5.6
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCmsRepositorySession(CmsObjectWrapper cms, CmsRepositoryFilter filter, CmsResourceTranslator translation) Constructor with an initializedCmsObjectWrapperand aCmsRepositoryFilterto use. -
Method Summary
Modifier and TypeMethodDescriptionvoidCopies the item found at the source path to the destination path.voidCreates a new item at the given path.static StringdecodeNamespace(String code) Decodes the namespace URI.voidDeletes the item at the given path.static StringencodeNamespace(String data) Encodes the namespace URI.booleanReturns if an item exists at the given path.Returns the item found at the given path.Returns the lock for the resource at the given path.getProperties(String path) Gets the properties for the given path.protected booleanisFiltered(String name) Adds the site root to the path name and checks then if the path is filtered.Returns a list with all items found directly in the given path.booleanlock(String path, CmsRepositoryLockInfo lock) Creates a new lock on the item at the path with the given information in the lock info.voidMoves an item from a source path to a destination path.voidsave(String path, InputStream inputStream, boolean overwrite) Saves an item at the given path.voidUnlocks the item found at the path.voidupdateProperties(String path, Map<CmsPropertyName, String> properties) Updates the properties for the given path.Methods inherited from class org.opencms.repository.A_CmsRepositorySession
getFilter, setFilter
-
Field Details
-
PROPERTY_NAMESPACE
Default namespace for OpenCms properties.- See Also:
-
EXTERNAL_PREFIX
Prefix used for encoded property names outside the default property namespace.- See Also:
-
-
Constructor Details
-
CmsRepositorySession
public CmsRepositorySession(CmsObjectWrapper cms, CmsRepositoryFilter filter, CmsResourceTranslator translation) Constructor with an initializedCmsObjectWrapperand aCmsRepositoryFilterto use.- Parameters:
cms- the initialized CmsObjectfilter- the repository filter to usetranslation- the repository specific file translations (may be null)
-
-
Method Details
-
decodeNamespace
Decodes the namespace URI.- Parameters:
code- the encoded namespace URI- Returns:
- the decoded namespace URI
- Throws:
Exception- if something goes wrong
-
encodeNamespace
Encodes the namespace URI.- Parameters:
data- a namesapce URI- Returns:
- the encoded namespace URI
- Throws:
Exception- if something goes wrong
-
copy
Description copied from interface:I_CmsRepositorySessionCopies the item found at the source path to the destination path.- Parameters:
src- the path of the item which should be copieddest- the destination path where to copy tooverwrite- should any existing item be overwrittenshallow- if true, when copying a folder, only the folder will be copied and not its contents- Throws:
CmsException- if something goes wrong- See Also:
-
create
Description copied from interface:I_CmsRepositorySessionCreates a new item at the given path.In this case this should be a collection (directory).
- Parameters:
path- the complete path of the new collection- Throws:
CmsException- if something goes wrong- See Also:
-
delete
Description copied from interface:I_CmsRepositorySessionDeletes the item at the given path.- Parameters:
path- the complete path of the item to delete- Throws:
CmsException- if something goes wrong- See Also:
-
exists
Description copied from interface:I_CmsRepositorySessionReturns if an item exists at the given path.- Parameters:
path- the complete path of the item to check existance- Returns:
- true if the item exists otherwise false
- See Also:
-
getItem
Description copied from interface:I_CmsRepositorySessionReturns the item found at the given path.- Parameters:
path- the complete path of the item to return- Returns:
- the item found at the path
- Throws:
CmsException- if something goes wrong- See Also:
-
getLock
Description copied from interface:I_CmsRepositorySessionReturns the lock for the resource at the given path.- Parameters:
path- the complete path where to return the lock for- Returns:
- the found lock as CmsWebdavLockInfo or null if not found
- See Also:
-
getProperties
Description copied from interface:I_CmsRepositorySessionGets the properties for the given path.- Parameters:
path- the path- Returns:
- the properties for the path
- Throws:
CmsException- if something goes wrong- See Also:
-
list
Description copied from interface:I_CmsRepositorySessionReturns a list with all items found directly in the given path.- Parameters:
path- the complete path from which to return the items- Returns:
- a list with
I_CmsRepositoryItemfound in the path - Throws:
CmsException- if something goes wrong- See Also:
-
lock
Description copied from interface:I_CmsRepositorySessionCreates a new lock on the item at the path with the given information in the lock info.- Parameters:
path- the complete path of the itemlock- the information about the lock to create- Returns:
- if the lock was successfully
- Throws:
CmsException- if something goes wrong- See Also:
-
move
Description copied from interface:I_CmsRepositorySessionMoves an item from a source path to a destination path.- Parameters:
src- the complete path to the item which should be copieddest- the complete destination path where to copy tooverwrite- should any existing item should be overwritten- Throws:
CmsException- if something goes wrong- See Also:
-
save
public void save(String path, InputStream inputStream, boolean overwrite) throws CmsException, IOException Description copied from interface:I_CmsRepositorySessionSaves an item at the given path.This creates a new single item (file) if it does not exist.
- Parameters:
path- the complete path of the new iteminputStream- the content of the itemoverwrite- should an existing item at the path be overwritten- Throws:
CmsException- if something goes wrongIOException- if a write error occurs- See Also:
-
unlock
Description copied from interface:I_CmsRepositorySessionUnlocks the item found at the path.- Parameters:
path- The complete path of the item to unlock- See Also:
-
updateProperties
public void updateProperties(String path, Map<CmsPropertyName, String> properties) throws CmsExceptionDescription copied from interface:I_CmsRepositorySessionUpdates the properties for the given path.- Parameters:
path- the pathproperties- the properties- Throws:
CmsException- if something goes wrong- See Also:
-
isFiltered
Adds the site root to the path name and checks then if the path is filtered.- Overrides:
isFilteredin classA_CmsRepositorySession- Parameters:
name- the path of a resource to check- Returns:
- true if the name matches one of the given filter patterns
- See Also:
-