private static void addDeleteDirective ( Element compViewNode , String elementID , IPerson person , Document plf , Element delSet ) throws PortalException { String ID = null ; try { ID = getDLS ( ) . getNextStructDirectiveId ( person ) ; } catch ( Exception e ) { throw new PortalException ( "Exception encountered while " + "generating new delete node " + "Id for userId=" + person . getID ( ) , e ) ; } Element delete = plf . createElement ( Constants . ELM_DELETE ) ; delete . setAttribute ( Constants . ATT_TYPE , Constants . ELM_DELETE ) ; delete . setAttribute ( Constants . ATT_ID , ID ) ; delete . setAttributeNS ( Constants . NS_URI , Constants . ATT_NAME , elementID ) ; delSet . appendChild ( delete ) ; // now pass through children and add delete directives for those with // IDs indicating that they were incorporated Element child = ( Element ) compViewNode . getFirstChild ( ) ; while ( child != null ) { String childID = child . getAttribute ( "ID" ) ; if ( childID . startsWith ( Constants . FRAGMENT_ID_USER_PREFIX ) ) addDeleteDirective ( child , childID , person , plf , delSet ) ; child = ( Element ) child . getNextSibling ( ) ; } }
This method does the actual work of adding a delete directive and then recursively calling itself for any incoporated children that need to be deleted as well .