wt.folder
Class FolderLogic

java.lang.Object
  extended bywt.folder.FolderLogic

final class FolderLogic
extends Object

Server-only utility class with multi-object implementations of the core folder operations. Access controls are applied to the results of these methods unless otherwise documented.

Supported API: false

Extendable: false


Nested Class Summary
private static class FolderLogic.FolderChange
          Utility class used to manage the folder change operation
private static class FolderLogic.FolderPropertyApplier
          Utilty class used by both changeFolder and prepareForCheckin to update the membership and related cookies of a collection of entries
private static class FolderLogic.PathData
          Utility class used by getFoldersByPath
 
Field Summary
private static String BRANCH_ID
           
private static String CABINET_ID
           
private static String CLASSNAME
           
private static boolean DEBUG
           
private static String DOMAIN_ID
           
private static boolean FEEDBACK
           
private static String FOLDER_SEPARATOR_STRING
           
private static Map ITERATED_FOLDER_ENTRY_CACHE
           
private static RefreshSpec LINK_ONLY_NO_ACCESS
           
private static RefreshSpec LOCK_NO_ACCESS
           
private static DebugWriter LOG
           
private static String RESOURCE
           
private static String SHARED_OBJECT
           
private static String SHARED_VERSION
           
private static String TARGET_CONTAINER
           
private static String TARGET_FOLDER_CLASSNAME
           
private static String TARGET_FOLDER_ID
           
 
Constructor Summary
(package private) FolderLogic()
           
 
Method Summary
(package private) static WTSet changeFolders(WTValuedMap targets_to_destinations, StandardFolderService service)
          Change the folder of the given set of target entries to map to the corresponding new destinations
(package private) static WTValuedMap createMemberships(WTValuedMap entries_to_destinations)
          Store membership links for the given entry-to-folder mappings
(package private) static WTValuedMap getCabinetBasedToCabinetMap(WTCollection objects)
          Get the cabinets for the given set of CabinetBased objects.
(package private) static WTValuedMap getCabinetBasedToFolderMap(WTCollection objects, AccessPermission permission)
          Get the parent folders for the given collection of CabinetBased objects
private static WTValuedMap getCabinetBasedToFolderMap(WTCollection objects, AccessPermission permission, WTValuedMap memberships)
          Same as getCabinetBasedToFolderMap(WTCollection,AccessPermission), except that it uses the given mapping of FolderEntry objects to their corresponding memberships, as opposed to querying for them.
(package private) static WTKeyedMap getCabinetBasedToLocationMap(WTCollection objects)
          Get the locations for the given CabinetBased objects.
(package private) static WTKeyedMap getCabinetBasedToPathMap(WTCollection objects)
          Get the paths for the given CabinetBased objects.
(package private) static WTList getCabinetsByName(WTList containers, List names, boolean read_only, AccessPermission permission)
          Get the cabinets that correspond to the given name/container pairs.
(package private) static WTKeyedMap getContainerToCabinetNamesMap(WTCollection containers, boolean shared_only)
          Get a mapping of the given containers to the names of their cabinets that the current user has read access to
(package private) static WTKeyedMap getContainerToCabinetsMap(WTCollection containers, boolean shared_only, boolean read_only, AccessPermission permission)
          Get a mapping of the given containers to their cabinets
(package private) static WTValuedMap getContentsToMembershipsMap(WTSet folders, Class entry_class, boolean include_shares, AccessPermission permission)
          Get the contents of the given set of folders.
(package private) static WTValuedMap getEntryToMembershipMap(WTCollection entries, boolean inflate_folders, AccessPermission permission)
          Get the FolderMemberships for the given entries.
(package private) static WTKeyedMap getEntryToMembershipMap(WTCollection entries, boolean inflate_folders, AccessPermission permission, boolean throw_exceptions)
          Gets the FolderMemberships for the given entries.
(package private) static WTList getFoldersByPath(WTList containers, List paths, boolean read_only, AccessPermission permission)
          Get the folders that correspond to the given path/container pairs.
(package private) static WTKeyedMap getFolderToContentsMap(WTSet folders, AccessPermission permission)
          Get the contents of the given set of folders.
(package private) static WTKeyedMap getFolderToContentsMap(WTSet folders, Class entry_class, boolean include_shares, AccessPermission permission)
          Get the contents of the given set of folders.
private static List getIteratedFolderEntries(Class entry_class)
          Gets the subclasses of the givne entry class that are iterated, and caches the result
(package private) static WTKeyedMap getParentToSubFoldersMap(WTCollection parents, boolean read_only, AccessPermission permission)
          Get a mapping of the parent folders to their accessible subfolders
private static StatementSpec getStatementForContents(long[] folder_ids, List excludes, Class entry_class, boolean select_links, boolean include_shares)
          Private utility method that creates the spec used in getFolderContents
(package private) static WTValuedMap getSubFolderToParentMap(WTCollection subfolders, boolean read_only, AccessPermission permission)
          Get the parent folders for the given collection of SubFolders
(package private) static void prepareForCheckin(WTValuedMap checkedout_to_working_copies)
          Cleans up the folder membership for working copies that will not asusme the folder membership of their corresponding checked out copy.
(package private) static void validate(WTCollection collection, AccessPermission permission)
          Validates that the user has the permission to the collection, if the permission is non-null
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

DEBUG

private static final boolean DEBUG

LOG

private static final DebugWriter LOG

FOLDER_SEPARATOR_STRING

private static final String FOLDER_SEPARATOR_STRING

TARGET_CONTAINER

private static final String TARGET_CONTAINER
See Also:
Constant Field Values

TARGET_FOLDER_ID

private static final String TARGET_FOLDER_ID
See Also:
Constant Field Values

TARGET_FOLDER_CLASSNAME

private static final String TARGET_FOLDER_CLASSNAME
See Also:
Constant Field Values

SHARED_OBJECT

private static final String SHARED_OBJECT
See Also:
Constant Field Values

SHARED_VERSION

private static final String SHARED_VERSION
See Also:
Constant Field Values

BRANCH_ID

private static final String BRANCH_ID
See Also:
Constant Field Values

CABINET_ID

private static final String CABINET_ID
See Also:
Constant Field Values

DOMAIN_ID

private static final String DOMAIN_ID
See Also:
Constant Field Values

ITERATED_FOLDER_ENTRY_CACHE

private static final Map ITERATED_FOLDER_ENTRY_CACHE

LOCK_NO_ACCESS

private static final RefreshSpec LOCK_NO_ACCESS

LINK_ONLY_NO_ACCESS

private static final RefreshSpec LINK_ONLY_NO_ACCESS

FEEDBACK

private static final boolean FEEDBACK
Constructor Detail

FolderLogic

FolderLogic()
Method Detail

createMemberships

static WTValuedMap createMemberships(WTValuedMap entries_to_destinations)
                              throws WTException
Store membership links for the given entry-to-folder mappings

Returns:
A mapping of FolderEntrys to their newly created membership links
Throws:
WTException

changeFolders

static WTSet changeFolders(WTValuedMap targets_to_destinations,
                           StandardFolderService service)
                    throws WTException
Change the folder of the given set of target entries to map to the corresponding new destinations

Parameters:
targets_to_destinations - A mapping of FolderEntry to destination Folders
service - A reference to the folder service
Returns:
The set of updated FolderEntrys
Throws:
WTException

prepareForCheckin

static final void prepareForCheckin(WTValuedMap checkedout_to_working_copies)
                             throws WTException
Cleans up the folder membership for working copies that will not asusme the folder membership of their corresponding checked out copy.

Parameters:
checkedout_to_working_copies - A mapping of checked out to working copies
Throws:
WTException

getContainerToCabinetsMap

static WTKeyedMap getContainerToCabinetsMap(WTCollection containers,
                                            boolean shared_only,
                                            boolean read_only,
                                            AccessPermission permission)
                                     throws WTException
Get a mapping of the given containers to their cabinets

Parameters:
containers - The containers to search in
shared_only - Whether or not to limit the result to shared cabinets
read_only - Whether or not to return cached instances of the cabinets
permission - The permission to filter the resulting cabinets by. If the permission is null, then no access control is applied to the cabinets
Returns:
A map of containers to WTSets of their cabinets that meet the specified criteria
Throws:
WTException

getContainerToCabinetNamesMap

static WTKeyedMap getContainerToCabinetNamesMap(WTCollection containers,
                                                boolean shared_only)
                                         throws WTException
Get a mapping of the given containers to the names of their cabinets that the current user has read access to

Parameters:
containers - The containers to search in
shared_only - Whether or not to limit the result to shared cabinets
Returns:
A map of containers to Sets of their accessible cabinet names
Throws:
WTException

getParentToSubFoldersMap

static WTKeyedMap getParentToSubFoldersMap(WTCollection parents,
                                           boolean read_only,
                                           AccessPermission permission)
                                    throws WTException
Get a mapping of the parent folders to their accessible subfolders

Parameters:
parents - The parent folders to search in
read_only - Whether or not to return cached instances of the subfolders
permission - The permission to filter the resulting subfolders by. If the permission is null, then no access control is applied to the subfolders
Returns:
A map of the parent folders to WTSets of their subfolders
Throws:
WTException

getCabinetBasedToCabinetMap

static WTValuedMap getCabinetBasedToCabinetMap(WTCollection objects)
                                        throws WTException
Get the cabinets for the given set of CabinetBased objects. param objects

Returns:
A mapping of the CabinetBased objects to their cabinets
Throws:
WTException - If the user doesn't have access to any of the objects' cabinets

getSubFolderToParentMap

static WTValuedMap getSubFolderToParentMap(WTCollection subfolders,
                                           boolean read_only,
                                           AccessPermission permission)
                                    throws WTException
Get the parent folders for the given collection of SubFolders

Parameters:
read_only - Whether or not to return cached instances of the parent Folders
permission - The permission that the current user must have to the resulting Folders. If this is null, then no access control checking is done on the folders
Returns:
A mapping of the subfolders to their parent folders
Throws:
FolderNotFoundException - If the current user doesn't have the specified permission to any of the resulting folders
WTException

getCabinetBasedToFolderMap

static final WTValuedMap getCabinetBasedToFolderMap(WTCollection objects,
                                                    AccessPermission permission)
                                             throws WTException
Get the parent folders for the given collection of CabinetBased objects

Parameters:
objects - A collection of CabinetBased objects
permission - The permission that the current user must have to the resulting Folders. If this is null, then no access control checking is done on the folders
Returns:
A mapping of the entries to their parent folders
Throws:
FolderNotFoundException - If the current user doesn't have the required permission to any of the resulting folders
WTException

getCabinetBasedToFolderMap

private static final WTValuedMap getCabinetBasedToFolderMap(WTCollection objects,
                                                            AccessPermission permission,
                                                            WTValuedMap memberships)
                                                     throws WTException
Same as getCabinetBasedToFolderMap(WTCollection,AccessPermission), except that it uses the given mapping of FolderEntry objects to their corresponding memberships, as opposed to querying for them. The implementation will inflate the membership's folder roles

Parameters:
objects - The objects to get folders for
permission - The permission that the user must have on the resulting folders, or null
memberships - A set of pre-queried entry-to-membership mappings. May be null, in which case the links are queried for.
Returns:
WTValuedMap
Throws:
WTException

getEntryToMembershipMap

static WTValuedMap getEntryToMembershipMap(WTCollection entries,
                                           boolean inflate_folders,
                                           AccessPermission permission)
                                    throws WTException
Get the FolderMemberships for the given entries.

Parameters:
entries -
inflate_folders - When true, the folder references on the returned membership links are inflated.
permission - When inflate_folders is true, the current user must have this permission to the resulting memberships' inflated folders. If null, then the results are not filtered by access control
Returns:
A mapping of entries to their FolderMemberships
Throws:
FolderNotFoundException - If the user does not have the specified permission to any of the resulting memberships' inflated folders
WTException

getEntryToMembershipMap

static WTKeyedMap getEntryToMembershipMap(WTCollection entries,
                                          boolean inflate_folders,
                                          AccessPermission permission,
                                          boolean throw_exceptions)
                                   throws WTException
Gets the FolderMemberships for the given entries.

Parameters:
entries -
inflate_folders - When true, the folder references on the returned membership links are inflated.
permission - When inflate_folders is true, the current user must have this permission to the resulting memberships' inflated folders. If null, then the results are not filtered by access control
throw_exceptions - When false, the resulting map may contain exceptions as values instead of FolderMemberships
Returns:
A mapping of entries to their FolderMemberships, or to FolderExceptions if throw_exceptions is false and there was a problem getting the membership for the entry
Throws:
FolderNotFoundException - If the user does not have the specified permission to any of the resulting memberships' inflated folders
WTException

getCabinetBasedToLocationMap

static final WTKeyedMap getCabinetBasedToLocationMap(WTCollection objects)
                                              throws WTException
Get the locations for the given CabinetBased objects. The current user must have read access to all of their ancestor folders.

Parameters:
objects - The CabinetBased objects to find locations for
Returns:
A mapping of CabinetBased objects to locations
Throws:
FolderNotFoundException - If the current user doesn't have read access to any of the objects' ancestor folders
WTException

getCabinetBasedToPathMap

static final WTKeyedMap getCabinetBasedToPathMap(WTCollection objects)
                                          throws WTException
Get the paths for the given CabinetBased objects. The path includes the folder location of the object along with its own name

Returns:
A mapping of objects to paths
Throws:
FolderNotFoundException - If the current user doesn't have read access to any of the objects' ancestor folders
WTException

getCabinetsByName

static WTList getCabinetsByName(WTList containers,
                                List names,
                                boolean read_only,
                                AccessPermission permission)
                         throws WTException
Get the cabinets that correspond to the given name/container pairs. This API needs to be list-based since neither the names nor the containers can provide a unique key for use in a map

Parameters:
containers - The containers within which the corresponding name should be looked for. This may either have as many elements as names, or have a single element used with each name
names - The cabinet names to find folders for
read_only - Whether or not to return cached instances of the Cabinets
permission - If non-null, the user must have the given permission to the resulting cabinets
Returns:
A WTList of Cabinets corresponding to the order in the name/container list
Throws:
FolderNotFoundException - If any of the cabinets can't be found, or if the current user doesn't have read access to any of the cabinets
WTException

getFoldersByPath

static WTList getFoldersByPath(WTList containers,
                               List paths,
                               boolean read_only,
                               AccessPermission permission)
                        throws WTException
Get the folders that correspond to the given path/container pairs. This API needs to be list-based since neither the paths nor the containers can provide a unique key for use in a map

Parameters:
containers - The containers within which the corresponding path should be looked for. This may either have as many elements as paths, or have a single element used with each name
paths - The folder paths to find folders for
read_only - Whether or not to return cached instances of the folders
permission - If non-null, the user must have the given permission to the resulting subfolders
Returns:
A WTList of Folders corresponding to the order in the path/container list
Throws:
FolderNotFoundException - If any of the folders can't be found, or if the current user doesn't have read access to any of the requested folders -or- to any of their parent folders
WTException

getFolderToContentsMap

static WTKeyedMap getFolderToContentsMap(WTSet folders,
                                         AccessPermission permission)
                                  throws WTException
Get the contents of the given set of folders. Objects that are shared into the folders are included

Parameters:
folders - The folders to search in
permission - The permission to filter the contents by. If this is null, then the results are not filtered by access control
Returns:
A WTKeyedMap of parent folders to WTSets of their contents
Throws:
WTException

getFolderToContentsMap

static WTKeyedMap getFolderToContentsMap(WTSet folders,
                                         Class entry_class,
                                         boolean include_shares,
                                         AccessPermission permission)
                                  throws WTException
Get the contents of the given set of folders.

Parameters:
folders - The folders to search in
entry_class - The class of FolderEntry to look for
include_shares - Whether or not to include entries shared into the folder
permission - The permission to filter the contents by. If this is null, then the results are not filtered by access control
Returns:
A WTKeyedMap of parent folders to WTSets of their contents
Throws:
WTException

getContentsToMembershipsMap

static WTValuedMap getContentsToMembershipsMap(WTSet folders,
                                               Class entry_class,
                                               boolean include_shares,
                                               AccessPermission permission)
                                        throws WTException
Get the contents of the given set of folders.

Parameters:
folders - The folders to search in
entry_class - The class of FolderEntry to look for
include_shares - Whether or not to include objects that are shared into the folders
permission - The permission to filter the contents by. If this is null, then the results are not filtered by access control
Returns:
A WTValuedMap of the contents of the given folders to their memberships or sharemaps (if include shares is enabled). The memberships contain folder references that are connected back to the folder references in the input collection
Throws:
WTException

getStatementForContents

private static final StatementSpec getStatementForContents(long[] folder_ids,
                                                           List excludes,
                                                           Class entry_class,
                                                           boolean select_links,
                                                           boolean include_shares)
                                                    throws WTException
Private utility method that creates the spec used in getFolderContents

Parameters:
folder_ids - The folder oids to look for
excludes - The List of folder classes that do not need to be queried on
entry_class - The class of FolderEntry to look for
include_shares - Whether or not to include entries shared into the folder
Returns:
A StatementSpec that selects the classname and oid of the entry followed by the classname and oid of the entry's parent folder
Throws:
WTException

getIteratedFolderEntries

private static final List getIteratedFolderEntries(Class entry_class)
                                            throws WTException
Gets the subclasses of the givne entry class that are iterated, and caches the result

Parameters:
entry_class -
Returns:
A List of Classes that both entry_class and Iterated are assignable from
Throws:
WTException

validate

static void validate(WTCollection collection,
                     AccessPermission permission)
              throws WTException
Validates that the user has the permission to the collection, if the permission is non-null

Parameters:
collection -
permission - May be null
Throws:
FolderNotFoundException - If the permission check fails
WTException