Domino Upgrade

Search

About Me

I am the "Lotus Technology & Productivity Advisor" for IBM Asia Pacific. I'm based in Singapore.
Reach out to me via:
Follow notessensei on Twitter
Yahoo IM
Skype
Sametime
IBM

Ads by Google

Twitter

Languages

Other languages on request.

Visitors

« What Does Your Birth Date Mean? | Main| Developing OpenSource Software is fun (allways) and paid for (sometime) »

Getting hold of your replication formulas (SnTT Sunday edition)

QuickImage

Since R6 we are able to manipulate replication formulas using Lotus Script. You simply retrieve the entry and update or delete it. There is only one problem: If you don't know what custom replication pairs are in your database you can't do anything about it. Since "wild" custom replication formulas are a nightmare to track down I created the following script and XSLT stylesheet to extract this information using DXL. My script simply creates documents that document the settings. It will be easy to extend the script to include deletion of the entries. Or you could modifiy it to track replication formulas in multiple databases.

As usual: your mileage might vary!

Option Public Option Declare Sub Initialize Dim db As NotesDatabase Dim notecol As NotesNoteCollection Dim exporter As NotesDXLExporter Dim importer As NotesDXLImporter Dim transformer As NotesXSLTransformer Dim result As String Dim stream As NotesStream Dim s As New NotesSession 'Setup envionment Set db = s.CurrentDatabase 'Create the collection Set notecol = db.CreateNoteCollection(False) Call notecol.SelectAllAdminNotes(True) 'ACL, Replication Formulas Call notecol.BuildCollection Print "Build the collection ..." 'Get the transformation stylesheet Set stream = getRichTextSource("DocumentCustomReplicationFormulas") 'Create the import/export/transformer Set exporter = s.CreateDXLExporter Set transformer = s.CreateXSLTransformer Set importer = s.CreateDXLImporter 'Now we need to wire the exporter to the transformer to the importer Call exporter.SetInput(notecol) Call exporter.SetOutput(transformer) Call transformer.SetStylesheet(stream) Call transformer.setOutput(importer) Call importer.setOutput(db) 'Set the parameters for processing exporter.ExitOnFirstFatalError = False importer.ReplaceDBProperties = False importer.ReplicaRequiredForReplaceOrUpdate = False importer.ACLImportOption = DXLIMPORTOPTION_IGNORE importer.DesignImportOption = DXLIMPORTOPTION_IGNORE importer.DocumentImportOption = DXLIMPORTOPTION_CREATE Print "Processing" On Error Resume Next Call exporter.Process Print "Backup completed" result = exporter.log Call stream.Close Beep Msgbox result, 0, Cstr(importer.importednotecount) & " Documents created" End Sub Function getRichTextSource(SourceName As String) As NotesStream 'Retrieves a RichTextitem from the XSLTDefinitions view Dim db As NotesDatabase Dim doc As NotesDocument Dim v As NotesView Dim tmpStream As NotesStream Dim rt As NotesRichTextItem Dim s As New NotesSession Set db = s.CurrentDatabase Set v = db.GetView("XSLTDefinitions") Set doc = v.GetDocumentByKey(SourceName,True) If doc Is Nothing Then Msgbox "XSLT Definition " & SourceName & "not found" Exit Function End If Set rt = doc.GetFirstItem("Body") Set tmpStream = s.CreateStream tmpStream.WriteText(rt.GetUnformattedText) tmpStream.Position = 0 Set getRichTextSource = tmpStream End Function
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.

Here is the stylesheet I used:

<xsl:stylesheetversion="1.0"exclude-result-prefixes="d">
<xsl:outputmethod="xml"version="1.0"encoding="UTF-8"indent="yes" />
<xsl:templatematch="/" >
<xsl:apply-templates />
</xsl:template>
<xsl:templatematch="d:database" >
<xsl:elementname="database" >
<xsl:attributename="version" >
<xsl:value-ofselect="@version" />
</xsl:attribute>
<xsl:attributename="maintenanceversion" >
<xsl:value-ofselect="@maintenanceversion" />
</xsl:attribute>
<xsl:apply-templatesselect="d:note[@class='replicationformula']" />
</xsl:element>
</xsl:template>
<xsl:templatematch="d:note[@class='replicationformula']" >
<xsl:elementname="document" >
<xsl:attributename="form" />
<xsl:apply-templatesselect="d:item[@name='$TITLE']" />
<xsl:apply-templatesselect="d:item[@name='$ReplSrcServers']" />
</xsl:element>
</xsl:template>
<xsl:templatematch="d:item[@name='$ReplSrcServers']" >
<xsl:elementname="item" >
<xsl:attributename="name" />
<xsl:copy-ofselect="d:textlist" />
</xsl:element>
</xsl:template>
<xsl:templatematch="d:item[@name='$TITLE']" >
<xsl:elementname="item" >
<xsl:attributename="name" />
<xsl:copy-ofselect="d:text" />
</xsl:element>
</xsl:template>
<xsl:templatematch="d:note[@default='true' and @class='replicationformula']" />
<xsl:templatematch="*" />
</xsl:stylesheet>
P.S.: If anybody knows a good tool/stylesheet to transform XML source to HTML, let me know.

Post A Comment

Please note: Comments without a valid and working eMail address will be removed. This is my site, so I decide what stays here and what goes.

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)

Disclaimer

This site is in no way affiliated, endorsed, sanctioned, supported, nor enlightened by Lotus Software nor IBM Corporation. I may be an employee, but the opinions, theories, facts, etc. presented here are my own and are in now way given in any official capacity. In short, these are my words and this is my site, not IBM's - and don't even begin to think otherwise. (Disclaimer shamelessly plugged from Rocky Oliver)

© 2003 - 2010 Stephan H. Wissel - all rights reserved as listed here: Creative Commons License
Unless otherwise labeled by its originating author, the content found on this site is made available under the terms of an Attribution/NonCommercial/ShareAlike Creative Commons License, with the exception that no rights are granted -- since they are not mine to grant -- in any logo, graphic design, trademarks or trade names of any type.

Get Firefox Use OpenDNS