How to acquire instance of AssetStore or AssetHandler?
how acquire instance of assestore or assethandler? end goal use them create new rendition, example:
resource imageresource = resourceresolver.getresource(pathindam);
asset asset = imageresource.adaptto(asset.class);
assethandler handler = assetstore.getassethandler(asset.getmimetype());
thumbnailconfig myconfig = new thumbnailconfig(){
public boolean docenter() {return true;}
public int getheight() {return 95;}
public int getwidth() {return 95;}
};
list<thumbnailconfig> configs = new arraylist<thumbnailconfig>();
configs.add(myconfig);
handler.createthumbnails(asset, configs);
the missing piece puzzle on 3rd line: assetstore.getassethandler not static method , i've spent 2 hours decompiling half jars in sling trying figure out how workflowprocess class gets instance class can same.... i'm hoping there's either factory i'm not familiar or else registered service can't find.
cheers , thanks
-lance dolan
citytech inc
ah, found in fact registered service... should have checked first.
solution:
slingbindings bindings = (slingbindings) req.getslingrequest().getattribute(slingbindings.class.getname());
slingscripthelper slingscripthelper = bindings.getsling();
assetstore store = slingscripthelper.getservice(assetstore.class);
my next hurdle figuring out why rendition isn't persisted crx after method runs:
handler.createthumbnails(asset, configs);
if log.debug() renditions after running this, see rendition added asset's renditions list, correct path , name, rendition doesn't exist in crx afterwards. hmm.
More discussions in Archived Spaces
adobe
Comments
Post a Comment