Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.acs.damsel.srvr.db
Class DBUtils  view DBUtils download DBUtils.java

java.lang.Object
  extended byorg.acs.damsel.srvr.db.DBUtils

public class DBUtils
extends java.lang.Object

Title: Database utility method package

Description: This singleton class contains the high level methods for the AssetDB class. Methods include: the basic constructor, getPermissions, browse, and search, getCollections, getUsers, etc..

Version:
1.0

Field Summary
private static DBUtils instance
           
private static org.apache.log4j.Logger log
           
private  MidAssetDB midAssetDB
           
 
Constructor Summary
private DBUtils()
          Constructor for DBUtils
 
Method Summary
 void addAssetToCollection(java.lang.String fileName, java.lang.String collectionName)
          Method to add indicated existing asset to indicated existing collection only if asset is not already in that collection
 org.acs.damsel.srvr.collection.CollectionView advancedSearch(org.acs.damsel.srvr.search.AdvancedSearchParams params)
          This is a method that assists the SearchMgr by accessing the database and performing an advanced search given parameters from an AdvancedSearch params object.
 org.acs.damsel.srvr.collection.CollectionView browseDB(java.lang.String browseChar, java.lang.String tag, java.lang.String collectionSelect)
          This method browses through the the current collection view and returns all assets begin with the browseChar and whose tag mathces the tag.
 boolean canDoHighPerm(java.lang.String username, java.lang.String colName)
          Checks if a specified user is allowed to do a specified action.
 boolean canDoLowPerm(java.lang.String username, java.lang.String action, java.lang.String table, java.lang.String keyName, java.lang.String keyValue)
          A high-level method that determines if a user has a certain low level permission.
private  void clearVectors(java.util.Vector resultNames, java.util.Vector tableNames, java.util.Vector columnNames, java.util.Vector columnValues)
           
static java.util.Vector decode(java.util.Vector vector)
          Searches a Vector of Strings and decodes two single quotes as one single quote.
static java.lang.String encode(java.lang.String str)
          Searches a String and encodes single quotes as two single quotes.
static java.util.Vector encode(java.util.Vector vector)
          Searches a Vector of Strings and encodes single quotes as two single quotes.
 java.util.Vector getEditableCollections(org.acs.damsel.srvr.user.User user)
          This method returns a vector of collectionNames (Strings) editable by the specified user.
 java.util.Vector getEditableSchemas(org.acs.damsel.srvr.user.User user)
          This method returns a vector of strings containing all of the schema names that can be edited by user.
 Table getOrphanedAssets()
          This method returns all of the orphans in the assets Table
 java.lang.String getPermissions(int permissionID)
          This method will take in an integer representing the permissionID of a group of permissions as stored in the database.
 int getPermissions(java.lang.String perm)
          This method returns the permissionID associated with a set of permissions of the form "rwdrwdrwd" where the first set of "rwd" applies to the owner, the second set applies to the group, and the third set applies to others.
 java.util.Vector getPermissionsList()
          This method returns all of the permissions that the person can do.
 java.util.Vector getUsersCollections(org.acs.damsel.srvr.user.User user)
          This method returns a vector of strings containing all of the names of the collections that the user can view.
 org.acs.damsel.srvr.collection.CollectionView getUsersFavorites(org.acs.damsel.srvr.user.User user)
          This method will take in a user object and return the associated assets stored in the usersfavorites table in the database as a CollectionView.
 java.util.Vector getViewableCollections(org.acs.damsel.srvr.user.User user)
          This method returns a vector of collection that the user has rights to view.
 java.lang.String hash(java.lang.String input)
          Calculates the SHA-1 hash of the input string and returns the hash as a string of hexadecimal numbers representing the bytes of the hash.
static DBUtils instance()
          This is to be used instead of the construction because it is a sigleton class.
 boolean isCollectionPrivate(java.lang.String collectionName)
          This method determines of the specified collection is private.
 boolean isUserInGroup(java.lang.String userName, java.lang.String groupName)
          This method takes in the name of a user and a group and checks if the user is in the group in the database.
 org.acs.damsel.srvr.collection.CollectionView simpleSearch(java.lang.String keyword, java.lang.String tag, java.lang.String collectionSelect)
          Constructs a SQL query for the given keyword and returns the result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static DBUtils instance

log

private static org.apache.log4j.Logger log

midAssetDB

private MidAssetDB midAssetDB
Constructor Detail

DBUtils

private DBUtils()
         throws java.sql.SQLException
Constructor for DBUtils

Method Detail

instance

public static DBUtils instance()
                        throws java.sql.SQLException
This is to be used instead of the construction because it is a sigleton class. Establishes a connection to the database if one does not already exist and throws a SQLException if an error occurs.


simpleSearch

public org.acs.damsel.srvr.collection.CollectionView simpleSearch(java.lang.String keyword,
                                                                  java.lang.String tag,
                                                                  java.lang.String collectionSelect)
                                                           throws java.sql.SQLException
Constructs a SQL query for the given keyword and returns the result. Throws a SQLException if the SQL is malformed, there is not a database connection, etc.


advancedSearch

public org.acs.damsel.srvr.collection.CollectionView advancedSearch(org.acs.damsel.srvr.search.AdvancedSearchParams params)
                                                             throws java.sql.SQLException
This is a method that assists the SearchMgr by accessing the database and performing an advanced search given parameters from an AdvancedSearch params object. It returns a CollectionView containing all Assets matching the specified parameters.


canDoLowPerm

public boolean canDoLowPerm(java.lang.String username,
                            java.lang.String action,
                            java.lang.String table,
                            java.lang.String keyName,
                            java.lang.String keyValue)
                     throws java.sql.SQLException
A high-level method that determines if a user has a certain low level permission. Note that keyNames and keyValues hold keys for the table being checked. Also, the method automatically returns true if the user is an Administrator.


canDoHighPerm

public boolean canDoHighPerm(java.lang.String username,
                             java.lang.String colName)
                      throws java.sql.SQLException
Checks if a specified user is allowed to do a specified action. This checks high level permissions in the GroupsTable.


clearVectors

private void clearVectors(java.util.Vector resultNames,
                          java.util.Vector tableNames,
                          java.util.Vector columnNames,
                          java.util.Vector columnValues)

browseDB

public org.acs.damsel.srvr.collection.CollectionView browseDB(java.lang.String browseChar,
                                                              java.lang.String tag,
                                                              java.lang.String collectionSelect)
                                                       throws java.sql.SQLException
This method browses through the the current collection view and returns all assets begin with the browseChar and whose tag mathces the tag.


getOrphanedAssets

public Table getOrphanedAssets()
This method returns all of the orphans in the assets Table


hash

public java.lang.String hash(java.lang.String input)
Calculates the SHA-1 hash of the input string and returns the hash as a string of hexadecimal numbers representing the bytes of the hash. This is used to calculate the hashes of passwords.


addAssetToCollection

public void addAssetToCollection(java.lang.String fileName,
                                 java.lang.String collectionName)
                          throws java.sql.SQLException
Method to add indicated existing asset to indicated existing collection only if asset is not already in that collection


encode

public static java.util.Vector encode(java.util.Vector vector)
Searches a Vector of Strings and encodes single quotes as two single quotes.


encode

public static java.lang.String encode(java.lang.String str)
Searches a String and encodes single quotes as two single quotes.


decode

public static java.util.Vector decode(java.util.Vector vector)
Searches a Vector of Strings and decodes two single quotes as one single quote.


getUsersCollections

public java.util.Vector getUsersCollections(org.acs.damsel.srvr.user.User user)
                                     throws java.sql.SQLException
This method returns a vector of strings containing all of the names of the collections that the user can view.


getPermissions

public int getPermissions(java.lang.String perm)
This method returns the permissionID associated with a set of permissions of the form "rwdrwdrwd" where the first set of "rwd" applies to the owner, the second set applies to the group, and the third set applies to others. This method takes in a String of the form "rwdrwdrwd" with any character (dashes are preferable) in the place of permissions that are not held. For example, to return the permissionID associated with an object that has full owner permssions, group read and write, and others read, one would pass in the String "rwdrw-r--". The method would then compute the integer value of the permissionID as stored in the database and return it. NOTE: This method does not query the database, but simply calculates the number based on the same method for calculation used in the database.


getPermissions

public java.lang.String getPermissions(int permissionID)
This method will take in an integer representing the permissionID of a group of permissions as stored in the database. The String returned will be of the form "rwdrwdrwd" with dashes in place of permissions that are not held. The first group of "rwd" corresponds to the owner, second to the group, third to others. For example, a string which has full owner permssions, group read and write, and others read would be "rwdrw-r--". Passing in a permissionID integer will return the appropriate permission string as it would be stored in the database. NOTE: This function does not access the database but determines the string based on the math used to store the permissionID in the database.


getEditableCollections

public java.util.Vector getEditableCollections(org.acs.damsel.srvr.user.User user)
This method returns a vector of collectionNames (Strings) editable by the specified user.


getViewableCollections

public java.util.Vector getViewableCollections(org.acs.damsel.srvr.user.User user)
This method returns a vector of collection that the user has rights to view.


getEditableSchemas

public java.util.Vector getEditableSchemas(org.acs.damsel.srvr.user.User user)
This method returns a vector of strings containing all of the schema names that can be edited by user.


isCollectionPrivate

public boolean isCollectionPrivate(java.lang.String collectionName)
This method determines of the specified collection is private.


getPermissionsList

public java.util.Vector getPermissionsList()
                                    throws java.sql.SQLException
This method returns all of the permissions that the person can do.


isUserInGroup

public boolean isUserInGroup(java.lang.String userName,
                             java.lang.String groupName)
                      throws java.sql.SQLException
This method takes in the name of a user and a group and checks if the user is in the group in the database.


getUsersFavorites

public org.acs.damsel.srvr.collection.CollectionView getUsersFavorites(org.acs.damsel.srvr.user.User user)
                                                                throws java.sql.SQLException
This method will take in a user object and return the associated assets stored in the usersfavorites table in the database as a CollectionView. in the usersfavorites table in the database as a CollectionView.