Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.api.model.impl.primitives
Class ExternalBlobProperty

java.lang.Object
  extended by org.nuxeo.ecm.core.api.model.impl.AbstractProperty
      extended by org.nuxeo.ecm.core.api.model.impl.ComplexProperty
          extended by org.nuxeo.ecm.core.api.model.impl.MapProperty
              extended by org.nuxeo.ecm.core.api.model.impl.primitives.ExternalBlobProperty
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Property>, Map<String,Property>, Property

public class ExternalBlobProperty
extends MapProperty

Property handling an external blob: create/edit is done from a map, and the value returned is a blob.

Create/edit from a blob is not handled, and the blob uri cannot be retrieved from the blob (no api for now).

Author:
Anahide Tchertchian
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static String DIGEST
           
static String ENCODING
           
static String FILE_NAME
           
static String LENGTH
           
static String MIME_TYPE
           
static String URI
           
 
Fields inherited from class org.nuxeo.ecm.core.api.model.impl.AbstractProperty
IS_READONLY, IS_VALIDATING, KEYED_DATA
 
Fields inherited from interface org.nuxeo.ecm.core.api.model.Property
DIRTY_MASK, IS_DIRTY, IS_MODIFIED, IS_MOVED, IS_NEW, IS_PHANTOM, IS_REMOVED, NONE
 
Constructor Summary
ExternalBlobProperty(Property parent, Field field)
           
ExternalBlobProperty(Property parent, Field field, int flags)
           
 
Method Summary
static Blob getBlobFromMap(Map<String,Object> mapValue)
           
static Map<String,Serializable> getMapFromBlob(Blob blob)
           
 Map<String,Serializable> getMapFromBlobWithUri(Blob blob)
           
<T> T
getValue(Class<T> type)
          Gets the property value as the given type.
 Serializable getValueForWrite()
          Gets the property normalized value for write.
 void init(Serializable value)
          Initializes the property with the given normalized value.
 Serializable internalGetValue()
           
 void setValue(Object value)
          Overridden to be able to set a blob from a given map.
 
Methods inherited from class org.nuxeo.ecm.core.api.model.impl.MapProperty
accept, clone, getField, getName, getType, internalSetValue, isContainer
 
Methods inherited from class org.nuxeo.ecm.core.api.model.impl.ComplexProperty
addEmpty, addValue, addValue, clear, containsKey, containsValue, entrySet, get, get, get, getChild, getChildren, getDirtyChildren, getNonPhantomChild, getNonPhantomChildren, isEmpty, isNormalized, isSameAs, keySet, normalize, put, putAll, remove, values, visitChildren
 
Methods inherited from class org.nuxeo.ecm.core.api.model.impl.AbstractProperty
areFlagsSet, clearDirtyFlags, clearFlags, convertTo, getData, getData, getDirtyFlags, getParent, getPath, getRoot, getSchema, getValue, getValue, getValue, isComplex, isDirty, isList, isModified, isMoved, isNew, isPhantom, isReadOnly, isRemoved, isScalar, isValidating, iterator, moveTo, newInstance, remove, removePhantomFlag, resolvePath, resolvePath, setData, setData, setFlags, setIsModified, setReadOnly, setValidating, setValue, setValue, size, toString, validate, validateType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode, size
 

Field Detail

ENCODING

public static final String ENCODING
See Also:
Constant Field Values

MIME_TYPE

public static final String MIME_TYPE
See Also:
Constant Field Values

FILE_NAME

public static final String FILE_NAME
See Also:
Constant Field Values

DIGEST

public static final String DIGEST
See Also:
Constant Field Values

LENGTH

public static final String LENGTH
See Also:
Constant Field Values

URI

public static final String URI
See Also:
Constant Field Values
Constructor Detail

ExternalBlobProperty

public ExternalBlobProperty(Property parent,
                            Field field,
                            int flags)

ExternalBlobProperty

public ExternalBlobProperty(Property parent,
                            Field field)
Method Detail

init

public void init(Serializable value)
          throws PropertyException
Description copied from interface: Property
Initializes the property with the given normalized value.

The given value must be normalized - note that no check is done on that.

The phantom flag is unset by this operation.

This method should be used to initialize properties.

Specified by:
init in interface Property
Overrides:
init in class ComplexProperty
Parameters:
value - the normalized value to set
Throws:
PropertyException

internalGetValue

public Serializable internalGetValue()
                              throws PropertyException
Overrides:
internalGetValue in class ComplexProperty
Throws:
PropertyException

getValue

public <T> T getValue(Class<T> type)
           throws PropertyException
Description copied from interface: Property
Gets the property value as the given type.

The value is converted using the registered converter to the given type.

If conversion is not supported a runtime exception will be triggered.

Specified by:
getValue in interface Property
Overrides:
getValue in class AbstractProperty
Returns:
the property value, which may be null
Throws:
PropertyException

getValueForWrite

public Serializable getValueForWrite()
                              throws PropertyException
Description copied from interface: Property
Gets the property normalized value for write.

Can be different fropm Property.getValue() in cases where the property adapts the value it is given to store.

Specified by:
getValueForWrite in interface Property
Overrides:
getValueForWrite in class ComplexProperty
Returns:
the property value to use for write, which may be null
Throws:
PropertyException

setValue

public void setValue(Object value)
              throws PropertyException
Overridden to be able to set a blob from a given map.

Take care of not overriding the uri if set as this information is not on the blob.

Specified by:
setValue in interface Property
Overrides:
setValue in class ComplexProperty
Parameters:
value - the value to set
Throws:
PropertyException - if one of the sub properties throws an exception or if trying to set values to a blob without any already existing uri set.

getBlobFromMap

public static Blob getBlobFromMap(Map<String,Object> mapValue)

getMapFromBlobWithUri

public Map<String,Serializable> getMapFromBlobWithUri(Blob blob)
                                               throws PropertyException
Throws:
PropertyException

getMapFromBlob

public static Map<String,Serializable> getMapFromBlob(Blob blob)

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.