org.jdesktop.wonderland.client.assetmgr
Class AssetDB

java.lang.Object
  extended by org.jdesktop.wonderland.client.assetmgr.AssetDB

public class AssetDB
extends java.lang.Object

The AssetDB class represents the client-side cache of assets. The database itself simply stores the entries found in the cache; the cached assets are actually stored in a corresponding directorly.

Author:
paulby, Jordan Slott

Nested Class Summary
static class AssetDB.AssetDBRecord
          Represents a record in the Asset DB
 
Constructor Summary
AssetDB()
          Default constructor.
 
Method Summary
 void addAsset(AssetDB.AssetDBRecord assetRecord)
          Adds a new asset to database.
 void deleteAsset(AssetID assetID)
          Removes an asset given its unique identifying URI and checksum.
 void disconnect()
          Disconnects from the database.
 AssetDB.AssetDBRecord getAsset(AssetID assetID)
          Return the asset record for the supplied unique asset ID, or null if the asset described by the ID is not in the cache.
 java.util.List<AssetDB.AssetDBRecord> getAssetList(AssetURI assetURI)
          Returns a list of asset records for the unique asset uri.
 long getTotalSize()
          Computes and returns the sum of all of the assets.
 void listAssets()
          Prints out all of the assets to stdout
static void main(java.lang.String[] args)
          Main method that has a simple command-line interface to test the database.
 void updateAsset(AssetDB.AssetDBRecord assetRecord)
          Updates an existing asset in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssetDB

public AssetDB()
        throws AssetDBException
Default constructor.

Throws:
AssetDBException
Method Detail

disconnect

public void disconnect()
Disconnects from the database.


addAsset

public void addAsset(AssetDB.AssetDBRecord assetRecord)
              throws java.sql.SQLException
Adds a new asset to database. Throws a SQLException upon error, or if the asset already exists in the database.

Parameters:
assetRecord - The asset record to add to the database
Throws:
java.sql.SQLException

updateAsset

public void updateAsset(AssetDB.AssetDBRecord assetRecord)
                 throws java.sql.SQLException
Updates an existing asset in the database. Throws a SQLException upon error.

Parameters:
assetRecrord - The asset record to update
Throws:
java.sql.SQLException

deleteAsset

public void deleteAsset(AssetID assetID)
                 throws java.sql.SQLException
Removes an asset given its unique identifying URI and checksum. Throws SQLException upon error

Parameters:
assetID - The unique ID of the asset (URI, checksum)
Throws:
java.sql.SQLException

getAsset

public AssetDB.AssetDBRecord getAsset(AssetID assetID)
                               throws java.sql.SQLException
Return the asset record for the supplied unique asset ID, or null if the asset described by the ID is not in the cache. Throws SQLException upon error.

Parameters:
assetID - The unique asset ID (URI, checksum)
Returns:
The asset record in the cache, null if not present.
Throws:
java.sql.SQLException

getAssetList

public java.util.List<AssetDB.AssetDBRecord> getAssetList(AssetURI assetURI)
                                                   throws java.sql.SQLException
Returns a list of asset records for the unique asset uri. Returns an empty list if no such assets exists. Throws SQLException upon error

Parameters:
assetURI - The unique uri of the assets to fetch
Returns:
A list of assets that match the uri, an empty list if none
Throws:
java.sql.SQLException

getTotalSize

public long getTotalSize()
                  throws java.sql.SQLException
Computes and returns the sum of all of the assets. Throws a SQLException upon error

Returns:
The size in bytes of all of the assets
Throws:
java.sql.SQLException

listAssets

public void listAssets()
Prints out all of the assets to stdout


main

public static void main(java.lang.String[] args)
                 throws java.net.URISyntaxException,
                        AssetDBException
Main method that has a simple command-line interface to test the database. The usage is: java AssetDB [COMMAND] [ARGS], where COMMAND can be:

LIST: Lists all of the entries in the database ADD: Add an entry to the database, followed by the required data fields

Throws:
java.net.URISyntaxException
AssetDBException


Open Wonderland - http://openwonderland.org