Weblogic portal content propagation using Ant tasks

Content propagation is the process of moving portal artifacts from from one domain environment to other usually from staging to production. This moving basically involves the contents from database & ldap.






Weblogic offers three ways to do this:
1. Using Weblogic workshop by creating propagation session.
2. Customized Ant scripts
3. Import/export utility.

When you use weblogic workshop, it involves a lot of manual tasks. Those manual tasks are error prone. I thought ant scripts are more effective as you have a lot of control and it is automated process. I never tried the third option. This blog will cover how to do propagation using ant scripts.

Pre-requests:
Both source & destination admin server should be running and should have same weblogic portal version. Ant environment variable needs to be set up.

How to set up Ant:
1. Create environment variabale ANT_HOME in your local machine with value ${BEA_HOME}\modules\org.apache.ant_1.6.5. Eg: if you installed in C drive, value would be C:\bea\modules\org.apache.ant_1.6.5
2. Create another variable called ANT_OPTS with value of -Xmx500M

Steps for propagation:
1. Create a folder called propagation from you planned to run scripts

2. Copy propagation.xml file from below into propagation folder.

propagation.xml:


<?xml version="1.0" ?>
<!-- ==================================================================== -->
<!-- Propagation Ant Script -->
<!-- Author        :        Ananth Kannan -->
<!-- Date        :        05/30/2008      -->
<!-- Title:       propagation.xml                                            -->
<!--                                                                         -->
<!-- Usage Notes:                                                            -->
<!--                                                                         -->
<!-- The normal sequence of using this script is to invoke the targets in    -->
<!-- the following order:                                                    -->
<!--                                                                         -->
<!-- ant pingSrc                                                             -->
<!-- ant pingDest                                                             -->
<!-- ant downloadSrc                                                         -->
<!-- ant validateSrc                                                         -->
<!-- ant downloadDest                                                        -->
<!-- ant validateDest                                                        -->
<!-- ant combine                                                             -->
<!-- ant commit                                                                 -->
<!-- ant uploadCombined                                                      -->
<!--                                                                         -->
<!-- ======================================================================= -->

<project name="Portal Propagation Ant Tasks" basedir="." default="usage">
    <property environment="env"/>

    <!-- Environment Settings -->
   
    <!-- Runtime: this variable must point to your install directory. -->
    <property name="deploy.dir" value="C:\bea\wlserver_10.0"/>

    <!-- Runtime: this variable must indicate where the files will be read/written. -->
    <property name="working.dir" value="C:\propagation"/>

    <!-- Source: -->
    <!--         Setup the variables that identify your source environment (staging, for example) -->
    <!--         These variables are explained below, or consult the Propagation Ant Task documentation. -->
    <property name="source.servlet.url" value="http://{src_admin_server}:7001/EAR_NamePropagation/inventorymanagement"/>
    <property name="source.admin.username" value="weblogic"/>
    <property name="source.admin.password" value="weblogic"/>
    <property name="source.allow.http" value="true"/>

    <!-- Destination: -->
    <!--         Setup the variables that identify your destination environment (production, for example) -->
    <!--         These variables are explained below, or consult the Propagation Ant Task documentation. -->
    <property name="dest.servlet.url" value="http://{dest_admin_server}:7001/EAR_NamePropagation/inventorymanagement"/>
    <property name="dest.admin.username" value="weblogic"/>
    <property name="dest.admin.password" value="weblogic"/>
    <property name="dest.allow.http" value="true"/>
   
    <path id="onlineTask.classpath">
        <pathelement location="${deploy.dir}/platform/lib/p13n/p13n_common.jar"/>
        <pathelement location="${deploy.dir}/portal/lib/propagation/propagation.jar"/>
        <pathelement location="${deploy.dir}/portal/lib/propagation/propagation_ant.jar"/>
        <pathelement location="${deploy.dir}/portal/lib/propagation/content_prop.jar"/>
        <pathelement location="${deploy.dir}/portal/lib/propagation/netuix_prop.jar"/>
    </path>
   
    <path id="offlineTask.classpath">
        <pathelement location="${deploy.dir}/platform/lib/p13n/p13n_common.jar"/>
        <pathelement location="${deploy.dir}/platform/lib/wlp/wsrp-common.jar"/>
        <pathelement location="${deploy.dir}/portal/lib/propagation/propagation.jar"/>
        <pathelement location="${deploy.dir}/portal/lib/propagation/propagation_ant.jar"/>
        <pathelement location="${deploy.dir}/portal/lib/propagation/content_prop.jar"/>
        <pathelement location="${deploy.dir}/portal/lib/propagation/netuix_prop.jar"/>
        <pathelement location="${deploy.dir}/server/lib/api.jar"/>
        <pathelement location="${deploy.dir}/../modules/com.bea.core.xml.beaxmlbeans_2.2.0.0.jar"/>
        <pathelement location="${deploy.dir}/../modules/com.bea.core.weblogic.stax_1.0.1.0.jar"/>
        <pathelement location="${deploy.dir}/../modules/com.bea.core.utils_1.0.1.0.jar"/>   
    </path>   

    <!--
        SERVLET.URL:
       
        The online Propagation ant tasks require that the Propagation servlet be deployed in the
        application. By default, Portal applications will include the Propagation application library
        module which deploys the Propagation web application. Look for the following in the application's
        META-INF/weblogic-application.xml
       
       <library-ref>
           <library-name>wlp-propagation-app-lib</library-name>
       </library-ref>
       <library-context-root-override>
           <context-root>propagation</context-root>
           <override-value>portalAppPropagation</override-value>
       </library-context-root-override>
      
       In this example, the Propagation application module has been included, and the Propagation
       web application which is normally at context root "propagation" has been overridden to listen
       to context path "portalAppPropagation". Therefore, the servletURL in this case would be:
      
       http://hostname:port/portalAppPropagation/inventorymanagement
      
       The Propagation servlet is deployed by default to map to "inventorymanagement".
     -->

    <!-- ==================================================================== -->
    <!-- Targets -->
    <!-- ==================================================================== -->


    <target name="usage" description="list of commands">
        <echo message="Usage Instructions:" />
        <echo message="Choose from this list of standard ant targets, or modify the build file to create your own." />
        <echo message="1.  pingSrc and pingDest - pings the server and application to make sure it is alive" />
        <echo message="2.  checkMutexSrc and checkMutexDest - determines if another user is working with the application" />
        <echo message="3.  lockSrc and lockDest - prevents admin changes on the src and dest system." />
        <echo message="4.  downloadSrc and downloadDest - creates src.zip and dest.zip files respectively" />
        <echo message="5.  validateSrc and validateDest - makes sure the src.zip and dest.zip files are good" />
        <echo message="6.  listScopes - lists the scopes in src.zip, for potential scoping of the differencing step" />
        <echo message="6a. listPolicies - lists the policies in src.zip, for potential polices for the differencing step" />
        <echo message="7.  search - finds nodes with a specific string in their name, to help verify the wanted node was exported" />
        <echo message="8.  diff - differences src.zip and dest.zip and writes the results to diff_cm.xml" />
        <echo message="9.  combine - combines src.zip and dest.zip into a new inventory, combined.zip" />
        <echo message="10. validateCombined - makes sure combined.zip is a good file" />
        <echo message="11. extractCombined - extracts the working artifacts out of combined.zip for viewing" />
        <echo message="12. insertCombined - inserts updated working artifacts into combined.zip" />
        <echo message="13. checkManualElections - Test for the presence of manual elections. Used as condition to determine if continue to upload/commit or quit." />
        <echo message="14. uploadCombined - uploads combined.zip to the destination server" />
        <echo message="15. commit or commitOpt - commits uploaded inventory on dest, either pessimistically or optimistically" />
        <echo message="16. unlockSrc and unlockDest - allows admin changes on the src and dest system again." />
        <echo message="17. electionsAdd and electionsSubtract - allows for algebraic operations on two changemanifest files." />
    </target>


    <!-- ONLINEPING TASK -->

    <taskdef name="onlinePing" classname="com.bea.propagation.ant.taskdefs.OnlinePingTask">
        <classpath refid="onlineTask.classpath"/>
    </taskdef>

    <target name="pingSrc" description="ping the server">
        <echo message="****** Start: pingSrc ******" />
        <onlinePing
            servletURL="${source.servlet.url}"
            username="${source.admin.username}"
            password="${source.admin.password}"
            allowHttp="${source.allow.http}"
        />
        <echo message="****** Finish: pingSrc ******" />
    </target>

    <target name="pingDest" description="ping the server">
        <echo message="****** Start: pingDest ******" />
        <onlinePing
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
        />
        <echo message="****** Finish: pingDest ******" />
    </target>

    <!-- alternate method of pinging using Condition Ant construct -->
    <target name="pingDestC1" description="ping the server">
        <echo message="****** Start: pingDestC1 ******" />
        <condition property="ping_success">
            <onlinePing
                servletURL="${dest.servlet.url}"
                username="${dest.admin.username}"
                password="${dest.admin.password}"
                allowHttp="${dest.allow.http}"
            />
        </condition>
        <antcall target="ping_success" />
        <echo message="****** Finish: pingDestC1 ******" />
    </target>
    <target name="ping_success" if="ping_success"><echo message="The server is available." /></target>


    <!-- ONLINEMUTEX TASK -->

    <taskdef name="onlineMutex" classname="com.bea.propagation.ant.taskdefs.OnlineCheckMutexTask">
        <classpath refid="onlineTask.classpath"/>
    </taskdef>

    <target name="checkMutexSrc" description="checks to see if the mutex is available">
        <echo message="****** Start: checkMutexSrc ******" />
        <onlineMutex
            servletURL="${source.servlet.url}"
            username="${source.admin.username}"
            password="${source.admin.password}"
            allowHttp="${source.allow.http}"
            failOnError="false"
            retryTimes="3"
        />
        <echo message="****** Finish: checkMutexSrc ******" />
    </target>

    <target name="checkMutexDest"  description="checks to see if the mutex is available">
        <echo message="****** Start: checkMutexDest ******" />
        <onlineMutex
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            failOnError="false"
            retryTimes="10"
        />
        <echo message="****** Finish: checkMutexDest ******" />
    </target>

    <!-- alternate method of checking the mutex using Condition Ant construct -->
    <target name="checkMutexDestC1" description="checks to see if the mutex is available">
        <echo message="****** Start: checkMutexDestC1 ******" />
        <condition property="mutex_success">
            <onlineMutex
                servletURL="${dest.servlet.url}"
                username="${dest.admin.username}"
                password="${dest.admin.password}"
                allowHttp="${dest.allow.http}"
                failOnError="false"
                retryTimes="10"
            />
        </condition>
        <antcall target="mutex_success" />
        <echo message="****** Finish: checkMutexDestC1 ******" />
    </target>
    <target name="mutex_success" if="mutex_success"><echo message="The mutex is available." /></target>


    <!-- onlineMaintenanceMode TASK -->

    <taskdef name="onlineMaintenanceMode" classname="com.bea.propagation.ant.taskdefs.OnlineMaintenanceModeTask">
        <classpath refid="onlineTask.classpath"/>
    </taskdef>

    <target name="lockSrc" description="put the server into maintenance mode">
        <echo message="****** Start: lockSrc ******" />
        <onlineMaintenanceMode
            servletURL="${source.servlet.url}"
            username="${source.admin.username}"
            password="${source.admin.password}"
            allowHttp="${source.allow.http}"
            enable="true"
        />
        <echo message="****** Finish: lockSrc ******" />
    </target>

    <target name="lockDest" description="put the server into maintenance mode">
        <echo message="****** Start: lockDest ******" />
        <onlineMaintenanceMode
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            enable="true"
        />
        <echo message="****** Finish: lockDest ******" />
    </target>

    <!-- alternate method of locking using Condition Ant construct -->
    <target name="lockDestC1" description="put the server into maintenance mode">
        <condition property="lock_success">
            <onlineMaintenanceMode
                servletURL="${dest.servlet.url}"
                username="${dest.admin.username}"
                password="${dest.admin.password}"
                allowHttp="${dest.allow.http}"
                enable="true"
            />
        </condition>
        <antcall target="lock_success" />
    </target>
    <target name="lock_success" if="lock_success"><echo message="Maintenance mode has been toggled." /></target>


    <!-- ONLINEDOWNLOAD TASK -->

    <taskdef name="onlineDownload" classname="com.bea.propagation.ant.taskdefs.OnlineDownloadTask">
        <classpath refid="onlineTask.classpath"/>
    </taskdef>

    <target name="downloadSrc">
        <echo message="****** Start: downloadSrc ******" />
        <delete file="${working.dir}/src.zip" quiet="true" />
        <delete file="${working.dir}/downloadSrc.log" quiet="true" />
        <onlineDownload
            servletURL="${source.servlet.url}"
            username="${source.admin.username}"
            password="${source.admin.password}"
            allowHttp="${source.allow.http}"
            failOnError="true"
            outputInventoryFile="${working.dir}/src.zip"
            logFile="${working.dir}/downloadSrc.log"
        >
            <modifier name="cm_exportPolicy" value="lastPublished" />
            <modifier name="allowMaintenanceModeDisabled" value="true"/>
            <modifier name="allowSecurityOutOfSync" value="true"/>
        </onlineDownload>
        <echo message="****** Finish: downloadSrc ******" />
        <echo message="****** Please check :: src.zip is downloaded into ******${working.dir}" />
    </target>

    <target name="downloadSrcRemote">
        <echo message="****** Start: downloadSrcRemote ******" />
        <delete file="${working.dir}/src.zip" quiet="true" />
        <delete file="${working.dir}/downloadSrcRemote.log" quiet="true" />
        <onlineDownload
            servletURL="${source.servlet.url}"
            username="${source.admin.username}"
            password="${source.admin.password}"
            allowHttp="${source.allow.http}"
            failOnError="true"
            outputToServerFileSystem="true"
            outputInventoryFile="D:\TEMP\prop_test\src.zip"
            logFile="${working.dir}/downloadSrcRemote.log"
        >
            <modifier name="allowMaintenanceModeDisabled" value="true"/>
        </onlineDownload>
        <echo message="****** Finish: downloadSrcRemote ******" />
    </target>

    <target name="downloadDest">
        <echo message="****** Start: downloadDest ******" />
        <delete file="${working.dir}/dest.zip" quiet="true" />
        <delete file="${working.dir}/downloadDest.log" quiet="true" />
        <onlineDownload
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            outputInventoryFile="${working.dir}/dest.zip"
            logFile="${working.dir}/downloadDest.log"
        >
            <modifier name="allowMaintenanceModeDisabled" value="true"/>
            <modifier name="allowSecurityOutOfSync" value="true"/>

        </onlineDownload>
        <echo message="****** Finish: downloadDest ******" />
    </target>


    <!-- OFFLINEVALIDATE TASK -->

    <taskdef name="offlineValidate" classname="com.bea.propagation.ant.taskdefs.OfflineValidateTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>

    <target name="validateSrc" description="valid inventory, with logging">
        <echo message="****** Start: validateSrc ******" />
        <delete file="${working.dir}/validateSrc_log.txt" quiet="true" />
        <delete file="${working.dir}/validateSrc_verboselog.txt" quiet="true" />

        <offlineValidate
            sourceFile="${working.dir}/src.zip"
            logFile="${working.dir}/validateSrc_log.txt"
            verboseLogFile="${working.dir}/validateSrc_verboselog.txt"
        />
        <echo message="****** Finish: validateSrc ******" />
    </target>

    <target name="validateDest" description="validates to see if an inventory file is a valid inventory">
        <echo message="****** Start: validateDest ******" />
        <delete file="${working.dir}/validateDest_log.txt" quiet="true" />
        <delete file="${working.dir}/validateDest_verboselog.txt" quiet="true" />

        <offlineValidate
            sourceFile="${working.dir}/dest.zip"
            logFile="${working.dir}/validateDest_log.txt"
            verboseLogFile="${working.dir}/validateDest_verboselog.txt"
        />
        <echo message="****** Finish: validateDest ******" />
    </target>

    <!-- alternate method of validating using Condition Ant construct -->
    <target name="validateDestC1" description="validates to see if an inventory file is a valid inventory">
        <echo message="****** Start: validateC1 ******" />
        <condition property="validate_success">
            <offlineValidate
                sourceFile="${working.dir}/dest.zip"
            />
        </condition>

        <antcall target="validate_success" />

        <echo message="****** Finish: validateC1 ******" />
    </target>
    <target name="validate_success" if="validate_success"><echo message="The validation succeeded." /></target>


    <!-- OFFLINELISTSCOPES TASK -->

    <taskdef name="offlineListScopes" classname="com.bea.propagation.ant.taskdefs.OfflineListScopesTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>

    <target name="listScopes" description="lists the scopes found in the source inventory">
        <echo message="****** Start: listScopes ******" />
        <delete file="${working.dir}/listScopes_scopes.properties" quiet="true" />
        <delete file="${working.dir}/listScopes_log.txt" quiet="true" />
        <delete file="${working.dir}/listScopes_verboselog.txt" quiet="true" />
        <mkdir dir="${working.dir}/scopes"/>

        <offlineListScopes
            sourceFile="${working.dir}/src.zip"
            scopeFile="${working.dir}/scopes/listScopes_scopes.properties"
            logFile="${working.dir}/scopes/listScopes_log.txt"
            verboseLogFile="${working.dir}/scopes/listScopes_verboselog.txt"
        />
        <echo message="****** Finish: listScopes ****** under ${working.dir}/scopes" />
    </target>

    <!-- OFFLINELISTPOLICIES TASK -->

    <taskdef name="offlineListPolicies" classname="com.bea.propagation.ant.taskdefs.OfflineListPoliciesTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>

    <target name="listPolicies" description="lists the scopes found in the source inventory">
        <echo message="****** Start: listPolicies ******" />
        <delete file="${working.dir}/listPolicies_policies.properties" quiet="true" />
        <delete file="${working.dir}/listPolicies_log.txt" quiet="true" />
        <delete file="${working.dir}/listPolicies_verboselog.txt" quiet="true" />
        <mkdir dir="${working.dir}/policies"/>

        <offlineListPolicies
            sourceFile="${working.dir}/src.zip"
            policyFile="${working.dir}/policies/listPolicies_policies.properties"
            globalAddFlag="true"
            globalUpdateFlag="false"
            globalDeleteFlag="true"
            logFile="${working.dir}/policies/listPolicies_log.txt"
            verboseLogFile="${working.dir}/policies/listPolicies_verboselog.txt"
        />
        <echo message="****** Finish: listPolicies ****** under ${working.dir}/policies" />
    </target>

    <!-- OFFLINESEARCH TASK -->

    <taskdef name="offlineSearch" classname="com.bea.propagation.ant.taskdefs.OfflineSearchTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>

    <target name="search" description="finds the nodes that contain the search string in the name">
        <echo message="****** Start: search ******" />
        <delete file="${working.dir}/search.txt" quiet="true" />
        <delete file="${working.dir}/search_log.txt" quiet="true" />
        <delete file="${working.dir}/search_verboselog.txt" quiet="true" />

        <offlineSearch
            searchString="Global"
            sourceFile="${working.dir}/src.zip"
            listFile="${working.dir}/search.txt"
            logFile="${working.dir}/search_log.txt"
            verboseLogFile="${working.dir}/search_verboselog.txt"
        />
        <echo message="****** Finish: search ******" />
    </target>

    <!-- alternate method of searching using Condition Ant construct -->
    <target name="searchC1" description="finds the nodes that contain the search string in the name">
        <echo message="****** Start: searchC1 ******" />
        <condition property="search_success">
            <offlineSearch
                searchString="Global"
                sourceFile="${working.dir}/src.zip"
            />
        </condition>

        <antcall target="search_success" />

        <echo message="****** Finish: searchC1 ******" />
    </target>
    <target name="search_success" if="search_success"><echo message="The search succeeded." /></target>


    <!-- OFFLINEDIFF TASK -->

    <taskdef name="offlineDiff" classname="com.bea.propagation.ant.taskdefs.OfflineDiffTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>

    <target name="diff" description="compare two inventories with logging">
        <echo message="****** Start: diff ******" />
        <delete file="${working.dir}/diff_cm.xml" quiet="true" />
        <delete file="${working.dir}/diff_log.txt" quiet="true" />
        <delete file="${working.dir}/diff_verboselog.txt" quiet="true" />

        <offlineDiff
            sourceFile="${working.dir}/src.zip"
            destFile="${working.dir}/dest.zip"
            changeManifestFile="${working.dir}/diff_cm.xml"
            logFile="${working.dir}/diff_log.txt"
            verboseLogFile="${working.dir}/diff_verboselog.txt"
        />
        <echo message="****** Finish: diff ******" />
    </target>

    <!-- alternate method of diffing using Condition Ant construct -->
    <target name="diffC1" description="compare two inventories">
        <echo message="****** Start: diffC1 ******" />
        <delete file="${working.dir}/diffC1_cm.xml" quiet="true" />
        <condition property="diff_success">
            <offlineDiff
                sourceFile="${working.dir}/src.zip"
                destFile="${working.dir}/dest.zip"
                changeManifestFile="${working.dir}/diffC1_cm.xml"
            />
        </condition>
        <antcall target="diff_success" />

        <echo message="****** Finish: diffC1 ******" />
    </target>
    <target name="diff_success" if="diff_success"><echo message="The two inventories are different." /></target>


    <!-- OFFLINECOMBINE TASK -->

    <taskdef name="offlineCombine" classname="com.bea.propagation.ant.taskdefs.OfflineCombineTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>

    <target name="combine" description="Combine two inventories with logging">
        <echo message="****** Start: combine ******" />
        <delete file="${working.dir}/combined.zip" quiet="true" />
        <delete file="${working.dir}/combine_cm.xml" quiet="true" />
        <delete file="${working.dir}/combine_log.txt" quiet="true" />
        <delete file="${working.dir}/combine_verboselog.txt" quiet="true" />

        <offlineCombine
            sourceFile="${working.dir}/src.zip"
            destFile="${working.dir}/dest.zip"
            combinedInventoryFile="${working.dir}/combined.zip"
            changeManifestFile="${working.dir}/combine_cm.xml"
            logFile="${working.dir}/combine_log.txt"
            verboseLogFile="${working.dir}/combine_verboselog.txt"
        />
        <echo message="****** Finish: combine ******" />
    </target>
   
    <target name="combineWithPolicy" description="Combine two inventories using policy file">
        <echo message="****** Start: combine ******" />
        <delete file="${working.dir}/combined.zip" quiet="true" />
        <delete file="${working.dir}/combine_cm.xml" quiet="true" />
        <delete file="${working.dir}/combine_log.txt" quiet="true" />
        <delete file="${working.dir}/combine_verboselog.txt" quiet="true" />

        <offlineCombine
            sourceFile="${working.dir}/src.zip"
            destFile="${working.dir}/dest.zip"
            combinedInventoryFile="${working.dir}/combined.zip"
            policiesFile = "${working.dir}/policy.properties"
            changeManifestFile="${working.dir}/combine_cm.xml"
            logFile="${working.dir}/combine_log.txt"
            verboseLogFile="${working.dir}/combine_verboselog.txt"
        />
        <echo message="****** Finish: combine ******" />
    </target>

    <target name="combineWithScope" description="Combine two inventories using scope file">
        <echo message="****** Start: combine ******" />
        <delete file="${working.dir}/combined.zip" quiet="true" />
        <delete file="${working.dir}/combine_cm.xml" quiet="true" />
        <delete file="${working.dir}/combine_log.txt" quiet="true" />
        <delete file="${working.dir}/combine_verboselog.txt" quiet="true" />

        <offlineCombine
            sourceFile="${working.dir}/src.zip"
            destFile="${working.dir}/dest.zip"
            combinedInventoryFile="${working.dir}/combined.zip"
            scopeFile = "${working.dir}/singlescope.properties"
            changeManifestFile="${working.dir}/combine_cm.xml"
            logFile="${working.dir}/combine_log.txt"
            verboseLogFile="${working.dir}/combine_verboselog.txt"
        />
        <echo message="****** Finish: combine ******" />
    </target>
   
    <!-- OFFLINEVALIDATE TASK -->

    <target name="validateCombined" description="valid inventory, with no logging">
        <echo message="****** Start: validateCombined ******" />
        <delete file="${working.dir}/validateCombined_log.txt" quiet="true" />
        <delete file="${working.dir}/validateCombined_verboselog.txt" quiet="true" />

        <offlineValidate
            sourceFile="${working.dir}/combined.zip"
            logFile="${working.dir}/validateCombined_log.txt"
            verboseLogFile="${working.dir}/validateCombined_verboselog.txt"
        />
        <echo message="****** Finish: validateCombined ******" />
    </target>


    <!-- OFFLINEEXTRACT TASK -->

    <taskdef name="offlineExtract" classname="com.bea.propagation.ant.taskdefs.OfflineExtractTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>

    <target name="extractCombined" description="gather resources from the combined inventory">
        <echo message="****** Start: extractCombined ******" />
        <delete file="${working.dir}/extract/extractCombined_export.properties" quiet="true" />
        <delete file="${working.dir}/extract/extractCombined_scope.properties" quiet="true" />
        <delete file="${working.dir}/extract/extractCombined_policy.properties" quiet="true" />
        <delete file="${working.dir}/extract/extractCombined_change.xml" quiet="true" />
        <delete file="${working.dir}/extract/extractCombined_log.txt" quiet="true" />
        <delete file="${working.dir}/extract/extractCombined_verboselog.txt" quiet="true" />
        <mkdir dir="${working.dir}/extract"/>

        <offlineExtract
            sourceFile="${working.dir}/combined.zip"
            exportFile="${working.dir}/extract/extractCombined_export.properties"
            policyFile="${working.dir}/extract/extractCombined_policy.properties"
            changeManifestFile="${working.dir}/extract/extractCombined_change.xml"
            logFile="${working.dir}/extract/extractCombined_log.txt"
            verboseLogFile="${working.dir}/extract/extractCombined_verboselog.txt"
        />
        <echo message="****** Finish: extractCombined ******" />
    </target>


    <!-- OFFLINEALGEBRA TASK -->

    <taskdef name="offlineAlgebra" classname="com.bea.propagation.ant.taskdefs.OfflineElectionAlgebraTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>

    <target name="electionsAdd" description="add the two election lists">
        <echo message="****** Start: electionsAdd ******" />
        <delete file="${working.dir}/addedElections.xml" quiet="true" />

        <offlineAlgebra
            electionList1File="${working.dir}/elections1.xml"
            electionList2File="${working.dir}/elections2.xml"
            operation="add"
            outputFile="${working.dir}/addedElections.xml"
        />
        <echo message="****** Finish: electionsAdd ******" />
    </target>

    <target name="electionsSubtract" description="subtract the two election lists">
        <echo message="****** Start: electionsSubtract ******" />
        <delete file="${working.dir}/subtractedElections.xml" quiet="true" />

        <offlineAlgebra
            electionList1File="${working.dir}/elections1.xml"
            electionList2File="${working.dir}/elections2.xml"
            operation="subtract"
            outputFile="${working.dir}/subtractedElections.xml"
        />
        <echo message="****** Finish: electionsSubtract ******" />
    </target>


    <!-- OFFLINEINSERT TASK -->

    <taskdef name="offlineInsert" classname="com.bea.propagation.ant.taskdefs.OfflineInsertTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>

    <target name="insertCombined" description="insert resources into the combined inventory">
        <echo message="****** Start: insertCombined ******" />
        <delete file="${working.dir}/newCombined.zip" quiet="true" />

        <offlineInsert
            sourceFile="${working.dir}/combined.zip"
            policyFile="${working.dir}/extractCombined_policy.properties"
            changeManifestFile="${working.dir}/extractCombined_change.xml"
            outputFile="${working.dir}/newCombined.zip"
        />
        <echo message="****** Finish: insertCombined ******" />
    </target>

    <!-- OFFLINE Check for manual elections -->
   
    <taskdef name="offlineCheckForManualElections" classname="com.bea.propagation.ant.taskdefs.OfflineCheckManualElectionsTask">
        <classpath refid="offlineTask.classpath"/>
    </taskdef>
   
    <target name="checkManualElections" description="check if there is manual elections in combined inventory or change manifest XML">
        <echo message="****** Start: checkManualElections ******" />
        <offlineCheckForManualElections
                changeManifestFile="${working.dir}/combine_cm.xml"/>
        <echo message="****** Finish: checkManualElections ******" />
    </target>
   
    <target name="checkManualElectionsC1" description="check if there is manual elections in combined inventory or change manifest XML">
        <echo message="****** Start: checkManualElectionsC1 ******" />
        <condition property="hasManualElections">
            <offlineCheckForManualElections
                sourceFile="${working.dir}/combined.zip"/>
        </condition>
        <antcall target="continuePropagation" />
        <echo message="****** Finish: checkManualElectionsC1 ******" />
    </target>
    <target name="continuePropagation" unless="hasManualElections">
        <echo message="We could continue propagation" />
    </target>

    <!-- ONLINEUPLOAD TASK -->

    <taskdef name="onlineUpload" classname="com.bea.propagation.ant.taskdefs.OnlineUploadTask">
        <classpath refid="onlineTask.classpath"/>
    </taskdef>

    <target name="uploadCombined">
        <echo message="****** Start: upload ******" />
        <onlineUpload
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            sourceFile="${working.dir}/combined.zip"
        />
        <echo message="****** Finish: upload ******" />
    </target>

    <target name="uploadRemote">
        <echo message="****** Start: uploadRemote ******" />
        <onlineUpload
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            readFromServerFileSystem="true"
            sourceFile="D:\TEMP\prop_test\src.zip"
        />
        <echo message="****** Finish: uploadRemote ******" />
    </target>

    <target name="uploadSrc">
        <echo message="****** Start: uploadSrc ******" />
        <onlineUpload
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            sourceFile="${working.dir}/src.zip"
        />
        <echo message="****** Finish: uploadSrc ******" />
    </target>

    <target name="uploadDest">
        <echo message="****** Start: uploadDest ******" />
        <onlineUpload
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            sourceFile="${working.dir}/dest.zip"
        />
        <echo message="****** Finish: uploadDest ******" />
    </target>

    <!-- ONLINECOMMIT TASK -->

    <taskdef name="onlineCommit" classname="com.bea.propagation.ant.taskdefs.OnlineCommitTask">
        <classpath refid="onlineTask.classpath"/>
    </taskdef>

    <target name="commit">
        <echo message="****** Start: commit ******" />
        <delete file="${working.dir}/commit.log" quiet="true" />
        <onlineCommit
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            logFile="${working.dir}/commit.log"
        >
            <modifier name="differenceStrategy" value="pessimistic" />
            <modifier name="cm_checkinComment" value="My sample checkin comment." />
            <modifier name="allowMaintenanceModeDisabled" value="true"/>
            <modifier name="allowSecurityOutOfSync" value="true"/>
        </onlineCommit>
        <echo message="****** Finish: commit ******" />
    </target>

    <target name="commitOpt">
        <echo message="****** Start: commitOpt ******" />
        <delete file="${working.dir}/commitOpt.log" quiet="true" />
        <onlineCommit
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            logFile="${working.dir}/commitOpt.log"
        >
            <modifier name="differenceStrategy" value="optimistic" />
            <modifier name="cm_checkinComment" value="My sample checkin comment." />
            <modifier name="allowMaintenanceModeDisabled" value="true"/>
        </onlineCommit>
        <echo message="****** Finish: commitOpt ******" />
    </target>

    <!-- set scope file in commit task -->
    <target name="commitWithScope">
        <echo message="****** Start: commitScope ******" />
        <delete file="${working.dir}/commitScope.log" quiet="true" />
        <onlineCommit
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            scopeFile="${working.dir}/singlescope.properties"
            logFile="${working.dir}/commitScope.log"
        >
            <modifier name="differenceStrategy" value="pessimistic" />
            <modifier name="cm_checkinComment" value="My sample checkin comment." />
            <modifier name="allowMaintenanceModeDisabled" value="true"/>
        </onlineCommit>
        <echo message="****** Finish: commitOpt ******" />
    </target>
   
    <!-- ONLINEMAINTENANCEMODE TASK -->

    <target name="unlockSrc" description="disable maintenance mode on the src server">
        <echo message="****** Start: unlockSrc ******" />
        <onlineMaintenanceMode
            servletURL="${source.servlet.url}"
            username="${source.admin.username}"
            password="${source.admin.password}"
            allowHttp="${source.allow.http}"
            enable="false"
        />
        <echo message="****** Finish: unlockSrc ******" />
    </target>

    <target name="unlockDest" description="disable maintenance mode on the dest server">
        <echo message="****** Start: unlockDest ******" />
        <onlineMaintenanceMode
            servletURL="${dest.servlet.url}"
            username="${dest.admin.username}"
            password="${dest.admin.password}"
            allowHttp="${dest.allow.http}"
            enable="false"
        />
        <echo message="****** Finish: unlockDest ******" />
    </target>


    <target name="startProp"
        description="Starts the propagation operation.."
        depends="pingSrc, pingDest, downloadSrc, validateSrc, downloadDest, validateDest, combine, uploadCombined, commit">

        <echo message="****** Start: startProp ******" />
        <echo message="****** Start: startProp ******" />

        <echo message="****** Finish: startProp ******" />

    </target>

</project>

3. Create a folder called scopes under propagation.

4. In propagation.xml file. Make sure deploy.dir value is pointing to right BEA installation path on your local drive. For eg, C:\bea\wlserver_10.0"

5. Working.dir should point to propagation dir.

6. source.servlet.url is your source server. Where you copy the data from. For e.g, if you copy from INT box, then it should be http://source_server:7001/portlAppEARPropagation/inventorymanagement

7. Once you have all set up, run the following command from your propagation folder:
ant –f propagation.xml pingSrc
If the above command fails, source server is not running. re-start it.

8. Same thing goes with destination as well. try this command:
ant –f propagation.xml pingDest

9. Type to generate scopes file by generating sourcezip first: ant -f propagation.xml downloadSrc
then run this command: ant -f propagation.xml listScopes
This should create a file listScopes.properties under propagation/scopes folder. To know more about scopes, please visit BEA documentation.

10. Once source and destination server running run the propagation command:
ant –f propagation.xml startProp
It should propagate the data from source to destination.

Important links:
Propagation Ant Task Reference
Propagation Tips and Best Practices

What is the difference between streaming portal(desktop) and file based portal?

I have come across this question many times while working at client site from co-workers, clients and infrastructure folks - what is the difference between streaming portal and file based portal? Well, during portal development process we create .portal file in workshop. This is basically just a template in which more books, pages, portlets can be added. The .portal file is XML based and rendered as "single file mode". This file is mainly for development purpose and should not be used in the production though you can access it in production as well. You can not apply any entitlements or user customization as no data base involved in .portal template.

The streaming portal(desktop) is created out of .portal template using weblogic portal admin tool. A single portal template can have any number of desktops. A desktop contains all the portlets, content, shells, layouts, and look and feel elements necessary to create individual user views of a portal. For eg, assume I have a requirement from three different clients to show some functionality of a portal. I don't want to create a three .portal template though I could, but I would like to have three different desktops with similar functionality but with different "look-and-feel". So I go to weblogic portal admin tool create a desktop called sample1 for client 1. sample 2 for client 2 with different look-and-feel. sample 3 for client 3 again with different look & f. Oh yes! Look and feel can be applied at run time ie while creating desktop itself. Also I can add/remove portlets if I want to for any desktop. I can also add/remove any book/page at run time as well. So what I have done is created 3 different desktops but with a different look-and-feel per client.

When I create a desktop from a .portal template, the desktop is decoupled from the template, and modifications to the .portal file do not affect the desktop, and vice versa. For example, when you change a desktop's look and feel in the WebLogic Portal Administration Console, the change is made only to the desktop, not to the original .portal file. When you view a desktop with in a browser, the desktop is rendered in "streaming mode"  from data base.

P.S: If your portal application does not need any entitlements or personalizations and it is simple, static portal then file based portal is the best choice. File based portals give better peformance and propagation to other environments is also easy.