org.vrspace.server.object
Class File

java.lang.Object
  extended byjava.util.Observable
      extended byorg.vrspace.server.VRObject
          extended byorg.vrspace.server.DBObject
              extended byorg.vrspace.server.PublicDBObject
                  extended byorg.vrspace.server.OwnedDBObject
                      extended byorg.vrspace.server.object.File
All Implemented Interfaces:
java.lang.Cloneable, java.util.Observer, Owned
Direct Known Subclasses:
VrmlFile

public class File
extends OwnedDBObject
implements java.util.Observer

A File. This VRObject should be used for files not expected to have a Transform. For example, images, binaries, etc... The contents of the file are pointed to by its url NetResource.


Nested Class Summary
 class File.GZippedUploadFilter
          Implements the uploading of a .wrl file.
 class File.UploadFilter
          Implements file transfer.
 
Field Summary
 int _downloads
           
 long _lastUpdate
           
 int _uploads
           
 java.lang.String name
           
protected static Role ownerRole
           
protected static Role publicRole
           
 NetResource url
           
 
Fields inherited from class org.vrspace.server.DBObject
db
 
Fields inherited from class org.vrspace.server.VRObject
db_id, primitiveMap, primitives
 
Constructor Summary
File()
           
 
Method Summary
static java.lang.String encodeAsURI(java.lang.String preURI)
           
 java.lang.String getClassAndId(Request req)
           
protected  boolean grantAccess(Request req)
           
 void processEvent(Request req)
          Process a request.
 void sendEvent(Request req)
          Overrides OwnedDBObject.sendEvent().
 void set_download(Request req, java.lang.String value)
          Initiate file download.
 void set_upload(Request req, java.lang.String value)
          Initiate file upload.
 void setValue(Request r)
          Overrides PublicDbObject.setValue() .
 void update(java.util.Observable session, java.lang.Object signal)
           
 
Methods inherited from class org.vrspace.server.OwnedDBObject
addOwner, isOwned, notifyOwners, ownershipRequired, removeOwner
 
Methods inherited from class org.vrspace.server.DBObject
delete, get, put, put
 
Methods inherited from class org.vrspace.server.VRObject
arrayToString, canRead, canWrite, clone, equals, fieldToText, fromString, fromText, getClassName, getField, getFields, getId, getID, getMemebers, hasField, hasMethod, isNew, newInstance, sendResponse, setField, setField, setField, setFields, setFields, stringToArray, toString, toText, toText, toText
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public java.lang.String name

url

public NetResource url

_uploads

public int _uploads

_downloads

public int _downloads

_lastUpdate

public long _lastUpdate

publicRole

protected static Role publicRole

ownerRole

protected static Role ownerRole
Constructor Detail

File

public File()
Method Detail

set_upload

public void set_upload(Request req,
                       java.lang.String value)
                throws java.lang.Exception
Initiate file upload. Replaces this File's url and initiates the file transfer by responding to the client with an upload command.

Usage: upload path

Throws:
java.lang.Exception

encodeAsURI

public static java.lang.String encodeAsURI(java.lang.String preURI)
                                    throws java.net.URISyntaxException
Throws:
java.net.URISyntaxException

set_download

public void set_download(Request req,
                         java.lang.String value)
                  throws java.lang.Exception
Initiate file download. Not implemented.

Usage: download dummy_value

Throws:
java.lang.Exception

update

public void update(java.util.Observable session,
                   java.lang.Object signal)
Specified by:
update in interface java.util.Observer

sendEvent

public void sendEvent(Request req)
               throws RequestException
Overrides OwnedDBObject.sendEvent(). This method calls super.sendEvent() and if a RequestException is not thrown, the method exits. Otherwise the method calls setChanged() and then setValue(). In effect, this implements all the functionality of its ancestors, but if the event corresponds to an unknown field or method, simply forwards it to all observers.

Overrides:
sendEvent in class OwnedDBObject
Throws:
RequestException

grantAccess

protected boolean grantAccess(Request req)

processEvent

public void processEvent(Request req)
                  throws RequestException
Description copied from class: OwnedDBObject
Process a request. Called from sendEvent if request comes from owner. Intedend for use by sublcasses, utility function.

Overrides:
processEvent in class OwnedDBObject
Throws:
RequestException

setValue

public void setValue(Request r)
Overrides PublicDbObject.setValue() . Upload/download events are filtered. Clients are notified of all other requests.

Overrides:
setValue in class PublicDBObject

getClassAndId

public java.lang.String getClassAndId(Request req)