###   
### remove_DS.jacl   
###   
###   
###   
###   
###   
   
proc remove_DS {cname nname sname xQCF} {   
   
    puts "Removing MQQueueConnectionFactory: $cname $nname $sname $xQCF"
       
    ###   
    ### Set up globals   
    ###   
       
    global AdminConfig   
    global AdminControl   
    global AdminApp   
       
    
    set JMSProviderID [$AdminConfig getid /Cell:$cname/Node:$nname/Server:$sname/JMSProvider:/]

    if {[llength $JMSProviderID] == 0} {
         puts "JMSProvider ID null - returning "
         continue
    }


    set JMSProviderName [$AdminConfig showAttribute $JMSProviderID name]


    set zQCF [$AdminConfig getid /Cell:$cname/Node:$nname/Server:$sname/JMSProvider:$JMSProviderName/MQQueueConnectionFactory:$xQCF]
    
    
    foreach xp $zQCF {
    
        if {[llength $xp] != 0} {
        
            puts "Removing Queue Connection Factory Id: $xp"
            $AdminConfig remove $xp
            
            
            ###
            ### Save and sync
            ###
            puts "Saving and syncing...."

            $AdminConfig save   
            
            set Sync1 [$AdminControl completeObjectName type=NodeSync,node=$nname,*]
            set xstatus [$AdminControl invoke $Sync1 sync]
            
            
            if {$xstatus == "false"} {
                puts "Unable to synchronize..."
            }
        }
    }
}   
   
   
   
###   
### Main   
###   
   
   
if { !($argc == 4) } {   
   puts ""   
   puts "Usage:  "   
   puts " "   
   puts "wsadmin.sh -username system -password password -f remove_DS.jacl cell node server \"Queue Connection Factory\""
   puts ""   
   puts "For example:  "   
   puts " "   
   puts "wsadmin.sh -username was -password acme@ -f  remove_DS.jacl jupiterNetwork jupiter jupiterA \"Read Only DS\""
} else {    
   set zcell            [lindex $argv 0]     
   set znode            [lindex $argv 1]     
   set zserver          [lindex $argv 2]     
   set zMQQueueConnectionFactory     [lindex $argv 3]     
   remove_DS $zcell $znode $zserver $zMQQueueConnectionFactory
}