nl.uva.vlet.vrs
Class ResourceNode

java.lang.Object
  extended by nl.uva.vlet.vrs.VNode
      extended by nl.uva.vlet.vrs.ResourceNode
All Implemented Interfaces:
java.lang.Cloneable, VEditable, VRenamable, VStreamReadable
Direct Known Subclasses:
LinkNode

public abstract class ResourceNode
extends VNode
implements VEditable, java.lang.Cloneable, VRenamable, VStreamReadable

Super Class of LinkNode and ServerInfo. The ResourceNode describes a resource, which can be a Link or a Server. Instead of being the resource (File,Directory) itself, like VFile and VDir. the ResourceNode has a 'Target' which is the linked-to resource or the Remote Server. For example a LinkNode can be stored in as a VFile (.vlink) but the physical resource type of the LinkNode stays a VFile. When the LinkNode is loaded it becomes a ResourceNode. This delayed or lazy type of loading makes it possible for the VBrowser to optimize the link resolving, thus only load/resolve a link when really needed. TODO: Integration with ServerInfo


Field Summary
static java.lang.String ATTR_LINK_IS_COMPOSITE
          Hidden hint to quickly know whether target is composite
static java.lang.String ATTR_LINK_MIMETYPE
          Hidden attribute: mimetype of linkTarget.
static boolean default_show_shortcut_icon
          Default value when not specified
protected static java.lang.String[] guiAttributeNames
          extra link attributes
protected  VComposite parent
          Optional parent for in-memory resourceNode (=logical parent)
protected  VAttributeSet resourceAttributes
          Link Attributes, also used to store 'extra' or Server Attributes ! The names of these attributes are stored in serverAttributeNames.
static java.lang.String SERVER_ATTRIBUTES
          Hidden server Attributes Names
protected  java.lang.String[] serverAttributeNames
           
protected  VNode storageLocation
          The location where this ResourceNode is stored.
protected  java.lang.String type
           
protected static java.lang.String[] urlAttributeNames
           
 
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
 
Constructor Summary
ResourceNode(VRSContext context, VRL vrl)
           
 
Method Summary
protected  void _loadFrom(java.io.InputStream inps)
           
protected  void _loadFrom(VNode vnode)
          Load data from (VStreamReadable) VNode
protected  void checkAndStoreNewServerInfo()
           
protected  void copyFrom(ResourceNode source)
          Duplicate: Initializer
 boolean delete()
          Delete specified resource.
 boolean exists()
          A ResourcNode is an already resolved node (data object) in memory so as an 'object' it already exists.
 VAttribute getAttribute(java.lang.String name)
          This is the single method a Node has to implement so that attributes can be fetched.
 java.lang.String[] getAttributeNames()
          Get the names of the attributes this resource has
 java.lang.String getIconURL()
          Returns optional icon url, used by VBrowser
 VNode getImplementation()
          the VNode which stores the LinkNode object, usually a VFile
 java.io.InputStream getInputStream()
          Create InputStream to read from this (remote) resource.
 java.lang.String getName()
          Returns the short name of the resource.
The default is the basename of the resource or the last part of the path part in the URI.
 VNode getParent()
          Returns 'Logical' Parent.
 ServerInfo getServerInfo()
          Return ServerInfo stored in this ResourceNode
 boolean getShowShortCutIcon()
           
 java.lang.String getTargetHostname()
           
 boolean getTargetIsComposite()
          Checks whether remote resource is composite or not.
 java.lang.String getTargetMimeType()
          Returns mimetype of link target
 java.lang.String getTargetPath()
           
 int getTargetPort()
           
 java.lang.String getTargetScheme()
           
 java.lang.String getTargetType()
           
 java.lang.String getTargetUserInfo()
          Returns username + (optional) domainname added the to userinfo.
 java.lang.String getTargetUsername()
          This method returns the username without optional domain name info.
 VRL getTargetVRL()
          Returns linkTarget location
 java.lang.String getType()
          Returns resource type, if it has one
protected  void init(VRL logicalVRL, VRL targetVRL, boolean resolveLink)
           
protected  void initAttributes()
           
 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
 boolean isEditable()
          returns true is the caller has the permissions to edit this resource.
 boolean isRenamable()
          Returns true is the resource is renamble whit the current credentials.
 boolean isServerType()
           
 boolean isVirtual()
          New Generic Type for MyVLe and LinkNodes
 boolean renameTo(java.lang.String newName, boolean nameIsPath)
          Renames this resource.
Since for some implementations (java.io.File) a full path is needed.
 void save()
           
 boolean setAttribute(VAttribute attr)
          Set single attribute.
 boolean setAttribute(VAttribute attr, boolean store)
           
 boolean setAttributes(VAttribute[] attrs)
          Sets a list of attributes
 boolean setAttributes(VAttribute[] attrs, boolean store)
           
 void setIconURL(java.lang.String url)
          sets setIconURL of this linknode
 void setName(java.lang.String val)
           
protected  void setResourceVRL(VRL linkTarget)
           
protected  void setServerAttributeNames(java.lang.String[] attrNames)
           
 void setServerAttributes(VAttribute[] attributes)
          Sets server properties to store in link object, this will OVERIDE other old value of server properties!
 void setServerInfo(ServerInfo info)
          Set ServerInfo to be stored in this ResourceNode
 void setShowShortCutIcon(boolean b)
           
 void setTargetHostname(java.lang.String val)
           
protected  void setTargetPath(java.lang.String val)
           
protected  void setTargetPort(int val)
           
protected  void setTargetScheme(java.lang.String scheme)
           
 void setTargetUsername(java.lang.String val)
          Since the username is OPTIONAL setting this value to null will remove the username attribute from the linktarget attribute list, so it will not appear in the Attribute list ! (When doing a getAttributes() for example).
protected  void setType(java.lang.String type)
           
protected  boolean updateTargetAttributes()
          Update stored Target Attributes: isComposite.
 
Methods inherited from class nl.uva.vlet.vrs.VNode
compareTo, getAttributes, getAttributes, getAttributeSet, getBasename, getCharSet, getHelp, getHostname, getID, getLocation, getMimeType, getParents, getPath, getPort, getScheme, getServerAttributes, getURI, getVRL, getVRSContext, isComposite, isVLink, mergedGetAttributes, setLocation, setVRL, toLinkNode, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTR_LINK_MIMETYPE

public static final java.lang.String ATTR_LINK_MIMETYPE
Hidden attribute: mimetype of linkTarget.

See Also:
Constant Field Values

SERVER_ATTRIBUTES

public static final java.lang.String SERVER_ATTRIBUTES
Hidden server Attributes Names

See Also:
Constant Field Values

ATTR_LINK_IS_COMPOSITE

public static final java.lang.String ATTR_LINK_IS_COMPOSITE
Hidden hint to quickly know whether target is composite

See Also:
Constant Field Values

default_show_shortcut_icon

public static final boolean default_show_shortcut_icon
Default value when not specified

See Also:
Constant Field Values

urlAttributeNames

protected static java.lang.String[] urlAttributeNames

guiAttributeNames

protected static java.lang.String[] guiAttributeNames
extra link attributes


resourceAttributes

protected VAttributeSet resourceAttributes
Link Attributes, also used to store 'extra' or Server Attributes ! The names of these attributes are stored in serverAttributeNames. The VStream[Readable/Writeable] interface is used to read/write a linknode.


serverAttributeNames

protected java.lang.String[] serverAttributeNames

parent

protected VComposite parent
Optional parent for in-memory resourceNode (=logical parent)


storageLocation

protected VNode storageLocation
The location where this ResourceNode is stored. Typically a link File (.vlink) If null, this ResourceNode exists only in memory and is 'true' virtual.


type

protected java.lang.String type
Constructor Detail

ResourceNode

public ResourceNode(VRSContext context,
                    VRL vrl)
Method Detail

copyFrom

protected void copyFrom(ResourceNode source)
Duplicate: Initializer


init

protected void init(VRL logicalVRL,
                    VRL targetVRL,
                    boolean resolveLink)
             throws VlException
Throws:
VlException

initAttributes

protected void initAttributes()

getType

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

Specified by:
getType in class VNode

setType

protected void setType(java.lang.String type)

getName

public java.lang.String getName()
Description copied from class: VNode
Returns the short name of the resource.
The default is the basename of the resource or the last part of the path part in the URI. To use another name, subclassses must overide this method.

Overrides:
getName in class VNode

exists

public boolean exists()
A ResourcNode is an already resolved node (data object) in memory so as an 'object' it already exists. The storage location might not exist (yet).

Specified by:
exists in class VNode

getParent

public VNode getParent()
                throws VlException
Returns 'Logical' Parent. For example another virtual node or the 'MyVle' object

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

isVirtual

public boolean isVirtual()
Description copied from class: VNode
New Generic Type for MyVLe and LinkNodes

Overrides:
isVirtual in class VNode

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

setTargetHostname

public void setTargetHostname(java.lang.String val)

setTargetPort

protected void setTargetPort(int val)

setTargetUsername

public void setTargetUsername(java.lang.String val)
Since the username is OPTIONAL setting this value to null will remove the username attribute from the linktarget attribute list, so it will not appear in the Attribute list ! (When doing a getAttributes() for example).

Parameters:
val -

getTargetType

public java.lang.String getTargetType()

setTargetPath

protected void setTargetPath(java.lang.String val)

setTargetScheme

protected void setTargetScheme(java.lang.String scheme)

save

public void save()
          throws VlException
Throws:
VlException

getImplementation

public VNode getImplementation()
the VNode which stores the LinkNode object, usually a VFile


setIconURL

public void setIconURL(java.lang.String url)
sets setIconURL of this linknode


getTargetMimeType

public java.lang.String getTargetMimeType()
Returns mimetype of link target


getIconURL

public java.lang.String getIconURL()
Returns optional icon url, used by VBrowser

Overrides:
getIconURL in class VNode

isServerType

public boolean isServerType()

setShowShortCutIcon

public void setShowShortCutIcon(boolean b)

getShowShortCutIcon

public boolean getShowShortCutIcon()

setAttributes

public boolean setAttributes(VAttribute[] attrs,
                             boolean store)
                      throws VlException
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
Description copied from interface: VEditable
Set single attribute. Return true if attribute was set.

Specified by:
setAttribute in interface VEditable
Throws:
VlException

setAttribute

public boolean setAttribute(VAttribute attr,
                            boolean store)
                     throws VlException
Throws:
VlException

getServerInfo

public ServerInfo getServerInfo()
Return ServerInfo stored in this ResourceNode


setServerInfo

public void setServerInfo(ServerInfo info)
Set ServerInfo to be stored in this ResourceNode


setServerAttributes

public void setServerAttributes(VAttribute[] attributes)
Sets server properties to store in link object, this will OVERIDE other old value of server properties!


setServerAttributeNames

protected void setServerAttributeNames(java.lang.String[] attrNames)

setName

public void setName(java.lang.String val)

renameTo

public boolean renameTo(java.lang.String newName,
                        boolean nameIsPath)
                 throws VlException
Description copied from interface: VRenamable
Renames this resource.
Since for some implementations (java.io.File) a full path is needed. The parameter nameIsPath specifies whether only the basename (last part of path) or the full path is given as new name to avoid this ambiguoty !
For java.io.file a renameTo can also be used as a move !

Specified by:
renameTo in interface VRenamable
Parameters:
newName - New basename or fullpath of new filename
nameIsPath - whether the 'name' is an absolute path
Returns:
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();

getTargetScheme

public java.lang.String getTargetScheme()

getTargetPort

public int getTargetPort()

getTargetUsername

public java.lang.String getTargetUsername()
This method returns the username without optional domain name info. Since SRB URIs have the domainname added to the username, a destinction has to be made between the username and the userinfo part of an URI.

Returns:

getTargetUserInfo

public java.lang.String getTargetUserInfo()
                                   throws VlException
Returns username + (optional) domainname added the to userinfo. For example piter.de.boer.vlenl. Use this method to the get an URI/URL compatable UserInfo part for SRB uris. If no domain info is supplied, this method returns the same as getTargetUsername()

Returns:
Throws:
VlException

getTargetHostname

public java.lang.String getTargetHostname()

getTargetPath

public java.lang.String getTargetPath()

getTargetIsComposite

public boolean getTargetIsComposite()
                             throws VlException
Checks whether remote resource is composite or not. This method might auto update the isComposite attribute of the (remote) target is this isn't set yet!

Parameters:
resolve -
Returns:
Throws:
VlException

updateTargetAttributes

protected boolean updateTargetAttributes()
Update stored Target Attributes: isComposite. Note that IconURL is an attribute stored by the VBrowser! This method can also be used to (auto) update/check Link/Server nodes with new attributes.

Returns:

getTargetVRL

public VRL getTargetVRL()
                 throws VlException
Returns linkTarget location

Throws:
VlException

setResourceVRL

protected void setResourceVRL(VRL linkTarget)

_loadFrom

protected void _loadFrom(VNode vnode)
                  throws VlException
Load data from (VStreamReadable) VNode

Throws:
VlException

_loadFrom

protected void _loadFrom(java.io.InputStream inps)
                  throws VlException
Throws:
VlException

getAttribute

public VAttribute getAttribute(java.lang.String name)
                        throws VlException
Description copied from class: VNode
This is the single method a Node has to implement so that attributes can be fetched. subclasses can override this method and do a super.getAttribute first to check whether the superclass provides an attribute name.

Overrides:
getAttribute in class VNode
Throws:
VlException

delete

public boolean delete()
               throws VlException
Description copied from interface: VEditable
Delete specified resource.

Specified by:
delete in interface VEditable
Throws:
VlException

getAttributeNames

public java.lang.String[] getAttributeNames()
Description copied from class: VNode
Get the names of the attributes this resource has

Overrides:
getAttributeNames in class VNode

checkAndStoreNewServerInfo

protected void checkAndStoreNewServerInfo()
                                   throws VlException
Throws:
VlException

getInputStream

public java.io.InputStream getInputStream()
                                   throws VlException
Description copied from interface: VStreamReadable
Create InputStream to read from this (remote) resource.

Note that not all protocols support 'partially' reading from a remote file. Currently both Jargon's SRB and Java's File type support Input and OutputStreams !

Specified by:
getInputStream in interface VStreamReadable
Returns:
java.io.InputStream object
Throws:
VlException
See Also:
InputStream