<?xml version="1.0" encoding="UTF-8"?>
<!--
    
    Licensed Materials - Property of IBM, 5724-E76, (C) Copyright IBM Corp. 2004 - All Rights reserved.
    
    General purpose tasks
    
-->

<!-- define the classpath used with the discovery and dependency checking function -->
<path id="depcheck.classpath">
    <pathelement location="${WpsInstallLocation}/bin/able.jar" />
    <pathelement location="${WpsInstallLocation}/bin/ablerules.jar" />
    <pathelement location="${WpsInstallLocation}/bin/antlr.jar" />
    <pathelement location="${WpsInstallLocation}/bin/PortalDepCheck.jar" />
    <pathelement location="${WpsInstallLocation}/bin/itkdepcheck.jar" />
    <pathelement location="${WpsInstallLocation}/bin/wp.config.jar" />
    <pathelement location="${WpsInstallLocation}/bin/wp.depcheck.jar" />
</path>

<!-- define the task used to invoke the discovery/dependency checking vallidation shell -->
<taskdef name="validationshell" classname="com.ibm.wps.depcheck.PortalValidationAntTask">
    <classpath refid="depcheck.classpath" />
</taskdef>

<!-- define the task used to verify the supplied hostname is addressable -->
<taskdef name="validateHost" classname="com.ibm.wps.config.HostnameValidateTask">
    <classpath refid="depcheck.classpath" />
</taskdef>
<!--
 ##############################################################################
 #  Name: validate-database-driver
 #
 #  Description: task to check availability of JDBC driver class
 #
 #  Usage: call to validate existence of and access rights to JDBC driver 
 #             archive 
 #
 #  Syntax:
 #      WPSconfig.{bat | sh} validate-database-driver
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites: Database client available
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="validate-database-driver">
    <antcall target="iseries-switch-ccsid"/>
    <echo>DbDriver  == ${DbDriver}</echo>
    <echo>DbUrl     == ${DbUrl}</echo>
    <echo>DbUser    == ${DbUser}</echo>
    <echo>DbLibrary == ${DbLibrary}</echo>
    <echo>WpsInstallLocation == ${WpsInstallLocation}</echo>
    <java classname="com.ibm.wps.config.SqlProcessor" fork="yes" failonerror="yes">
        <jvmarg value="-Ddb2j.system.home=${WpsInstallLocation}/cloudscape"/>
        <jvmarg value="-Dautoreply=${autoreply}"/>
        <jvmarg value="-DDbType=${DbType}"/>
        <jvmarg value="-Dfile.encoding=${file.encoding}"/>
        <jvmarg value="${jvmArgForZos}"/>
        <arg value="${DbDriver}"/>
        <arg value="${DbUrl}"/>
        <arg value="${DbUser}"/>
        <arg value="${DbPassword}"/>
        <arg value="-check-driver"/>
        <classpath>
            <pathelement path="${DbLibrary}" />
            <pathelement location="${WpsInstallLocation}/bin/wp.config.jar" />
        </classpath>
    </java>
    <antcall target="iseries-switch-ccsid-original"/> 
</target>
        
<!--
 ##############################################################################
 #  Name: validate-database-connection-wps
 #
 #  Description: task to check connection to WPS database
 #
 #  Usage: call to validate existence of and access rights to WPS database 
 #
 #  Syntax:
 #      WPSconfig.{bat | sh} validate-database-connection-wps
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites: Database exists, client is available
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="validate-database-connection-wps">
    <antcall target="iseries-switch-ccsid"/>  
    <echo>DbDriver  == ${DbDriver}</echo>
    <echo>DbUrl     == ${DbUrl}</echo>
    <echo>DbUser    == ${DbUser}</echo>
    <echo>DbLibrary == ${DbLibrary}</echo>
    <echo>WpsInstallLocation == ${WpsInstallLocation}</echo>
    <java classname="com.ibm.wps.config.SqlProcessor" fork="yes" failonerror="yes">
        <jvmarg value="-Ddb2j.system.home=${WpsInstallLocation}/cloudscape"/>
        <jvmarg value="-Dautoreply=${autoreply}"/>
        <jvmarg value="-DDbType=${DbType}"/>
        <jvmarg value="-Dfile.encoding=${file.encoding}"/>
        <jvmarg value="${jvmArgForZos}"/>
        <arg value="${DbDriver}"/>
        <arg value="${DbUrl}"/>
        <arg value="${DbUser}"/>
        <arg value="${DbPassword}"/>
        <arg value="-check-connection"/>
        <classpath>
            <pathelement path="${DbLibrary}" />
            <pathelement location="${WpsInstallLocation}/bin/wp.config.jar" />
        </classpath>
    </java>
    <antcall target="iseries-switch-ccsid-original"/> 
</target>
        
<!--
 ##############################################################################
 #  Name: validate-database-connection-wmm
 #
 #  Description: task to check connection to WMM database
 #
 #  Usage: call to validate existence of and access rights to WMM database 
 #
 #  Syntax:
 #      WPSconfig.{bat | sh} validate-database-connection-wmm
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites: Database exists, client is available
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="validate-database-connection-wmm">
    <antcall target="iseries-switch-ccsid"/>  
    <echo>DbDriver  == ${DbDriver}</echo>
    <echo>WmmDbUrl  == ${WmmDbUrl}</echo>
    <echo>WmmDbUser == ${WmmDbUser}</echo>
    <echo>DbLibrary == ${DbLibrary}</echo>
    <echo>WpsInstallLocation == ${WpsInstallLocation}</echo>
    <java classname="com.ibm.wps.config.SqlProcessor" fork="yes" failonerror="yes">
        <jvmarg value="-Ddb2j.system.home=${WpsInstallLocation}/cloudscape"/>
        <jvmarg value="-Dautoreply=${autoreply}"/>
        <jvmarg value="-DDbType=${DbType}"/>
        <jvmarg value="-Dfile.encoding=${file.encoding}"/>
        <jvmarg value="${jvmArgForZos}"/>
        <arg value="${DbDriver}"/>
        <arg value="${WmmDbUrl}"/>
        <arg value="${WmmDbUser}"/>
        <arg value="${WmmDbPassword}"/>
        <arg value="-check-connection"/>
        <classpath>
            <pathelement path="${DbLibrary}" />
            <pathelement location="${WpsInstallLocation}/bin/wp.config.jar" />
        </classpath>
    </java>
    <antcall target="iseries-switch-ccsid-original"/> 
</target>
        
<!--
 ##############################################################################
 #  Name: validate-database-connection-jcr
 #
 #  Description: task to check connection to JCR database
 #
 #  Usage: call to validate existence of and access rights to JCR database
 #
 #  Syntax:
 #      WPSconfig.{bat | sh} validate-database-connection-jcr
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites: Database exists, client is available
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="validate-database-connection-jcr" unless="isZos">
    <antcall target="iseries-switch-ccsid"/>  
    <echo>DbDriver  == ${DbDriver}</echo>
    <echo>JcrDbUrl  == ${JcrDbUrl}</echo>
    <echo>JcrDbUser == ${JcrDbUser}</echo>
    <echo>DbLibrary == ${DbLibrary}</echo>
    <echo>WpsInstallLocation == ${WpsInstallLocation}</echo>
    <java classname="com.ibm.wps.config.SqlProcessor" fork="yes" failonerror="yes">
        <jvmarg value="-Ddb2j.system.home=${WpsInstallLocation}/cloudscape"/>
        <jvmarg value="-Dautoreply=${autoreply}"/>
        <jvmarg value="-DDbType=${DbType}"/>
        <jvmarg value="-Dfile.encoding=${file.encoding}"/>
        <jvmarg value="${jvmArgForZos}"/>
        <arg value="${DbDriver}"/>
        <arg value="${JcrDbUrl}"/>
        <arg value="${JcrDbUser}"/>
        <arg value="${JcrDbPassword}"/>
        <arg value="-check-connection"/>
        <classpath>
            <pathelement path="${DbLibrary}" />
            <pathelement location="${WpsInstallLocation}/bin/wp.config.jar" />
        </classpath>
    </java>
    <antcall target="iseries-switch-ccsid-original"/> 
</target>

<!--
 ##############################################################################
 #  Name: validate-database-connection-feedback
 #
 #  Description: task to check connection to Personalization Feedback database
 #
 #  Usage: call to validate existence of and access rights to Feedback database
 #
 #  Syntax:
 #      WPSconfig.{bat | sh} validate-database-connection-feedback
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites: Database exists, client is available
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="validate-database-connection-feedback" unless="isZos">
    <antcall target="iseries-switch-ccsid"/>  
    <echo>DbDriver  == ${DbDriver}</echo>
    <echo>FeedbackDbUrl  == ${FeedbackDbUrl}</echo>
    <echo>FeedbackDbUser == ${FeedbackDbUser}</echo>
    <echo>DbLibrary == ${DbLibrary}</echo>
    <echo>WpsInstallLocation == ${WpsInstallLocation}</echo>
    <java classname="com.ibm.wps.config.SqlProcessor" fork="yes" failonerror="yes">
        <jvmarg value="-Ddb2j.system.home=${WpsInstallLocation}/cloudscape"/>
        <jvmarg value="-Dautoreply=${autoreply}"/>
        <jvmarg value="-DDbType=${DbType}"/>
        <jvmarg value="-Dfile.encoding=${file.encoding}"/>
        <jvmarg value="${jvmArgForZos}"/>
        <arg value="${DbDriver}"/>
        <arg value="${FeedbackDbUrl}"/>
        <arg value="${FeedbackDbUser}"/>
        <arg value="${FeedbackDbPassword}"/>
        <arg value="-check-connection"/>
        <classpath>
            <pathelement path="${DbLibrary}" />
            <pathelement location="${WpsInstallLocation}/bin/wp.config.jar" />
        </classpath>
    </java>
    <antcall target="iseries-switch-ccsid-original"/> 
</target>

<!--
 ##############################################################################
 #  Name: validate-database-connection-likeminds
 #
 #  Description: task to check connection to Personalization LikeMinds database
 #
 #  Usage: call to validate existence of and access rights to LikeMinds database
 #
 #  Syntax:
 #      WPSconfig.{bat | sh} validate-database-connection-likeminds
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites: Database exists, client is available
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="validate-database-connection-likeminds" unless="isZos">
    <antcall target="iseries-switch-ccsid"/>  
    <echo>DbDriver  == ${DbDriver}</echo>
    <echo>LikemindsDbUrl  == ${LikemindsDbUrl}</echo>
    <echo>LikemindsDbUser == ${LikemindsDbUser}</echo>
    <echo>DbLibrary == ${DbLibrary}</echo>
    <echo>WpsInstallLocation == ${WpsInstallLocation}</echo>
    <java classname="com.ibm.wps.config.SqlProcessor" fork="yes" failonerror="yes">
        <jvmarg value="-Ddb2j.system.home=${WpsInstallLocation}/cloudscape"/>
        <jvmarg value="-Dautoreply=${autoreply}"/>
        <jvmarg value="-DDbType=${DbType}"/>
        <jvmarg value="-Dfile.encoding=${file.encoding}"/>
        <jvmarg value="${jvmArgForZos}"/>
        <arg value="${DbDriver}"/>
        <arg value="${LikemindsDbUrl}"/>
        <arg value="${LikemindsDbUser}"/>
        <arg value="${LikemindsDbPassword}"/>
        <arg value="-check-connection"/>
        <classpath>
            <pathelement path="${DbLibrary}" />
            <pathelement location="${WpsInstallLocation}/bin/wp.config.jar" />
        </classpath>
    </java>
    <antcall target="iseries-switch-ccsid-original"/> 
</target>

<!--
 ##############################################################################
 #  action-validate-was-instance validates the WAS instance given by ${WasHome}
 #  against the required level for the given product (defaults to WPS MP 5.1.0.0).
 #  If a WAS is found and it is at the correct level, the task succeeds. 
 #  If a WAS is not found or it is night at the right level, it fails. Success
 #  or failure is logged.
 ##############################################################################
-->
<target name="action-validate-was-instance" unless="action-validate-was-instance-ran">
        <antcall target="iseries-switch-back"/> 
        <property name="action-validate-was-instance-ran" value="true" />
        <logmsg level="INFO" task="action-validate-was-instance" subtask="predicate" message="Validation.was.instance.checking" param1="${WasUserHome}" />
        <validationshell predicate='validate_location_WAS("${WasUserHome}")'/>
        <antcall target="action-log-validate-was-instance-${validation.predicate_result}" />
        <antcall target="iseries-switch-to-was-user"/>
</target>

<target name="action-log-validate-was-instance-success">
        <logmsg level="INFO" task="action-validate-was-instance" subtask="predicate" message="Validation.was.instance.success" />
</target>
<target name="action-log-validate-was-instance-failure" >
        <logmsg level="WARNING" task="action-validate-was-instance" subtask="predicate" message="Validation.was.instance.failure" />
        <fail message="WAS instance validation failed" />
</target>
<!-- target if property set telling us to skip validation -->
<target name="action-log-validate-was-instance-skipped" >
</target>

        
<!--
 ##############################################################################
 #  Name: validate-ldap
 #
 #  Description: action to check connection to LDAP server,
 #               check other LDAP properties in config file
 #
 #  Usage: run before attempting to configure or modify LDAP configuration
 #
 #  Syntax:
 #      WPSconfig.{bat | sh} validate-ldap
 #
 #  Inputs: as noted with subtasks
 #
 #  Assumptions/Prerequisites:
 #      Directory is available, access is permitted
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file.
 #      insufficient directory privileges 
 ##############################################################################
-->
<target name="validate-ldap" >
    <antcall target="action-validate-ldap-connection" />
    <antcall target="action-validate-ldap-suffix" />
    <antcall target="action-validate-ldap-was-admin-user" />
    <antcall target="action-validate-ldap-portal-admin-user" />
    <antcall target="action-validate-ldap-portal-admin-group" />
    <antcall target="action-validate-ldap-bind-user" />
    <antcall target="action-validate-wmm-system-id" />
    <antcall target="action-validate-ldap-container-user" />
    <antcall target="action-validate-ldap-container-group" />
    <antcall target="action-validate-filter-user" />
    <antcall target="action-validate-filter-group" />
    <antcall target="action-validate-lpta-passwd-isdefined" />
</target>


<!--
 ##############################################################################
 #  Name: validate-wmmur-ldap
 #
 #  Description: action to check connection to LDAP server,
 #               check other LDAP properties in config file for wmmur configuration
 #
 #  Usage: run before attempting to configure or modify LDAP configuration
 #
 #  Syntax:
 #      WPSconfig.{bat | sh} validate-wmmur-ldap
 #
 #  Inputs: as noted with subtasks
 #
 #  Assumptions/Prerequisites:
 #      Directory is available, access is permitted
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file.
 #      insufficient directory privileges 
 ##############################################################################
-->
<target name="validate-wmmur-ldap" >
    <antcall target="action-validate-ldap-connection" />
    <antcall target="action-validate-ldap-suffix" />
    <antcall target="action-validate-ldap-was-admin-user" />
    <antcall target="action-validate-ldap-portal-admin-user" />
    <antcall target="action-validate-ldap-portal-admin-group" />
    <antcall target="action-validate-wmm-system-id" />
    <antcall target="action-validate-ldap-container-user" />
    <antcall target="action-validate-ldap-container-group" />
    <antcall target="action-validate-lpta-passwd-isdefined" />
</target>


<!--
 ##############################################################################
 #  Name: action-validate-ldap-connection
 #
 #  Description: action to check connection to LDAP server
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      Directory is available, access is permitted
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-ldap-connection" >
    <ldapcheck ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${LDAPAdminUId}" ldapPassword="${LDAPAdminPwd}" ldapSslEnabled="${LDAPsslEnabled}" />
</target>
                              
<!--
 ##############################################################################
 #  Name: action-validate-ldap-suffix
 #
 #  Description: action to check for specified suffix in directory
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      Directory is available, access is permitted
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-ldap-suffix" >
    <ldapcheck ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${LDAPAdminUId}" ldapPassword="${LDAPAdminPwd}" objectDn="${LDAPSuffix}" ldapSslEnabled="${LDAPsslEnabled}" />
</target>

<!--
 ##############################################################################
 #  Name: action-validate-ldap-was-admin-user
 #
 #  Description: action to check connection to LDAP server, using
 #               the user specified as WAS Administrator (user authorized
 #               to login to WAS administrative console).
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      Directory is available, access is permitted
 #      User/passwd pair is correct and have sufficient privilege to read
 #          from directory.
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-ldap-was-admin-user" >
    <ldapcheck ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${WasUserid}" ldapPassword="${WasPassword}" ldapSslEnabled="${LDAPsslEnabled}" />
</target>
  
<!--
 ##############################################################################
 #  Name: action-validate-ldap-portal-admin-user
 #
 #  Description: action to check connection to LDAP server, using
 #               the user specified as Portal Administrator
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      Directory is available, access is permitted
 #      User/passwd pair is correct and have sufficient privilege to read
 #          from directory.
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-ldap-portal-admin-user" >
    <ldapcheck ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${PortalAdminId}" ldapPassword="${PortalAdminPwd}" ldapSslEnabled="${LDAPsslEnabled}" />
</target>
  
<!--
 ##############################################################################
 #  Name: action-validate-ldap-portal-admin-group
 #
 #  Description: action to check existence of admin group
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      Group named by property "PortalAdminGroupId" exists
 #      Directory is available, access is permitted
 #      User/passwd pair is correct and have sufficient privilege to read
 #          from directory.
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-ldap-portal-admin-group" >
    <ldapcheck ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${PortalAdminId}" ldapPassword="${PortalAdminPwd}" ldapSslEnabled="${LDAPsslEnabled}" objectDn="${PortalAdminGroupId}" />
</target>
  
<!--
 ##############################################################################
 #  Name: action-validate-ldap-bind-user
 #
 #  Description: action to check connection to LDAP server, using
 #               the user specified as bind user. This is a user
 #               authorized to make authenticated queries into the directory
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      Group named by property "PortalAdminGroupId" exist
 #      Directory is available, access is permitted
 #      User/passwd pair is correct and have sufficient privilege to read
 #          from directory.
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-ldap-bind-user" >
    <ldapcheck ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${LDAPBindID}" ldapPassword="${LDAPBindPassword}" ldapSslEnabled="${LDAPsslEnabled}" />
</target>
  
<!--
 ##############################################################################
 #  Name: action-validate-ldap-container-user
 #
 #  Description: action to check value of LDAPUserSuffix property
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      container named by property "LDAPUserSuffix[,LDAPSuffix]" exists
 #      Directory is available, access is permitted
 #      User/passwd pair is correct and have sufficient privilege to read
 #          from directory.
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-ldap-container-user" >
    <ldapcheckcontainer ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${LDAPAdminUId}" ldapPassword="${LDAPAdminPwd}" container="${LDAPUserSuffix}" baseDn="${LDAPSuffix}" ldapSslEnabled="${LDAPsslEnabled}" />
</target>
  
<!--
 ##############################################################################
 #  Name: action-validate-ldap-container-group
 #
 #  Description: action to check value of LDAPGroupSuffix property
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      container named by property "LDAPGroupSuffix[,LDAPSuffix]" exists
 #      Directory is available, access is permitted
 #      User/passwd pair is correct and have sufficient privilege to read
 #          from directory.
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-ldap-container-group" >
    <ldapcheckcontainer ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${LDAPAdminUId}" ldapPassword="${LDAPAdminPwd}" container="${LDAPGroupSuffix}" baseDn="${LDAPSuffix}" ldapSslEnabled="${LDAPsslEnabled}" />
</target>



<!--
 ##############################################################################
 #  Name: action-validate-filter-user
 #
 #  Description: action to check value of LDAPUserFilter property
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      search for PortalAdminIdShort by LDAPUserFilter returns one and only
 #          one result.
 #      Directory is available, access is permitted
 #      User/passwd pair is correct and have sufficient privilege to read
 #          from directory.
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-filter-user">
    <ldapcheckfilter ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${LDAPBindID}" ldapPassword="${LDAPBindPassword}" idToCheck="${PortalAdminIdShort}" baseDn="${LDAPSuffix}" filter="${LDAPUserFilter}" ldapSslEnabled="${LDAPsslEnabled}" />
</target>    
    


<!--
 ##############################################################################
 #  Name: action-validate-filter-group
 #
 #  Description: action to check value of LDAPGroupFilter property
 #
 #  Usage: subtask of "validate-ldap"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      search for PortalAdminGroupIdShort by LDAPGroupFilter returns at least
 #          one result.
 #      Directory is available, access is permitted
 #      User/passwd pair is correct and have sufficient privilege to read
 #          from directory.
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-filter-group">
    <ldapcheckfilter ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${LDAPBindID}" ldapPassword="${LDAPBindPassword}" idToCheck="${PortalAdminGroupIdShort}" baseDn="${LDAPSuffix}" filter="${LDAPGroupFilter}" ldapSslEnabled="${LDAPsslEnabled}" requireUnique="false"/>
</target>    
    
  
<!--
 ##############################################################################
 #  Name: action-validate-wmm-system-id
 #
 #  Description: action to check connection to LDAP server, using
 #               the user specified as bind user. This is a user
 #               authorized to make authenticated queries into the directory
 #
 #  Usage: subtask of "action-add-wmm-system-id"
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites:
 #      Group named by property "PortalAdminGroupId" exist
 #      Directory is available, access is permitted
 #      User/passwd pair is correct and have sufficient privilege to read
 #          from directory.
 #      IF LDAPSslEnabled = true, THEN cacerts contains LDAP server certificate
 #
 #  Error conditions: 
 #      invalid information in properties file. 
 ##############################################################################
-->
<target name="action-validate-wmm-system-id" >
    <ldapcheck ldapURL="${LDAPHostName}:${LDAPPort}" ldapUser="${WmmSystemId}" ldapPassword="${WmmSystemIdPassword}" ldapSslEnabled="${LDAPsslEnabled}" />
</target>

<!--
 ##############################################################################
 #  Name: validate-http-portal
 #
 #  Description: action to check connection PortalServer using HTTP
 #
 #  Usage: To determine if Portal is running
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites: 
 #          Portal is installed and running
 #          Correct information in properties files
 #
 #  Error conditions: 
 #      WebSphere_Portal appserver is not running
 #      Port conflict with another application.
 #      URL cannot be resolved (DNS error, for example)
 ##############################################################################
-->
<target name="validate-http-portal" >
     <http-check url="${WpsHostName}:${WpsHostPort}/${WpsContextRoot}/${WpsDefaultHome}" 
                 waitSeconds="5" 
                 tryCount="5" />
</target>                                                           
                                                      
<!--
 ##############################################################################
 #  Name: validate-wps-admin-login
 #
 #  Description: action to check Portal administrator settings
 #
 #  Usage: To determine Portal Administrator has admin privileges
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites: 
 #          Portal is installed and running
 #          Correct information in properties files
 #
 #  Error conditions: 
 #      WebSphere_Portal appserver is not running
 #      Port conflict with another application.
 #      URL cannot be resolved (DNS error, for example)
 #      user does not exist
 #      user does not have admin privileges
 #      passwd is incorrect
 #      
 ##############################################################################
-->
<target name="validate-wps-admin-login" depends="init" >

    <property name="AdminTestSourceFile" location="${WpsInstallLocation}/config/work/PortalTest.xml" />
    <property name="AdminTestResultFile" location="${WpsInstallLocation}/config/work/PortalTestResults.xml" />

    <xmlaccess
        user="${PortalAdminIdShort}"
        password="${PortalAdminPwd}"
        url="http://${WpsHostName}:${WpsHostPort}/${WpsContextRoot}/config"
        srcfile="${AdminTestSourceFile}" 
        destFile="${AdminTestResultFile}"
        failOnError="false" />
            
    <admin-check resultsFileName="${AdminTestResultFile}" />
</target>                                                           

<!-- 
 ##############################################################################
 #  Name: action-validate-lpta-passwd-isdefined
 #
 #  Description: Action to empty LTPA password property.
 #               Setting security with empty LTPA passwd will fail in most
 #               cases.
 #
 #  Usage: subtask of security validation tasks
 #
 #  Inputs: from wpconfig.properties
 #
 #  Assumptions/Prerequisites: 
 #          Correct information in properties files
 #
 #  Error conditions: 
 #      LTPAPassword is empty or not defined
 #      
 ##############################################################################
-->     
<target name="action-validate-lpta-passwd-isdefined">
    <condition property="LTPAPasswordIsEmpty">
        <equals arg1="${LTPAPassword}" arg2="" trim="true" />
    </condition>
    <fail message="Property LTPAPassword is empty. Set the correct value and restart the task."       if="LTPAPasswordIsEmpty"/>
    <fail message="Property LTPAPassword is not defined. Set the correct value and restart the task." unless="LTPAPassword"/>
</target>

<!--
 #################################################################################
 #  Name:  		action-validate-schemas-nonexistence
 #
 #  Description:  validates the whether the Feedback, WMM, 
 #  			WebSphere Portal, Personalization & Business Rule Bean Exist  
 #
 #  Assumptions/Prerequisites: 
 # 	            Portal is installed and running
 #        		Correct information in properties files
 #
 #  Success: 	If the specified database schema doesnot exist,the task succeeds. 
 #
 #  Failure:	If the database schema name exists, the task fails and the task
 #			halts
 #
 #  Logging:	Both success and failure messages are logged.
 ##############################################################################
-->
<target name="validate-schemas-nonexistence">
        <logmsg level="INFO" task="action-validate-schemas-exist" subtask="predicate" message="OS400.Validation.schema.names.exist"/>
        <antcall target= "iseries-switch-back" />
        <antcall target="validate-WpsDbSchema-exist" />
        <antcall target="validate-WmmDbSchema-exist" />
        <antcall target="validate-FeedbackSchema-exist" />
        <antcall target="iseries-switch-to-was-user" />
</target>

<target name="validate-WpsDbSchema-exist">
        <logmsg level="INFO" task="action-validate-WpsDbSchema-exist" subtask="predicate" message="OS400.DB.schema.check" param1="${WpsDbSchema}"/>
	  <property name="parArg" value="${WpsDbSchema}"/> 
        <validationshell predicate='os400_is_db_existent("${WpsDbSchema}")'/>
<antcall target="action-log-validate-db-exist-${validation.predicate_result}"/>
</target>

<target name="validate-FeedbackSchema-exist">
        <logmsg level="INFO" task="action-validate-FeedbackSchema-exist" subtask="predicate" message="OS400.DB.schema.check" param1= "${FeedbackSchema}"/>
	  <property name="parArg" value="${FeedbackSchema}"/> 
        <validationshell predicate='os400_is_db_existent("${FeedbackSchema}")'/>
<antcall target="action-log-validate-db-exist-${validation.predicate_result}"/>
</target>

<target name="validate-WmmDbSchema-exist">
        <logmsg level="INFO" task="action-validate-WmmDbSchema-exist" subtask="predicate" message="OS400.DB.schema.check" param1="${WmmDbSchema} "/>
	  <property name="parArg" value="${WmmDbSchema}"/> 
        <validationshell predicate='os400_is_db_existent("${WmmDbSchema}")'/>
<antcall target="action-log-validate-db-exist-${validation.predicate_result}"/>
</target>

<target name="action-log-validate-db-exist-success">
        <logmsg level="INFO" task="validate-db-exist-success" subtask="predicate" 
message="OS400.DB.schema.existence.success" param1="${parArg}"/>
</target>

<target name="action-log-validate-db-exist-failure" >
        <logmsg level="WARNING" task="validate-db-exist-failure" subtask="predicate"  
message="OS400.Install.check.DBalreadyExists" param1="${parArg}"/>

        <fail message="Schema validation failed" />
</target>


<!--
 #################################################################################
 #  Name:  		action-validate-schema-names 
 #
 #  Description:  validates that the specified DB names meet iSeries Naming
 #  			Conventions. 
 #  			
 #  Assumptions/Prerequisites: 
 # 	            Portal is installed and running
 #        		The correct information is in the properties files
 #
 #  Success: 	If the name is valid (meets iSeries naming conventions), 
 #			the task succeeds
 #
 #  Failure:	If name is not valid or doesnot meet iSeries naming 
 #			conventions, the task fails.
 #
 #  Logging:	Both success and failure messages are logged.
 ##############################################################################
-->

<target name="validate-schema-names">
        <logmsg level="INFO" task="action-validate-schema-names" subtask="predicate" message="OS400.Schema.names.validation.check"/>
        <antcall target="validate-WmmDbSchema" />
        <antcall target="validate-FeedbackSchema" />
        <antcall target="validate-WpsDbSchema" />
</target>

<!-- target if property set telling us to skip database existence validation -->
<target name="action-log-validate-db-exist-skipped" >
</target>

<target name="validate-WpsDbSchema">
        <logmsg level="INFO" task="action-validate-WpsDbSchema" subtask="predicate" message="OS400.DB.Schema.name.validation" param1="${WpsDbSchema}"/>
	  <property name="parArg" value="${WpsDbSchema}"/> 
        <validationshell predicate='os400_validName("${WpsDbSchema}")'/>
        <antcall target="action-log-validate-schema-names-${validation.predicate_result}" />
</target>

<target name="validate-FeedbackSchema">
        <logmsg level="INFO" task="action-validate-FeedbackSchema" subtask="predicate" message="OS400.DB.Schema.name.validation" param1="${FeedbackSchema}"/>
	  <property name="parArg" value="${FeedbackSchema}"/> 
        <validationshell predicate='os400_validName("${FeedbackSchema}")'/>
        <antcall target="action-log-validate-schema-names-${validation.predicate_result}" />
</target>

<target name="validate-WmmDbSchema">
        <logmsg level="INFO" task="action-validate-WmmDbSchema" subtask="predicate" message="OS400.DB.Schema.name.validation" param1="${WmmDbSchema}"/>
	  <property name="parArg" value="${WmmDbSchema}"/> 
        <validationshell predicate='os400_validName("${WmmDbSchema}")'/>
        <antcall target="action-log-validate-schema-names-${validation.predicate_result}" />
</target>


<target name="action-log-validate-schema-names-success">
        <logmsg level="INFO" task="validate-schema-names" subtask="predicate" message="OS400.DB.Schema.name.validation.success" param1="${parArg}"/>
</target>

<target name="action-log-validate-schema-names-failure" >
        <logmsg level="WARNING" task="validate-schema-names" subtask="predicate"  
message="OS400.DB.Schema.name.validation.failure" param1="${parArg}"/>
        <fail message="Schema validation failed" />
</target>


<!-- target if property set telling us to skip validation -->
<target name="action-log-validate-schema-names-skipped" >
</target>

 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.