Novell Home

Using the GroupWise Post Office Record Count with IDM

Novell Cool Solutions: Feature
By David Gersic

Digg This - Slashdot This

Posted: 27 Jun 2007
 

Problem

A Forum reader recently asked:

"Has anyone got the Post Office Record Count piece to work? I am trying to query the record count of 2 or more post offices and place the user in the least populated post office.

I would like to build the the query with policy builder. I have tried the example in the GroupWise docs but keep getting errors. I need to know where to place the query to determine the count and the syntax to facilitate the count."

And here's the response from David Gersic ...

Solution

It works for me, here. I have a bunch of POs, and we want to keep them all "full" of users. Here's my Placement rule from the Subscriber channel:

<?xml version="1.0" encoding="UTF-8"?><policy
xmlns:query="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsQueryProcessor">
 <rule>
  <description>User Placement - Top Off PO1</description>
  <conditions>
   <and>
    <if-class-name op="equal">User</if-class-name>
    <if-xpath op="true">query:search($destQueryProcessor, "subtree", "",
"", "User", "50062", "PO1Dev", "Record Count") < 1000</if-xpath>
   </and>
  </conditions>
  <actions>
   <do-set-op-dest-dn>
    <arg-dn>
     <token-text xml:space="preserve">NIU\GW\PO1Dev</token-text>
    </arg-dn>
   </do-set-op-dest-dn>
   <do-break/>
  </actions>
 </rule>
 <rule>
  <description>User Placement - Top Off PO2</description>
  <conditions>
   <and>
    <if-class-name op="equal">User</if-class-name>
    <if-xpath op="true">query:search($destQueryProcessor, "subtree", "",
"", "User", "50062", "PO2Dev", "Record Count") < 1000</if-xpath>
   </and>
  </conditions>
  <actions>
   <do-set-op-dest-dn>
    <arg-dn>
     <token-text xml:space="preserve">NIU\GW\PO2Dev</token-text>
    </arg-dn>
   </do-set-op-dest-dn>
   <do-break/>
  </actions>
 </rule>
 <rule>
  <description>User Placement - Top Off PO3</description>
  <conditions>
   <and>
    <if-class-name op="equal">User</if-class-name>
    <if-xpath op="true">query:search($destQueryProcessor, "subtree", "",
"", "User", "50062", "PO3Dev", "Record Count") < 1000</if-xpath>
   </and>
  </conditions>
  <actions>
   <do-set-op-dest-dn>
    <arg-dn>
     <token-text xml:space="preserve">NIU\GW\PO3Dev</token-text>
    </arg-dn>
   </do-set-op-dest-dn>
   <do-break/>
  </actions>
 </rule>
 <rule>
  <description>User Placement - Top Off PO4</description>
  <conditions>
   <and>
    <if-class-name op="equal">User</if-class-name>
    <if-xpath op="true">query:search($destQueryProcessor, "subtree", "",
"", "User", "50062", "PO4Dev", "Record Count") < 1000</if-xpath>
   </and>
  </conditions>
  <actions>
   <do-set-op-dest-dn>
    <arg-dn>
     <token-text xml:space="preserve">NIU\GW\PO4Dev</token-text>
    </arg-dn>
   </do-set-op-dest-dn>
   <do-break/>
  </actions>
 </rule>
 <rule>
  <description>User Placement - Fill PO5</description>
  <conditions>
   <and>
    <if-class-name op="equal">User</if-class-name>
   </and>
  </conditions>
  <actions>
   <do-set-op-dest-dn>
    <arg-dn>
     <token-text xml:space="preserve">NIU\GW\PO5Dev</token-text>
    </arg-dn>
   </do-set-op-dest-dn>
   <do-break/>
  </actions>
 </rule>
 <rule>
  <description>Group Placement</description>
  <conditions>
   <and>
    <if-class-name op="equal">Group</if-class-name>
    <if-global-variable name="GW.Groups"
op="equal">true</if-global-variable>
   </and>
  </conditions>
  <actions>
   <do-set-op-dest-dn>
    <arg-dn>
     <token-text xml:space="preserve">PO1DEV</token-text>
    </arg-dn>
   </do-set-op-dest-dn>
   <do-break/>
  </actions>
 </rule>
</policy>

And here's a magic bit of XSLT that I needed to add to my Subscriber Output Transform to make it work:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet exclude-result-prefixes="query cmd dncv" version="1.0"

xmlns:cmd="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsCommandProcessor"

xmlns:dncv="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.DNConverter"

xmlns:query="http://www.novell.com/nxsl/java/com.novell.nds.dirxml.driver.XdsQueryProcessor"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <!-- parameters passed in from the DirXML engine -->
 <xsl:param name="srcQueryProcessor"/>
 <xsl:param name="destQueryProcessor"/>
 <xsl:param name="srcCommandProcessor"/>
 <xsl:param name="destCommandProcessor"/>
 <xsl:param name="dnConverter"/>
 <xsl:param name="fromNds"/>
 <!-- identity transformation template -->
 <!-- in the absence of any other templates this will cause -->
 <!-- the stylesheet to copy the input through unchanged to the output
-->
 <xsl:template match="node()|@*">
  <xsl:copy>
   <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
 </xsl:template>
 <!-- add your custom templates here -->
 <xsl:template match="search-attr[@attr-name='50062']">
  <search-attr attr-name="50035">
   <value>MailDev</value>
  </search-attr>
  <xsl:copy>
   <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
 </xsl:template>
</xsl:stylesheet>

The magic is that GroupWise needs two attributes in the search query, and I developed this with IDM 3.01, where only one search attribute was supported. This could probably be simplified now with IDM35 and its enhanced search token that can specify multiple search attributes, but I haven't done that yet.


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell