com.xpn.xwiki.store
Class XWikiCacheStore

java.lang.Object
  extended by com.xpn.xwiki.store.XWikiCacheStore
All Implemented Interfaces:
XWikiCacheStoreInterface, XWikiStoreInterface, org.xwiki.observation.EventListener

public class XWikiCacheStore
extends Object
implements XWikiCacheStoreInterface, org.xwiki.observation.EventListener

A proxy store implementation that caches Documents when they are first fetched and subsequently return them from a cache. It delegates all write and search operations to an underlying store without doing any caching on them.

Version:
$Id: 0bf0339507d089f109bcd3161435d013f449c0c1 $

Constructor Summary
XWikiCacheStore(XWikiStoreInterface store, XWikiContext context)
           
 
Method Summary
 void cleanUp(XWikiContext context)
           
 int countDocuments(String parametrizedSqlClause, List<?> parameterValues, XWikiContext context)
          API allowing to count the total number of documents that would be returned by a parameterized query.
 int countDocuments(String wheresql, XWikiContext context)
          API allowing to count the total number of documents that would be returned by a query.
 void createWiki(String wikiName, XWikiContext context)
          Allows to create a new wiki database and initialize the default tables.
 void deleteLinks(long docId, XWikiContext context, boolean bTransaction)
           
 void deleteLock(XWikiLock lock, XWikiContext context, boolean bTransaction)
           
 void deleteWiki(String wikiName, XWikiContext context)
          Delete a wiki database.
 void deleteXWikiDoc(XWikiDocument doc, XWikiContext context)
           
 boolean exists(XWikiDocument doc, XWikiContext context)
           
 void flushCache()
           
 Cache<XWikiDocument> getCache()
           
 List<String> getClassList(XWikiContext context)
           
 List<String> getCustomMappingPropertyList(BaseClass bclass)
           
 List<org.xwiki.observation.event.Event> getEvents()
           
 String getKey(String wiki, String fullName, String language)
          Deprecated. since 4.0M1 use XWikiDocument.getKey()
 String getKey(String fullName, String language, XWikiContext context)
          Deprecated. since 4.0M1 use XWikiDocument.getKey()
 String getKey(XWikiDocument doc)
          Deprecated. 
 String getKey(XWikiDocument doc, XWikiContext context)
          Deprecated. since 4.0M1 use XWikiDocument.getKey()
 String getName()
           
 Cache<Boolean> getPageExistCache()
           
 QueryManager getQueryManager()
           
 XWikiStoreInterface getStore()
           
 List<String> getTranslationList(XWikiDocument doc, XWikiContext context)
           
 void initCache(int capacity, int pageExistCacheCapacity, XWikiContext context)
           
 void initCache(XWikiContext context)
           
 boolean injectCustomMapping(BaseClass doc1class, XWikiContext context)
           
 void injectCustomMappings(XWikiContext context)
           
 boolean injectCustomMappings(XWikiDocument doc, XWikiContext context)
           
 void injectUpdatedCustomMappings(XWikiContext context)
           
 boolean isCustomMappingValid(BaseClass bclass, String custommapping1, XWikiContext context)
           
 boolean isWikiNameAvailable(String wikiName, XWikiContext context)
          Indicate if the provided wiki name could be used to create a new wiki.
 List<DocumentReference> loadBacklinks(DocumentReference documentReference, boolean bTransaction, XWikiContext context)
           
 List<String> loadBacklinks(String fullName, XWikiContext context, boolean bTransaction)
           
 List<XWikiLink> loadLinks(long docId, XWikiContext context, boolean bTransaction)
           
 XWikiLock loadLock(long docId, XWikiContext context, boolean bTransaction)
           
 XWikiDocument loadXWikiDoc(XWikiDocument doc, XWikiContext context)
           
 void onEvent(org.xwiki.observation.event.Event event, Object source, Object data)
           
 void saveLinks(XWikiDocument doc, XWikiContext context, boolean bTransaction)
           
 void saveLock(XWikiLock lock, XWikiContext context, boolean bTransaction)
           
 void saveXWikiDoc(XWikiDocument doc, XWikiContext context)
           
 void saveXWikiDoc(XWikiDocument doc, XWikiContext context, boolean bTransaction)
           
<T> List<T>
search(String sql, int nb, int start, List<?> parameterValues, XWikiContext context)
          Execute a reading request with parameters and return result.
<T> List<T>
search(String sql, int nb, int start, Object[][] whereParams, List<?> parameterValues, XWikiContext context)
          Execute a reading request with parameters and return result.
<T> List<T>
search(String sql, int nb, int start, Object[][] whereParams, XWikiContext context)
          Execute a reading request and return result.
<T> List<T>
search(String sql, int nb, int start, XWikiContext context)
          Execute a reading request and return result.
 List<DocumentReference> searchDocumentReferences(String parametrizedSqlClause, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents by passing HQL where clause values as parameters.
 List<DocumentReference> searchDocumentReferences(String wheresql, int nb, int start, String selectColumns, XWikiContext context)
           
 List<DocumentReference> searchDocumentReferences(String wheresql, int nb, int start, XWikiContext context)
           
 List<DocumentReference> searchDocumentReferences(String parametrizedSqlClause, List<?> parameterValues, XWikiContext context)
          Same as XWikiStoreInterface.searchDocumentReferences(String, int, int, List, XWikiContext) but returns all rows.
 List<DocumentReference> searchDocumentReferences(String wheresql, XWikiContext context)
           
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, boolean customMapping, boolean checkRight, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbyname, boolean customMapping, boolean checkRight, int nb, int start, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, boolean customMapping, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbyname, boolean customMapping, int nb, int start, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbyname, boolean customMapping, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbylanguage, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbyname, int nb, int start, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, boolean distinctbyname, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, int nb, int start, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, int nb, int start, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, List<?> parameterValues, XWikiContext context)
          Search documents in the storing system.
 List<XWikiDocument> searchDocuments(String wheresql, XWikiContext context)
          Search documents in the storing system.
 List<String> searchDocumentsNames(String parametrizedSqlClause, int nb, int start, List<?> parameterValues, XWikiContext context)
           
 List<String> searchDocumentsNames(String wheresql, int nb, int start, String selectColumns, XWikiContext context)
           
 List<String> searchDocumentsNames(String wheresql, int nb, int start, XWikiContext context)
           
 List<String> searchDocumentsNames(String parametrizedSqlClause, List<?> parameterValues, XWikiContext context)
           
 List<String> searchDocumentsNames(String wheresql, XWikiContext context)
           
 void setCache(Cache<XWikiDocument> cache)
           
 void setPageExistCache(Cache<Boolean> pageExistCache)
           
 void setStore(XWikiStoreInterface store)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XWikiCacheStore

public XWikiCacheStore(XWikiStoreInterface store,
                       XWikiContext context)
                throws XWikiException
Throws:
XWikiException
Method Detail

getName

public String getName()
Specified by:
getName in interface org.xwiki.observation.EventListener

getEvents

public List<org.xwiki.observation.event.Event> getEvents()
Specified by:
getEvents in interface org.xwiki.observation.EventListener

initCache

public void initCache(XWikiContext context)
               throws XWikiException
Throws:
XWikiException

initCache

public void initCache(int capacity,
                      int pageExistCacheCapacity,
                      XWikiContext context)
               throws XWikiException
Specified by:
initCache in interface XWikiCacheStoreInterface
Throws:
XWikiException

getStore

public XWikiStoreInterface getStore()
Specified by:
getStore in interface XWikiCacheStoreInterface

setStore

public void setStore(XWikiStoreInterface store)
Specified by:
setStore in interface XWikiCacheStoreInterface

saveXWikiDoc

public void saveXWikiDoc(XWikiDocument doc,
                         XWikiContext context)
                  throws XWikiException
Specified by:
saveXWikiDoc in interface XWikiStoreInterface
Throws:
XWikiException

saveXWikiDoc

public void saveXWikiDoc(XWikiDocument doc,
                         XWikiContext context,
                         boolean bTransaction)
                  throws XWikiException
Specified by:
saveXWikiDoc in interface XWikiStoreInterface
Throws:
XWikiException

flushCache

public void flushCache()
Specified by:
flushCache in interface XWikiCacheStoreInterface

onEvent

public void onEvent(org.xwiki.observation.event.Event event,
                    Object source,
                    Object data)
Specified by:
onEvent in interface org.xwiki.observation.EventListener

getKey

@Deprecated
public String getKey(XWikiDocument doc)
Deprecated. 


getKey

@Deprecated
public String getKey(XWikiDocument doc,
                                XWikiContext context)
Deprecated. since 4.0M1 use XWikiDocument.getKey()


getKey

@Deprecated
public String getKey(String fullName,
                                String language,
                                XWikiContext context)
Deprecated. since 4.0M1 use XWikiDocument.getKey()


getKey

@Deprecated
public String getKey(String wiki,
                                String fullName,
                                String language)
Deprecated. since 4.0M1 use XWikiDocument.getKey()


loadXWikiDoc

public XWikiDocument loadXWikiDoc(XWikiDocument doc,
                                  XWikiContext context)
                           throws XWikiException
Specified by:
loadXWikiDoc in interface XWikiStoreInterface
Throws:
XWikiException

deleteXWikiDoc

public void deleteXWikiDoc(XWikiDocument doc,
                           XWikiContext context)
                    throws XWikiException
Specified by:
deleteXWikiDoc in interface XWikiStoreInterface
Throws:
XWikiException

getClassList

public List<String> getClassList(XWikiContext context)
                          throws XWikiException
Specified by:
getClassList in interface XWikiStoreInterface
Throws:
XWikiException

countDocuments

public int countDocuments(String wheresql,
                          XWikiContext context)
                   throws XWikiException
Description copied from interface: XWikiStoreInterface
API allowing to count the total number of documents that would be returned by a query.

Specified by:
countDocuments in interface XWikiStoreInterface
Parameters:
wheresql - Query to use, similar to the ones accepted by XWikiStoreInterface.searchDocuments(String, XWikiContext). It should not contain order by or group clauses, since this kind of queries are not portable.
context - The current request context.
Returns:
The number of documents that matched the query.
Throws:
XWikiException - if there was a problem executing the query.

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String wheresql,
                                                        XWikiContext context)
                                                 throws XWikiException
Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentsNames

public List<String> searchDocumentsNames(String wheresql,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String wheresql,
                                                        int nb,
                                                        int start,
                                                        XWikiContext context)
                                                 throws XWikiException
Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentsNames

public List<String> searchDocumentsNames(String wheresql,
                                         int nb,
                                         int start,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String wheresql,
                                                        int nb,
                                                        int start,
                                                        String selectColumns,
                                                        XWikiContext context)
                                                 throws XWikiException
Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentsNames

public List<String> searchDocumentsNames(String wheresql,
                                         int nb,
                                         int start,
                                         String selectColumns,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String parametrizedSqlClause,
                                                        int nb,
                                                        int start,
                                                        List<?> parameterValues,
                                                        XWikiContext context)
                                                 throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Example

 <code>
 #set($orphans = $xwiki.searchDocuments(" where doc.fullName <> ? and (doc.parent = ? or "
     + "(doc.parent = ? and doc.space = ?))",
     ["${doc.fullName}as", ${doc.fullName}, ${doc.name}, ${doc.space}]))
 </code>
 

Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Parameters:
parametrizedSqlClause - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))"
nb - the number of rows to return. If 0 then all rows are returned
start - the number of rows to skip. If 0 don't skip any row
parameterValues - the where clause values that replace the question marks (?)
context - the XWiki context required for getting information about the execution context
Returns:
a list of document references
Throws:
XWikiException - in case of error while performing the query

searchDocumentsNames

public List<String> searchDocumentsNames(String parametrizedSqlClause,
                                         int nb,
                                         int start,
                                         List<?> parameterValues,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

searchDocumentReferences

public List<DocumentReference> searchDocumentReferences(String parametrizedSqlClause,
                                                        List<?> parameterValues,
                                                        XWikiContext context)
                                                 throws XWikiException
Description copied from interface: XWikiStoreInterface
Same as XWikiStoreInterface.searchDocumentReferences(String, int, int, List, XWikiContext) but returns all rows.

Specified by:
searchDocumentReferences in interface XWikiStoreInterface
Throws:
XWikiException
See Also:
XWikiStoreInterface.searchDocumentReferences(String, int, int, java.util.List, com.xpn.xwiki.XWikiContext)

searchDocumentsNames

public List<String> searchDocumentsNames(String parametrizedSqlClause,
                                         List<?> parameterValues,
                                         XWikiContext context)
                                  throws XWikiException
Specified by:
searchDocumentsNames in interface XWikiStoreInterface
Throws:
XWikiException

isCustomMappingValid

public boolean isCustomMappingValid(BaseClass bclass,
                                    String custommapping1,
                                    XWikiContext context)
                             throws XWikiException
Specified by:
isCustomMappingValid in interface XWikiStoreInterface
Throws:
XWikiException

injectCustomMapping

public boolean injectCustomMapping(BaseClass doc1class,
                                   XWikiContext context)
                            throws XWikiException
Specified by:
injectCustomMapping in interface XWikiStoreInterface
Throws:
XWikiException

injectCustomMappings

public boolean injectCustomMappings(XWikiDocument doc,
                                    XWikiContext context)
                             throws XWikiException
Specified by:
injectCustomMappings in interface XWikiStoreInterface
Throws:
XWikiException

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbyname,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbyname - when a document has multiple version for each language it is returned as one document a language.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbyname,
                                           boolean customMapping,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbyname - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbyname,
                                           int nb,
                                           int start,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbyname - when a document has multiple version for each language it is returned as one document a language.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbyname,
                                           boolean customMapping,
                                           int nb,
                                           int start,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbyname - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           int nb,
                                           int start,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbyname,
                                           boolean customMapping,
                                           boolean checkRight,
                                           int nb,
                                           int start,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbyname - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
checkRight - if true check for each found document if context's user has "view" rights for it.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           int nb,
                                           int start,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           boolean customMapping,
                                           int nb,
                                           int start,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           int nb,
                                           int start,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

searchDocuments

public List<XWikiDocument> searchDocuments(String wheresql,
                                           boolean distinctbylanguage,
                                           boolean customMapping,
                                           boolean checkRight,
                                           int nb,
                                           int start,
                                           List<?> parameterValues,
                                           XWikiContext context)
                                    throws XWikiException
Description copied from interface: XWikiStoreInterface
Search documents in the storing system.

Search documents by passing HQL where clause values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escpaing yourself before calling them.

Specified by:
searchDocuments in interface XWikiStoreInterface
Parameters:
wheresql - the HQL where clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
distinctbylanguage - when a document has multiple version for each language it is returned as one document a language.
customMapping - inject custom mapping in session.
checkRight - if true check for each found document if context's user has "view" rights for it.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

countDocuments

public int countDocuments(String parametrizedSqlClause,
                          List<?> parameterValues,
                          XWikiContext context)
                   throws XWikiException
Description copied from interface: XWikiStoreInterface
API allowing to count the total number of documents that would be returned by a parameterized query.

Specified by:
countDocuments in interface XWikiStoreInterface
Parameters:
parametrizedSqlClause - Parameterized query to use, similar to the ones accepted by XWikiStoreInterface.searchDocuments(String, List, XWikiContext). It should not contain order by or group clauses, since this kind of queries are not portable.
parameterValues - The parameter values that replace the question marks.
context - The current request context.
Returns:
The number of documents that matched the query.
Throws:
XWikiException - if there was a problem executing the query.

loadLock

public XWikiLock loadLock(long docId,
                          XWikiContext context,
                          boolean bTransaction)
                   throws XWikiException
Specified by:
loadLock in interface XWikiStoreInterface
Throws:
XWikiException

saveLock

public void saveLock(XWikiLock lock,
                     XWikiContext context,
                     boolean bTransaction)
              throws XWikiException
Specified by:
saveLock in interface XWikiStoreInterface
Throws:
XWikiException

deleteLock

public void deleteLock(XWikiLock lock,
                       XWikiContext context,
                       boolean bTransaction)
                throws XWikiException
Specified by:
deleteLock in interface XWikiStoreInterface
Throws:
XWikiException

loadLinks

public List<XWikiLink> loadLinks(long docId,
                                 XWikiContext context,
                                 boolean bTransaction)
                          throws XWikiException
Specified by:
loadLinks in interface XWikiStoreInterface
Throws:
XWikiException

loadBacklinks

public List<DocumentReference> loadBacklinks(DocumentReference documentReference,
                                             boolean bTransaction,
                                             XWikiContext context)
                                      throws XWikiException
Specified by:
loadBacklinks in interface XWikiStoreInterface
Throws:
XWikiException

loadBacklinks

public List<String> loadBacklinks(String fullName,
                                  XWikiContext context,
                                  boolean bTransaction)
                           throws XWikiException
Specified by:
loadBacklinks in interface XWikiStoreInterface
Throws:
XWikiException

saveLinks

public void saveLinks(XWikiDocument doc,
                      XWikiContext context,
                      boolean bTransaction)
               throws XWikiException
Specified by:
saveLinks in interface XWikiStoreInterface
Throws:
XWikiException

deleteLinks

public void deleteLinks(long docId,
                        XWikiContext context,
                        boolean bTransaction)
                 throws XWikiException
Specified by:
deleteLinks in interface XWikiStoreInterface
Throws:
XWikiException

search

public <T> List<T> search(String sql,
                          int nb,
                          int start,
                          XWikiContext context)
               throws XWikiException
Description copied from interface: XWikiStoreInterface
Execute a reading request and return result.

Specified by:
search in interface XWikiStoreInterface
Parameters:
sql - the HQL request clause. For example " where doc.fullName <> ? and (doc.parent = ? or (doc.parent = ? and doc.space = ?))".
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

search

public <T> List<T> search(String sql,
                          int nb,
                          int start,
                          Object[][] whereParams,
                          XWikiContext context)
               throws XWikiException
Description copied from interface: XWikiStoreInterface
Execute a reading request and return result.

Specified by:
search in interface XWikiStoreInterface
Parameters:
sql - the HQL request.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
whereParams - if not null add to sql a where clause based on a table of table containing field name, field value and compared symbol ("=", ">", etc.).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

search

public <T> List<T> search(String sql,
                          int nb,
                          int start,
                          List<?> parameterValues,
                          XWikiContext context)
               throws XWikiException
Description copied from interface: XWikiStoreInterface
Execute a reading request with parameters and return result.

Execute query by passing HQL request values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escaping yourself before calling them.

Specified by:
search in interface XWikiStoreInterface
Parameters:
sql - the HQL request.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

search

public <T> List<T> search(String sql,
                          int nb,
                          int start,
                          Object[][] whereParams,
                          List<?> parameterValues,
                          XWikiContext context)
               throws XWikiException
Description copied from interface: XWikiStoreInterface
Execute a reading request with parameters and return result.

Execute query by passing HQL request values as parameters. This allows generating a Named HQL query which will automatically encode the passed values (like escaping single quotes). This API is recommended to be used over the other similar methods where the values are passed inside the where clause and for which you'll need to do the encoding/escaping yourself before calling them.

Specified by:
search in interface XWikiStoreInterface
Parameters:
sql - the HQL request.
nb - the number of rows to return. If 0 then all rows are returned.
start - the number of rows to skip. If 0 don't skip any row.
whereParams - if not null add to sql a where clause based on a table of table containing field name, field value and compared symbol ("=", ">", etc.).
parameterValues - the where clause values that replace the question marks (?).
context - the XWiki context required for getting information about the execution context.
Returns:
a list of XWikiDocument.
Throws:
XWikiException - in case of error while performing the query.

cleanUp

public void cleanUp(XWikiContext context)
Specified by:
cleanUp in interface XWikiStoreInterface

isWikiNameAvailable

public boolean isWikiNameAvailable(String wikiName,
                                   XWikiContext context)
                            throws XWikiException
Description copied from interface: XWikiStoreInterface
Indicate if the provided wiki name could be used to create a new wiki.

Specified by:
isWikiNameAvailable in interface XWikiStoreInterface
Parameters:
wikiName - the name of the wiki.
context - the XWiki context.
Returns:
true if the name is already used, false otherwise.
Throws:
XWikiException - error when looking if wiki name already used.

createWiki

public void createWiki(String wikiName,
                       XWikiContext context)
                throws XWikiException
Description copied from interface: XWikiStoreInterface
Allows to create a new wiki database and initialize the default tables.

Specified by:
createWiki in interface XWikiStoreInterface
Parameters:
wikiName - the name of the new wiki.
context - the XWiki context.
Throws:
XWikiException - error when creating new wiki.

deleteWiki

public void deleteWiki(String wikiName,
                       XWikiContext context)
                throws XWikiException
Description copied from interface: XWikiStoreInterface
Delete a wiki database.

Specified by:
deleteWiki in interface XWikiStoreInterface
Parameters:
wikiName - the name of the wiki.
context - the XWiki context.
Throws:
XWikiException - error when deleting wiki database.

exists

public boolean exists(XWikiDocument doc,
                      XWikiContext context)
               throws XWikiException
Specified by:
exists in interface XWikiStoreInterface
Throws:
XWikiException

getCache

public Cache<XWikiDocument> getCache()

setCache

public void setCache(Cache<XWikiDocument> cache)

getPageExistCache

public Cache<Boolean> getPageExistCache()

setPageExistCache

public void setPageExistCache(Cache<Boolean> pageExistCache)

getCustomMappingPropertyList

public List<String> getCustomMappingPropertyList(BaseClass bclass)
Specified by:
getCustomMappingPropertyList in interface XWikiStoreInterface

injectCustomMappings

public void injectCustomMappings(XWikiContext context)
                          throws XWikiException
Specified by:
injectCustomMappings in interface XWikiStoreInterface
Throws:
XWikiException

injectUpdatedCustomMappings

public void injectUpdatedCustomMappings(XWikiContext context)
                                 throws XWikiException
Specified by:
injectUpdatedCustomMappings in interface XWikiStoreInterface
Throws:
XWikiException

getTranslationList

public List<String> getTranslationList(XWikiDocument doc,
                                       XWikiContext context)
                                throws XWikiException
Specified by:
getTranslationList in interface XWikiStoreInterface
Throws:
XWikiException

getQueryManager

public QueryManager getQueryManager()
Specified by:
getQueryManager in interface XWikiStoreInterface
Returns:
QueryManager used for creating queries to store. Use QueryManager instead of #search* methods because it is more abstract from store implementation and support multiple query languages.


Copyright © 2004-2013 XWiki. All Rights Reserved.