update existing assets | Asset API
Dears, I have been using Asset API read and write operations, to update an attribute inside a link asset which is contained in a content asset. But the problem is read and update are done successfully but when i check the attribute updated from the contributor UI, i found it not changed.
Here is the code:
I try to read the link attribute (external URL) then updating it to append some text to it
and please note that link asset is contained as an attribute of a content asset
// read asset attributes given asset ID
Session ses = SessionFactory.getSession();
AssetDataManager mgr =(AssetDataManager)
ses.getManager( AssetDataManager.class.getName() );
AssetId id = new AssetIdImpl( "Link",linkId );
linkId = Long.valueOf(inputLinkValue);
List attrNames = new ArrayList();
attrNames.add( "externalUrl" );
AssetData data = mgr.readAttributes( id, attrNames );
AttributeData linkUrlDataName = data.getAttributeData("externalUrl");
externalLinkUrl = (String) linkUrlDataName.getData();
// this works fine and link external url is retrieved correctly
// then i will try to update its value:
Session ses = SessionFactory.getSession();
AssetDataManager adm = (AssetDataManager) ses.getManager( AssetDataManager.class.getName() );
Iterable assets = adm.read( Arrays.asList( new AssetIdImpl( "Content", Long.valueOf(instance.getAssetID())),new AssetIdImpl( "Link", linkId))