<!DOCTYPE project [
    <!ENTITY importExternalLogs SYSTEM "file:./scripts/importExternalLogs.xml">
]>
<project name="filetransferConfig" default="filetransferConfig" basedir=".">
    
    <taskdef name="wscmtlog"
        classname="com.ibm.ws.install.configmanager.actionengine.ant.utils.AntTaskToLogToConfigManagersLogFiles"/>
        
  	<taskdef name="wsadmin" classname="com.ibm.websphere.ant.tasks.WsAdminInProcess"/>
         &importExternalLogs; 	 
    <property name="NODE_NAME" value="${WS_CMT_NODE_NAME}"/>
    <property name="CELL_NAME" value="${WS_CMT_CELL_NAME}"/>
    <property name="serverName" value="dmgr"/>

    <target name="detectCurrentOSFamily"
            description="Detects the current OS family (UNIX or Windows)">
        
        <!-- OS/400 setting must come before the unix setting -->
        <condition property="currentOSFamily" value="os/400">
            <equals arg1="${os.name}" arg2="OS/400"/>
        </condition>

        <!-- z/OS setting must come before the unix setting -->
        <condition property="currentOSFamily" value="z/os">
            <os family="z/os"/>
        </condition>
        
        <condition property="currentOSFamily" value="windows">
            <os family="windows"/>
        </condition>
        
        <condition property="currentOSFamily" value="unix">            
            <os family="unix"/>
        </condition>
        
        <wscmtlog>Detected current OS family to be: ${currentOSFamily}</wscmtlog>
    </target>

    <target name="defineOSSpecificConfigFlag"
            description="Defines either configUNIX or configWindows depending on the current OS">
            
        <condition property="configOS400" value="true">
            <equals arg1="${currentOSFamily}" arg2="os/400"/>
        </condition>
        
        <condition property="configZOS" value="true">
            <equals arg1="${currentOSFamily}" arg2="z/os"/>
        </condition>

        <condition property="configUNIX" value="true">
            <equals arg1="${currentOSFamily}" arg2="unix"/>
        </condition>
        
        <condition property="configWindows" value="true">
            <equals arg1="${currentOSFamily}" arg2="windows"/>
        </condition>
    </target>
    
    <target name="convertWASHomeToUNIXStylePath">
        <path id="id.was.home">
            <pathelement location="${WAS_HOME}"/>
        </path>
    
        <pathconvert targetos="unix" 
            property="WAS_HOME_UNIX_STYLE" 
            refid="id.was.home"/>
    </target>
    
    <target name="deployFileTransferAppOS400"
            description="Deploys the FileTransfer EAR Application for OS400"
            if="configOS400">
            
        <wscmtlog>Deploying FileTransfer EAR, the output will be recorded in: ${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log</wscmtlog>
          <!-- fail on error was true, but changed to false to accomodate F69142-65189 -->              
        <wsadmin conntype="none"
                 failonerror="false"
                 returnproperty="rcProperty"
				 lang="jacl"
                 tracefile="${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log"
                 wasHome="${WAS_HOME}"
                 wasInstallRoot="${WAS_HOME}"
                 wasRepositoryRoot="${profilePath}/config"
                 userInstallRoot="${profilePath}"
                 localCell="${cellName}"
                 localNode="${nodeName}"
                 wsadminProps="${profilePath}/properties/wsadmin.properties"
                 command="$AdminApp install ${WAS_HOME_UNIX_STYLE}/systemApps/filetransferSecured.ear {-node ${NODE_NAME} -cell ${CELL_NAME} -server ${serverName} -usedefaultbindings -nocreateMBeansForResources -appname filetransfer -zeroEarCopy -skipPreparation -custom installed.ear.destination.final=${WAS_HOME}/systemApps/filetransferSecured.ear}"
                 ipcFilename="${profilePath}/temp/wsadmin"
                 >
        </wsadmin>   
        <antcall target="importLogsToMain" >
            <param name="logfile" value="${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log" />
            <param name="description" value="Deploying FileTransfer EAR" />
            <param name="precondition" value="foetrue" />
        </antcall>	
    </target>

    <target name="deployFileTransferAppZOS"
            description="Deploys the FileTransfer EAR Application for z/OS"
            if="configZOS">
            
        <wscmtlog>Deploying FileTransfer EAR, the output will be recorded in: ${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log</wscmtlog>
         <!-- fail on error was true, but changed to false to accomodate F69142-65189 -->           
        <wsadmin conntype="none"
                 failonerror="false"
                 returnproperty="rcProperty"
				 lang="jacl"
                 tracefile="${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log"
                 wasHome="${WAS_HOME}"
                 wasInstallRoot="${WAS_HOME}"
                 wasRepositoryRoot="${profilePath}/config"
                 userInstallRoot="${profilePath}"
                 localCell="${cellName}"
                 localNode="${nodeName}"
                 wsadminProps="${profilePath}/properties/wsadmin.properties"
                 command="$AdminApp install ${WAS_HOME_UNIX_STYLE}/systemApps/filetransferSecured.ear {-node ${NODE_NAME} -cell ${CELL_NAME} -server ${serverName} -usedefaultbindings -nocreateMBeansForResources -appname filetransfer -zeroEarCopy -skipPreparation -custom installed.ear.destination.final=${WAS_HOME}/systemApps/filetransferSecured.ear}"
                 ipcFilename="${profilePath}/temp/wsadmin"
                 >
        </wsadmin>   
        <antcall target="importLogsToMain" >
            <param name="logfile" value="${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log" />
            <param name="description" value="Deploying FileTransfer EAR" />
            <param name="precondition" value="foetrue" />
        </antcall>	
    </target>


    <target name="deployFileTransferAppUNIX"
            description="Deploys the FileTransfer EAR Application for UNIX"
            if="configUNIX">
            
        <wscmtlog>Deploying FileTransfer EAR, the output will be recorded in: ${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log</wscmtlog>
         <!-- fail on error was true, but changed to false to accomodate F69142-65189 -->   
				<wsadmin conntype="none"
                 failonerror="false"
                 returnproperty="rcProperty"
				 lang="jacl"
                 tracefile="${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log"
                 wasHome="${WAS_HOME}"
                 wasInstallRoot="${WAS_HOME}"
                 wasRepositoryRoot="${profilePath}/config"
                 userInstallRoot="${profilePath}"
                 localCell="${cellName}"
                 localNode="${nodeName}"
                 wsadminProps="${profilePath}/properties/wsadmin.properties"
                 command="$AdminApp install ${WAS_HOME_UNIX_STYLE}/systemApps/filetransferSecured.ear {-node ${NODE_NAME} -cell ${CELL_NAME} -server ${serverName} -usedefaultbindings -nocreateMBeansForResources -appname filetransfer -zeroEarCopy -skipPreparation -custom installed.ear.destination.final=${WAS_HOME}/systemApps/filetransferSecured.ear}"
                 ipcFilename="${profilePath}/temp/wsadmin"
                 >
         </wsadmin>
        <antcall target="importLogsToMain" >
            <param name="logfile" value="${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log" />
            <param name="description" value="Deploying FileTransfer EAR" />
            <param name="precondition" value="foetrue" />
        </antcall>	
    </target>

    <target name="deployFileTransferAppWindows"
            description="Deploys the FileTransfer EAR Application for Windows"
            if="configWindows">
            
        <wscmtlog>Deploying FileTransfer EAR, the output will be recorded in: ${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log</wscmtlog>
          <!-- fail on error was true, but changed to false to accomodate F69142-65189 -->          
        <wsadmin conntype="none"
                 failonerror="false"
                 returnproperty="rcProperty"
				 lang="jacl"
                 tracefile="${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log"
                 wasHome="${WAS_HOME}"
                 wasInstallRoot="${WAS_HOME}"
                 wasRepositoryRoot="${profilePath}/config"
                 userInstallRoot="${profilePath}"
                 localCell="${cellName}"
                 localNode="${nodeName}"
                 wsadminProps="${profilePath}/properties/wsadmin.properties"
                 command="$AdminApp install &quot;${WAS_HOME_UNIX_STYLE}/systemApps/filetransferSecured.ear&quot; {-node ${NODE_NAME} -cell ${CELL_NAME} -server ${serverName} -usedefaultbindings -nocreateMBeansForResources -appname filetransfer -zeroEarCopy -skipPreparation -custom &quot;installed.ear.destination.final=${WAS_HOME}/systemApps/filetransferSecured.ear&quot;}"
                 ipcFilename="${profilePath}/temp/wsadmin"
                 >
        </wsadmin>
        <antcall target="importLogsToMain" >
            <param name="logfile" value="${WS_CMT_LOG_HOME}/${profileName}/filetransfer_config.log" />
            <param name="description" value="Deploying FileTransfer EAR" />
            <param name="precondition" value="foetrue" />
        </antcall>			
    </target>
    
    <target name="filetransferConfig"
        description="Configures filetransfer"
        depends="detectCurrentOSFamily,          
            defineOSSpecificConfigFlag,
            convertWASHomeToUNIXStylePath,
            deployFileTransferAppOS400,
            deployFileTransferAppZOS,
            deployFileTransferAppUNIX,
            deployFileTransferAppWindows"/>
</project>
