<?xml version="1.0"?>
<!DOCTYPE configuration SYSTEM "dtd/Configuration.dtd">
<configuration name="KernelTasks" version="1.0">
  <package name="com.sap.sdt.tools" version="1.0"/>
  
  <task name="SET_EXEC_SDM" type="extProcess">
  	<process id="ChmodSDMRemoteGui"/>
  	<process id="ChmodSDMStart"/>
  	<process id="ChmodSDMStop"/>
  	<process id="ChmodSDM"/>
  	<process id="ChmodSDMJdk"/>
  	<process id="ChmodSDMPrepCom"/>
  </task>

  <task name="SET_EXEC_JSPM" type="extProcess">
  	<process id="ChmodGo"/>
    <process id="ChmodStartGui"/>
	<process id="ChmodJSPMBootstrap"/>
  </task>

	<task name="SET_EXEC_CORETOOLS" type="extProcess">
		<process id="ChmodAdmin"/>
		<process id="ChmodCfgTool"/>
		<process id="ChmodConsoleCfg"/>
		<process id="ChmodOfflineCfg"/>
		<process id="ChmodDeployTool"/>
  </task>
  
  <task name="SET_EXEC_JLOGVIEW" type="extProcess">
  	<process id="ChmodLogviewer"/>
  	<process id="ChmodLv"/>
  	<process id="ChmodLvRegisterLog"/>
  	<process id="ChmodLvRemoteServer"/>
  	<process id="ChmodLvStopServer"/>
  	<process id="ChmodLvDaemon"/>
  	<process id="ChmodServerNohup"/>
  </task>
  
  <task name="SET_EXEC_LMTOOLS" type="extProcess">
  	<process id="ChmodCTC"/>
  </task>

  <task name="UNSET_AUTOSTART" type="modifyFile">
	</task>

	<task name="CREATE_EXE_DIRS" type="fs">
    <createDirectory name="$(/J2EE/StandardSystem/ExecutableDirectory)"/>
    <createDirectory name="$(/J2EE/StandardSystem/ServiceInstance/ExecutableDirectory)"/>
    <createDirectory name="$(/J2EE/StandardSystem/CentralInstance/ExecutableDirectory)"/>
  </task>

  <task name="CREATE_UPGRADE_PROFILES" type="fs">
    <copy file="$(JSPM/DIR/CONFIG/TEMPLATES)/UPGRADE_JC_profile" 
      toFile="$(JSPM/DIR/DATA)/UPGRADE_$(/J2EE/StandardSystem/CentralInstance/InstanceName)_$(/J2EE/SAPGlobalHost)"
      macroprocess="true" overwrite="true" />
    <copy file="$(JSPM/DIR/CONFIG/TEMPLATES)/UPGRADE_SCS_profile" 
      toFile="$(JSPM/DIR/DATA)/UPGRADE_$(/J2EE/StandardSystem/ServiceInstance/ServiceInstanceName)_$(/J2EE/SAPGlobalHost)"
      macroprocess="true" overwrite="true" />
  </task>


  <task name="UPDATE_PROFILES" type="modifyFile">
  
    <modifyFile file="$(/J2EE/StandardSystem/DefaultProfilePath)" commentPattern="# *****  %  *****">
      <description>
------------------------------------------------------------
 Parameters for running with VMClite
 Please outcomment the parameters for the hotspot VM below
------------------------------------------------------------
 jstartup/framework_jars = jstartup.jar;vmcallinone.jar
 jstartup/vm/parameters =  -Xtrace2:0x0 -Xss256K -DSAPSTART=1 -Xgc:youngGen=20m
 jstartup/vm/ignore_unrecognized=1
 jstartup/vm/type = cvm
 jstartup/vm/home = $$(DIR_JKIT)

------------------------------------------------------------
 Use 250 MB of extended memory and offer 200 MB to the
 virtual machines.
------------------------------------------------------------
 em/address_space_MB = 301
 em/initial_size_MB  = 301
 em/global_area_MB   = 300
 abap/shared_objects_size_MB = 0
------------------------------------------------------------
      </description>

      <addProperty target="j2ee/scs/host">
        <stringValue>$(/J2EE/SAPGlobalHost)</stringValue>
      </addProperty>
      <addProperty target="j2ee/scs/system">
        <stringValue>$(/J2EE/StandardSystem/ServiceInstance/ServiceInstanceID)</stringValue>
      </addProperty>
    </modifyFile>

    <modifyFile file="$(/J2EE/StandardSystem/CentralInstance/InstanceProfilePath)" commentPattern="# *****  %  *****">
      <addProperty target="j2ee/instance_id">
        <stringValue>$(/J2EE/StandardSystem/CentralInstance/InstancePrefix)</stringValue>
      </addProperty>
      <addProperty target="j2ee/dbdriver">
        <stringValue>$(/J2EE/DBSystem/JDBCDriverClasspath)</stringValue>
      </addProperty>
      <setProperty target="SDM_PROPERTIES">
        <stringValue> </stringValue>
      </setProperty>

	  <deleteProperty target="jstartup/instance_properties"/>
    </modifyFile>
	<if test="$(/J2EE/StandardSystem/BCSystemPresent) == true">
    	<if test="$(/J2EE/StandardSystem/HighAvailability) == false">
	    	<modifyFile file="$(/J2EE/StandardSystem/CentralInstance/InstanceProfilePath)" commentPattern="# *****  %  *****">
               <setProperty target="exe/j2ee">
                  <stringValue>$$(DIR_EXECUTABLE)/jstart$$(FT_EXE)</stringValue>
               </setProperty>
           </modifyFile>
    	</if>
	</if>

    <for-each variable="/J2EE/StandardSystem/Instances" into="Instance" test="$(Instance@IsCentralInstance) == false">
		<modifyFile file="$(Instance@InstanceProfilePath)" commentPattern="# *****  %  *****">
			<setProperty target="j2ee/instance_id">
			  <stringValue>$(Instance@InstancePrefix)</stringValue>
			</setProperty>
			<deleteProperty target="jstartup/instance_properties"/>
        </modifyFile>	
		<if test="$(/J2EE/StandardSystem/BCSystemPresent) == true">
			<if test="$(/J2EE/StandardSystem/HighAvailability) == false">
				<modifyFile file="$(/J2EE/StandardSystem/CentralInstance/InstanceProfilePath)" commentPattern="# *****  %  *****">
				   <setProperty target="exe/j2ee">
					  <stringValue>$$(DIR_EXECUTABLE)/jstart$$(FT_EXE)</stringValue>
				   </setProperty>
			   </modifyFile>
			</if>
		</if>

	</for-each>

  </task>

  <task name="DELETE_OBSOLETE_JARS" type="fs">
    <delete>
      <fileset dir="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/bootstrap" recursive="true">
        <include name="*.jar"/>
      </fileset>
      <fileset dir="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/configtool/lib" recursive="true">
        <include name="*.jar"/>
      </fileset>
      <fileset dir="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/j2eeclient" recursive="false">
        <include name="logging.jar"/>
        <include name="sapj2eeclient.jar"/>
        <include name="exception.jar"/>
      </fileset>
    </delete>

	  <choose>
	    <when test="$FILE_EXISTS($(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/bin/system) == true">
		    <delete>
				  <fileset dir="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/bin/system" recursive="true">
						<include name="*.jar"/>
				  </fileset>
			  </delete>
		  </when>
    </choose>

	  <choose>
	    <when test="$FILE_EXISTS($(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/bin/core_lib) == true">
		    <delete>
				  <fileset dir="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/bin/core_lib" recursive="true">
						<include name="*.jar"/>
				  </fileset>
			  </delete>
		  </when>
    </choose>

	  <choose>
	    <when test="$FILE_EXISTS($(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/version.bin) == true">
		    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/version.bin" />
		  </when>
    </choose>

	  <choose>
	    <when test="$FILE_EXISTS($(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/dispatcher) == true">
		    <delete dir="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/dispatcher" />
		  </when>
    </choose>

    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server0/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server0/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server1/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server1/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server2/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server2/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server3/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server3/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server4/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server4/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server5/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server5/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server6/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server6/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server7/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server7/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server8/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server8/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server9/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server9/remote.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server10/java.policy" />
    <delete file="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/cluster/server10/remote.policy" />

  </task>


    <task name="DEPLOY_JDD_EXTRAMILE" type="extProcess">
    <javaProcess className="com.sap.engine.offline.OfflineToolStart" fork="true" dir="$(/JSPM/JavaDVDLocation)/install" 
      stdout="$(/JSPM/DIR/LOG)/BATCHDEPLOYER_JDD.OUT" stderr="$(/JSPM/DIR/LOG)/BATCHDEPLOYER_JDD.ERR" >
      <classPath>
        <pathelement location="lib/sap.com~tc~bl~offline_launcher~impl.jar"/>
        <pathelement location="lib"/>
      </classPath>
      <arg value="com.sap.engine.extramile.BatchDeployer"/>
      <arg value="lib$(/SystemProperties/Pathseparator)lib/engine$(/SystemProperties/Pathseparator)lib/tools"/>
      <arg value="-pf"/>
      <arg value="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/configtool/config.properties"/>
      <arg value="-list"/>
      <arg value="$(/JSPM/JavaDVDLocation)/DEPLOY_ENGINE_JDD.LST"/>
      <checkRC result="FATAL">
        <values invert="true">
          <single value="0"/>
        </values>
        <message>Deployment with Extramile Tool completed with error</message>
      </checkRC>
    </javaProcess>
  </task>

  <task name="DEPLOY_OFFLINE_EXTRAMILE" type="extProcess">
    <javaProcess className="com.sap.engine.offline.OfflineToolStart" fork="true" dir="$(/JSPM/JavaDVDLocation)/install" 
      stdout="$(/JSPM/DIR/LOG)/BATCHDEPLOYER_OFFLINE.OUT" stderr="$(/JSPM/DIR/LOG)/BATCHDEPLOYER_OFFLINE.ERR" >
      <classPath>
        <pathelement location="lib/sap.com~tc~bl~offline_launcher~impl.jar"/>
        <pathelement location="lib"/>
      </classPath>
      <arg value="com.sap.engine.extramile.BatchDeployer"/>
      <arg value="lib$(/SystemProperties/Pathseparator)lib/engine$(/SystemProperties/Pathseparator)lib/tools"/>
      <arg value="-pf"/>
      <arg value="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/configtool/config.properties"/>
      <arg value="-list"/>
      <arg value="$(/JSPM/JavaDVDLocation)/DEPLOY_ENGINE_OFFLINE.LST"/>
      <checkRC result="FATAL">
        <values invert="true">
          <single value="0"/>
        </values>
        <message>Deployment with Extramile Tool completed with error</message>
      </checkRC>
    </javaProcess>
  </task>

    <task name="DEPLOY_FS_EXTRAMILE" type="extProcess">
    <javaProcess className="com.sap.engine.offline.OfflineToolStart" fork="true" dir="$(/JSPM/JavaDVDLocation)/install" 
      stdout="$(/JSPM/DIR/LOG)/BATCHDEPLOYER_FS.OUT" stderr="$(/JSPM/DIR/LOG)/BATCHDEPLOYER_FS.ERR" >
      <classPath>
        <pathelement location="lib/sap.com~tc~bl~offline_launcher~impl.jar"/>
        <pathelement location="lib"/>
      </classPath>
      <arg value="com.sap.engine.extramile.BatchDeployer"/>
      <arg value="lib"/>
      <arg value="-pf"/>
      <arg value="$(/J2EE/StandardSystem/CentralInstance/J2EEDirectory)/configtool/config.properties"/>
      <arg value="-list"/>
      <arg value="$(/JSPM/JavaDVDLocation)/DEPLOY_ENGINE_FS.LST"/>
      <checkRC result="FATAL">
        <values invert="true">
          <single value="0"/>
        </values>
        <message>Deployment with Extramile Tool completed with error</message>
      </checkRC>
    </javaProcess>
  </task>

</configuration>
