Class UploadedFileCacheService

java.lang.Object
fr.paris.lutece.portal.service.cache.AbstractCacheableService<String,byte[]>
fr.paris.lutece.plugins.asynchronousupload.service.UploadedFileCacheService
All Implemented Interfaces:
IUploadedFileStore, fr.paris.lutece.portal.service.cache.CacheableService<String,byte[]>, fr.paris.lutece.portal.service.cache.Lutece107Cache<String,byte[]>, fr.paris.lutece.portal.service.util.LuteceService, Closeable, Serializable, AutoCloseable, Iterable<javax.cache.Cache.Entry<String,byte[]>>, javax.cache.Cache<String,byte[]>

@ApplicationScoped public class UploadedFileCacheService extends fr.paris.lutece.portal.service.cache.AbstractCacheableService<String,byte[]> implements IUploadedFileStore
Keeps the content of the uploaded files in a cache shared by the instances, when the cache provider is distributed. With one instance (Ehcache) the files stay in the session: nothing is stored here.

The cache is required (never disabled from the back office) and never reset: it holds files the users are still working on. Each file is removed when it is deleted (removed from the form, form submitted, session destroyed); the time to live only purges the files of the sessions lost without notice.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface javax.cache.Cache

    javax.cache.Cache.Entry<K extends Object,V extends Object>
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    delete(String strId)
    Removes the content of an uploaded file
    void
    Creates the cache
    boolean
    Tells whether the content of the uploaded files is kept outside the session
    byte[]
    load(String strId)
    Loads the content of an uploaded file
    store(byte[] content)
    Stores the content of an uploaded file

    Methods inherited from class fr.paris.lutece.portal.service.cache.AbstractCacheableService

    clear, close, containsKey, deregisterCacheEntryListener, enableCache, get, getAll, getAndPut, getAndRemove, getAndReplace, getCache, getCacheManager, getCacheSize, getConfiguration, getFromCache, getInfos, getKeys, initCache, initCache, initCache, invoke, invokeAll, isCacheEnable, isClosed, isPreventGlobalReset, isPreventReset, isRequired, iterator, loadAll, put, putAll, putIfAbsent, putInCache, registerCacheEntryListener, remove, remove, removeAll, removeAll, removeKey, replace, replace, resetCache, setCache, unwrap

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface fr.paris.lutece.portal.service.cache.CacheableService

    getMaxElements, getMemorySize, getTimeToLive

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • UploadedFileCacheService

      public UploadedFileCacheService()
  • Method Details

    • init

      @PostConstruct public void init()
      Creates the cache
    • getName

      public String getName()
      Specified by:
      getName in interface javax.cache.Cache<String,byte[]>
      Specified by:
      getName in interface fr.paris.lutece.portal.service.util.LuteceService
    • isActive

      public boolean isActive()
      Tells whether the content of the uploaded files is kept outside the session
      Specified by:
      isActive in interface IUploadedFileStore
      Returns:
      true when the files are stored here, false when they stay in the session (one instance)
    • store

      public String store(byte[] content)
      Stores the content of an uploaded file
      Specified by:
      store in interface IUploadedFileStore
      Parameters:
      content - the content
      Returns:
      the id of the stored content, or null when the content could not be stored and must stay in the session
    • load

      public byte[] load(String strId)
      Loads the content of an uploaded file
      Specified by:
      load in interface IUploadedFileStore
      Parameters:
      strId - the id given by IUploadedFileStore.store(byte[])
      Returns:
      the content, or null when it is no longer stored
    • delete

      public void delete(String strId)
      Removes the content of an uploaded file
      Specified by:
      delete in interface IUploadedFileStore
      Parameters:
      strId - the id given by IUploadedFileStore.store(byte[])