Package org.ametys.plugins.ai.search
Class CacheDAO
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.ai.search.CacheDAO
- All Implemented Interfaces:
DeferredServiceable,LogEnabled,PluginAware,Disposable,Component,Contextualizable
public class CacheDAO
extends AbstractLogEnabled
implements DeferredServiceable, PluginAware, Contextualizable, Component, Disposable
DAO for AI cache management.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <T extends AmetysObject>
T_getOrCreateNode(JCRTraversableAmetysObject parentNode, String nodeName, String nodeType) Get or create a nodevoidcontextualize(Context context) voiddeferredService(ServiceManager manager) Pass theServiceManagerused to access other components.voiddispose()getCacheContentNode(Content content, boolean creates) Get the cache node for a given content idgetCacheContentVersionNode(Content content, String version) Get the cache node for a given content idGet the root plugin storage object.getChunk(DefaultTraversableAmetysObject cacheContentVersionNode, int number, boolean createIfNotExist) Get or create a chunk nodegetNearestCacheContentVersionNode(Content content, String version) Get the cache node for a given content idvoidsetPluginInfo(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The avalon role -
CACHEROOT_CONTENT_DATA_CONTENTID
The property name to store content id on Content node of the cache- See Also:
-
-
Constructor Details
-
CacheDAO
public CacheDAO()
-
-
Method Details
-
setPluginInfo
Description copied from interface:PluginAwareSets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfoin interfacePluginAware- Parameters:
pluginName- Unique identifier for the plugin hosting the extensionfeatureName- Unique feature identifier (unique for a given pluginName)id- Unique identifier of this component
-
deferredService
Description copied from interface:DeferredServiceablePass theServiceManagerused to access other components.- Specified by:
deferredServicein interfaceDeferredServiceable- Parameters:
manager- TheServiceManagerwhich thisDeferredServiceableuses. Must not benull.- Throws:
ServiceException- if an error occurs
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
dispose
- Specified by:
disposein interfaceDisposable
-
getCacheRootNode
public AmetysObjectCollection getCacheRootNode() throws AmetysRepositoryException, javax.jcr.LoginException, javax.jcr.RepositoryExceptionGet the root plugin storage object.- Returns:
- the root plugin storage object.
- Throws:
AmetysRepositoryException- if a repository error occurs.javax.jcr.RepositoryException- if a repository error occurs.javax.jcr.LoginException- if a repository error occurs.
-
getCacheContentNode
public DefaultTraversableAmetysObject getCacheContentNode(Content content, boolean creates) throws AmetysRepositoryException, javax.jcr.RepositoryException Get the cache node for a given content id- Parameters:
content- the contentcreates- Create the node if not existing- Returns:
- the cache node or null if not existing and not created
- Throws:
AmetysRepositoryException- if an error occurs when manipulating the repositoryjavax.jcr.RepositoryException- if an error occurs when manipulating the repository
-
getNearestCacheContentVersionNode
public DefaultTraversableAmetysObject getNearestCacheContentVersionNode(Content content, String version) throws AmetysRepositoryException, javax.jcr.LoginException, javax.jcr.RepositoryException Get the cache node for a given content id- Parameters:
content- the contentversion- the content version- Returns:
- the cache node
- Throws:
AmetysRepositoryException- if an error occurs when manipulating the repositoryjavax.jcr.RepositoryException- if an error occurs when manipulating the repositoryjavax.jcr.LoginException- if an error occurs when manipulating the repository
-
getCacheContentVersionNode
public DefaultTraversableAmetysObject getCacheContentVersionNode(Content content, String version) throws AmetysRepositoryException, javax.jcr.LoginException, javax.jcr.RepositoryException Get the cache node for a given content id- Parameters:
content- the contentversion- the content version- Returns:
- the cache node
- Throws:
AmetysRepositoryException- if an error occurs when manipulating the repositoryjavax.jcr.RepositoryException- if an error occurs when manipulating the repositoryjavax.jcr.LoginException- if an error occurs when manipulating the repository
-
getChunk
public CacheContentVersionChunk getChunk(DefaultTraversableAmetysObject cacheContentVersionNode, int number, boolean createIfNotExist) throws AmetysRepositoryException Get or create a chunk node- Parameters:
cacheContentVersionNode- The cache content version nodenumber- the chunk numbercreateIfNotExist- true to create the chunk if it does not exist- Returns:
- The retrieved or created chunk node, or null otherwise
- Throws:
AmetysRepositoryException- if an error occurs when manipulating the repository
-
_getOrCreateNode
protected <T extends AmetysObject> T _getOrCreateNode(JCRTraversableAmetysObject parentNode, String nodeName, String nodeType) throws AmetysRepositoryException Get or create a node- Type Parameters:
T- The type of the node- Parameters:
parentNode- the parent nodenodeName- the name of the nodenodeType- the type of the node- Returns:
- The retrieved or created node
- Throws:
AmetysRepositoryException- if an error occurs when manipulating the repository
-