nl.uva.vlet.vfs
Class VFSNode

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

public abstract class VFSNode
extends VNode
implements VRenamable, VEditable, VACL

Super class of the all VFS Nodes.
Represents shared methods for (Virtual) Directories and Files.

See Also:
VDir, VFile

Field Summary
static java.lang.String ATTR_ACCESS_TIME
           
static java.lang.String ATTR_CREATION_TIME
          Creation time in millis since Epoch (01-01-1970)
static java.lang.String ATTR_DATA_TYPE
          SRB Data Type attribute
static java.lang.Object ATTR_DIRNAME
          Ambiguos 'dirname' can be both parent directory of file or directory name itself
static java.lang.String ATTR_EXISTS
           
static java.lang.String ATTR_GID
           
static java.lang.String ATTR_GROUP
           
static java.lang.String ATTR_ISDIR
           
static java.lang.String ATTR_ISFILE
           
static java.lang.String ATTR_ISHIDDEN
           
static java.lang.String ATTR_ISREADABLE
           
static java.lang.String ATTR_ISSOFTLINK
           
static java.lang.String ATTR_ISWRITABLE
           
static java.lang.String ATTR_LENGTH
           
static java.lang.String ATTR_LINKTARGET
           
static java.lang.String ATTR_MODIFICATION_TIME
          Modification time in millis since Epoch (01-01-1970)
static java.lang.String ATTR_NRACLENTRIES
           
static java.lang.String ATTR_NRCHILDS
           
static java.lang.String ATTR_OWNER
           
static java.lang.String ATTR_PARENT_DIRNAME
          Unambigous Parent directory attribute for both files and directores
static java.lang.String ATTR_PERMISSIONS_STRING
           
static java.lang.String ATTR_RESOURCE
          SRB attribute,but moved up level for visibility !
static java.lang.String ATTR_UID
           
static java.lang.String ATTR_UNIQUE
           
static java.lang.String[] attributeNames
          Default attributes names for all VFSNodes
static int defaultStreamBufferSize
          Default buffer for streamCopy to use
 
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
VFSNode(VRSContext context, VRL vrl)
           
 
Method Summary
 VFSTransfer asyncCopyMoveTo(VDir dest, java.lang.String optNewName, boolean isMove)
          Asynchronous transfer method to iniate a copy or a move.
abstract  VFSNode copyTo(VDir dest)
           
abstract  VFSNode copyTo(VDir dest, java.lang.String newName)
           
 boolean create()
          Create this Resource.
 VAttribute[] createACLRecord(VAttribute entity, boolean writeThrough)
          Create a new ACL Record for the given ACL Entry, that is, a new row in the ACL[][] matrix returned in getACL().
protected static VFSTransfer createTransfer(VNode source, VDir dest, java.lang.String optNewName, boolean isMove)
           
protected  VFSTransfer createTransferTo(VDir dest, java.lang.String optNewName, boolean isMove)
           
 boolean deleteACLEntity(VAttribute entity)
          Delete entry in the ACL list or set permissions to none
abstract  boolean exists()
          Returns true if the VRL points to an existing object.
 VAttribute[][] getACL()
          Experimental ACL method: Default return simplist ACL of all.
 VAttribute[] getACLEntities()
          Returns all possible ACL entities (users,groups, etc);
 VAttribute getAttribute(java.lang.String name)
          Returns single atttribute triplet
 java.lang.String[] getAttributeNames()
          Returns all default attributes names
 java.lang.String getLinkTarget()
          Optional method to resolve (soft) links if this VFS Implementation supports it.
 VRL getLinkTargetVRL()
          Return LinkTarget is VRL
abstract  long getModificationTime()
          Return time of last modification in milli seconds after 'epoch' epoch = (1-jan-1970 GMT).
 VDir getParent()
          VFSnode implements getParent by calling VFSNode.getParentDir
 VNode[] getParents()
          Returns array whith one parent.
 VFSNode getPath(java.lang.String path)
          Fetch any VFSNode (VFile or VDir) with the specified absolute path
 java.lang.String getPermissionsString()
          Return unix-style permissions string
 VDir getRoot()
          Returns root directory of this directory/file system
 VFSTransfer getTranferInfo()
          Returns TransferInfo Object of ongoing or finished transfer.
 boolean isDeletable()
          returns true is the caller has the permissions to delete this resource The default implementation for a VFSNode is to check whether it is writable
abstract  boolean isDir()
          Returns true if the node is a Directory
 boolean isEditable()
          returns true is the caller has the permissions to edit this resource.
abstract  boolean isFile()
          Returns true if the node is a file.
 boolean isHidden()
          Optional method for filesystems who support hidden files.
 boolean isLink()
          Optional method for filesystems who support soft links.
 boolean isLocal()
          Whether the location points to a local available path !
To get the actual local path, do a getPath().
 boolean isRandomAccessable()
          RandomAccessable methods:
abstract  boolean isReadable()
          Returns whether the object is readable using current user credentials.
 boolean isRenamable()
          Returns true is the resource is renamble whit the current credentials.
abstract  boolean isWritable()
          Returns whether the object is writable using current user credentials.
abstract  VFSNode moveTo(VDir dest)
           
abstract  VFSNode moveTo(VDir dest, java.lang.String newName)
           
static VFSNode[] returnAsArray(java.util.Vector<VFSNode> nodes)
           
 void setACL(VAttribute[][] acl)
          Set the modified ACL list
 boolean setAttribute(VAttribute attr)
          Set atribute.
 boolean setAttributes(VAttribute[] attrs)
          Sets a list of attributes
 VFSNode startCopyMoveTo(VDir dest, java.lang.String optNewName, boolean isMove)
           
protected  VFSNode startCopyMoveTo(VFSTransfer transfer, VDir dest, java.lang.String optNewName, boolean isMove)
          Initiate a Copy or Move with the specified Transfer Information object.
 
Methods inherited from class nl.uva.vlet.vrs.VNode
compareTo, getAttributes, getAttributes, getAttributeSet, getBasename, getCharSet, getHelp, getHostname, getIconURL, getID, getLocation, getMimeType, getName, getPath, getPort, getScheme, getServerAttributes, getType, 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.VRenamable
renameTo
 
Methods inherited from interface nl.uva.vlet.vrs.VEditable
delete
 

Field Detail

ATTR_EXISTS

public static final java.lang.String ATTR_EXISTS
See Also:
Constant Field Values

ATTR_ISREADABLE

public static final java.lang.String ATTR_ISREADABLE
See Also:
Constant Field Values

ATTR_ISWRITABLE

public static final java.lang.String ATTR_ISWRITABLE
See Also:
Constant Field Values

ATTR_ISHIDDEN

public static final java.lang.String ATTR_ISHIDDEN
See Also:
Constant Field Values

ATTR_ISSOFTLINK

public static final java.lang.String ATTR_ISSOFTLINK
See Also:
Constant Field Values

ATTR_LINKTARGET

public static final java.lang.String ATTR_LINKTARGET
See Also:
Constant Field Values

ATTR_ISFILE

public static final java.lang.String ATTR_ISFILE
See Also:
Constant Field Values

ATTR_ISDIR

public static final java.lang.String ATTR_ISDIR
See Also:
Constant Field Values

ATTR_NRCHILDS

public static final java.lang.String ATTR_NRCHILDS
See Also:
Constant Field Values

ATTR_LENGTH

public static final java.lang.String ATTR_LENGTH
See Also:
Constant Field Values

ATTR_ACCESS_TIME

public static final java.lang.String ATTR_ACCESS_TIME
See Also:
Constant Field Values

ATTR_MODIFICATION_TIME

public static final java.lang.String ATTR_MODIFICATION_TIME
Modification time in millis since Epoch (01-01-1970)

See Also:
Constant Field Values

ATTR_CREATION_TIME

public static final java.lang.String ATTR_CREATION_TIME
Creation time in millis since Epoch (01-01-1970)

See Also:
Constant Field Values

ATTR_PERMISSIONS_STRING

public static final java.lang.String ATTR_PERMISSIONS_STRING
See Also:
Constant Field Values

ATTR_PARENT_DIRNAME

public static final java.lang.String ATTR_PARENT_DIRNAME
Unambigous Parent directory attribute for both files and directores

See Also:
Constant Field Values

ATTR_DIRNAME

public static final java.lang.Object ATTR_DIRNAME
Ambiguos 'dirname' can be both parent directory of file or directory name itself


ATTR_OWNER

public static final java.lang.String ATTR_OWNER
See Also:
Constant Field Values

ATTR_GROUP

public static final java.lang.String ATTR_GROUP
See Also:
Constant Field Values

ATTR_UNIQUE

public static final java.lang.String ATTR_UNIQUE
See Also:
Constant Field Values

ATTR_UID

public static final java.lang.String ATTR_UID
See Also:
Constant Field Values

ATTR_GID

public static final java.lang.String ATTR_GID
See Also:
Constant Field Values

ATTR_NRACLENTRIES

public static final java.lang.String ATTR_NRACLENTRIES
See Also:
Constant Field Values

ATTR_RESOURCE

public static final java.lang.String ATTR_RESOURCE
SRB attribute,but moved up level for visibility !

See Also:
Constant Field Values

ATTR_DATA_TYPE

public static final java.lang.String ATTR_DATA_TYPE
SRB Data Type attribute

See Also:
Constant Field Values

attributeNames

public static final java.lang.String[] attributeNames
Default attributes names for all VFSNodes


defaultStreamBufferSize

public static int defaultStreamBufferSize
Default buffer for streamCopy to use

Constructor Detail

VFSNode

public VFSNode(VRSContext context,
               VRL vrl)
Method Detail

create

public boolean create()
               throws VlException
Create this Resource.

Throws:
VlException

getRoot

public VDir getRoot()
             throws VlException
Returns root directory of this directory/file system

Throws:
VlException

getPath

public VFSNode getPath(java.lang.String path)
                throws VlException
Fetch any VFSNode (VFile or VDir) with the specified absolute path

Throws:
VlException

isHidden

public boolean isHidden()
Optional method for filesystems who support hidden files. Note that the implementation of hidden files on filesystems might differ! Default implemententation is to return true for 'dot' files.


isLink

public boolean isLink()
               throws VlException
Optional method for filesystems who support soft links. Default this method return false. Note that implementations of links on filesystems might differ!

Throws:
VlException

getLinkTarget

public java.lang.String getLinkTarget()
                               throws VlException
Optional method to resolve (soft) links if this VFS Implementation supports it. Use isLink() first to check whether this file is a (soft) link or a windows shortcut

Throws:
VlException

getLinkTargetVRL

public VRL getLinkTargetVRL()
                     throws VlException
Return LinkTarget is VRL

Throws:
VlException

isLocal

public boolean isLocal()
Whether the location points to a local available path !
To get the actual local path, do a getPath().


getAttributeNames

public java.lang.String[] getAttributeNames()
Returns all default attributes names

Overrides:
getAttributeNames in class VNode

getAttribute

public VAttribute getAttribute(java.lang.String name)
                        throws VlException
Returns single atttribute triplet

Overrides:
getAttribute in class VNode
Throws:
VlException

getPermissionsString

public java.lang.String getPermissionsString()
                                      throws VlException
Return unix-style permissions string

Throws:
VlException

getParent

public VDir getParent()
               throws VlException
VFSnode implements getParent by calling VFSNode.getParentDir

Overrides:
getParent in class VNode
Returns:
Parent VNode or null.
Throws:
VlException
See Also:
VNode.getParents()

getParents

public VNode[] getParents()
                   throws VlException
Returns array whith one parent.

Overrides:
getParents in class VNode
Throws:
VlException

isRandomAccessable

public boolean isRandomAccessable()
RandomAccessable methods:


isEditable

public boolean isEditable()
                   throws VlException
Description copied from interface: VEditable
returns true is the caller has the permissions to edit this resource. This means the setAttribute(s) method(s) are allowed. The default implementation for a VFSNode is to check whether it is writable

Specified by:
isEditable in interface VEditable
Throws:
VlException

isDeletable

public boolean isDeletable()
                    throws VlException
Description copied from interface: VEditable
returns true is the caller has the permissions to delete this resource The default implementation for a VFSNode is to check whether it is writable

Specified by:
isDeletable in interface VEditable
Throws:
VlException

setAttributes

public boolean setAttributes(VAttribute[] attrs)
                      throws VlException
Description copied from interface: VEditable
Sets a list of attributes

Specified by:
setAttributes in interface VEditable
Throws:
VlException

setAttribute

public boolean setAttribute(VAttribute attr)
                     throws VlException
Set atribute. Not much attributes can be set currently by the VFSNode super class. To add extra attributes in a subclass do a super.setAttributes(attr) first check the return value and if it is false add your own. For example:
  SubClass.setAttribute(VAtribute attr) 
  {
     if (super.setAttribute(attr)==true) 
         return true;
     
     if (isMyAttribute(attr)) 
        return setMyAttribute(attr); 
     else   
        return false; 
  } 
  

Specified by:
setAttribute in interface VEditable
Throws:
VlException

isRenamable

public boolean isRenamable()
                    throws VlException
Description copied from interface: VRenamable
Returns true is the resource is renamble whit the current credentials. When false is returned, this doesn't mean this resource isn't renamable in general (if not, this interface wouldn't be implemented) just that the current permission prohobit it. Default implementation for a VFSNode is to check whether it is writable.

Specified by:
isRenamable in interface VRenamable
Returns:
true if the current user can rename this resource.
Throws:
VlException
See Also:
VFSNode.isRenamable();

returnAsArray

public static VFSNode[] returnAsArray(java.util.Vector<VFSNode> nodes)

copyTo

public abstract VFSNode copyTo(VDir dest)
                        throws VlException
Throws:
VlException

copyTo

public abstract VFSNode copyTo(VDir dest,
                               java.lang.String newName)
                        throws VlException
Throws:
VlException

moveTo

public abstract VFSNode moveTo(VDir dest)
                        throws VlException
Throws:
VlException

moveTo

public abstract VFSNode moveTo(VDir dest,
                               java.lang.String newName)
                        throws VlException
Throws:
VlException

isFile

public abstract boolean isFile()
Returns true if the node is a file.

See Also:
VFile

isDir

public abstract boolean isDir()
Returns true if the node is a Directory

See Also:
VDir

exists

public abstract boolean exists()
                        throws VlException
Returns true if the VRL points to an existing object. (After an delete, exists() return false)

Specified by:
exists in class VNode
Throws:
VlException

getModificationTime

public abstract long getModificationTime()
                                  throws VlException
Return time of last modification in milli seconds after 'epoch' epoch = (1-jan-1970 GMT). Important: this value will be used for file/attribute caching. Make sure the time is correct and alway reread from the filesystem. Other getAttribute methods might first check whether the modification time has changed and decide to use a cache value for speed.

Throws:
VlException

isReadable

public abstract boolean isReadable()
                            throws VlException
Returns whether the object is readable using current user credentials.
For a Directory isReadable means it must have r-x permissions !

Throws:
VlException
See Also:
exists, isWritable

isWritable

public abstract boolean isWritable()
                            throws VlException
Returns whether the object is writable using current user credentials. Note that some implementations make a difference between 'deletable' 'appendable' and 'can create directories' (GridFTP).

Throws:
VlException
See Also:
exists, isReadable

setACL

public void setACL(VAttribute[][] acl)
            throws VlException
Description copied from interface: VACL
Set the modified ACL list

Specified by:
setACL in interface VACL
Throws:
VlException

getACL

public VAttribute[][] getACL()
                      throws VlException
Experimental ACL method: Default return simplist ACL of all.

Specified by:
getACL in interface VACL
Returns:
Throws:
VlException

getACLEntities

public VAttribute[] getACLEntities()
                            throws VlIOException
Returns all possible ACL entities (users,groups, etc);

Specified by:
getACLEntities in interface VACL
Returns:
VAttribute array of possible entities.
Throws:
VlIOException

createACLRecord

public VAttribute[] createACLRecord(VAttribute entity,
                                    boolean writeThrough)
                             throws VlException
Create a new ACL Record for the given ACL Entry, that is, a new row in the ACL[][] matrix returned in getACL(). The nr of- and types in this row must match.

Specified by:
createACLRecord in interface VACL
Parameters:
writeThrough -
Returns:
Throws:
NotImplementedException
VlException

deleteACLEntity

public boolean deleteACLEntity(VAttribute entity)
                        throws VlException
Delete entry in the ACL list or set permissions to none

Specified by:
deleteACLEntity in interface VACL
Returns:
Throws:
VlException

asyncCopyMoveTo

public final VFSTransfer asyncCopyMoveTo(VDir dest,
                                         java.lang.String optNewName,
                                         boolean isMove)
                                  throws VlException
Asynchronous transfer method to iniate a copy or a move. Returns VFSTransfer info object so the transfer can be monitored. All background copy or move methods are started by this method.

Throws:
VlException

createTransferTo

protected VFSTransfer createTransferTo(VDir dest,
                                       java.lang.String optNewName,
                                       boolean isMove)
                                throws VlException
Throws:
VlException

createTransfer

protected static VFSTransfer createTransfer(VNode source,
                                            VDir dest,
                                            java.lang.String optNewName,
                                            boolean isMove)
                                     throws VlException
Throws:
VlException

startCopyMoveTo

public final VFSNode startCopyMoveTo(VDir dest,
                                     java.lang.String optNewName,
                                     boolean isMove)
                              throws VlException
Throws:
VlException

startCopyMoveTo

protected final VFSNode startCopyMoveTo(VFSTransfer transfer,
                                        VDir dest,
                                        java.lang.String optNewName,
                                        boolean isMove)
                                 throws VlException
Initiate a Copy or Move with the specified Transfer Information object.

Parameters:
transfer - TransferInfo object which must be updated during transfer
dest -
optNewName -
isMove -
Returns:
Throws:
VlException

getTranferInfo

public final VFSTransfer getTranferInfo()
Returns TransferInfo Object of ongoing or finished transfer. Returns null if no tranfer has been done with this object. If two transfers have been started on this object, only the last info object will be returned. Call this method for each transfer started or use the asyncCopyMoveTo() method.

Note that in the current implementation the source VFile will initiate a transfer, so the source file has the TransferInfo Object. The (newly created) destination File object won't have a Trasnfer object.

Returns: