peregrine-cms icon indicating copy to clipboard operation
peregrine-cms copied to clipboard

per:Asset should inherit form nt:file

Open cmrockwell opened this issue 3 years ago • 2 comments

The per:Asset in Peregrine is intended to work with binary files such as images. As such they should inherit from nt:file, and then a per:Asset resource can be adapted to an Inputstream. This is necessary to make use of org.apache.sling.thumbnails

cmrockwell avatar Jul 13 '21 20:07 cmrockwell

@cmrockwell not sure if we really should make per:Asset depend on nt:file - an asset does not need to be a file, right? its more the sub node that holds the content that would need to be a file

reusr1 avatar Jul 14 '21 14:07 reusr1

nt:file isn't literally a file. it's a JCR node meant to represent storage of a file.

Nodes of this node type may be used to represent files. This node type inherits the child nodes and properties of nt:hierarchyNode and requires a single child node called jcr:content. The jcr:content node is used to hold the actual content of the file.

It's the same thing as per:Asset as for as I can tell. When per:Asset inherits from nt:file, then Sling Thumbnail can process per:Assets, but currently the following method returns null.

@Override
public InputStream getThumbnail(Resource resource) {
    return resource.adaptTo(InputStream.class);
}

Only nt:file and nt:resource types can be adapted to an InputStream. So Sling Thumbnails could only process per:Assets if we approve this PR.

In addition, we might also make per:AssetContent inherit from nt:resource because this has same relationship to nt:file as per:AssetContent does to per:Asset.

https://docs.adobe.com/content/docs/en/spec/jcr/1.0/6.7.22.6_nt_file.html https://docs.adobe.com/content/docs/en/spec/jcr/1.0/6.7.22.9_nt_resource.html

cmrockwell avatar Jul 14 '21 19:07 cmrockwell