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)
Selectively clearing the "Deleted Items" folder
System
I would like to remove from the "Deleted Items" container only the assets that have been there for more than one week (just to give users the time to realize they made a mistake and ask the administrator to undelete a given file).
Is there a way to do this? I haven't found any metadata that may allow me to do it.
Thanks in advance
Folco
Find more posts tagged with
Comments
lyman
Afraid that cleaning Deleted Items has been implemented as an atomic operation (i.e., no). You might be able to accomlpish something similar with some extremely fancy script writing, but there is no easy way to accomplish this.
Sorry about that.
Lyman Hurd
MediaBin Server Team
Migrateduser
Fancy script writing like "direct queries in the database"?
Does MediaBin keep track internally of when an asset was added to the "Deleted Items" container?
Folco
lyman
>Fancy script writing like "direct queries in the database"?
Not recommended as we don't guarantee consistency in the database models between releases. I.e., harmless manipulation in one case could be disastrous in the next release!
>Does MediaBin keep track internally of when an asset was added to the "Deleted Items" container?
>Folco
Yes, there's a searchable field called TimeStamp (internally called refModified) that tracks when an asset has moved or been renamed. The act of putting something in Deleted Items "looks" like a move.
More sophisticated aging/archiving strategies are certainly on the drawing board. We're always interested in hearing about use cases.
Cheers,
Lyman Hurd
Interwoven - MediaBin Server Team
Migrateduser
As we were expecting, the situation has come up...
Users deleted some files (quite a few, so that they can't give us the exact filenames) by mistake, and came to us saying "we deleted them yesterday".
Now, we only perform the cleanup once a month, and right now the amount of files in the Deleted Items folder is huge...
I would appreciate if you could post here a database query for version 4.01 to retrieve the IDs of the assets moved into "Deleted Items" in the last x days.
Thanks in advance
Folco Banfi
lyman
There is a timestamp field that can be searched on. In other words, to find files deleted after 10/21/2004 you would search with root Deleted Items (you have to be an MBAdmin for that) timestamp >= '10/21/2004'. Unfortunately you must be running a script as it is not exposed in the UI (it was implemented for internal reasons). I will post a sample script shortly.
I stress that direct manipulation (even read-only) of the database is only recommended in extremely limited circumstances (i.e., querying logs).
Cheers,
Lyman Hurd
Interwoven
MB Server Team
MediaBin Server Team
Interwoven, Inc.
lyman
Here's a start adapted by one of our script writers. He points out that with some work one could make the script move the files instead of just listing them. Exuse the unnecessary parts.
You need to determine the container id of Deleted Items and, of course, insert your own login credentials. Let m eknow if you have more questions and I'll pass them on.
Cheers,
Lyman Hurd
MB Server Team
What follows is a vbs:
'Option Explicit
'****************************************************************
'*** These values should be modified based on environment
' MediaBin logon info
Const MEDIABIN_SERVER = ""
Const MEDIABIN_DOMAIN = ""
Const MEDIABIN_USERID = ""
Const MEDIABIN_PASSWORD = ""
Const MEDIABIN_PORT = -1
'ID of the container to search
Const ContainerID = ""
Const g_UseTimeStamp = true
'******************************************
' ID of the Timestamp metadata
Const TimeStampID = "{0E2D45EE-C317-4a51-BFFC-7FE1B16EFC8E}"
' ID of the Timestamp metadata
Const AssetTypeID = "{4510D310-E6BB-11D2-BF95-00A024DB7160}"
'Sort Order types
Const SortByAssetName = 1
'Metadata search operators
const SearchEqual = 0
const SearchNotEqual = 1
const SearchLessThan = 2
const SearchGreaterThan = 3
Const SearchLessThanEqual = 4
const SearchGreaterThanEqual = 5
Dim g_objSession
On Error Goto 0
'Begin
Err.Clear
Main()
'*******************************************************
'*** Main
'*******************************************************
Function Main()
' connect to MediaBin
Set g_objSession = CreateObject("MBPScriptModel.MBSession")
If Err.Number <> 0 Then
WScript.Echo FormatDateTime(Now) & " --- Cannot create scriptmodel component.", Err
Else
g_objSession.Logon MEDIABIN_SERVER, MEDIABIN_DOMAIN, MEDIABIN_USERID, MEDIABIN_PASSWORD, MEDIABIN_PORT
If Err.Number <> 0 Then
WScript.Echo FormatDateTime(Now) & " --- Cannot log on to MediaBin.", Err
Else
WScript.Echo "Succesful logon to: " & g_objSession.ServerName
TestSearch()
End If ' else logged on to MediaBin successfully
g_objSession.Logoff
Set g_objSession = nothing
End if
End Function
Function TestSearch()
dim objSrcContainer
dim searchValue
dim searchId
dim searchOp
'We will either search on timestamp or asset type
if g_UseTimeStamp then
searchValue = CDate(#10/21/2004#)
searchId = TimeStampID
searchOp = SearchGreaterThanEqual
WScript.Echo "Searching on timestamp: " + FormatDateTime(searchValue)
else
searchValue = 1 'JPEG
searchId = AssetTypeID
searchOp = SearchEqual
WScript.Echo "Searching on asset type = JPEG"
End if
If ContainerID <> "" Then
set objSrcContainer = g_objSession.GetContainer( ContainerID )
Else
WScript.Echo "ContainerID is not set...defaulting to the Root container"
set objSrcContainer = g_objSession.RootContainer
End if
WScript.Echo "Searching in: " + objSrcContainer.Name
dim objSearchConstraint 'As MBSearchConstraint
set objSearchConstraint = g_objSession.CreateMetaDataCompareSearchConstraint(searchID, searchOp, searchValue)
dim objSearchCriteria 'As MBSearchCriteria
set objSearchCriteria = g_objSession.CreateConstraintSearchCriteria(objSearchConstraint, &H7FFFFFFF)
dim colSearchResults
set colSearchResults = objSrcContainer.FindAllAssets (objSearchCriteria)
colSearchResults.Sort SortByAssetName
dim arrSearchResults()
redim preserve arrSearchResults (colSearchResults.Count-1)
WScript.Echo "Assets found: " & colSearchResults.Count
for each objAsset in colSearchResults
WScript.Echo "Name: " & objAsset.Name & " ID: " & objAsset.Identifier
next
End Function
MediaBin Server Team
Interwoven, Inc.
Migrateduser
Thank you for the script. It's certainly a good base to work upon for those rare occasions in which we will need to do something like that.
Folco Banfi
Migrateduser
I made some tests, and it works rather well for what we had in mind.
Searching using the TimeStamp works just fine.
However, I have the impression that this TimeStamp metadata is unreadable, as I cannot find a way to display its value.
I would like to display it so that the administrator who is restoring the files can see when the file was deleted.
Thanks in advance.
Folco Banfi
lyman
That is correct. The Timestamp field is meant primarily for special-purpose scripts and is not directly displayed.
Lyman Hurd
MB Server Team
MediaBin Server Team
Interwoven, Inc.
Migrateduser
What I ended up doing is a script that restores all assets/containers that were sent to the Deleted Items folder after a given date into a particular container.
People may be interested in knowing that when you delete a container its hidden timestamp is updated, but those of the assets/containers within it are not.
Folco Banfi
lyman
Good observation. In fact it goes a bit further than that. A delete of a container is implemented similarly to a move in that the parent is modified but the system does not change anything below it (as you may imaine, this makes the operation extremely efficient). Neither moves or deletes of a container affect the timestamp of their children. This phenomenon is taken into account by the Syndication Manager when it uses this field.
We could have made the server modify these fields but we decided that was a lot of overhead to impose on the operation for a limited set of use cases and there are workarounds as you found. Doing it the other way would penalize people doing moves/deletes who have no reason to worry about the timestamp.
Cheers,
Lyman Hurd
MediaBin Server Team
MediaBin Server Team
Interwoven, Inc.
Migrateduser
I understand that fully
I was not criticizing, I just wanted other people that may be using the timestamp in the future to be aware of it. It's easy to work around once you know that it works like that.
Folco Banfi