Example scripts for site management

View example scripts for creating, publishing, promoting, and demoting a page by using the Portal Scripting Interface.


JACL code example for creating a page with a object ID for publishing:

# Scripting bean example: create a simple page (multi-column Layout)           
#                                                                              
 
# Procedure: create a multi-column page below the page that is currently       
# selected, and place the given portlets into the layout.                      
#                                                                              
# parameters:                                                                  
#   name              The name of the page                                     
#   portlet_names     A list of portlet names.                                 
# returns:
#   oid               The id of the page that has been created                 
proc create_multi_col_page { name uniqueName portlet_names } {           
  global Content Layout Portlet                                                
    set thePage  [$Content create page $name html]                              
    $Content select $thePage  
    /$Content set uniquename /$uniqueName                                  
    set lyt0  [$Layout create container horizontal select]                      
    foreach pn $portlet_names {                                                
      set pid  [$Portlet find portlet cn $pn]                                   
      $Layout create control $pid                                              
    }                                                                          
  return $thePage                                                              
}                                                                              
                                                                               
# main code starts here                                                        
                                                                               
# set User ID/ pwd for portal Login command                                    
# Hint: User ID and passwords should normally not be placed inside a           
# configuration script; better use property files or command line arguments    
  
set user portaladmin                                                           
set pwd  adminpwd                                                              
$Portal login $user $pwd                                                       
                                                                               
# determine and select the parent of the page to be created.                   
# In this example, This is the "Home" label.                                   
$Content select  [$Content find all uniquename "ibm.portal.Home"]               
                                                                               
# Invoke the page creation procedure. The label of the page is "My test page", 
# portlets to be added are the reminder portlet and the welcome portlet.   
set newbie  [create_multi_col_page "A Page" "aPage" 
           { "Reminder" "Welcome_to_WebSphere_Portal" } ]
                                                                               
puts "ok, we are done."       

This example is based on the testme.jacl example for creating a page under Script mode. The additions that are required for later publishing are highlighted.
JACL code example for publishing the page:

# Scripting bean example: publish a page with the uniquename of "pageUniqueName"
                                                                            
                                                                            
# main code starts here                                                     
                                                                            
# set User ID/ pwd for portal Login command                                 
# Hint: User ID and passwords should normally not be placed inside a        
# configuration script; better use property files or command line arguments 
 
set user portaladmin                                                        
set pwd  adminpwd                                                           
 
set sourceServer http://sourceServer:sourceport/wps/mycontenthandler        
set sourceUser sourceUser                                                   
set sourcePwd  sourcePwd
 
set targetServer http://targetServer:sourceport/wps/mycontenthandler
set targetUser targetUser                                                   
set targetPwd  targetPwd
 
set uniqueName "pageUniqueName"
set parentPage parentPage
set siblingPage siblingPage
 
set targetServerUniqueName MyTargetServerUn
                                                                            
$Portal login $user $pwd                                                    
                                                                            
# Publish a page               
 
$Publish publishPage $sourceServer $sourceUser $sourcePwd 
                     $targetServer $targetUser $targetPwd 
                     $uniqueName $parentPage $siblingPage 
                     $targetServerUniqueName true 
                                                                        
puts "ok, we are done."       

JACL code example for promoting the page:

# Scripting bean example: promote a page with the uniquename of 
#   "com.ibm.portal.published_aPage"
# main code starts here                                                        
                                                                               
# set User ID/ pwd for portal Login command                                    
# Hint: User ID and passwords should normally not be placed inside a           
# configuration script; better use property files or command line arguments 
 
set user portaladmin                                                           
set pwd  adminpwd                                                              
 
set server http://server:port/wps/mycontenthandler
set sUser sUser                                                        
set sPwd  sPwd
set promoteOption 0
 
set uniqueName "com.ibm.portal.published_aPage"
 
                                                         
$Portal login $user $pwd                                                       
                                                                               
# Promote a page               
 
$Publish promotePage $server $sUser $sPwd $uniqueName $promoteOption true 
                                                                               
puts "ok, we are done."      

JACL code example for demoting the page:

# Scripting bean example: demote a page with the uniquename of "aPage"         
# main code starts here                                                        
                                                                               
# set User ID/ pwd for portal Login command                                    
# Hint: User ID and passwords should normally not be placed inside a           
# configuration script; better use property files or command line arguments 
 
set user portaladmin                                                           
set pwd  adminpwd                                                              
 
set server http://server:port/wps/mycontenthandler
set sUser sUser                                                        
set sPwd  sPwd
 
set uniqueName "aPage"
                                                         
$Portal login $user $pwd                                                       
                                                                               
# Demote a page               
 
$Publish demotePage $server $sUser $sPwd $uniqueName true 
                                                                               
puts "ok, we are done."       


Parent

Portal Scripting Interface extension for site management
Publish a page using the Portal Scripting Interface
Promoting a page using the Portal Scripting Interface
Demoting a page using the Portal Scripting Interface

 


+

Search Tips   |   Advanced Search