Package ru.bgcrm.dao
Class FileDataDAO
java.lang.Object
ru.bgcrm.dao.CommonDAO
ru.bgcrm.dao.FileDataDAO
Files DAO. Stores metadata in DB and bodies in filesystem.
-
Nested Class Summary
Nested classes/interfaces inherited from class ru.bgcrm.dao.CommonDAO
CommonDAO.ObjectExtractor<T>, CommonDAO.RecordUpdater<T extends Id>
-
Field Summary
Fields inherited from class ru.bgcrm.dao.CommonDAO
con, SQL_AND, SQL_DELETE, SQL_DELETE_FROM, SQL_DESC, SQL_DISTINCT, SQL_FROM, SQL_GROUP_BY, SQL_INNER_JOIN, SQL_INSERT_IGNORE, SQL_INSERT_INTO, SQL_LEFT_JOIN, SQL_LIMIT, SQL_ON_DUP_KEY_UPDATE, SQL_ORDER_BY, SQL_REPLACE, SQL_SELECT, SQL_SELECT_ALL_FROM, SQL_SELECT_COUNT_ROWS, SQL_SET, SQL_UNION_ALL, SQL_UPDATE, SQL_VALUES, SQL_WHERE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionSetssecret
,time
forfileData
and inserts the entity in DB table.void
Deletes file entity and the related file in a filesystem.Gets file object for a given file data.static FileData
Loads file entity from a result set.Selects file entities with given IDs, ordered by them.boolean
moveBatch
(int batchSize) Moves batch of files placed in the root dir to subdirectories yyyy/MM/dd.stat()
Storage directory statistics.Methods inherited from class ru.bgcrm.dao.CommonDAO
deleteById, foundRows, getById, getGroupedIds, getGroupedIds, getIds, getIds, getPageLimit, getPeriodSql, lastInsertId, setPeriodParamValue, setRecordCount, update, updateColumn, updateIds, updateIds, updateOrInsert
-
Constructor Details
-
FileDataDAO
Constructor. Creates a store directory if not exists.- Parameters:
con
- might be null if onlygetFile(FileData)
is used andtime
is already set.
-
-
Method Details
-
list
Selects file entities with given IDs, ordered by them.- Parameters:
ids
- the IDs.- Returns:
- Throws:
SQLException
-
add
Setssecret
,time
forfileData
and inserts the entity in DB table.- Parameters:
fileData
- file data.- Returns:
- output stream to the related file in filesystem.
- Throws:
Exception
-
delete
Deletes file entity and the related file in a filesystem.- Parameters:
fileData
- the file entity.- Throws:
Exception
-
getFromRs
Loads file entity from a result set.- Parameters:
rs
- the result set.prefix
-- Returns:
- Throws:
SQLException
-
getFile
Gets file object for a given file data. File'stime
is loaded from DB case if not defined.- Parameters:
fileData
-- Returns:
- Throws:
SQLException
-
stat
Storage directory statistics.- Returns:
-
moveBatch
Moves batch of files placed in the root dir to subdirectories yyyy/MM/dd.- Parameters:
batchSize
- batch size.- Returns:
- is there something more to move.
- Throws:
SQLException
IOException
-