Package org.ametys.cms.data.type.impl
Class FileRepositoryElementType
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.model.type.AbstractModelItemType
-
- org.ametys.core.model.type.AbstractElementType<File>
-
- org.ametys.cms.data.type.AbstractFileElementType
-
- org.ametys.cms.data.type.impl.FileRepositoryElementType
-
- All Implemented Interfaces:
RepositoryElementType<File>
,RepositoryModelItemType
,ElementType<File>
,ModelItemType
,LogEnabled
,PluginAware
,Component
,Configurable
,Contextualizable
,Serviceable
- Direct Known Subclasses:
FileContentElementType
public class FileRepositoryElementType extends AbstractFileElementType implements RepositoryElementType<File>
Class for file type of elements stored in the repository
-
-
Field Summary
-
Fields inherited from class org.ametys.cms.data.type.AbstractFileElementType
__EXPLORER_FILE_TYPE, _binaryType, _context, _resolver, _uploadManager, _userProvider
-
Fields inherited from class org.ametys.core.model.type.AbstractElementType
_jsonUtils
-
Fields inherited from interface org.ametys.plugins.repository.data.type.RepositoryModelItemType
EMPTY_METADATA_SUFFIX
-
-
Constructor Summary
Constructors Constructor Description FileRepositoryElementType()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
_isBinaryDataEmpty(RepositoryData parentData, String name)
private boolean
_isStringDataEmpty(RepositoryData parentData, String name)
private Object
_readFileFromBinaryData(RepositoryData parentData, String name)
private Object
_readFileFromStringData(RepositoryData parentData, String name)
private void
_writeMultipleBinaryValue(ModifiableRepositoryData parentData, String name, Binary[] value)
private void
_writeSingleBinaryValue(ModifiableRepositoryData parentData, String name, Binary binary)
String
getRepositoryDataType()
Retrieves the type of repository data used for this typeboolean
hasNonEmptyValue(RepositoryData parentData, String name)
Check if there is a non empty value in the given repository databoolean
isCompatible(RepositoryData parentData, String name)
Checks if the value in the given repository data is compatible with the item typeObject
read(RepositoryData parentData, String name)
Read the value in the given repository datavoid
write(ModifiableRepositoryData parentData, String name, Object value)
Write the value into the given repository dataprivate void
writeExplorerFile(ModifiableRepositoryData parentData, String name, ExplorerFile explorerFile)
-
Methods inherited from class org.ametys.cms.data.type.AbstractFileElementType
_compareMultipleValues, _compareSingleValues, _singleValueFromXML, _useJSONForEdition, _valueToSAX, configure, contextualize, convertValue, fromJSONForClient, isCompatible, isSimple, service, toString, valueToJSONForClient
-
Methods inherited from class org.ametys.core.model.type.AbstractElementType
_getValueAttributes, _isValueFromXMLMultiple, _singleValueToJSON, _singleValueToSAX, _valueToSAX, _valueToSAXForEdition, castValue, compareValues, getManagedClass, getManagedClassArray, parseConfiguration, valueFromXML, valueToSAX, valueToSAXForEdition
-
Methods inherited from class org.ametys.core.model.type.AbstractModelItemType
_getContextAttributes, getId, setPluginInfo
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.ametys.runtime.model.type.ElementType
castValue, compareValues, fromJSONForClient, getManagedClass, getManagedClassArray, isCompatible, isSimple, parseConfiguration, toString, valueFromXML, valueToJSONForClient
-
Methods inherited from interface org.ametys.runtime.model.type.ModelItemType
getId, valueToSAX, valueToSAX, valueToSAXForEdition
-
Methods inherited from interface org.ametys.runtime.plugin.component.PluginAware
setPluginInfo
-
Methods inherited from interface org.ametys.plugins.repository.data.type.RepositoryElementType
externalizableValueToSAX
-
Methods inherited from interface org.ametys.plugins.repository.data.type.RepositoryModelItemType
hasValue, isMultiple, remove
-
-
-
-
Constructor Detail
-
FileRepositoryElementType
public FileRepositoryElementType()
-
-
Method Detail
-
read
public Object read(RepositoryData parentData, String name) throws BadItemTypeException, AmetysRepositoryException
Description copied from interface:RepositoryElementType
Read the value in the given repository data- Specified by:
read
in interfaceRepositoryElementType<File>
- Parameters:
parentData
- repository data containing the valuename
- the name of the element to read- Returns:
- the value. Can return a T or a T[]. That's why the return type is Object
- Throws:
BadItemTypeException
- if the reading value doesn't match this element typeAmetysRepositoryException
-
_readFileFromStringData
private Object _readFileFromStringData(RepositoryData parentData, String name)
-
_readFileFromBinaryData
private Object _readFileFromBinaryData(RepositoryData parentData, String name)
-
hasNonEmptyValue
public boolean hasNonEmptyValue(RepositoryData parentData, String name) throws BadItemTypeException
Description copied from interface:RepositoryModelItemType
Check if there is a non empty value in the given repository data- Specified by:
hasNonEmptyValue
in interfaceRepositoryModelItemType
- Parameters:
parentData
- repository data containing the valuename
- the name of the element to check- Returns:
true
if there is a non empty value,false
otherwise- Throws:
BadItemTypeException
- if the reading value doesn't match this element type
-
_isStringDataEmpty
private boolean _isStringDataEmpty(RepositoryData parentData, String name)
-
_isBinaryDataEmpty
private boolean _isBinaryDataEmpty(RepositoryData parentData, String name)
-
write
public void write(ModifiableRepositoryData parentData, String name, Object value) throws BadItemTypeException
Description copied from interface:RepositoryElementType
Write the value into the given repository data- Specified by:
write
in interfaceRepositoryElementType<File>
- Parameters:
parentData
- repository where to store the value.name
- the name of the element to writevalue
- the value to write. Can be a T or a T[]. That's why it is an Object- Throws:
BadItemTypeException
- If the given value doesn't match this element type
-
writeExplorerFile
private void writeExplorerFile(ModifiableRepositoryData parentData, String name, ExplorerFile explorerFile)
-
_writeMultipleBinaryValue
private void _writeMultipleBinaryValue(ModifiableRepositoryData parentData, String name, Binary[] value)
-
_writeSingleBinaryValue
private void _writeSingleBinaryValue(ModifiableRepositoryData parentData, String name, Binary binary)
-
getRepositoryDataType
public String getRepositoryDataType()
Description copied from interface:RepositoryModelItemType
Retrieves the type of repository data used for this type- Specified by:
getRepositoryDataType
in interfaceRepositoryModelItemType
- Returns:
- the type of repository data used for this type
-
isCompatible
public boolean isCompatible(RepositoryData parentData, String name) throws UnknownDataException
Description copied from interface:RepositoryModelItemType
Checks if the value in the given repository data is compatible with the item type- Specified by:
isCompatible
in interfaceRepositoryModelItemType
- Parameters:
parentData
- repository data containing the data to checkname
- the name of the data to check- Returns:
true
if the data type matches the current type,false
otherwise- Throws:
UnknownDataException
- if there is no data in the parent repository data with this name
-
-