nl.uva.vlet.vfs
Class VDir

java.lang.Object
  extended by nl.uva.vlet.vrs.VNode
      extended by nl.uva.vlet.vfs.VFSNode
          extended by nl.uva.vlet.vfs.VDir
All Implemented Interfaces:
VACL, VComposite, VEditable, VRenamable

public abstract class VDir
extends VFSNode
implements VComposite, VRenamable

Super class of the VFS Directory implementation. Represents an abstract interface to a Directory implementation.

See Also:
VFile, VFSNode

Field Summary
 
Fields inherited from class nl.uva.vlet.vfs.VFSNode
ATTR_ACCESS_TIME, ATTR_CREATION_TIME, ATTR_DATA_TYPE, ATTR_DIRNAME, ATTR_EXISTS, ATTR_GID, ATTR_GROUP, ATTR_ISDIR, ATTR_ISFILE, ATTR_ISHIDDEN, ATTR_ISREADABLE, ATTR_ISSOFTLINK, ATTR_ISWRITABLE, ATTR_LENGTH, ATTR_LINKTARGET, ATTR_MODIFICATION_TIME, ATTR_NRACLENTRIES, ATTR_NRCHILDS, ATTR_OWNER, ATTR_PARENT_DIRNAME, ATTR_PERMISSIONS_STRING, ATTR_RESOURCE, ATTR_UID, ATTR_UNIQUE, attributeNames, defaultStreamBufferSize
 
Fields inherited from class nl.uva.vlet.vrs.VNode
ATTR_CHARSET, ATTR_HOSTNAME, ATTR_ICON, ATTR_ISVLINK, ATTR_LOCATION, ATTR_MIMETYPE, ATTR_NAME, ATTR_PATH, ATTR_PORT, ATTR_SCHEME, ATTR_TYPE, location, vrsContext
 
Fields inherited from interface nl.uva.vlet.vfs.VACL
GROUP_ENTITY, PERM_ACCESSABLE, PERM_EXECUTABLE, PERM_READABLE, PERM_WRITABLE, USER_ENTITY, WORLD_ENTITY
 
Constructor Summary
VDir(VRSContext context, VRL vrl)
           
 
Method Summary
 VFSNode addNode(VFSNode node, java.lang.String optNewName, boolean isMove)
           
 VFSNode addNode(VNode node, boolean isMove)
          Add (VFS)Node to this directory location.
 VFSNode addNode(VNode node, java.lang.String optNewName, boolean isMove)
          Add a node to the underlaying Resource with a optional new name.
 VFSNode[] addNodes(VFSNode[] nodes, boolean isMove)
           
 VNode[] addNodes(VNode[] nodes, boolean isMove)
          Add mutiple (VFS)Nodes to this directory location.
 VFSTransfer asyncDownload(VNode source, java.lang.String optNewName, boolean isMove)
          Asynchronous transfer method to download an Resource Returns VFSTransfer info object so the transfer can be monitored.
 VDir copyTo(VDir dest)
          Copy/Move to specified location is called by VFSClient.copyDir() ...
 VDir copyTo(VDir dest, java.lang.String newName)
          Copy/Move to specified location is called by VFSClient.copyDir() ...
 VFSNode createChild(java.lang.String type, java.lang.String name, boolean force)
          VDir implements createChild by calling createFile and createDir, depending on the type.
 VDir createDir(java.lang.String subdirName)
          Create subdirectory.
abstract  VDir createDir(java.lang.String name, boolean ignoreExisting)
          Creates subdirectory in this directory.
 VFile createFile(java.lang.String name)
          Create file in this Virtual Directory.
abstract  VFile createFile(java.lang.String name, boolean force)
          Create file in this Virtual Directory.
protected static VDir defaultCopyMove(VFSTransfer transfer, VDir source, VDir dest, java.lang.String optNewName, boolean isMove)
          Default Copy/Move: performs recursive copy of a directory.
lists children and performs cmoveTo on childs.
protected: may only be used by subclasses if they do not have an optimized CopyMoveTo themselfs.
protected static boolean defaultRecursiveDeleteChildren(VDir dir)
          Default Recursive delete: lists children and perform delete() on child list.
 boolean delete()
          Non-recursive Delete.
Calles recursive delete from VComposite with resurse=false.
 boolean delNode(VNode childNode)
          Delete node.
 boolean delNodes(VNode[] childNodes)
          Delete nodes.
protected  VDir doCopyMoveTo(VFSTransfer transfer, VDir dest, java.lang.String optNewName, boolean isMove)
          Default implementation to do actual copy/move.
 VFile downloadNode(VNode node, java.lang.String optNewName, boolean isMove)
          Create new VFile and copies contents from (VStreamreadable) vnode.
protected  VDir downloadTo(VFSTransfer transfer, VDir localDir, java.lang.String optNewName, boolean isMove)
          Default implementation to download this directory.
abstract  boolean existsDir(java.lang.String fileName)
          returns true whether child exists and is a VDir
abstract  boolean existsFile(java.lang.String fileName)
          returns true whether child exists and is a VFile
 VFSNode getChild(java.lang.String name)
          Get VFSNode
 VAttribute[][] getChildAttributes(java.lang.String[] names)
          Returns attributes for all childs
 VAttribute[][] getChildAttributes(java.lang.String[] childNames, java.lang.String[] names)
          Return attribute matrix for given nodes.
 VFSNode[] getChilds()
          default implementation calls the VDir method list()
 VDir getDir(java.lang.String dirname)
          Get subdirectory
 VFile getFile(java.lang.String name)
          Get file in this directory
 VRL getHelp()
          Returns simple text file or complete HTML page.
 java.lang.String[] getResourceTypes()
          Returns allowed child types for VDir.

The default types for VDir are 'File' and 'Dir' type
 java.lang.String getType()
          Returns resource type, if it has one
 boolean hasChild(java.lang.String name)
          Checks whether this node has a child with the specified name
 boolean isAccessable()
          Override this method if your directory can be accessable but not be 'readable'.
 boolean isDir()
          return true if the VFSNode is a (V)Directory
 boolean isFile()
          return true if the VFSNode is a (V)File
abstract  VFSNode[] list()
          This method is Similar to getChilds, but returns an array of VFSNodes.
The method getChilds returns an array of type VNode.
 VFSNode[] listSorted(boolean typeFirst, boolean ignoreCase)
          List the chidren and sorts them.
 VDir moveTo(VDir dest)
          Move to specified VDir location.
 VDir moveTo(VDir dest, java.lang.String newName)
          Move to specified VDir location.
 VDir putDir(VDir dir)
          Put Directory (copy) Directory to this Directory is called by VFSClient.copyDir() ...
 VDir putDir(VDir dir, java.lang.String optNewName)
          Put Directory (copy) Directory to this Directory is called by VFSClient.copyDir() ...
 VFile putFile(VFile file)
          Put File (copy) to this directory is called by VFSClient.copyDir() ...
 VFile putFile(VFile file, java.lang.String optNewName)
          Put File (copy) to this directory is called by VFSClient.copyDir() ...
protected  VDir uploadLocalDir(VFSTransfer transfer, VDir localDir, java.lang.String optNewName, boolean isMove)
          Default implementation to upload a directory.
protected  VFile uploadLocalFile(VFSTransfer transfer, VFile localFile, java.lang.String optNewName, boolean isMove)
          Default implementation to upload a local file to this directory.
 
Methods inherited from class nl.uva.vlet.vfs.VFSNode
asyncCopyMoveTo, create, createACLRecord, createTransfer, createTransferTo, deleteACLEntity, exists, getACL, getACLEntities, getAttribute, getAttributeNames, getLinkTarget, getLinkTargetVRL, getModificationTime, getParent, getParents, getPath, getPermissionsString, getRoot, getTranferInfo, isDeletable, isEditable, isHidden, isLink, isLocal, isRandomAccessable, isReadable, isRenamable, isWritable, returnAsArray, setACL, setAttribute, setAttributes, startCopyMoveTo, startCopyMoveTo
 
Methods inherited from class nl.uva.vlet.vrs.VNode
compareTo, getAttributes, getAttributes, getAttributeSet, getBasename, getCharSet, getHostname, getIconURL, getID, getLocation, getMimeType, getName, getPath, getPort, getScheme, getServerAttributes, getURI, getVRL, getVRSContext, isComposite, isVirtual, isVLink, mergedGetAttributes, setLocation, setVRL, toLinkNode, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface nl.uva.vlet.vrs.VComposite
delete, getNrOfChilds, isDeletable
 
Methods inherited from interface nl.uva.vlet.vrs.VRenamable
isRenamable, renameTo
 

Constructor Detail

VDir

public VDir(VRSContext context,
            VRL vrl)
Method Detail

getHelp

public VRL getHelp()
Description copied from class: VNode
Returns simple text file or complete HTML page. Method should point to installed documentation. Default is to return help about this type.

Overrides:
getHelp in class VNode

getType

public java.lang.String getType()
Description copied from class: VNode
Returns resource type, if it has one

Specified by:
getType in class VNode

getResourceTypes

public java.lang.String[] getResourceTypes()
Returns allowed child types for VDir.

The default types for VDir are 'File' and 'Dir' type

Specified by:
getResourceTypes in interface VComposite

addNode

public VFSNode addNode(VNode node,
                       boolean isMove)
                throws VlException
Add (VFS)Node to this directory location. Node must be of type VFSNode since this method calls addNode(VFSNode...)

Specified by:
addNode in interface VComposite
Returns:
new created VNode
Throws:
VlException

addNode

public VFSNode addNode(VNode node,
                       java.lang.String optNewName,
                       boolean isMove)
                throws VlException
Description copied from interface: VComposite
Add a node to the underlaying Resource with a optional new name.

For optimization the isMove determines if it is a move, so the implementation can optimize local movements for example on the same filesystems or on the same SRB Server.

Specified by:
addNode in interface VComposite
Returns:
new created VNode
Throws:
VlException

downloadNode

public VFile downloadNode(VNode node,
                          java.lang.String optNewName,
                          boolean isMove)
                   throws VlException
Create new VFile and copies contents from (VStreamreadable) vnode.

Throws:
VlException

asyncDownload

public VFSTransfer asyncDownload(VNode source,
                                 java.lang.String optNewName,
                                 boolean isMove)
                          throws VlException
Asynchronous transfer method to download an Resource Returns VFSTransfer info object so the transfer can be monitored.

Throws:
VlException

addNode

public VFSNode addNode(VFSNode node,
                       java.lang.String optNewName,
                       boolean isMove)
                throws VlException
Throws:
VlException

addNodes

public VNode[] addNodes(VNode[] nodes,
                        boolean isMove)
                 throws VlException
Add mutiple (VFS)Nodes to this directory location. Nodes must be of type VFSNode since this method calls addNodes(VFSNode[]...)

Specified by:
addNodes in interface VComposite
Throws:
VlException

addNodes

public VFSNode[] addNodes(VFSNode[] nodes,
                          boolean isMove)
                   throws VlException
Throws:
VlException

delNode

public boolean delNode(VNode childNode)
                throws VlException
Delete node. Node must be of type VFSNode

Specified by:
delNode in interface VComposite
Throws:
VlException

delNodes

public boolean delNodes(VNode[] childNodes)
                 throws VlException
Delete nodes. Nodes must be of type VFSNode

Specified by:
delNodes in interface VComposite
Throws:
VlException

isFile

public boolean isFile()
return true if the VFSNode is a (V)File

Specified by:
isFile in class VFSNode
See Also:
VFile

isDir

public boolean isDir()
return true if the VFSNode is a (V)Directory

Specified by:
isDir in class VFSNode
See Also:
VDir

getChilds

public VFSNode[] getChilds()
                    throws VlException
default implementation calls the VDir method list()

Specified by:
getChilds in interface VComposite
Throws:
VlException

createChild

public VFSNode createChild(java.lang.String type,
                           java.lang.String name,
                           boolean force)
                    throws VlException
VDir implements createChild by calling createFile and createDir, depending on the type.

Specified by:
createChild in interface VComposite
Parameters:
type - must be on of the types getResourceTypes() returns.
name - may be null. The implementation might choose a default name or prompt the user.
force - means to create the child even if it already exists.
Throws:
VlException

createFile

public VFile createFile(java.lang.String name)
                 throws VlException
Create file in this Virtual Directory. The default implementation is to ignore existing files.

Throws:
VlException

createDir

public VDir createDir(java.lang.String subdirName)
               throws VlException
Create subdirectory. Directory may alread exist.

Throws:
VlException

putFile

public final VFile putFile(VFile file)
                    throws VlException
Put File (copy) to this directory is called by VFSClient.copyDir() ...

Throws:
VlException

putFile

public final VFile putFile(VFile file,
                           java.lang.String optNewName)
                    throws VlException
Put File (copy) to this directory is called by VFSClient.copyDir() ...

Throws:
VlException

putDir

public final VDir putDir(VDir dir)
                  throws VlException
Put Directory (copy) Directory to this Directory is called by VFSClient.copyDir() ...

Throws:
VlException

putDir

public final VDir putDir(VDir dir,
                         java.lang.String optNewName)
                  throws VlException
Put Directory (copy) Directory to this Directory is called by VFSClient.copyDir() ...

Throws:
VlException

copyTo

public final VDir copyTo(VDir dest)
                  throws VlException
Copy/Move to specified location is called by VFSClient.copyDir() ...

Specified by:
copyTo in class VFSNode
Throws:
VlException

copyTo

public final VDir copyTo(VDir dest,
                         java.lang.String newName)
                  throws VlException
Copy/Move to specified location is called by VFSClient.copyDir() ...

Specified by:
copyTo in class VFSNode
Throws:
VlException

moveTo

public final VDir moveTo(VDir dest)
                  throws VlException
Move to specified VDir location. Is also called by VFSClient.moveDir().

Specified by:
moveTo in class VFSNode
Throws:
VlException

moveTo

public final VDir moveTo(VDir dest,
                         java.lang.String newName)
                  throws VlException
Move to specified VDir location. Is also called by VFSClient.moveDir().

Specified by:
moveTo in class VFSNode
Throws:
VlException

delete

public boolean delete()
               throws VlException
Non-recursive Delete.
Calles recursive delete from VComposite with resurse=false.

Specified by:
delete in interface VEditable
Throws:
VlException
See Also:
nl.uva.vlet.vrs.VNode#delete(), nl.uva.vlet.vrs.VComposite#delete()

getDir

public VDir getDir(java.lang.String dirname)
            throws VlException
Get subdirectory

Throws:
VlException

getFile

public VFile getFile(java.lang.String name)
              throws VlException
Get file in this directory

Throws:
VlException

getChild

public VFSNode getChild(java.lang.String name)
                 throws VlException
Get VFSNode

Specified by:
getChild in interface VComposite
Throws:
VlException

hasChild

public boolean hasChild(java.lang.String name)
                 throws VlException
Description copied from interface: VComposite
Checks whether this node has a child with the specified name

Specified by:
hasChild in interface VComposite
Throws:
VlException

getChildAttributes

public VAttribute[][] getChildAttributes(java.lang.String[] childNames,
                                         java.lang.String[] names)
                                  throws VlException
Return attribute matrix for given nodes. The matrix should be in the form: VAttribute[node][attrname].
Developers note:
Override this method for a faster getall attributes. Also allow for entries in the name and node list to be null ! This is for attribute list merging (Ritsen)!

Specified by:
getChildAttributes in interface VComposite
Parameters:
childs - array of VNodes
names -
Returns:
Throws:
VlException

getChildAttributes

public VAttribute[][] getChildAttributes(java.lang.String[] names)
                                  throws VlException
Description copied from interface: VComposite
Returns attributes for all childs

Specified by:
getChildAttributes in interface VComposite
Throws:
VlException

isAccessable

public boolean isAccessable()
                     throws VlException
Description copied from interface: VComposite
Override this method if your directory can be accessable but not be 'readable'. For example a the contents of unix directory may not be 'read' (list() will fails), but each individual file may be accessable (mode= --x).

Specified by:
isAccessable in interface VComposite
Throws:
VlException

doCopyMoveTo

protected VDir doCopyMoveTo(VFSTransfer transfer,
                            VDir dest,
                            java.lang.String optNewName,
                            boolean isMove)
                     throws VlException
Default implementation to do actual copy/move. Decides whether to upload,download or perform a stream copy, depending on whether this directory or the remote one (or neither) is local. Subclasses can overide this method if they have optimized (bulk) up- or download methods. Note that uploadDir() and uploadFile() are used to upload files/directories by the LocalFS Implementation ! (See LocalFS). These method are recommended to be overidden by the VFS implementation.
 
  This Dir    Remote Destination   method 
   local       remote               VDir.uploadDir
   remote      local                VDir.downloadTo
   local       local                streamcopy 
   remote      other remote         streamcopy
   [ ... move on same server ... ]  VDir.renameTo
 

Parameters:
transfer -
Throws:
VlException
See Also:
moveTo(VDir), copyTo(VDir), uploadDir(VDir), uploadFIle(VFile)

uploadLocalFile

protected VFile uploadLocalFile(VFSTransfer transfer,
                                VFile localFile,
                                java.lang.String optNewName,
                                boolean isMove)
                         throws VlException
Default implementation to upload a local file to this directory. Uses stream copy to copy the file. A newfile is created in this directory, optionally with the new name 'optNewName'.

Override this method if the VFS implementation has a more efficient (bulk/parallel) upload method for files.

protected: use copyTo/moveTo or doCopyMoveTo

Throws:
VlException

uploadLocalDir

protected VDir uploadLocalDir(VFSTransfer transfer,
                              VDir localDir,
                              java.lang.String optNewName,
                              boolean isMove)
                       throws VlException
Default implementation to upload a directory. Recursively copies the contents in this directory. A new (sub) directory is created in this directory, optionally with the new name 'optNewName'.

This method is used by Local Directories to upload themself. Override this method if the VFS implementation has a more efficient (bulk) upload method for directories.

Throws:
VlException

downloadTo

protected VDir downloadTo(VFSTransfer transfer,
                          VDir localDir,
                          java.lang.String optNewName,
                          boolean isMove)
                   throws VlException
Default implementation to download this directory. Recursively copies the contents in this directory. A new directory is created in the local directory, optionally with the new name 'optNewName'.

Override this method if the VFS implementation has a more efficient (bulk) download method.

Throws:
VlException

defaultRecursiveDeleteChildren

protected static boolean defaultRecursiveDeleteChildren(VDir dir)
                                                 throws VlException
Default Recursive delete: lists children and perform delete() on child list. This method does NOT delete the parent node itself !

Parameters:
dir -
Returns:
Throws:
VlException

defaultCopyMove

protected static VDir defaultCopyMove(VFSTransfer transfer,
                                      VDir source,
                                      VDir dest,
                                      java.lang.String optNewName,
                                      boolean isMove)
                               throws VlException
Default Copy/Move: performs recursive copy of a directory.
lists children and performs cmoveTo on childs.
protected: may only be used by subclasses if they do not have an optimized CopyMoveTo themselfs.

Throws:
VlException

listSorted

public VFSNode[] listSorted(boolean typeFirst,
                            boolean ignoreCase)
                     throws VlException
List the chidren and sorts them.

Parameters:
if - typeFirst==true return directories first, then files.
ignoreCase - ignore case when sorting
Returns:
Throws:
VlException

createDir

public abstract VDir createDir(java.lang.String name,
                               boolean ignoreExisting)
                        throws VlException
Creates subdirectory in this directory.

Returns:
new VDir created. null if mustnotexist=true and the directory already exists.
Throws:
VlException

existsFile

public abstract boolean existsFile(java.lang.String fileName)
                            throws VlException
returns true whether child exists and is a VFile

Throws:
VlException

existsDir

public abstract boolean existsDir(java.lang.String fileName)
                           throws VlException
returns true whether child exists and is a VDir

Throws:
VlException

createFile

public abstract VFile createFile(java.lang.String name,
                                 boolean force)
                          throws VlException
Create file in this Virtual Directory.

Throws:
VlException

list

public abstract VFSNode[] list()
                        throws VlException
This method is Similar to getChilds, but returns an array of VFSNodes.
The method getChilds returns an array of type VNode. Also this method is similar the Java File interface.

Returns:
array of VFSNodes
Throws:
VlException