<!DOCTYPE project [
    <!ENTITY importExternalLogs SYSTEM "file:./scripts/importExternalLogs.xml">
]>
<project name="cleanupAdminApp" default="cleanupAdminApp" basedir=".">

    
    <taskdef name="wscmtlog" classname="com.ibm.ws.install.configmanager.actionengine.ant.utils.AntTaskToLogToConfigManagersLogFiles"/>
    <taskdef name="wsadmin" classname="com.ibm.websphere.ant.tasks.WsAdminInProcess"/>
    <taskdef name="checkForOmittedApps" classname="com.ibm.ws.install.configmanager.actionengine.ant.utils.CheckForOmittedApps"/>
    &importExternalLogs;  
		         
    <target name="checkForOmitted">
        <checkForOmittedApps appToCheck="deployAdminConsole" property="isAppOmitted"/>
  
        <condition property="isAdminConsoleOmitted" value="true">
           <equals arg1="${isAppOmitted}" arg2="true"/>
        </condition>
   
        <wscmtlog> Value of isAdminConsoleOmitted = ${isAdminConsoleOmitted}</wscmtlog>

        <wscmtlog> Value of isAppOmitted = ${isAppOmitted} </wscmtlog>
	<echo> isAppOmitted = ${isAppOmitted} </echo>
    </target>

    <target name="checkForAllOmitted">
        <checkForOmittedApps appToCheck="All" property="allAppsOmitted"/>
  
        <condition property="noAppsInstalled" value="true">
           <equals arg1="${allAppsOmitted}" arg2="true"/>
        </condition>
   
        <condition property="uninstallAdmin" value="true">
        <and>
           <equals arg1="${isAdminConsoleOmitted}" arg2="true"/>       
            <not>
	      <equals arg1="${noAppsInstalled}" arg2="true"/>
           </not>
        </and>

        </condition>
        <wscmtlog> Value of noAppsInstalled = ${noAppsInstalled}</wscmtlog>

        <wscmtlog> Value of isAdminConsoleOmitted = ${isAdminConsoleOmitted}</wscmtlog>

        <echo>  Value of uninstallAdmin = ${uninstallAdmin} </echo>
        <wscmtlog> Value of uninstallAdmin = ${uninstallAdmin}</wscmtlog>

    </target>

    <target name="uninstallAdminConsole"
            description="Uninstall the admin console"
            if="uninstallAdmin"
            >
            
        <wscmtlog>Uninstalling the admin console, the output will be recorded in: ${WS_CMT_LOG_HOME}/${profileName}/uninstallAdminConsole.log</wscmtlog>
         <!-- fail on error was true, but changed to false to accomodate F69142-65189 -->   
         <wsadmin conntype="none"
                 failonerror="false"
				 returnproperty="rcProperty"
                 tracefile="${WS_CMT_LOG_HOME}/${profileName}/uninstallAdminConsole.log"
                 wasHome="${WAS_HOME}"
                 wasInstallRoot="${WAS_HOME}"
                 wasRepositoryRoot="${profilePath}/config"
                 userInstallRoot="${profilePath}"
                 localCell="${cellName}"
                 localNode="${nodeName}"
                 wsadminProps="${profilePath}/properties/wsadmin.properties"
                 command="$AdminApp uninstall isclite"
                 ipcFilename="${profilePath}/temp/wsadmin"
				 lang="jacl"
                 >
        </wsadmin>               
         <antcall target="importLogsToMain" >
            <param name="logfile" value="${WS_CMT_LOG_HOME}/${profileName}/uninstallAdminConsole.log" />
            <param name="description" value="Uninstalling the admin console" />
            <param name="precondition" value="foetrue" />
        </antcall>           
    </target> 

    <target name="cleanupAdminApp"
        description="Adjusts the config tree to remove actifacts created by omitted actions."
        depends="
            checkForOmitted, 
	    checkForAllOmitted,
            uninstallAdminConsole"/>
</project>
