I have over 11,000 documents in an image archive DB, all with a hotspot URL link on a thumbnail to a larger version of the image on a server. The server directory structure has just been changed and I now need to globally replace a portion of all the hotspot URL links from
http://server.domain/docs/photos/unique_picture_id.gif
to
http://docs.domain/photos/unique_picture_id.gif
Is there a way to do the string replacement? An agent seems the best tool, but I don’t know how to code the search for a hotspot value.
Thanks!
Subject: Global replacement of hotspot URL link
The best way to do it is to:
-
export the data documents as DXL;
-
pipe them to a NotesDOMParser;
-
use GetElementsByTagName(“urllink”) to get the collection of all URL hotspots;
-
cycle through the resulting NotesDOMNodeList, using GetAttribute(“href”) to see if the URL contains the old server string (all the way to the last “/”);
-
if the old server string is present, then SetAttribute(“href”,newServerString & StrRightBack(oldHREFValue,“/”))
-
re-import the data when done, making sure that the NotesDXLImporter’s DocumentImportOption is set to DXLIMPORTOPTION_REPLACE_ELSE_IGNORE or DXLIMPORTOPTION_REPLACE_ELSE_CREATE.
Designer Help has most of the code you need in the examples for NotesDXLExporter, NotesDOMParser and NotesDXLImporter.
Subject: Stan’s right, but there is an alternative
I’m sure someone will shoot me for hawking a third party product, but while Stan is right, that sounded like a fair amount of work to me, so I took about five minutes and wrote the following agent using my company’s Midas Rich Text LSX. It does the job quickly and easily. Now, granted, it costs something, but you could have the job fixed before the weekend, and still own a license to Midas for the next time a rich text job comes up. Just an alternative to think about:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtitem As New GeniiRTItem
Dim rtchunk As GeniiRTChunk
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument
While Not (doc Is Nothing)
Call rtitem.ConnectBackend(doc.Handle, "Body")
Call rtitem.Everything.ReplaceText("http://server.domain/docs/photos/", "http://docs.domain/photos/", "URL")
rtitem.Save
Set doc = collection.GetNextDocument(doc)
Wend
End Sub
Subject: *Bang!!!
It IS a lot of work, especially if you want to do something more than a search-and-replace – and the DOM parser is a memory hog (a parsed DOM tree can be many times larger than the document it represents). Midas is a much better idea if you can swing it.
Subject: RE: *Bang!!!
Hi,
Another option is configure in the WEB view of your DD a redirection rule.
That one is the faster you have…
HTH
Daniel
Subject: Redirection rule
Thank you Stan and Ben for your kind offerings, but for this non-programmer it looks like Daniel’s idea might be easiest to try first.
B/R,
Rick