public class FileFolderService extends Object implements org.springframework.beans.factory.InitializingBean
Modifier and Type | Field and Description |
---|---|
protected com.mongodb.DBCollection |
collection
The collection of users, which can be reused by derived extensions.
|
static String |
FIELD_CONTEXT |
static String |
FIELD_FILE_COUNT |
static String |
FIELD_FOLDER_COUNT |
static String |
FIELD_ID |
static String |
FIELD_LEVEL |
static String |
FIELD_NAME |
static String |
FIELD_PARENT_PATH |
static String |
FIELD_PATH |
Constructor and Description |
---|
FileFolderService(com.mongodb.DB db,
String collection) |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
long |
countChildFolders(String context,
String path)
Produces a count of the folders that have the given context and path as a parent folder.
|
long |
countEmptyFolders(String context)
Count folders without either subfolders or files
|
void |
createNewFolder(FolderData data)
Create a new folder entry with the given data
|
void |
createNewFolder(String id,
String context,
String path)
Create a new folder entry with the given data.
|
int |
deleteFolder(String context,
String path,
boolean cascade)
Delete a folder entry based on the folder ID
|
protected List<FolderData> |
fromDBCursor(com.mongodb.DBCursor cursor)
Turn a cursor into an array of API-friendly objects
|
protected FolderData |
fromDBObject(com.mongodb.DBObject folderDataObj)
Helper to convert a Mongo DBObject into the API consumable object
Note that null is handled as a null return.
|
List<FolderData> |
getChildFolders(String context,
String path,
int skip,
int limit)
Get a list of folders that have the given context and path as a parent folder.
|
FolderData |
getFolder(String id)
Retrieve a folder by the ID
|
FolderData |
getFolder(String context,
String path)
Retrieve a folder by the path
|
List<FolderData> |
getFoldersByCounts(String context,
Long minLevel,
Long maxLevel,
Long minFolders,
Long maxFolders,
Long minFiles,
Long maxFiles,
int skip,
int limit)
Get a list of folders filtered by the number of child files and/or folders, returning
results sorted according to the parameters supplied.
|
void |
incrementFileCount(String context,
String path,
long fileCountInc)
Increment the count of the files in a folder.
|
void |
incrementFolderCount(String context,
String path,
long folderCountInc)
Increment the count of the subfolders in a folder.
|
public static final String FIELD_ID
public static final String FIELD_CONTEXT
public static final String FIELD_PATH
public static final String FIELD_LEVEL
public static final String FIELD_PARENT_PATH
public static final String FIELD_NAME
public static final String FIELD_FOLDER_COUNT
public static final String FIELD_FILE_COUNT
protected final com.mongodb.DBCollection collection
public FileFolderService(com.mongodb.DB db, String collection)
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
protected FolderData fromDBObject(com.mongodb.DBObject folderDataObj)
protected List<FolderData> fromDBCursor(com.mongodb.DBCursor cursor)
public void createNewFolder(String id, String context, String path)
public void createNewFolder(FolderData data)
public int deleteFolder(String context, String path, boolean cascade)
id
- the folder IDpublic FolderData getFolder(String id)
id
- the folder idpublic FolderData getFolder(String context, String path)
context
- the context in which the folder path is valid (mandatory)path
- the folder path relative to the given contextpublic void incrementFolderCount(String context, String path, long folderCountInc)
context
- the context in which the folder path is valid (mandatory)path
- the folder path relative to the given contextfileCountInc
- the file count increment (can be negative)public void incrementFileCount(String context, String path, long fileCountInc)
context
- the context in which the folder path is valid (mandatory)path
- the folder path relative to the given contextfileCountInc
- the file count increment (can be negative)public long countChildFolders(String context, String path)
/home/tests/a /home/tests/bthen the counts for:
/home/testswill be 2
public long countEmptyFolders(String context)
public List<FolderData> getChildFolders(String context, String path, int skip, int limit)
/home/teststhen the following results can be returned:
/home/tests/a /home/tests/b
context
- the context in which the folder path is valid (mandatory)path
- the path that will be the parent of all child folders returnedskip
- the number of entries to skiplimit
- the number of entries to returnpublic List<FolderData> getFoldersByCounts(String context, Long minLevel, Long maxLevel, Long minFolders, Long maxFolders, Long minFiles, Long maxFiles, int skip, int limit)
context
- the context in which the folder path is valid (mandatory)minLevel
- the minimum folder level to consider (inclusive, optional)maxLevel
- the maximum folder level to consider (inclusive, optional)minFiles
- the minimum number of files in the folder (inclusive, optional)maxFiles
- the maximum number of files in the folder (inclusive, optional)skip
- the number of entries to skiplimit
- the number of entries to returnCopyright © 2005–2018 Alfresco Software. All rights reserved.