org.olat.core.util.vfs
Class NamedContainerImpl

java.lang.Object
  extended by org.olat.core.util.vfs.AbstractVirtualContainer
      extended by org.olat.core.util.vfs.NamedContainerImpl
All Implemented Interfaces:
VFSContainer, VFSItem
Direct Known Subclasses:
OlatNamedContainerImpl

public class NamedContainerImpl
extends AbstractVirtualContainer

Description:
TODO: Felix Jost Class Description for VirtualContainerImpl

Initial Date: 23.06.2005

Author:
Felix Jost

Constructor Summary
NamedContainerImpl(java.lang.String name, VFSContainer delegate)
           
 
Method Summary
 VFSStatus canCopy()
           
 VFSStatus canWrite()
           
 VFSStatus copyFrom(VFSItem source)
          copy either a file or a folder to this folder.
 VFSContainer createChildContainer(java.lang.String name)
          Create a new child container (of same type) if possible.
 VFSLeaf createChildLeaf(java.lang.String name)
          Create a new leaf (of same type) if possible,
 VFSStatus delete()
          deltes the item.
 VFSItemFilter getDefaultItemFilter()
           
 VFSContainer getDelegate()
           
 java.util.List getItems()
           
 java.util.List getItems(VFSItemFilter filter)
           
 long getLastModified()
          Return the last modified date of this item or -1 if not available.
 VFSSecurityCallback getLocalSecurityCallback()
          Get the local security callback for this item.
 VFSContainer getParentContainer()
          Get the parent of this vfsItem.
 boolean isSame(VFSItem vfsItem)
          Test if this is the same item as ourselves.
 VFSStatus rename(java.lang.String newname)
           
 VFSItem resolve(java.lang.String path)
          a relative path.
 void setDefaultItemFilter(VFSItemFilter defaultFilter)
          Set a default filter that will be applied to this container getItems method
 void setLocalSecurityCallback(VFSSecurityCallback secCallback)
          Set a custom security callback for this item.
 void setParentContainer(VFSContainer parentContainer)
          Sets the parent container.
 java.lang.String toString()
           
 
Methods inherited from class org.olat.core.util.vfs.AbstractVirtualContainer
canDelete, canRename, getName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NamedContainerImpl

public NamedContainerImpl(java.lang.String name,
                          VFSContainer delegate)
Parameters:
name -
delegate -
Method Detail

getDelegate

public VFSContainer getDelegate()

getParentContainer

public VFSContainer getParentContainer()
Description copied from interface: VFSItem
Get the parent of this vfsItem.

Returns:
See Also:
org.olat.core.util.vfs.VFSItem#getParent()

setParentContainer

public void setParentContainer(VFSContainer parentContainer)
Description copied from interface: VFSItem
Sets the parent container. -> DO NOT CALL THIS METHOD... USED ONLY INTERNALLY!

See Also:
VFSItem.setParentContainer(org.olat.core.util.vfs.VFSContainer)

getItems

public java.util.List getItems()
Returns:
a list of VFSItem containing
See Also:
VFSContainer.getItems()

getItems

public java.util.List getItems(VFSItemFilter filter)
Returns:
a list of VFSItem which are accepted by the given filter. If a default filter is set, the default filter will be applied in addition to the given filter in this method
See Also:
VFSContainer.getItems(org.olat.core.util.vfs.filters.VFSItemFilter)

copyFrom

public VFSStatus copyFrom(VFSItem source)
Description copied from interface: VFSContainer
copy either a file or a folder to this folder. e.g. this folder is based at /bla/blu, copying source bli (from /whatever/bli) will add a child bli, so it looks like /bla/blu/bli later. the operation fails when the source or target do not support canCopyFrom and canCopyTo, resp., or there is already a child with the same name, or the quota would be exceeded.

Specified by:
copyFrom in interface VFSContainer
Overrides:
copyFrom in class AbstractVirtualContainer
Parameters:
source - the source (must exist)
Returns:
the status
See Also:
VFSContainer.copyFrom(org.olat.core.util.vfs.VFSItem)

canWrite

public VFSStatus canWrite()
Returns:
true if a child can be added at all(only files and folder cab be copied to). the operation may still fail because e.g. of quota limitation.
See Also:
VFSItem.canWrite()

canCopy

public VFSStatus canCopy()
Specified by:
canCopy in interface VFSItem
Overrides:
canCopy in class AbstractVirtualContainer
Returns:
true if this container (and all its children recursively) can be copied to some other place. this is normally true for containers with a physical implementation, but not for virtual/named containers
See Also:
VFSItem.canCopy()

rename

public VFSStatus rename(java.lang.String newname)
Specified by:
rename in interface VFSItem
Overrides:
rename in class AbstractVirtualContainer
Parameters:
newname - e.g test.txt or myfolder (no path prepended)
Returns:
status
See Also:
VFSItem.rename(java.lang.String)

delete

public VFSStatus delete()
Description copied from interface: VFSItem
deltes the item. if the item is a container, all children will be deleted recursively

Specified by:
delete in interface VFSItem
Overrides:
delete in class AbstractVirtualContainer
Returns:
status
See Also:
VFSItem.delete()

getLastModified

public long getLastModified()
Description copied from interface: VFSItem
Return the last modified date of this item or -1 if not available.

Specified by:
getLastModified in interface VFSItem
Overrides:
getLastModified in class AbstractVirtualContainer
Returns:
See Also:
VFSItem.getLastModified()

resolve

public VFSItem resolve(java.lang.String path)
Description copied from interface: VFSItem
a relative path. the implementation will search all its children. e.g. bla/blu/bli.txt this vfsitem's name must thus be 'bla'

Returns:
See Also:

Be aware that this method can return tricky values:
  • If the path is '/', the named container itself is returned
  • for child elements, the item of the delegate object is returned
In the second case, the returned item does not know anymore that it was embedded in a named container. Thus, the isSame() method on the root element of the resolved item is not the same as this object.

createChildContainer

public VFSContainer createChildContainer(java.lang.String name)
Description copied from interface: VFSContainer
Create a new child container (of same type) if possible.

Specified by:
createChildContainer in interface VFSContainer
Overrides:
createChildContainer in class AbstractVirtualContainer
Returns:
VFSItem if successfull, null otherwise.
See Also:
VFSContainer.createChildContainer(java.lang.String)

createChildLeaf

public VFSLeaf createChildLeaf(java.lang.String name)
Description copied from interface: VFSContainer
Create a new leaf (of same type) if possible,

Specified by:
createChildLeaf in interface VFSContainer
Overrides:
createChildLeaf in class AbstractVirtualContainer
Returns:
VFSItem if successfull, null otherwise.
See Also:
VFSContainer.createChildLeaf(java.lang.String)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getLocalSecurityCallback

public VFSSecurityCallback getLocalSecurityCallback()
Description copied from interface: VFSItem
Get the local security callback for this item. NOTE: Usually you would not need to access local security callbacks directly. You'd rather want to get the inherited security callback of this item via getInheritedSecurityCallback. This will get you the local security callback if set aswell but also any inherited security callbacks from parent containers.

Returns:
SecurityCallback if any, or null if not set.
See Also:
VFSItem.getLocalSecurityCallback()

setLocalSecurityCallback

public void setLocalSecurityCallback(VFSSecurityCallback secCallback)
Description copied from interface: VFSItem
Set a custom security callback for this item.

See Also:
VFSItem.setLocalSecurityCallback(org.olat.core.util.vfs.callbacks.VFSSecurityCallback)

isSame

public boolean isSame(VFSItem vfsItem)
Description copied from interface: VFSItem
Test if this is the same item as ourselves.

Returns:
See Also:
VFSItem.isSame(org.olat.core.util.vfs.VFSItem)

setDefaultItemFilter

public void setDefaultItemFilter(VFSItemFilter defaultFilter)
Description copied from interface: VFSContainer
Set a default filter that will be applied to this container getItems method

Specified by:
setDefaultItemFilter in interface VFSContainer
Overrides:
setDefaultItemFilter in class AbstractVirtualContainer
See Also:
VFSContainer.setDefaultItemFilter(org.olat.core.util.vfs.filters.VFSItemFilter)

getDefaultItemFilter

public VFSItemFilter getDefaultItemFilter()
Specified by:
getDefaultItemFilter in interface VFSContainer
Overrides:
getDefaultItemFilter in class AbstractVirtualContainer
Returns:
The default filter for this container or NULL if no filter is set
See Also:
VFSContainer.getDefaultItemFilter()