Class 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: 2017-05-22 14:35:27 +0200 (må, 22 maj 2017) $
    • Field Detail

      • log

        private static final org.slf4j.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,
                                                     Set<Item> itemTypes,
                                                     int firstItem,
                                                     int maxItems,
                                                     Restriction restriction)
                                              throws BaseException
        Load all items flagged for deletion that are owned by or removed by the logged in user. A restriction may be specified to limit the returned items. Note that separate queries are used for each item type but the same restriction is applied to all of them. It is recommended that the restriction is created with Restrictions.conditionalRestriction(Filter, Restriction, Restriction, boolean) so that a restriction on, for example, the 'name' is only applied to Nameable items.
        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
        restriction - A restriction to apply when loading items
        Returns:
        A list containing removable items
        Throws:
        BaseException - If there is an error of some kind
        Since:
        3.7
      • 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
        • have been marked for deletion (unless the ignoreFlag parameter is set)
        • the logged in user has permission to delete
        • not are used by other items
        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. To avoid multithread-related problems the session control is cloned before being used by this method.
        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