org.opencms.repository
Class CmsRepositorySession

java.lang.Object
  extended by org.opencms.repository.A_CmsRepositorySession
      extended by org.opencms.repository.CmsRepositorySession
All Implemented Interfaces:
I_CmsRepositorySession

public class CmsRepositorySession
extends A_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
Version:
$Revision: 1.12 $
Author:
Peter Bonrad
See Also:
A_CmsRepositorySession, I_CmsRepositorySession

Constructor Summary
CmsRepositorySession(CmsObjectWrapper cms, CmsRepositoryFilter filter)
          Constructor with an initialized CmsObjectWrapper and a CmsRepositoryFilter to use.
 
Method Summary
 void copy(java.lang.String src, java.lang.String dest, boolean overwrite)
          Copies the item found at the source path to the destination path.
 void create(java.lang.String path)
          Creates a new item at the given path.
 void delete(java.lang.String path)
          Deletes the item at the given path.
 boolean exists(java.lang.String path)
          Returns if an item exists at the given path.
 I_CmsRepositoryItem getItem(java.lang.String path)
          Returns the item found at the given path.
 CmsRepositoryLockInfo getLock(java.lang.String path)
          Returns the lock for the resource at the given path.
protected  boolean isFiltered(java.lang.String name)
          Adds the site root to the path name and checks then if the path is filtered.
 java.util.List list(java.lang.String path)
          Returns a list with all items found directly in the given path.
 boolean lock(java.lang.String path, CmsRepositoryLockInfo lock)
          Creates a new lock on the item at the path with the given information in the lock info.
 void move(java.lang.String src, java.lang.String dest, boolean overwrite)
          Moves an item from a source path to a destination path.
 void save(java.lang.String path, java.io.InputStream inputStream, boolean overwrite)
          Saves an item at the given path.
 void unlock(java.lang.String path)
          Unlocks the item found at the path.
 
Methods inherited from class org.opencms.repository.A_CmsRepositorySession
getFilter, setFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsRepositorySession

public CmsRepositorySession(CmsObjectWrapper cms,
                            CmsRepositoryFilter filter)
Constructor with an initialized CmsObjectWrapper and a CmsRepositoryFilter to use.

Parameters:
cms - the initialized CmsObject
filter - the repository filter to use
Method Detail

copy

public void copy(java.lang.String src,
                 java.lang.String dest,
                 boolean overwrite)
          throws CmsException
Description copied from interface: I_CmsRepositorySession
Copies the item found at the source path to the destination path.

Parameters:
src - the path of the item which should be copied
dest - the destination path where to copy to
overwrite - should any existing item be overwritten
Throws:
CmsException - if something goes wrong
See Also:
I_CmsRepositorySession.copy(java.lang.String, java.lang.String, boolean)

create

public void create(java.lang.String path)
            throws CmsException
Description copied from interface: I_CmsRepositorySession
Creates 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:
I_CmsRepositorySession.create(java.lang.String)

delete

public void delete(java.lang.String path)
            throws CmsException
Description copied from interface: I_CmsRepositorySession
Deletes the item at the given path.

Parameters:
path - the complete path of the item to delete
Throws:
CmsException - if something goes wrong
See Also:
I_CmsRepositorySession.delete(java.lang.String)

exists

public boolean exists(java.lang.String path)
Description copied from interface: I_CmsRepositorySession
Returns 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:
I_CmsRepositorySession.exists(java.lang.String)

getItem

public I_CmsRepositoryItem getItem(java.lang.String path)
                            throws CmsException
Description copied from interface: I_CmsRepositorySession
Returns 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:
I_CmsRepositorySession.getItem(java.lang.String)

getLock

public CmsRepositoryLockInfo getLock(java.lang.String path)
Description copied from interface: I_CmsRepositorySession
Returns 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:
I_CmsRepositorySession.getLock(java.lang.String)

list

public java.util.List list(java.lang.String path)
                    throws CmsException
Description copied from interface: I_CmsRepositorySession
Returns 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_CmsRepositoryItem found in the path
Throws:
CmsException - if something goes wrong
See Also:
I_CmsRepositorySession.list(java.lang.String)

lock

public boolean lock(java.lang.String path,
                    CmsRepositoryLockInfo lock)
             throws CmsException
Description copied from interface: I_CmsRepositorySession
Creates a new lock on the item at the path with the given information in the lock info.

Parameters:
path - the complete path of the item
lock - the information about the lock to create
Returns:
if the lock was successfully
Throws:
CmsException - if something goes wrong
See Also:
I_CmsRepositorySession.lock(java.lang.String, org.opencms.repository.CmsRepositoryLockInfo)

move

public void move(java.lang.String src,
                 java.lang.String dest,
                 boolean overwrite)
          throws CmsException
Description copied from interface: I_CmsRepositorySession
Moves an item from a source path to a destination path.

Parameters:
src - the complete path to the item which should be copied
dest - the complete destination path where to copy to
overwrite - should any existing item should be overwritten
Throws:
CmsException - if something goes wrong
See Also:
I_CmsRepositorySession.move(java.lang.String, java.lang.String, boolean)

save

public void save(java.lang.String path,
                 java.io.InputStream inputStream,
                 boolean overwrite)
          throws CmsException,
                 java.io.IOException
Description copied from interface: I_CmsRepositorySession
Saves 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 item
inputStream - the content of the item
overwrite - should an existing item at the path be overwritten
Throws:
CmsException - if something goes wrong
java.io.IOException - if a write error occurs
See Also:
I_CmsRepositorySession.save(java.lang.String, java.io.InputStream, boolean)

unlock

public void unlock(java.lang.String path)
Description copied from interface: I_CmsRepositorySession
Unlocks the item found at the path.

Parameters:
path - The complete path of the item to unlock
See Also:
I_CmsRepositorySession.unlock(java.lang.String)

isFiltered

protected boolean isFiltered(java.lang.String name)
Adds the site root to the path name and checks then if the path is filtered.

Overrides:
isFiltered in class A_CmsRepositorySession
Parameters:
name - the path of a resource to check
Returns:
true if the name matches one of the given filter patterns
See Also:
A_CmsRepositorySession.isFiltered(java.lang.String)