#include <sql_storage.h>
Data Structures | |
| class | AddUpdateTable |
| class | ChangedContainersStr |
Public Member Functions | |
| virtual zmm::String | quote (zmm::String str)=0 |
| virtual zmm::String | quote (int val)=0 |
| virtual zmm::String | quote (unsigned int val)=0 |
| virtual zmm::String | quote (long val)=0 |
| virtual zmm::String | quote (unsigned long val)=0 |
| virtual zmm::String | quote (bool val)=0 |
| virtual zmm::String | quote (char val)=0 |
| virtual zmm::Ref< SQLResult > | select (const char *query, int length)=0 |
| virtual int | exec (const char *query, int length, bool getLastInsertId=false)=0 |
| void | dbReady () |
| zmm::Ref< SQLResult > | select (zmm::Ref< zmm::StringBuffer > buf) |
| int | exec (zmm::Ref< zmm::StringBuffer > buf, bool getLastInsertId=false) |
| virtual void | addObject (zmm::Ref< CdsObject > object, int *changedContainer) |
| virtual void | updateObject (zmm::Ref< CdsObject > object, int *changedContainer) |
| virtual zmm::Ref< CdsObject > | loadObject (int objectID) |
| virtual int | getChildCount (int contId, bool containers, bool items, bool hideFsRoot) |
| virtual zmm::Ref< DBRHash< int > > | getObjects (int parentID, bool withoutContainer) |
| Get all objects under the given parentID. | |
| virtual zmm::Ref < ChangedContainers > | removeObject (int objectID, bool all) |
| Removes the object identified by the objectID from the database. all references will be automatically removed. If the object is a container, all children will be also removed automatically. If the object is a reference to another object, the "all" flag determines, if the main object will be removed too. | |
| virtual zmm::Ref < ChangedContainers > | removeObjects (zmm::Ref< DBRHash< int > > list, bool all=false) |
| Remove all objects found in list. | |
| virtual zmm::Ref< CdsObject > | loadObjectByServiceID (zmm::String serviceID) |
| Loads an object given by the online service ID. | |
| virtual zmm::Ref< zmm::IntArray > | getServiceObjectIDs (char servicePrefix) |
| Return an array of object ID's for a particular service. | |
| virtual int | getTotalFiles () |
| virtual zmm::Ref< zmm::Array < CdsObject > > | browse (zmm::Ref< BrowseParam > param) |
| virtual zmm::Ref< zmm::Array < zmm::StringBase > > | getMimeTypes () |
| virtual zmm::Ref< CdsObject > | findObjectByPath (zmm::String fullpath) |
| Loads a given (pc directory) object, identified by the given path from the database. | |
| virtual int | findObjectIDByPath (zmm::String fullpath) |
| checks for a given (pc directory) object, identified by the given path from the database | |
| virtual zmm::String | incrementUpdateIDs (int *ids, int size) |
| increments the updateIDs for the given objectIDs | |
| virtual zmm::String | buildContainerPath (int parentID, zmm::String title) |
| Builds the container path. Fetches the path of the parent and adds the title. | |
| virtual void | addContainerChain (zmm::String path, zmm::String lastClass, int lastRefID, int *containerID, int *updateID) |
| Adds a virtual container chain specified by path. | |
| virtual zmm::String | getInternalSetting (zmm::String key) |
| virtual void | storeInternalSetting (zmm::String key, zmm::String value)=0 |
| virtual void | updateAutoscanPersistentList (scan_mode_t scanmode, zmm::Ref< AutoscanList > list) |
| virtual zmm::Ref< AutoscanList > | getAutoscanList (scan_mode_t scanmode) |
| virtual void | addAutoscanDirectory (zmm::Ref< AutoscanDirectory > adir) |
| virtual void | updateAutoscanDirectory (zmm::Ref< AutoscanDirectory > adir) |
| virtual void | removeAutoscanDirectoryByObjectID (int objectID) |
| virtual void | removeAutoscanDirectory (int autoscanID) |
| virtual int | getAutoscanDirectoryType (int objectId) |
| returns wheather the given id is an autoscan start point and if yes, if it is persistent | |
| virtual int | isAutoscanDirectoryRecursive (int objectId) |
| returns wheather the given id is an autoscan start point and if yes, if it is recursive | |
| virtual void | autoscanUpdateLM (zmm::Ref< AutoscanDirectory > adir) |
| updates the last modified info for the given AutoscanDirectory in the database | |
| virtual zmm::Ref < AutoscanDirectory > | getAutoscanDirectory (int objectID) |
| returns the AutoscanDirectory for the given objectID or nil if it's not an autoscan start point - scan id will be invalid | |
| virtual int | isAutoscanChild (int objectID) |
| checks if the given object is a direct or indirect child of a recursive autoscan start point | |
| virtual void | checkOverlappingAutoscans (zmm::Ref< AutoscanDirectory > adir) |
| virtual zmm::Ref< zmm::IntArray > | getPathIDs (int objectID) |
| virtual void | shutdown () |
| shutdown the Storage with its possible threads | |
| virtual void | shutdownDriver ()=0 |
| virtual int | ensurePathExistence (zmm::String path, int *changedContainer) |
| Ensures that a container given by it's location on disk is present in the database. If it does not exist it will be created, but it's content will not be added. | |
| virtual zmm::String | getFsRootName () |
| virtual void | clearFlagInDB (int flag) |
| clears the given flag in all objects in the DB | |
Protected Member Functions | |
| SQLStorage () | |
| virtual void | init () |
| virtual void | threadCleanup ()=0 |
| virtual bool | threadCleanupRequired ()=0 |
| virtual void | registerSingleton () |
| void | retain () |
| void | release () |
| int | getRefCount () |
Static Protected Member Functions | |
| static zmm::Ref< Storage > | getInstance () |
| static void | stripAndUnescapeVirtualContainerFromPath (zmm::String path, zmm::String &first, zmm::String &last) |
| static zmm::Ref< Storage > | createInstance () |
| static void * | operator new (size_t size) |
| static void | operator delete (void *ptr) |
Protected Attributes | |
| char | table_quote_begin |
| char | table_quote_end |
| mt_atomic_t | _ref_count |
Static Protected Attributes | |
| static zmm::Ref< Mutex > | mutex |
| static zmm::Ref< Storage > | instance |
| static bool | singletonActive |
Private Member Functions | |
| zmm::String | getRealLocation (int parentID, zmm::String location) |
| zmm::Ref< CdsObject > | createObjectFromRow (zmm::Ref< SQLRow > row) |
| zmm::Ref< CdsObject > | _findObjectByPath (zmm::String fullpath) |
| int | _ensurePathExistence (zmm::String path, int *changedContainer) |
| zmm::Ref< zmm::Array < AddUpdateTable > > | _addUpdateObject (zmm::Ref< CdsObject > obj, bool isUpdate, int *changedContainer) |
| void | _removeObjects (zmm::Ref< zmm::StringBuffer > objectIDs, int offset) |
| zmm::Ref< ChangedContainersStr > | _recursiveRemove (zmm::Ref< zmm::StringBuffer > items, zmm::Ref< zmm::StringBuffer > containers, bool all) |
| virtual zmm::Ref < ChangedContainers > | _purgeEmptyContainers (zmm::Ref< ChangedContainersStr > changedContainersStr) |
| int | _getAutoscanObjectID (int autoscanID) |
| void | _autoscanChangePersistentFlag (int objectID, bool persistent) |
| zmm::Ref< AutoscanDirectory > | _fillAutoscanDirectory (zmm::Ref< SQLRow > row) |
| int | _getAutoscanDirectoryInfo (int objectID, zmm::String field) |
| zmm::Ref< zmm::IntArray > | _checkOverlappingAutoscans (zmm::Ref< AutoscanDirectory > adir) |
| zmm::String | addLocationPrefix (char prefix, zmm::String path) |
| zmm::String | stripLocationPrefix (char *prefix, zmm::String path) |
| zmm::String | stripLocationPrefix (zmm::String path) |
| zmm::Ref< CdsObject > | checkRefID (zmm::Ref< CdsObject > obj) |
| int | createContainer (int parentID, zmm::String name, zmm::String path, bool isVirtual, zmm::String upnpClass, int refID) |
| zmm::String | mapBool (bool val) |
| bool | remapBool (zmm::String field) |
| void | setFsRootName (zmm::String rootName=nil) |
| int | getNextID () |
| void | loadLastID () |
| bool | cacheOn () |
| void | addObjectToCache (zmm::Ref< CdsObject > object, bool dontLock=false) |
| bool | doInsertBuffering () |
| void | addToInsertBuffer (zmm::Ref< zmm::StringBuffer > query) |
| void | flushInsertBuffer (bool dontLock=false) |
| virtual void | _addToInsertBuffer (zmm::Ref< zmm::StringBuffer > query)=0 |
| virtual void | _flushInsertBuffer ()=0 |
Private Attributes | |
| zmm::String | sql_query |
| zmm::String | fsRootName |
| int | lastID |
| zmm::Ref< Mutex > | nextIDMutex |
| zmm::Ref< StorageCache > | cache |
| bool | insertBufferOn |
| bool | insertBufferEmpty |
| int | insertBufferStatementCount |
| int | insertBufferByteCount |
| zmm::Ref< Mutex > | insertBufferMutex |
Definition at line 73 of file sql_storage.h.
| SQLStorage::SQLStorage | ( | ) | [protected] |
Definition at line 129 of file sql_storage.cc.
References INVALID_OBJECT_ID, lastID, table_quote_begin, and table_quote_end.
| virtual void SQLStorage::_addToInsertBuffer | ( | zmm::Ref< zmm::StringBuffer > | query | ) | [private, pure virtual] |
Referenced by addToInsertBuffer().
| Ref< Array< SQLStorage::AddUpdateTable > > SQLStorage::_addUpdateObject | ( | zmm::Ref< CdsObject > | obj, | |
| bool | isUpdate, | |||
| int * | changedContainer | |||
| ) | [private] |
Definition at line 235 of file sql_storage.cc.
References _, _Exception, addLocationPrefix(), CDS_ACTIVE_ITEM_TABLE, CDS_OBJECT_TABLE, checkRefID(), ensurePathExistence(), INVALID_OBJECT_ID, IS_CDS_ACTIVE_ITEM, IS_CDS_CONTAINER, IS_CDS_ITEM, IS_CDS_PURE_ITEM, loadObject(), LOC_FILE_PREFIX, LOC_VIRT_PREFIX, nil, OBJECT_FLAG_ONLINE_SERVICE, OBJECT_FLAG_PLAYLIST_REF, OBJECT_FLAG_USE_RESOURCE_REF, quote(), RefCast, RESOURCE_SEP, select(), split_path(), SQL_NULL, string_ok(), stringHash(), and TQ.
Referenced by addObject(), and updateObject().
| void SQLStorage::_autoscanChangePersistentFlag | ( | int | objectID, | |
| bool | persistent | |||
| ) | [private] |
Definition at line 2112 of file sql_storage.cc.
References _, CDS_OBJECT_TABLE, exec(), INVALID_OBJECT_ID, INVALID_OBJECT_ID_2, OBJECT_FLAG_PERSISTENT_CONTAINER, quote(), and TQ.
Referenced by addAutoscanDirectory(), removeAutoscanDirectory(), removeAutoscanDirectoryByObjectID(), and updateAutoscanDirectory().
| Ref< IntArray > SQLStorage::_checkOverlappingAutoscans | ( | zmm::Ref< AutoscanDirectory > | adir | ) | [private] |
Definition at line 2163 of file sql_storage.cc.
References _, _Exception, AUTOSCAN_TABLE, getPathIDs(), INVALID_OBJECT_ID, loadObject(), log_debug, log_error, mapBool(), nil, quote(), select(), and TQ.
Referenced by addAutoscanDirectory(), checkOverlappingAutoscans(), and updateAutoscanDirectory().
| int SQLStorage::_ensurePathExistence | ( | zmm::String | path, | |
| int * | changedContainer | |||
| ) | [private] |
Definition at line 974 of file sql_storage.cc.
References CDS_ID_FS_ROOT, createContainer(), DIR_SEPARATOR, ensurePathExistence(), StringConverter::f2i(), findObjectByPath(), INVALID_OBJECT_ID, nil, NULL, and split_path().
Referenced by ensurePathExistence().
| Ref< AutoscanDirectory > SQLStorage::_fillAutoscanDirectory | ( | zmm::Ref< SQLRow > | row | ) | [private] |
Definition at line 1925 of file sql_storage.cc.
References INVALID_OBJECT_ID, INVALID_SCAN_ID, LOC_DIR_PREFIX, nil, remapBool(), AutoscanDirectory::remapScanlevel(), AutoscanDirectory::remapScanmode(), string_ok(), stripLocationPrefix(), TimedScanMode, and zmm::String::toInt().
Referenced by getAutoscanDirectory(), and getAutoscanList().
| Ref< CdsObject > SQLStorage::_findObjectByPath | ( | zmm::String | fullpath | ) | [private] |
Definition at line 894 of file sql_storage.cc.
References _, _Exception, addLocationPrefix(), AUTOLOCK, cache, cacheOn(), createObjectFromRow(), DIR_SEPARATOR, LOC_DIR_PREFIX, LOC_FILE_PREFIX, nil, quote(), zmm::String::reduce(), select(), split_path(), SQL_QUERY, string_ok(), stringHash(), and TQD.
Referenced by findObjectByPath(), and findObjectIDByPath().
| virtual void SQLStorage::_flushInsertBuffer | ( | ) | [private, pure virtual] |
Referenced by flushInsertBuffer().
| int SQLStorage::_getAutoscanDirectoryInfo | ( | int | objectID, | |
| zmm::String | field | |||
| ) | [private] |
Definition at line 2080 of file sql_storage.cc.
References AUTOSCAN_TABLE, INVALID_OBJECT_ID, nil, quote(), remapBool(), select(), and TQ.
Referenced by getAutoscanDirectoryType(), and isAutoscanDirectoryRecursive().
| int SQLStorage::_getAutoscanObjectID | ( | int | autoscanID | ) | [private] |
Definition at line 2097 of file sql_storage.cc.
References _, _StorageException, AUTOSCAN_TABLE, INVALID_OBJECT_ID, nil, quote(), select(), string_ok(), and TQ.
Referenced by removeAutoscanDirectory(), and updateAutoscanDirectory().
| Ref< Storage::ChangedContainers > SQLStorage::_purgeEmptyContainers | ( | zmm::Ref< ChangedContainersStr > | changedContainersStr | ) | [private, virtual] |
Definition at line 1670 of file sql_storage.cc.
References _, _Exception, _removeObjects(), cache, cacheOn(), CDS_OBJECT_TABLE, log_debug, MAX_REMOVE_RECURSION, nil, OBJECT_FLAG_PERSISTENT_CONTAINER, quote(), select(), string_ok(), TQ, and TQD.
Referenced by removeObject(), and removeObjects().
| Ref< SQLStorage::ChangedContainersStr > SQLStorage::_recursiveRemove | ( | zmm::Ref< zmm::StringBuffer > | items, | |
| zmm::Ref< zmm::StringBuffer > | containers, | |||
| bool | all | |||
| ) | [private] |
Definition at line 1520 of file sql_storage.cc.
References _, _Exception, _removeObjects(), _StorageException, CDS_OBJECT_TABLE, IS_CDS_CONTAINER, log_debug, MAX_REMOVE_RECURSION, MAX_REMOVE_SIZE, nil, select(), string_ok(), and TQ.
Referenced by removeObject(), and removeObjects().
| void SQLStorage::_removeObjects | ( | zmm::Ref< zmm::StringBuffer > | objectIDs, | |
| int | offset | |||
| ) | [private] |
Definition at line 1417 of file sql_storage.cc.
References AUTOSCAN_TABLE, CDS_ACTIVE_ITEM_TABLE, CDS_OBJECT_TABLE, exec(), log_debug, nil, quote(), remapBool(), select(), SQL_NULL, stripLocationPrefix(), TQ, and TQD.
Referenced by _purgeEmptyContainers(), and _recursiveRemove().
| void SQLStorage::addAutoscanDirectory | ( | zmm::Ref< AutoscanDirectory > | adir | ) | [virtual] |
Implements Storage.
Definition at line 1964 of file sql_storage.cc.
References _, _autoscanChangePersistentFlag(), _checkOverlappingAutoscans(), _Exception, AUTOSCAN_TABLE, CDS_ID_FS_ROOT, DIR_SEPARATOR, exec(), findObjectIDByPath(), FS_ROOT_DIRECTORY, mapBool(), AutoscanDirectory::mapScanlevel(), AutoscanDirectory::mapScanmode(), nil, quote(), SQL_NULL, and TQ.
Referenced by updateAutoscanPersistentList().
| void SQLStorage::addContainerChain | ( | zmm::String | path, | |
| zmm::String | lastClass, | |||
| int | lastRefID, | |||
| int * | containerID, | |||
| int * | updateID | |||
| ) | [virtual] |
Adds a virtual container chain specified by path.
| path | container path separated by '/'. Slashes in container titles must be escaped. | |
| lastClass | upnp:class of the last container in the chain, it is only set when the container is created for the first time. | |
| lastRefID | reference id of the last container in the chain, INVALID_OBJECT_ID indicates that the id will not be set. | |
| containerID | will be filled in by the function | |
| updateID | will be filled in by the function only if it is set to INVALID_OBJECT_ID and it is necessary to update a container. Otherwise it will be left unchanged. |
The function gets a path (i.e. "/Audio/All Music/") and will create the container path if needed. The container ID will be filled in with the object ID of the container that is last in the path. The updateID will hold the objectID of the container that was changed, in case new containers were created during the operation.
Implements Storage.
Definition at line 1073 of file sql_storage.cc.
References addLocationPrefix(), CDS_ID_ROOT, CDS_OBJECT_TABLE, createContainer(), INVALID_OBJECT_ID, LOC_VIRT_PREFIX, nil, NULL, quote(), zmm::String::reduce(), select(), stringHash(), Storage::stripAndUnescapeVirtualContainerFromPath(), TQ, and VIRTUAL_CONTAINER_SEPARATOR.
| String SQLStorage::addLocationPrefix | ( | char | prefix, | |
| zmm::String | path | |||
| ) | [private] |
Definition at line 1107 of file sql_storage.cc.
Referenced by _addUpdateObject(), _findObjectByPath(), addContainerChain(), and createContainer().
Implements Storage.
Definition at line 445 of file sql_storage.cc.
References _, _addUpdateObject(), _Exception, addObjectToCache(), addToInsertBuffer(), AUTOLOCK, cache, cacheOn(), CDS_OBJECT_TABLE, doInsertBuffering(), exec(), flushInsertBuffer(), getNextID(), INVALID_OBJECT_ID, log_debug, nil, quote(), and TQ.
Definition at line 2329 of file sql_storage.cc.
References AUTOLOCK_DEFINE_ONLY, AUTOLOCK_NO_DEFINE, cache, cacheOn(), flushInsertBuffer(), and nil.
Referenced by addObject(), createObjectFromRow(), and updateObject().
| void SQLStorage::addToInsertBuffer | ( | zmm::Ref< zmm::StringBuffer > | query | ) | [private] |
Definition at line 2344 of file sql_storage.cc.
References _addToInsertBuffer(), AUTOLOCK, doInsertBuffering(), flushInsertBuffer(), insertBufferByteCount, insertBufferEmpty, insertBufferStatementCount, and Singleton< Storage >::mutex.
Referenced by addObject().
| void SQLStorage::autoscanUpdateLM | ( | zmm::Ref< AutoscanDirectory > | adir | ) | [virtual] |
updates the last modified info for the given AutoscanDirectory in the database
| adir | the AutoscanDirectory to be updated |
Implements Storage.
Definition at line 2125 of file sql_storage.cc.
References AUTOSCAN_TABLE, exec(), log_debug, quote(), and TQ.
| Ref< Array< CdsObject > > SQLStorage::browse | ( | zmm::Ref< BrowseParam > | param | ) | [virtual] |
Implements Storage.
Definition at line 654 of file sql_storage.cc.
References _, _ObjectNotFoundException, AUTOLOCK, BROWSE_CONTAINERS, BROWSE_DIRECT_CHILDREN, BROWSE_HIDE_FS_ROOT, BROWSE_ITEMS, BROWSE_TRACK_SORT, cache, cacheOn(), CDS_ID_FS_ROOT, CDS_ID_ROOT, CDS_OBJECT_TABLE, createObjectFromRow(), flushInsertBuffer(), getChildCount(), IS_CDS_CONTAINER, log_debug, nil, OBJECT_TYPE_CONTAINER, OBJECT_TYPE_ITEM, quote(), RefCast, select(), SQL_QUERY, TQ, and TQD.
| String SQLStorage::buildContainerPath | ( | int | parentID, | |
| zmm::String | title | |||
| ) | [virtual] |
Builds the container path. Fetches the path of the parent and adds the title.
| parentID | the parent id of the parent container | |
| title | the title of the container to add to the path. It will be escaped. |
Implements Storage.
Definition at line 1052 of file sql_storage.cc.
References _, _Exception, CDS_ID_ROOT, CDS_OBJECT_TABLE, LOC_VIRT_PREFIX, nil, select(), stripLocationPrefix(), TQ, and VIRTUAL_CONTAINER_SEPARATOR.
| bool SQLStorage::cacheOn | ( | ) | [inline, private] |
Definition at line 238 of file sql_storage.h.
Referenced by _findObjectByPath(), _purgeEmptyContainers(), addObject(), addObjectToCache(), browse(), createContainer(), getChildCount(), and loadObject().
| void SQLStorage::checkOverlappingAutoscans | ( | zmm::Ref< AutoscanDirectory > | adir | ) | [virtual] |
Implements Storage.
Definition at line 2158 of file sql_storage.cc.
References _checkOverlappingAutoscans().
Definition at line 203 of file sql_storage.cc.
References _, _Exception, findObjectByPath(), loadObject(), nil, and string_ok().
Referenced by _addUpdateObject().
| void SQLStorage::clearFlagInDB | ( | int | flag | ) | [virtual] |
clears the given flag in all objects in the DB
Implements Storage.
Definition at line 2376 of file sql_storage.cc.
References CDS_OBJECT_TABLE, exec(), and TQ.
| int SQLStorage::createContainer | ( | int | parentID, | |
| zmm::String | name, | |||
| zmm::String | path, | |||
| bool | isVirtual, | |||
| zmm::String | upnpClass, | |||
| int | refID | |||
| ) | [private] |
Definition at line 993 of file sql_storage.cc.
References _, _Exception, addLocationPrefix(), AUTOLOCK, cache, cacheOn(), CDS_OBJECT_TABLE, exec(), flushInsertBuffer(), getNextID(), loadObject(), LOC_DIR_PREFIX, LOC_VIRT_PREFIX, nil, OBJECT_TYPE_CONTAINER, quote(), SQL_NULL, string_ok(), stringHash(), TQ, and UPNP_DEFAULT_CLASS_CONTAINER.
Referenced by _ensurePathExistence(), and addContainerChain().
Definition at line 72 of file storage.cc.
References _, _Exception, CFG_SERVER_STORAGE_DRIVER, and Storage::getInstance().
Referenced by Storage::getInstance().
Definition at line 1130 of file sql_storage.cc.
References _, _as_persistent, _auxdata, _dc_title, _Exception, _flags, _id, _location, _metadata, _mime_type, _object_type, _parent_id, _ref_auxdata, _ref_id, _ref_location, _ref_metadata, _ref_mime_type, _ref_resources, _ref_service_id, _ref_upnp_class, _resources, _service_id, _StorageException, _track_number, _update_id, _upnp_class, addObjectToCache(), CDS_ACTIVE_ITEM_TABLE, CdsObject::createObject(), CdsResource::decode(), fallbackString(), IS_CDS_ACTIVE_ITEM, IS_CDS_CONTAINER, IS_CDS_ITEM, IS_CDS_PURE_ITEM, LOC_VIRT_PREFIX, nil, OBJECT_AUTOSCAN_CFG, OBJECT_AUTOSCAN_NONE, OBJECT_AUTOSCAN_UI, quote(), RefCast, remapBool(), RESOURCE_SEP, select(), split_string(), string_ok(), stripLocationPrefix(), and TQ.
Referenced by _findObjectByPath(), browse(), loadObject(), and loadObjectByServiceID().
| void SQLStorage::dbReady | ( | ) |
Definition at line 185 of file sql_storage.cc.
References loadLastID(), and nextIDMutex.
| bool SQLStorage::doInsertBuffering | ( | ) | [inline, private] |
Definition at line 241 of file sql_storage.h.
References insertBufferOn.
Referenced by addObject(), addToInsertBuffer(), and flushInsertBuffer().
| int SQLStorage::ensurePathExistence | ( | zmm::String | path, | |
| int * | changedContainer | |||
| ) | [virtual] |
Ensures that a container given by it's location on disk is present in the database. If it does not exist it will be created, but it's content will not be added.
| *changedContainer | returns the ID for the UpdateManager |
Implements Storage.
Definition at line 963 of file sql_storage.cc.
References _ensurePathExistence(), CDS_ID_FS_ROOT, zmm::String::charAt(), DIR_SEPARATOR, INVALID_OBJECT_ID, zmm::String::length(), zmm::String::reduce(), and zmm::String::substring().
Referenced by _addUpdateObject(), and _ensurePathExistence().
| int SQLStorage::exec | ( | zmm::Ref< zmm::StringBuffer > | buf, | |
| bool | getLastInsertId = false | |||
| ) | [inline] |
| virtual int SQLStorage::exec | ( | const char * | query, | |
| int | length, | |||
| bool | getLastInsertId = false | |||
| ) | [pure virtual] |
Referenced by _autoscanChangePersistentFlag(), _removeObjects(), addAutoscanDirectory(), addObject(), autoscanUpdateLM(), clearFlagInDB(), createContainer(), incrementUpdateIDs(), removeAutoscanDirectory(), removeAutoscanDirectoryByObjectID(), updateAutoscanDirectory(), updateAutoscanPersistentList(), and updateObject().
| Ref< CdsObject > SQLStorage::findObjectByPath | ( | zmm::String | path | ) | [virtual] |
Loads a given (pc directory) object, identified by the given path from the database.
| path | the path of the object; object is interpreted as directory if the path ends with DIR_SEPERATOR, as file otherwise multiple DIR_SEPERATOR are irgnored |
Implements Storage.
Definition at line 950 of file sql_storage.cc.
References _findObjectByPath().
Referenced by _ensurePathExistence(), and checkRefID().
| int SQLStorage::findObjectIDByPath | ( | zmm::String | fullpath | ) | [virtual] |
checks for a given (pc directory) object, identified by the given path from the database
| path | the path of the object; object is interpreted as directory if the path ends with DIR_SEPERATOR, as file otherwise multiple DIR_SEPERATOR are irgnored |
Implements Storage.
Definition at line 955 of file sql_storage.cc.
References _findObjectByPath(), INVALID_OBJECT_ID, and nil.
Referenced by addAutoscanDirectory(), and updateAutoscanPersistentList().
| void SQLStorage::flushInsertBuffer | ( | bool | dontLock = false |
) | [private] |
Definition at line 2359 of file sql_storage.cc.
References _flushInsertBuffer(), AUTOLOCK_DEFINE_ONLY, AUTOLOCK_NO_DEFINE, doInsertBuffering(), insertBufferByteCount, insertBufferEmpty, insertBufferStatementCount, log_debug, and Singleton< Storage >::mutex.
Referenced by addObject(), addObjectToCache(), addToInsertBuffer(), browse(), createContainer(), getChildCount(), getMimeTypes(), getObjects(), getPathIDs(), getServiceObjectIDs(), getTotalFiles(), loadObjectByServiceID(), removeObject(), removeObjects(), shutdown(), and updateObject().
| Ref< AutoscanDirectory > SQLStorage::getAutoscanDirectory | ( | int | objectID | ) | [virtual] |
returns the AutoscanDirectory for the given objectID or nil if it's not an autoscan start point - scan id will be invalid
| objectID | the object id to get the AutoscanDirectory for |
Implements Storage.
Definition at line 1902 of file sql_storage.cc.
References _, _fillAutoscanDirectory(), _StorageException, AUTOSCAN_TABLE, CDS_OBJECT_TABLE, FLD, nil, quote(), select(), TQ, and TQD.
| int SQLStorage::getAutoscanDirectoryType | ( | int | objectId | ) | [virtual] |
returns wheather the given id is an autoscan start point and if yes, if it is persistent
| objectId | the object id to check |
Implements Storage.
Definition at line 2070 of file sql_storage.cc.
References _, and _getAutoscanDirectoryInfo().
| Ref< AutoscanList > SQLStorage::getAutoscanList | ( | scan_mode_t | scanmode | ) | [virtual] |
Implements Storage.
Definition at line 1874 of file sql_storage.cc.
References _, _fillAutoscanDirectory(), _StorageException, AUTOSCAN_TABLE, CDS_OBJECT_TABLE, FLD, AutoscanDirectory::mapScanmode(), nil, quote(), removeAutoscanDirectory(), select(), TQ, and TQD.
| int SQLStorage::getChildCount | ( | int | contId, | |
| bool | containers, | |||
| bool | items, | |||
| bool | hideFsRoot | |||
| ) | [virtual] |
Implements Storage.
Definition at line 814 of file sql_storage.cc.
References AUTOLOCK, cache, cacheOn(), CDS_ID_FS_ROOT, CDS_ID_ROOT, CDS_OBJECT_TABLE, flushInsertBuffer(), nil, OBJECT_TYPE_CONTAINER, OBJECT_TYPE_ITEM, quote(), select(), and TQ.
Referenced by browse().
| String SQLStorage::getFsRootName | ( | ) | [virtual] |
Implements Storage.
Definition at line 2280 of file sql_storage.cc.
References fsRootName, setFsRootName(), and string_ok().
Reimplemented from Singleton< Storage >.
Definition at line 51 of file storage.cc.
References _, _Exception, AUTOLOCK, Storage::createInstance(), Singleton< Storage >::instance, Singleton< Storage >::mutex, and nil.
Referenced by Storage::createInstance(), FileRequestHandler::get_info(), CdsItem::getVirtualPath(), CdsContainer::getVirtualPath(), FileRequestHandler::open(), web::autoscan::process(), web::items::process(), web::edit_load::process(), web::containers::process(), and AutoscanList::updateLMinDB().
| String SQLStorage::getInternalSetting | ( | zmm::String | key | ) | [virtual] |
Implements Storage.
Definition at line 1794 of file sql_storage.cc.
References INTERNAL_SETTINGS_TABLE, nil, quote(), select(), and TQ.
| Ref< Array< StringBase > > SQLStorage::getMimeTypes | ( | ) | [virtual] |
Implements Storage.
Definition at line 869 of file sql_storage.cc.
References _, _Exception, CDS_OBJECT_TABLE, flushInsertBuffer(), nil, select(), and TQ.
| int SQLStorage::getNextID | ( | ) | [private] |
Definition at line 2301 of file sql_storage.cc.
References _, _Exception, AUTOLOCK, CDS_ID_FS_ROOT, lastID, and nextIDMutex.
Referenced by addObject(), and createContainer().
Get all objects under the given parentID.
| parentID | parent container | |
| withoutContainer | if false: all children are returned; if true: only items are returned |
Implements Storage.
Definition at line 1343 of file sql_storage.cc.
References _, _Exception, CDS_OBJECT_TABLE, flushInsertBuffer(), INVALID_OBJECT_ID, INVALID_OBJECT_ID_2, nil, OBJECT_TYPE_CONTAINER, select(), and TQ.
Implements Storage.
Definition at line 2254 of file sql_storage.cc.
References CDS_ID_ROOT, CDS_OBJECT_TABLE, flushInsertBuffer(), INVALID_OBJECT_ID, nil, quote(), select(), and TQ.
Referenced by _checkOverlappingAutoscans(), and isAutoscanChild().
| zmm::String SQLStorage::getRealLocation | ( | int | parentID, | |
| zmm::String | location | |||
| ) | [private] |
| int Object::getRefCount | ( | ) | [inherited] |
Definition at line 78 of file object.cc.
References zmm::Object::_ref_count, and atomic_get().
Return an array of object ID's for a particular service.
In the database, the service is identified by a service id prefix.
Implements Storage.
Definition at line 630 of file sql_storage.cc.
References _, _Exception, CDS_OBJECT_TABLE, flushInsertBuffer(), nil, quote(), select(), and TQ.
| int SQLStorage::getTotalFiles | ( | ) | [virtual] |
Implements Storage.
Definition at line 1257 of file sql_storage.cc.
References CDS_OBJECT_TABLE, flushInsertBuffer(), nil, OBJECT_TYPE_CONTAINER, quote(), select(), and TQ.
| String SQLStorage::incrementUpdateIDs | ( | int * | ids, | |
| int | size | |||
| ) | [virtual] |
increments the updateIDs for the given objectIDs
| ids | pointer to the array of ids | |
| size | number of entries in the given array |
Implements Storage.
Definition at line 1274 of file sql_storage.cc.
References _, _Exception, CDS_OBJECT_TABLE, exec(), nil, select(), and TQ.
| void SQLStorage::init | ( | ) | [protected, virtual] |
Implements Storage.
Definition at line 136 of file sql_storage.cc.
References _, _Exception, cache, CFG_SERVER_STORAGE_CACHING_ENABLED, Singleton< ConfigManager >::getInstance(), insertBufferByteCount, insertBufferEmpty, insertBufferMutex, insertBufferOn, insertBufferStatementCount, nil, sql_query, SQL_QUERY_FOR_STRINGBUFFER, table_quote_begin, and table_quote_end.
| int SQLStorage::isAutoscanChild | ( | int | objectID | ) | [virtual] |
checks if the given object is a direct or indirect child of a recursive autoscan start point
| objectID | the object id of the object to check |
Implements Storage.
Definition at line 2144 of file sql_storage.cc.
References getPathIDs(), INVALID_OBJECT_ID, isAutoscanDirectoryRecursive(), and nil.
| int SQLStorage::isAutoscanDirectoryRecursive | ( | int | objectId | ) | [virtual] |
returns wheather the given id is an autoscan start point and if yes, if it is recursive
| objectId | the object id to check |
Implements Storage.
Definition at line 2075 of file sql_storage.cc.
References _, and _getAutoscanDirectoryInfo().
Referenced by isAutoscanChild().
| void SQLStorage::loadLastID | ( | ) | [private] |
Definition at line 2309 of file sql_storage.cc.
References _, _Exception, CDS_ID_FS_ROOT, CDS_OBJECT_TABLE, lastID, nil, select(), and TQ.
Referenced by dbReady().
Implements Storage.
Definition at line 577 of file sql_storage.cc.
References _, _ObjectNotFoundException, AUTOLOCK, cache, cacheOn(), createObjectFromRow(), nil, select(), SQL_QUERY, and TQD.
Referenced by _addUpdateObject(), _checkOverlappingAutoscans(), checkRefID(), createContainer(), and setFsRootName().
| Ref< CdsObject > SQLStorage::loadObjectByServiceID | ( | zmm::String | serviceID | ) | [virtual] |
Loads an object given by the online service ID.
Implements Storage.
Definition at line 614 of file sql_storage.cc.
References createObjectFromRow(), flushInsertBuffer(), nil, quote(), select(), SQL_QUERY, and TQD.
| zmm::String SQLStorage::mapBool | ( | bool | val | ) | [inline, private] |
Definition at line 224 of file sql_storage.h.
References quote().
Referenced by _checkOverlappingAutoscans(), addAutoscanDirectory(), updateAutoscanDirectory(), and updateAutoscanPersistentList().
| void Object::operator delete | ( | void * | ptr | ) | [static, inherited] |
| void * Object::operator new | ( | size_t | size | ) | [static, inherited] |
| virtual zmm::String SQLStorage::quote | ( | char | val | ) | [pure virtual] |
| virtual zmm::String SQLStorage::quote | ( | bool | val | ) | [pure virtual] |
| virtual zmm::String SQLStorage::quote | ( | unsigned long | val | ) | [pure virtual] |
| virtual zmm::String SQLStorage::quote | ( | long | val | ) | [pure virtual] |
| virtual zmm::String SQLStorage::quote | ( | unsigned int | val | ) | [pure virtual] |
| virtual zmm::String SQLStorage::quote | ( | int | val | ) | [pure virtual] |
| virtual zmm::String SQLStorage::quote | ( | zmm::String | str | ) | [pure virtual] |
Referenced by _addUpdateObject(), _autoscanChangePersistentFlag(), _checkOverlappingAutoscans(), _findObjectByPath(), _getAutoscanDirectoryInfo(), _getAutoscanObjectID(), _purgeEmptyContainers(), _removeObjects(), addAutoscanDirectory(), addContainerChain(), addObject(), autoscanUpdateLM(), browse(), createContainer(), createObjectFromRow(), getAutoscanDirectory(), getAutoscanList(), getChildCount(), getInternalSetting(), getPathIDs(), getServiceObjectIDs(), getTotalFiles(), loadObjectByServiceID(), mapBool(), removeAutoscanDirectory(), removeAutoscanDirectoryByObjectID(), removeObject(), updateAutoscanDirectory(), updateAutoscanPersistentList(), and updateObject().
Definition at line 94 of file singleton.h.
| void Object::release | ( | ) | [inherited] |
Definition at line 66 of file object.cc.
References zmm::Object::_ref_count, atomic_dec(), and zmm::Object::mutex.
Referenced by zmm::ArrayBase::clear(), zmm::String::operator=(), DSOHash< zmm::Array< CacheObject > >::releaseData(), DSBHash< VT >::releaseData(), DSOHash< zmm::Array< CacheObject > >::remove(), zmm::ArrayBase::remove(), zmm::ArrayBase::removeUnordered(), zmm::ArrayBase::set(), zmm::ArrayBase::~ArrayBase(), DSOHash< zmm::Array< CacheObject > >::~DSOHash(), zmm::ObjectQueue< AutoscanDirectory >::~ObjectQueue(), zmm::ObjectStack< Element >::~ObjectStack(), and zmm::String::~String().
| bool SQLStorage::remapBool | ( | zmm::String | field | ) | [inline, private] |
Definition at line 225 of file sql_storage.h.
References string_ok().
Referenced by _fillAutoscanDirectory(), _getAutoscanDirectoryInfo(), _removeObjects(), and createObjectFromRow().
| void SQLStorage::removeAutoscanDirectory | ( | int | autoscanID | ) | [virtual] |
Implements Storage.
Definition at line 2057 of file sql_storage.cc.
References _autoscanChangePersistentFlag(), _getAutoscanObjectID(), AUTOSCAN_TABLE, exec(), INVALID_OBJECT_ID, quote(), and TQ.
Referenced by getAutoscanList().
| void SQLStorage::removeAutoscanDirectoryByObjectID | ( | int | objectID | ) | [virtual] |
Implements Storage.
Definition at line 2045 of file sql_storage.cc.
References _autoscanChangePersistentFlag(), AUTOSCAN_TABLE, exec(), INVALID_OBJECT_ID, quote(), and TQ.
| Ref< Storage::ChangedContainers > SQLStorage::removeObject | ( | int | objectID, | |
| bool | all | |||
| ) | [virtual] |
Removes the object identified by the objectID from the database. all references will be automatically removed. If the object is a container, all children will be also removed automatically. If the object is a reference to another object, the "all" flag determines, if the main object will be removed too.
| objectID | the object id of the object to remove | |
| all | if true and the object to be removed is a reference | |
| objectType | pointer to an int; will be filled with the objectType of the removed object, if not NULL |
Implements Storage.
Definition at line 1480 of file sql_storage.cc.
References _, _Exception, _purgeEmptyContainers(), _recursiveRemove(), CDS_OBJECT_TABLE, flushInsertBuffer(), IS_CDS_CONTAINER, IS_FORBIDDEN_CDS_ID, nil, quote(), select(), string_ok(), zmm::String::toInt(), and TQ.
| Ref< Storage::ChangedContainers > SQLStorage::removeObjects | ( | zmm::Ref< DBRHash< int > > | list, | |
| bool | all = false | |||
| ) | [virtual] |
Remove all objects found in list.
| list | a DBHash containing objectIDs that have to be removed | |
| all | if true and the object to be removed is a reference |
Implements Storage.
Definition at line 1373 of file sql_storage.cc.
References _, _Exception, _purgeEmptyContainers(), _recursiveRemove(), CDS_OBJECT_TABLE, hash_data_array_t< KT >::data, flushInsertBuffer(), IS_CDS_CONTAINER, IS_FORBIDDEN_CDS_ID, nil, select(), hash_data_array_t< KT >::size, and TQ.
| void Object::retain | ( | ) | [inherited] |
Definition at line 58 of file object.cc.
References zmm::Object::_ref_count, atomic_inc(), and zmm::Object::mutex.
Referenced by zmm::ArrayBase::append(), zmm::ObjectQueue< AutoscanDirectory >::enqueue(), zmm::ArrayBase::insert(), zmm::String::operator=(), zmm::ObjectStack< Element >::push(), DSOHash< zmm::Array< CacheObject > >::put(), DSBHash< VT >::put(), zmm::ArrayBase::set(), and zmm::String::String().
| zmm::Ref<SQLResult> SQLStorage::select | ( | zmm::Ref< zmm::StringBuffer > | buf | ) | [inline] |
Referenced by _addUpdateObject(), _checkOverlappingAutoscans(), _findObjectByPath(), _getAutoscanDirectoryInfo(), _getAutoscanObjectID(), _purgeEmptyContainers(), _recursiveRemove(), _removeObjects(), addContainerChain(), browse(), buildContainerPath(), createObjectFromRow(), getAutoscanDirectory(), getAutoscanList(), getChildCount(), getInternalSetting(), getMimeTypes(), getObjects(), getPathIDs(), getServiceObjectIDs(), getTotalFiles(), incrementUpdateIDs(), loadLastID(), loadObject(), loadObjectByServiceID(), removeObject(), removeObjects(), and updateAutoscanPersistentList().
| void SQLStorage::setFsRootName | ( | zmm::String | rootName = nil |
) | [private] |
Definition at line 2288 of file sql_storage.cc.
References CDS_ID_FS_ROOT, fsRootName, loadObject(), and string_ok().
Referenced by getFsRootName(), and updateObject().
| void SQLStorage::shutdown | ( | ) | [virtual] |
shutdown the Storage with its possible threads
Implements Storage.
Definition at line 191 of file sql_storage.cc.
References flushInsertBuffer(), and shutdownDriver().
| virtual void SQLStorage::shutdownDriver | ( | ) | [pure virtual] |
Referenced by shutdown().
| virtual void SQLStorage::storeInternalSetting | ( | zmm::String | key, | |
| zmm::String | value | |||
| ) | [pure virtual] |
Implements Storage.
| void Storage::stripAndUnescapeVirtualContainerFromPath | ( | zmm::String | path, | |
| zmm::String & | first, | |||
| zmm::String & | last | |||
| ) | [static, protected, inherited] |
Definition at line 105 of file storage.cc.
References _, _Exception, zmm::String::charAt(), zmm::String::rindex(), zmm::String::substring(), unescape(), VIRTUAL_CONTAINER_ESCAPE, and VIRTUAL_CONTAINER_SEPARATOR.
Referenced by addContainerChain().
| String SQLStorage::stripLocationPrefix | ( | zmm::String | path | ) | [private] |
Definition at line 1123 of file sql_storage.cc.
References nil, and zmm::String::substring().
| String SQLStorage::stripLocationPrefix | ( | char * | prefix, | |
| zmm::String | path | |||
| ) | [private] |
Definition at line 1112 of file sql_storage.cc.
References zmm::String::charAt(), LOC_ILLEGAL_PREFIX, nil, and zmm::String::substring().
Referenced by _fillAutoscanDirectory(), _removeObjects(), buildContainerPath(), and createObjectFromRow().
| virtual void Storage::threadCleanup | ( | ) | [pure virtual, inherited] |
| virtual bool Storage::threadCleanupRequired | ( | ) | [pure virtual, inherited] |
| void SQLStorage::updateAutoscanDirectory | ( | zmm::Ref< AutoscanDirectory > | adir | ) | [virtual] |
Implements Storage.
Definition at line 2009 of file sql_storage.cc.
References _, _autoscanChangePersistentFlag(), _checkOverlappingAutoscans(), _Exception, _getAutoscanObjectID(), AUTOSCAN_TABLE, exec(), log_debug, mapBool(), AutoscanDirectory::mapScanlevel(), AutoscanDirectory::mapScanmode(), nil, quote(), SQL_NULL, and TQ.
Referenced by updateAutoscanPersistentList().
| void SQLStorage::updateAutoscanPersistentList | ( | scan_mode_t | scanmode, | |
| zmm::Ref< AutoscanList > | list | |||
| ) | [virtual] |
Implements Storage.
Definition at line 1812 of file sql_storage.cc.
References _, _Exception, _StorageException, addAutoscanDirectory(), AUTOSCAN_TABLE, exec(), findObjectIDByPath(), INVALID_OBJECT_ID, log_debug, mapBool(), AutoscanDirectory::mapScanmode(), nil, quote(), select(), string_ok(), TQ, and updateAutoscanDirectory().
Implements Storage.
Definition at line 524 of file sql_storage.cc.
References _, _addUpdateObject(), _Exception, addObjectToCache(), CDS_ID_FS_ROOT, CDS_OBJECT_TABLE, exec(), flushInsertBuffer(), IS_FORBIDDEN_CDS_ID, log_debug, nil, quote(), setFsRootName(), and TQ.
mt_atomic_t zmm::Object::_ref_count [protected, inherited] |
Definition at line 54 of file object.h.
Referenced by zmm::Object::getRefCount(), zmm::Object::Object(), zmm::Object::release(), and zmm::Object::retain().
zmm::Ref<StorageCache> SQLStorage::cache [private] |
Definition at line 237 of file sql_storage.h.
Referenced by _findObjectByPath(), _purgeEmptyContainers(), addObject(), addObjectToCache(), browse(), cacheOn(), createContainer(), getChildCount(), init(), and loadObject().
zmm::String SQLStorage::fsRootName [private] |
Definition at line 229 of file sql_storage.h.
Referenced by getFsRootName(), and setFsRootName().
int SQLStorage::insertBufferByteCount [private] |
Definition at line 252 of file sql_storage.h.
Referenced by addToInsertBuffer(), flushInsertBuffer(), and init().
bool SQLStorage::insertBufferEmpty [private] |
Definition at line 250 of file sql_storage.h.
Referenced by addToInsertBuffer(), flushInsertBuffer(), and init().
zmm::Ref<Mutex> SQLStorage::insertBufferMutex [private] |
Definition at line 253 of file sql_storage.h.
Referenced by init().
bool SQLStorage::insertBufferOn [private] |
Definition at line 249 of file sql_storage.h.
Referenced by doInsertBuffering(), and init().
int SQLStorage::insertBufferStatementCount [private] |
Definition at line 251 of file sql_storage.h.
Referenced by addToInsertBuffer(), flushInsertBuffer(), and init().
Definition at line 91 of file singleton.h.
Referenced by Storage::getInstance().
int SQLStorage::lastID [private] |
Definition at line 231 of file sql_storage.h.
Referenced by getNextID(), loadLastID(), and SQLStorage().
Reimplemented from zmm::Object.
Definition at line 90 of file singleton.h.
Referenced by addToInsertBuffer(), flushInsertBuffer(), and Storage::getInstance().
zmm::Ref<Mutex> SQLStorage::nextIDMutex [private] |
Definition at line 235 of file sql_storage.h.
Referenced by dbReady(), and getNextID().
bool Singleton< Storage >::singletonActive [static, protected, inherited] |
Definition at line 92 of file singleton.h.
zmm::String SQLStorage::sql_query [private] |
Definition at line 174 of file sql_storage.h.
Referenced by init().
char SQLStorage::table_quote_begin [protected] |
Definition at line 157 of file sql_storage.h.
Referenced by init(), and SQLStorage().
char SQLStorage::table_quote_end [protected] |
Definition at line 158 of file sql_storage.h.
Referenced by init(), and SQLStorage().
1.6.1