2.17.2: 2011-06-17

net.sf.basedb.core
Class Trashcan

java.lang.Object
  extended by net.sf.basedb.core.Trashcan

public class Trashcan
extends Object

This class contains functionality to manage items that have been marked for deletion.

Version:
2.0
Author:
nicklas
Last modified
$Date: 2008-09-11 22:11:02 +0200 (Thu, 11 Sep 2008) $

Field Summary
private static boolean isDebug
           
private static Logger log
          Log trashcan events.
 
Constructor Summary
Trashcan()
           
 
Method Summary
static int delete(SessionControl sc, Collection<? extends Identifiable> items, boolean ignoreFlag, ProgressReporter progress)
          Delete items permanently.
static int deleteAll(SessionControl sc, ProgressReporter progress)
          Delete all items in the trashcan of the logged in user.
static ResultList<Removable> getItems(DbControl dc, Item itemType, int firstItem, int maxItems)
           
static ResultList<Removable> getItems(DbControl dc, Set<Item> itemTypes, int firstItem, int maxItems)
          Load all items flagged for deletion that are owned by the logged in user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final Logger log
Log trashcan events.


isDebug

private static final boolean isDebug
Constructor Detail

Trashcan

public Trashcan()
Method Detail

getItems

public static ResultList<Removable> getItems(DbControl dc,
                                             Item itemType,
                                             int firstItem,
                                             int maxItems)
                                      throws BaseException
Throws:
BaseException
See Also:
getItems(DbControl, Set, int, int)

getItems

public static ResultList<Removable> getItems(DbControl dc,
                                             Set<Item> itemTypes,
                                             int firstItem,
                                             int maxItems)
                                      throws BaseException
Load all items flagged for deletion that are owned by the logged in user.

Parameters:
dc - The DbControl to use for database access
itemTypes - Limit the list to only return items of the types, included in the set, use null or an empty set to return items of all types
firstItem - The index of the first item to return (0-based)
maxItems - The maximum number of items to return, or 0 to return all items
Returns:
A list containing removable items
Throws:
BaseException - If there is an error of some kind
Since:
2.7.1

delete

public static int delete(SessionControl sc,
                         Collection<? extends Identifiable> items,
                         boolean ignoreFlag,
                         ProgressReporter progress)
                  throws BaseException
Delete items permanently. This method only delete items that Other items are ignored. This method may have to open several transactions to be able to delete as many items as possible. This means that this operation is not atomic and if an exception is thrown some items may have been deleted and some may not.

Parameters:
sc - The session control to use for connecting to the database
items - The items to remove
ignoreFlag - TRUE to also remove items that hasn't been flagged for removal
progress - An optional progress reporter
Returns:
The number of deleted items
Throws:
BaseException - If an item can't be deleted.
Since:
2.4

deleteAll

public static int deleteAll(SessionControl sc,
                            ProgressReporter progress)
Delete all items in the trashcan of the logged in user. This method calls getItems(DbControl, Item, int, int) to load all items that have been flagged for removal and then delete(SessionControl, Collection, boolean, ProgressReporter) to remove those items. See the delete for more information about transactions.

Parameters:
sc - The session control to use for connecting to the database
progress - An optional progress reporter
Returns:
The number of deleted items
Since:
2.4

2.17.2: 2011-06-17