Package org.cyclos.impl.storage
Class StoredFileHandlerImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseNetworkedHandlerImpl
-
- org.cyclos.impl.storage.StoredFileHandlerImpl
-
- All Implemented Interfaces:
StoredFileHandler
@Component public class StoredFileHandlerImpl extends BaseNetworkedHandlerImpl implements StoredFileHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected static longTIMEOUT_MILLISTimeout used to wait for a lock to be acquired-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
Fields inherited from interface org.cyclos.impl.storage.StoredFileHandler
SKIP_LOCK, SKIP_LOCK_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description StoredFileHandlerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopy(StoredFile source, StoredFile target)Copies the source's attributes and content to target.com.querydsl.core.types.dsl.BooleanExpressioncustomFieldEquals(com.querydsl.core.types.EntityPath<?> sf, CustomField<?,?,?> customField)Returns a query predicate that any property of type CustomField points to the given custom field<T extends StoredFile>
Tfind(Class<T> clazz, long id)Finds aStoredFilein the catalog, if found returns the StoredFile with the specified id.
This method doesn't check if the related content is present through theStoredFileContentManagerbyte[]getBytes(StoredFile storedFile)Returns the content of the specifiedStoredFileas bytesSerializableInputStreamgetContent(StoredFile storedFile)Opens an input stream to allow read the content of the specifiedStoredFile.
It is caller's responsibility to close the stream after read.Set<String>getStorageDirectories()Returns the set of directory names available for store an individual document or a custom field of type image/file configured in the cyclos.properties only if the underlyingStoredFileContentManagerimplementation support store files in a specific directory other than the default.StringgetStorageDirectory(StoredFile storedFile)Returns the storage directory, if any, for those cases where a custom storage directory can be specified (individual documents, image/file custom fields).booleanisStoredOnDB()Returns whether the underlying storage for files is databasevoidmove(StoredFile source, StoredFile target)Moves the source's attributes and content to target REMOVING the source.voidremove(long id)Remove the stored file and its content.voidsave(StoredFile storedFile, SerializableInputStream in)Saves (create/update) a stored file reading its content from the specified stream.
This method closes the providedSerializableInputStreamafter the method has completed.StoredFileContentManagersetStoredFileContentManager(StoredFileContentManager storedFileContentManager)The purpose of this method is only to facilitate the unit testing.booleansupportStorageDirectories()Returns true if the underlyingStoredFileContentManagerimplementation support store files in a specific directory other than the default-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Field Detail
-
TIMEOUT_MILLIS
protected static final long TIMEOUT_MILLIS
Timeout used to wait for a lock to be acquired- See Also:
- Constant Field Values
-
-
Method Detail
-
copy
public final void copy(StoredFile source, StoredFile target) throws StoredFileException
Description copied from interface:StoredFileHandlerCopies the source's attributes and content to target.- Specified by:
copyin interfaceStoredFileHandler- Throws:
StoredFileException
-
customFieldEquals
public com.querydsl.core.types.dsl.BooleanExpression customFieldEquals(com.querydsl.core.types.EntityPath<?> sf, CustomField<?,?,?> customField)Description copied from interface:StoredFileHandlerReturns a query predicate that any property of type CustomField points to the given custom field- Specified by:
customFieldEqualsin interfaceStoredFileHandler
-
find
public final <T extends StoredFile> T find(Class<T> clazz, long id) throws EntityNotFoundException
Description copied from interface:StoredFileHandlerFinds aStoredFilein the catalog, if found returns the StoredFile with the specified id.
This method doesn't check if the related content is present through theStoredFileContentManager- Specified by:
findin interfaceStoredFileHandler- Throws:
EntityNotFoundException- if a stored file was not found.
-
getBytes
public byte[] getBytes(StoredFile storedFile) throws StoredFileException, EntityNotFoundException
Description copied from interface:StoredFileHandlerReturns the content of the specifiedStoredFileas bytes- Specified by:
getBytesin interfaceStoredFileHandler- Throws:
StoredFileExceptionEntityNotFoundException
-
getContent
public SerializableInputStream getContent(StoredFile storedFile) throws StoredFileException, EntityNotFoundException
Description copied from interface:StoredFileHandlerOpens an input stream to allow read the content of the specifiedStoredFile.
It is caller's responsibility to close the stream after read.- Specified by:
getContentin interfaceStoredFileHandler- Throws:
StoredFileExceptionEntityNotFoundException
-
getStorageDirectories
public Set<String> getStorageDirectories()
Description copied from interface:StoredFileHandlerReturns the set of directory names available for store an individual document or a custom field of type image/file configured in the cyclos.properties only if the underlyingStoredFileContentManagerimplementation support store files in a specific directory other than the default. Otherwise returns an empty Set.- Specified by:
getStorageDirectoriesin interfaceStoredFileHandler
-
getStorageDirectory
public String getStorageDirectory(StoredFile storedFile)
Description copied from interface:StoredFileHandlerReturns the storage directory, if any, for those cases where a custom storage directory can be specified (individual documents, image/file custom fields). Otherwise it returns null.- Specified by:
getStorageDirectoryin interfaceStoredFileHandler
-
isStoredOnDB
public boolean isStoredOnDB()
Description copied from interface:StoredFileHandlerReturns whether the underlying storage for files is database- Specified by:
isStoredOnDBin interfaceStoredFileHandler
-
move
public final void move(StoredFile source, StoredFile target) throws StoredFileException
Description copied from interface:StoredFileHandlerMoves the source's attributes and content to target REMOVING the source.- Specified by:
movein interfaceStoredFileHandler- Throws:
StoredFileException
-
remove
public final void remove(long id) throws StoredFileException, EntityNotFoundExceptionDescription copied from interface:StoredFileHandlerRemove the stored file and its content.- Specified by:
removein interfaceStoredFileHandler- Throws:
StoredFileExceptionEntityNotFoundException
-
save
public final void save(StoredFile storedFile, SerializableInputStream in) throws StoredFileException
Description copied from interface:StoredFileHandlerSaves (create/update) a stored file reading its content from the specified stream.
This method closes the providedSerializableInputStreamafter the method has completed.- Specified by:
savein interfaceStoredFileHandler- Throws:
StoredFileException
-
setStoredFileContentManager
public StoredFileContentManager setStoredFileContentManager(StoredFileContentManager storedFileContentManager)
The purpose of this method is only to facilitate the unit testing.- Returns:
- the previous
StoredFileContentManager
-
supportStorageDirectories
public boolean supportStorageDirectories()
Description copied from interface:StoredFileHandlerReturns true if the underlyingStoredFileContentManagerimplementation support store files in a specific directory other than the default- Specified by:
supportStorageDirectoriesin interfaceStoredFileHandler
-
-