Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
DeleteAsset using revision 0 - correct webservice behaviour
Sky_Rumsey
Hi
I'm back doing the MediaBin development (mass import of 400gb of files, and then a nightly scheduled import tool), and during my last stages of code, I want to implement the following business role:
MediaBin should keep no more than N number of asset revisions per asset (currently 2). On an import of an asset, delete all outstanding assets (earliest revision No first) and revise latest with new asset info.
I've done the code required for this
private static void deleteOldAssets(
MBAssetRevision[] assets,
int noRevisionsToKeep)
{
if (assets == null || noRevisionsToKeep<=0)
return;
string assetId = assets[0].mID;
// attempt to delete all assets that fall out of the number
// we are wanting to keep - any problems throw error
// to dangerous to handle
for (int i = assets.Length; i >=noRevisionsToKeep; i--)
{
int revisionNo = assets[i-1].revision;
if (!mbs.DeleteAsset(assetId, revisionNo))
{
string errMess = string.Format("Unable to delete Asset {0}, Revision {1}",
assetId,
revisionNo);
Classes.Log.WriteError(errMess);
throw new ApplicationException(errMess);
}
}
}
Where mbs is an instance of the MediaBinServer webservice (all in c#) and using v4.5.3
One thing I've encountered, is that if the revision number is 0, it deletes the all asset revisions! Is this the correct behaviour? If so, how do I delete revision 0 of an asset? It must possible as you can delete the Revision 0 using the Web Client.
If I delete revision 0 using the client, then revision's 1-N delete just fine!
In main -
1) How do I delete revision 0 for a given asset Id using the webservice API
2) Can you configure MediaBin to keep N number of revision only?
3) Is my methodology acceptable - is there a better way of keeping N revision and removing them rather than trawling through the returning array from GetAssetRevisions(string assetId)?
4) Does GetAssetRevisions(string assetId) always return the assets in order of revision no with index 0 being the latest revision? (I am relying on this without implementing my own sorting!)
In the meantime, we are bypassing asset revision 0 and jumping onto the next one, which is all a little awkward!
Look forward to someone's response, and merry xmas!
Kind Regards
Sky Rumsey
Find more posts tagged with
Comments
lyman
I can fill in the server behavior.
Deleting revisions is one of the few operations in MediaBin that destroy data and cannot be reversed. The data being deleted does not get moved to Deleted Items, but rather is immediately expunged. Partially because of this we do not have a way to automatically keep only N revisions server side.
Just as a possible alternative, you might consider occasionally doing an asset copy of the folder and then deleting the originals. Copy only copies the last revision of an asset.
The web service behavior is a bug and I am informed that a patch is in process.
Cheers,
Lyman Hurd