Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
Reported by project member bdelacretaz, May 26, 2010
The ContentItem can currently only provide an InputStream for its data, but in some cases other
data types (String, RDF graph, etc.) might be convenient.
As discussed at the hackathon, using an adapter pattern allows us to do this in a flexible way, the
ContentItem interface would then look like this:
public interface ContentItem {
/** Unique ID, either supplied by client or generated by FISE */
String getId();
/** The binary content stream
- @deprecated use adaptTo(InputStream.class) */
InputStream getStream();
/** Adapt to specified class, for example InputStream, String,
- RDF graph or future raw/formatted content types.
- @return null if not adaptable
*/
<AdapterType> AdapterType adaptTo(Class<AdapterType> type);
/** Mime-type of the input stream */
String getMimeType();
/** Optional metadata */
MGraph getMetadata();
}
At first adaptTo would only work for InputStream, so it's a minor code change.
Later we can add an AdapterFactory service interface to provide more adapters.
The Sling codebase uses that pattern, see examples there.
The adaptTo method needs a second parameter for options, probably a Map.
Use case: adapt to an InputStream with mime type image/jpeg
Attachments
Issue Links
- relates to
-
STANBOL-414 Refactor EnhancementEngine to support contents with multiple related parts
- Closed