<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements. See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<?include "cpack_variables.wxi"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
    RequiredVersion="3.14.1.8722"
    xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension">

  <Product Id="$(var.CPACK_WIX_PRODUCT_GUID)"
      Name="Apache NiFi MiNiFi"
      Language="1033"
      UpgradeCode="$(var.CPACK_WIX_UPGRADE_GUID)"
      Version="$(var.CPACK_PACKAGE_VERSION)"
      Manufacturer="$(var.CPACK_PACKAGE_VENDOR)">


    <Package InstallScope="perMachine" InstallerVersion="301" Compressed="yes"/>

    <MajorUpgrade DowngradeErrorMessage="A newer version of Apache NiFi MiNiFi C++ is already installed." />

    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes"/>

    <WixVariable Id="WixUILicenseRtf" Value="$(var.CPACK_WIX_LICENSE_RTF)"/>
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALL_ROOT"/>

    <?ifdef CPACK_WIX_PRODUCT_ICON?>
    <Property Id="ARPPRODUCTICON">ProductIcon.ico</Property>
    <Icon Id="ProductIcon.ico" SourceFile="$(var.CPACK_WIX_PRODUCT_ICON)"/>
    <?endif?>

    <?ifdef CPACK_WIX_UI_BANNER?>
    <WixVariable Id="WixUIBannerBmp" Value="$(var.CPACK_WIX_UI_BANNER)"/>
    <?endif?>

${WIX_EXTRA_FEATURES}

    <Feature Id="InstallService" Title="Apache NiFi MiNiFi C++ Service" AllowAdvertise="no" Display="hidden" Level="1">
      <ComponentRef Id="minifiService"/>
      <ComponentRef Id="minifiServiceNotLocal"/>
      <ComponentRef Id="minifiService_autostart"/>
    </Feature>

    <Feature Id="InstallConf" Title="Apache NiFi MiNiFi C++ Configuration" AllowAdvertise="yes"  Level="1">
      <ComponentRef Id="LOGPROP"/>
      <ComponentRef Id="UIDPROP"/>
      <ComponentRef Id="CONFIGFILE"/>
      <ComponentRef Id="OPENSSLCONFCOMP"/>
      <ComponentRef Id="UpdateConfig"/>
      <ComponentRef Id="UpdateConfigNotExist"/>
    </Feature>

<?ifdef INCLUDE_PYTHON_PROCESSORS?>
    <Feature Id="InstallMiNiFiPython" Title="Apache NiFi MiNiFi C++ Python processors" AllowAdvertise="yes"  Level="1">
      <ComponentRef Id="PythonProcessorExampleFiles"/>
      <ComponentRef Id="NifiPythonProcessorFiles"/>
      <ComponentRef Id="PythonProcessorMojoFiles"/>
      <ComponentRef Id="PythonProcessorH2oFiles"/>
      <ComponentRef Id="PythonProcessorNifiApiFiles"/>
      <ComponentRef Id="PythonProcessorGoogleFiles"/>
      <ComponentRef Id="NifiPythonProcessorUtilsFiles"/>
    </Feature>
<?endif?>

    <FeatureRef Id="ProductFeature"/>

    <?ifdef CPACK_WIX_UI_DIALOG?>
    <WixVariable Id="WixUIDialogBmp" Value="$(var.CPACK_WIX_UI_DIALOG)"/>
    <?endif?>
    <UI Id="WixUI_HK">
      <TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
      <TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="12" />
      <TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />

      <Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
      <Property Id="WixUI_Mode" Value="InstallDir" />

      <DialogRef Id="BrowseDlg" />
      <DialogRef Id="DiskCostDlg" />
      <DialogRef Id="ErrorDlg" />
      <DialogRef Id="FatalError" />
      <DialogRef Id="FilesInUse" />
      <DialogRef Id="MsiRMFilesInUse" />
      <DialogRef Id="PrepareDlg" />
      <DialogRef Id="ProgressDlg" />
      <DialogRef Id="ResumeDlg" />
      <DialogRef Id="ResumeDlg" />
      <DialogRef Id="CustomizeDlg" />
      <DialogRef Id="UserExit" />

      <DialogRef Id="ApacheLicenseDlg"/>
      <DialogRef Id="PropertiesDialog" />
      <DialogRef Id="UserDialog" />

      <Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
      <Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>

      <Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

      <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="ApacheLicenseDlg">NOT Installed</Publish>
      <Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>

      <Publish Dialog="ApacheLicenseDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
      <Publish Dialog="ApacheLicenseDlg" Control="Next" Event="NewDialog" Value="CustomizeDlg">LicenseAccepted = "1"</Publish>

      <Publish Dialog="CustomizeDlg" Control="Back" Event="NewDialog" Value="ApacheLicenseDlg">1</Publish>
      <Publish Dialog="CustomizeDlg" Control="Next" Event="NewDialog" Value="UserDialog">1</Publish>

      <Publish Dialog="UserDialog" Control="Back" Event="NewDialog" Value="CustomizeDlg">1</Publish>
      <Publish Dialog="UserDialog" Control="Next" Event="NewDialog" Value="PropertiesDialog">1</Publish>

      <Publish Dialog="PropertiesDialog" Control="Back" Event="NewDialog" Value="UserDialog">1</Publish>
      <Publish Dialog="PropertiesDialog" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>

      <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="PropertiesDialog" Order="1">NOT Installed</Publish>
      <Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed</Publish>

      <Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

      <Publish Dialog="MaintenanceTypeDlg" Control="ChangeButton" Event="NewDialog" Value="CustomizeDlg">1</Publish>
      <Publish Dialog="MaintenanceTypeDlg" Control="RepairButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
      <Publish Dialog="MaintenanceTypeDlg" Control="RemoveButton" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>
      <Publish Dialog="MaintenanceTypeDlg" Control="Back" Event="NewDialog" Value="MaintenanceWelcomeDlg">1</Publish>
    </UI>

    <UIRef Id="WixUI_Common" />
    <UI>
      <!-- Define the installer UI -->

      <Dialog Id="ApacheLicenseDlg" Width="370" Height="270" Title="Please review our license">
        <Control Id="LicenseAcceptedCheckBox" Type="CheckBox" X="20" Y="207" Width="330" Height="18" CheckBoxValue="1" Property="LicenseAccepted" Text="Click here to accept this license" />
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back" />
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next">
          <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
          <Condition Action="disable"><![CDATA[LicenseAccepted <> "1"]]></Condition>
          <Condition Action="enable">LicenseAccepted = "1"</Condition>
        </Control>
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>
        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
        <Control Id="LicenseText" Type="ScrollableText" X="20" Y="60" Width="330" Height="140" Sunken="yes" TabSkip="no">

          <Text SourceFile="$(var.CPACK_WIX_LICENSE_RTF)" />
        </Control>
        <Control Id="Print" Type="PushButton" X="112" Y="243" Width="56" Height="17" Text="Print">
          <Publish Event="DoAction" Value="WixUIPrintEula">1</Publish>
        </Control>
        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
        <Control Id="Description" Type="Text" X="25" Y="23" Width="340" Height="15" Transparent="yes" NoPrefix="yes" Text="Please read and accept our license agreement." />
        <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="Apache NiFi MiNiFi License" />
      </Dialog>

      <Dialog Id="UserDialog" Width="370" Height="270" Title="Service Account Information">
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="Next" />
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="Back" />
        <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>

        <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Please enter your service account information.  " />
        <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="Apache NiFi MiNiFi Properties" />
        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
        <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />

        <Control Id="AccountLabel" Type="Text" X="20" Y="60" Width="290" Height="20" NoPrefix="yes" Text="Account" />
        <Control Id="Account" Type="Edit" X="20" Y="80" Width="320" Height="18" Property="SERVICEACCOUNT" Indirect="no" />

        <Control Id="AccountPasswordLabel" Type="Text" X="20" Y="100" Width="290" Height="20" NoPrefix="yes" Text="AccountPassword" />
        <Control Id="AccountPassword" Type="Edit" X="20" Y="120" Width="320" Height="18" Password="yes" Property="SERVICEACCOUNTPASSWORD" Indirect="no" />

      </Dialog>


      <Dialog Id="PropertiesDialog" Width="370" Height="380" Title="Agent Properties">
        <Control Id="Next" Type="PushButton" X="236" Y="350" Width="56" Height="17" Default="yes" Text="Next" />
        <Control Id="Back" Type="PushButton" X="180" Y="350" Width="56" Height="17" Text="Back" />
        <Control Id="Cancel" Type="PushButton" X="304" Y="350" Width="56" Height="17" Cancel="yes" Text="Cancel">
          <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>

        <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Please enter values for properties you wish to use.  " />
        <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="Apache NiFi MiNiFi Properties" />
        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" />
        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
        <Control Id="BottomLine" Type="Line" X="0" Y="343" Width="370" Height="0" />

        <Control Id="AutoStartMiNiFi" Type="CheckBox" X="20" Y="55"
                         Width="200" Height="17" Property="AUTOSTART"
                         CheckBoxValue="1"
                         Text="Start MiNiFi service at the end of the installation." Default="no" />

        <Control Id="EnableC2" Type="CheckBox" X="20" Y="80"
                         Width="200" Height="17" Property="ENABLEC2"
                         CheckBoxValue="1"
                         Text="Enable interactive Command and Control." Default="no" />

        <Control Id="AgentClassLabel" Type="Text" X="20" Y="100" Width="290" Height="20" NoPrefix="yes" Text="Agent Class" />
        <Control Id="AgentClass" Type="Edit" X="20" Y="120" Width="320" Height="18" Property="AGENT_CLASS" Indirect="no" >
          <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
          <Condition Action="enable">ENABLEC2="1"</Condition>
        </Control>

        <Control Id="AgentIdentifierLabel" Type="Text" X="20" Y="140" Width="60" Height="20" NoPrefix="yes" Text="Agent Identifier" />
        <Control Id="AgentIdentifier" Type="Edit" X="20" Y="160" Width="320" Height="18" Property="AGENT_IDENTIFIER"  Indirect="no"  >
          <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
          <Condition Action="enable">ENABLEC2="1"</Condition>
        </Control>

        <Control Id="ServerPathBaseIdentifierLabel" Type="Text" X="20" Y="180" Width="80" Height="20" NoPrefix="yes" Text="Server Base URL" />
        <Control Id="ServerPathBaseIdentifier" Type="Edit" X="20" Y="200" Width="320" Height="18" Property="SERVER_PATH_BASE" Indirect="no"  >
          <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
          <Condition Action="enable">ENABLEC2="1"</Condition>
        </Control>

        <Control Id="ServertHeartbeatIdentifierLabel" Type="Text" X="20" Y="220" Width="80" Height="20" NoPrefix="yes" Text="Server Heartbeat URL" />
        <Control Id="ServerHeartbeatIdentifier" Type="Edit" X="20" Y="240" Width="320" Height="18" Property="SERVER_HEARTBEAT" Indirect="no"  >
          <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
          <Condition Action="enable">ENABLEC2="1"</Condition>
        </Control>

        <Control Id="ServerAckIdentifierLabel" Type="Text" X="20" Y="260" Width="60" Height="20" NoPrefix="yes" Text="Server Ack URL" />
        <Control Id="ServeAckrIdentifier" Type="Edit" X="20" Y="280" Width="320" Height="18" Property="SERVER_ACK" Indirect="no"  >
          <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
          <Condition Action="enable">ENABLEC2="1"</Condition>
        </Control>

        <Control Id="AgentHeartbeatLabel" Type="Text" X="20" Y="300" Width="80" Height="20" NoPrefix="yes" Text="Agent Heartbeat" />
        <Control Id="AgentHeartbeat" Type="ComboBox" X="20" Y="320" Width="300" Height="17" Property="AGENT_HEARTBEAT" Sorted="yes" >
          <ComboBox Property="AGENT_HEARTBEAT">
            <ListItem Value="250 msec" />
            <ListItem Value="1 sec" />
            <ListItem Value="10 sec" />
            <ListItem Value="30 sec" />
            <ListItem Value="1 min" />
            <ListItem Value="5 min" />
            <ListItem Value="10 min" />
            <ListItem Value="30 min" />
            <ListItem Value="60 min" />
          </ComboBox>
          <Condition Action="disable"><![CDATA[ENABLEC2<>1]]></Condition>
          <Condition Action="enable">ENABLEC2="1"</Condition>
        </Control>
      </Dialog>

      <UIRef Id="WixUI_HK" />

    </UI>

    <Property Id="AGENT_CLASS"  Value="Your Agent Class" />
    <Property Id="AGENT_IDENTIFIER"  />
    <Property Id="AGENT_HEARTBEAT"  Value="30 sec" />
    <Property Id="SERVER_PATH_BASE"  Value="http://localhost:8181/api" />
    <Property Id="SERVER_HEARTBEAT"  Value="/c2-protocol/heartbeat" />
    <Property Id="SERVER_ACK"  Value="/c2-protocol/acknowledge" />
    <Property Id="ENABLEC2" />
    <Property Id="AUTOSTART" Value="1" />
    <Property Id="SERVICEACCOUNT" Value="LocalSystem" />
    <Property Id="SERVICEACCOUNTPASSWORD" />

    <SetProperty Id="AGENT_IDENTIFIER" After="AppSearch" Value="[ComputerName]" Sequence="first" />
    <SetProperty Id="ENABLEC2" After="AppSearch" Value="0" Sequence="first" >
      <![CDATA[ENABLEC2 = 0]]>
    </SetProperty>

    <CustomAction Id="MakeSymbolicLink" Directory="RootInstallDir" ExeCommand="cmd /c mklink extensions\minifi_native.pyd minifi-python-script-extension.dll" Execute="deferred" Impersonate="no" />
    <CustomAction Id="RemoveSymbolicLink" Directory="RootInstallDir"  ExeCommand="cmd /c DEL extensions\minifi_native.pyd" Execute="deferred" Impersonate="no"/>

    <InstallExecuteSequence>
      <Custom Action="MakeSymbolicLink" After="InstallFiles">NOT Installed</Custom>
    </InstallExecuteSequence>

    <InstallExecuteSequence>
      <Custom Action="RemoveSymbolicLink" After="InstallInitialize">Installed AND NOT REINSTALL</Custom>
    </InstallExecuteSequence>
  </Product>

  <Fragment>
    <DirectoryRef Id="INSTALL_ROOT">
        <Directory Id="RootInstallDir" Name="nifi-minifi-cpp">
            <Directory Id="CONFIGDIR" Name="conf">
              <Component Id="LOGPROP" Guid="87658309-0339-425c-8633-f54ffaaa4942">
                <File Id="LOG" Source="conf/minifi-log.properties" KeyPath="yes"/>
              </Component>

              <Component Id="UIDPROP" Guid="87658309-0339-425c-8633-f54ffaaa4943">
                <File Id="UID" Source="conf/minifi-uid.properties" KeyPath="yes"/>
              </Component>

              <Component Id="CONFIGFILE" Guid="87658309-0339-425c-8633-f54ffaaa4944">
                <File Id="CONFIG" Source="conf/config.yml" KeyPath="yes"/>
              </Component>

              <Component Id="UpdateConfig" Guid="87658309-0339-425c-8633-f54ffaaa4945">

                <File Source="conf/minifi.properties" Id="minifiprops" KeyPath="yes" />

                <IniFile Id="ConfigFileA" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.agent.class" Value="[AGENT_CLASS]" />
                <IniFile Id="ConfigFileI" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.agent.identifier" Value="[AGENT_IDENTIFIER]" />
                <IniFile Id="ConfigFileE" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.enable" Value="true" />
                <IniFile Id="ConfigFileT" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.agent.heartbeat.period" Value="[AGENT_HEARTBEAT]" />
                <IniFile Id="ConfigFileS" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.rest.path.base" Value="[SERVER_PATH_BASE]" />
                <IniFile Id="ConfigFileH" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.rest.url" Value="[SERVER_HEARTBEAT]" />
                <IniFile Id="ConfigFileAck" Action="addLine" Name="minifi.properties" Directory="CONFIGDIR" Section="c2props" Key="nifi.c2.rest.url.ack" Value="[SERVER_ACK]" />
                <Condition><![CDATA[ENABLEC2="1"]]></Condition>
              </Component>
              <Component Id="UpdateConfigNotExist" Guid="87658309-0339-425c-8633-f54ffaaa4946">

                <File Source="conf/minifi.properties" Id="minifiprops2" KeyPath="yes" />
                <Condition><![CDATA[ENABLEC2<>"1"]]></Condition>
              </Component>
            </Directory>

            <Directory Id="FIPSDIR" Name="fips">
              <Component Id="OPENSSLCONFCOMP" Guid="77845aec-87fb-46e3-b0c8-b86b57256aec">
                <File Id="OPENSSLCONF" Source="fips\openssl.cnf" KeyPath="yes"/>
              </Component>
            </Directory>

            <Directory Id="INSTALLBINDIR" Name="bin">
              <Component Id="minifiService" Guid="87658309-0339-425c-8633-f54ffaaa4921">
                <File Id="MiNiFiExe" Name="minifi.exe" KeyPath="yes" Source="minifi_main\minifi.exe"/>
                <!--
                It is not possible to set 'ServiceConfig' for 2 'Component' (error LGHT0130 : The primary key 'Apache NiFi MiNiFi' is duplicated in table 'ServiceConfig').
                Problem is described: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Installing-a-Service-with-Varying-Dependencies-td693097.html
                For now 'ServiceConfig' is set only for 'LocalSystem'.
                -->
                <ServiceInstall Id="MiNiFiExeService"
                                Type="ownProcess"
                                Vital="yes"
                                Name="Apache NiFi MiNiFi"
                                DisplayName="Apache NiFi MiNiFi"
                                Description="Apache NiFi MiNiFi Service"
                                ErrorControl="ignore"
                                Start="auto"
                                Interactive="no">
                    <Util:ServiceConfig
                        FirstFailureActionType="restart"
                        SecondFailureActionType="restart"
                        ThirdFailureActionType="restart"
                        RestartServiceDelayInSeconds="60"/>
                </ServiceInstall>
                <RegistryValue Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\Apache NiFi MiNiFi" Type="integer" Name="DelayedAutostart" Value="1"/>
                <ServiceControl Id="ServiceControl_Stop"
                                Name="Apache NiFi MiNiFi"
                                Stop="both"
                                Remove="uninstall"
                                Wait="yes" />
                <Util:EventSource Log="Application"
                                  Name="ApacheNiFiMiNiFi"
                                  EventMessageFile="[#MiNiFiExe]" />
                <Condition><![CDATA[SERVICEACCOUNT="LocalSystem"]]></Condition>
              </Component>

              <Component Id="minifiServiceNotLocal" Guid="87658309-0339-425c-8633-f54ffaaa4922">
                <File Id="MiNiFiExeWithPassword" Name="minifi.exe" KeyPath="yes" Source="minifi_main\minifi.exe"/>
                <ServiceInstall Id="MiNiFiExeServiceWithPassword"
                                Type="ownProcess"
                                Vital="yes"
                                Name="Apache NiFi MiNiFi"
                                DisplayName="Apache NiFi MiNiFi"
                                Description="Apache NiFi MiNiFi Service"
                                ErrorControl="ignore"
                                Account="[SERVICEACCOUNT]"
                                Password="[SERVICEACCOUNTPASSWORD]"
                                Start="auto"
                                Interactive="no" />
                <RegistryValue Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\Apache NiFi MiNiFi" Type="integer" Name="DelayedAutostart" Value="1"/>
                <ServiceControl Id="ServiceControl_Stop_WithPassword"
                                Name="Apache NiFi MiNiFi"
                                Stop="both"
                                Remove="uninstall"
                                Wait="yes" />
                <Util:EventSource Log="Application"
                                  Name="ApacheNiFiMiNiFi"
                                  EventMessageFile="[#MiNiFiExeWithPassword]" />
                <Condition><![CDATA[SERVICEACCOUNT<>"LocalSystem"]]></Condition>
              </Component>

              <Component Id="minifiService_autostart" Guid="17e2be83-e375-4b54-95da-f26fbf20b2ca">
                <File Id="MiNiFiExe_autostart" Name="minifi.exe" KeyPath="yes" Source="minifi_main\minifi.exe"/>
                <ServiceControl Id="ServiceControl_Start"
                      Name="Apache NiFi MiNiFi"
                      Start="install"
                      Wait="no" />
                <Condition><![CDATA[AUTOSTART="1"]]></Condition>
              </Component>

${WIX_EXTRA_COMPONENTS}

            </Directory>

<?ifdef INCLUDE_PYTHON_PROCESSORS?>
            <Directory Id="INSTALLPYTHONDIR" Name="minifi-python">
              <Directory Id="INSTALLNIFIAPIDIR" Name="nifiapi">
                <Component Id="PythonProcessorNifiApiFiles" Guid="a9cb7b7b-e66d-4e32-9115-eab4aa980124">
                  <File Id="NifiApi_processorbase" Name="processorbase.py" KeyPath="no" Source="pythonprocessors\nifiapi\processorbase.py"/>
                  <File Id="NifiApi_flowfiletransform" Name="flowfiletransform.py" KeyPath="no" Source="pythonprocessors\nifiapi\flowfiletransform.py"/>
                  <File Id="NifiApi_flowfilesource" Name="flowfilesource.py" KeyPath="no" Source="pythonprocessors\nifiapi\flowfilesource.py"/>
                  <File Id="NifiApi_properties" Name="properties.py" KeyPath="no" Source="pythonprocessors\nifiapi\properties.py"/>
                  <File Id="NifiApi_relationship" Name="relationship.py" KeyPath="no" Source="pythonprocessors\nifiapi\relationship.py"/>
                  <File Id="NifiApi_documentation" Name="documentation.py" KeyPath="no" Source="pythonprocessors\nifiapi\documentation.py"/>
                  <File Id="NifiApi_init" Name="__init__.py" KeyPath="no" Source="pythonprocessors\nifiapi\__init__.py"/>
                </Component>
              </Directory>
              <Directory Id="INSTALLNIFIPYTHONPROCESSORSDIR" Name="nifi_python_processors">
                <Component Id="NifiPythonProcessorFiles" Guid="66ce16d4-aea4-4fcb-bbbb-8a28813e2138">
                  <File Id="NifiPythonProcessors_init" Name="__init__.py" KeyPath="yes" Source="pythonprocessors\nifi_python_processors\__init__.py"/>
                </Component>
                <Directory Id="INSTALLNIFIPYTHONPROCESSORSUTILSDIR" Name="utils">
                  <Component Id="NifiPythonProcessorUtilsFiles" Guid="6bb11f67-007f-4467-970a-c42c2bae0891">
                    <File Id="NifiPythonProcessorUtils_dependency_installer" Name="dependency_installer.py" KeyPath="yes" Source="pythonprocessors\nifi_python_processors\utils\dependency_installer.py"/>
                  </Component>
                </Directory>
              </Directory>
            </Directory>

            <Directory Id="INSTALLPYTHONEXAMPLESDIR" Name="minifi-python-examples">
              <Component Id="PythonProcessorExampleFiles" Guid="2508ace9-6f5d-4cb1-af66-58d5f44ae2b1">
                <File Id="Examples_AddPythonAttribute" Name="AddPythonAttribute.py" KeyPath="no" Source="pythonprocessor-examples\AddPythonAttribute.py"/>
                <File Id="Examples_CountingProcessor" Name="CountingProcessor.py" KeyPath="no" Source="pythonprocessor-examples\CountingProcessor.py"/>
                <File Id="Examples_GaussianDistributionWithNumpy" Name="GaussianDistributionWithNumpy.py" KeyPath="no" Source="pythonprocessor-examples\GaussianDistributionWithNumpy.py"/>
                <File Id="Examples_MoveContentToJson" Name="MoveContentToJson.py" KeyPath="no" Source="pythonprocessor-examples\MoveContentToJson.py"/>
                <File Id="Examples_RemoveFlowFile" Name="RemoveFlowFile.py" KeyPath="no" Source="pythonprocessor-examples\RemoveFlowFile.py"/>
                <File Id="Examples_SentimentAnalysis" Name="SentimentAnalysis.py" KeyPath="no" Source="pythonprocessor-examples\SentimentAnalysis.py"/>
              </Component>
              <Directory Id="INSTALLGOOGLEDIR" Name="google">
                <Component Id="PythonProcessorGoogleFiles" Guid="90b898a9-76fb-4888-a4aa-adcd22097863">
                  <File Id="Google_SentimentAnalyzer" Name="SentimentAnalyzer.py" KeyPath="yes" Source="pythonprocessor-examples\google\SentimentAnalyzer.py"/>
                </Component>
              </Directory>
              <Directory Id="INSTALLH2ODIR" Name="h2o">
                <Component Id="PythonProcessorH2oFiles" Guid="b290aeb3-c67a-4cd1-a0a4-1ba049a2e44e">
                  <File Id="H2o_ConvertDsToCsv" Name="ConvertDsToCsv.py" KeyPath="yes" Source="pythonprocessor-examples\h2o\ConvertDsToCsv.py"/>
                </Component>
                <Directory Id="INSTALLH2O3DIR" Name="h2o3">
                  <Directory Id="INSTALLMOJODIR" Name="mojo">
                    <Component Id="PythonProcessorMojoFiles" Guid="d2b803da-1cd1-4925-802b-19f3e09fc0f7">
                      <File Id="H2o_ExecuteH2oMojoScoring" Name="ExecuteH2oMojoScoring.py" KeyPath="yes" Source="pythonprocessor-examples\h2o\h2o3\mojo\ExecuteH2oMojoScoring.py"/>
                    </Component>
                  </Directory>
                </Directory>
              </Directory>
            </Directory>
<?endif?>

          </Directory>

    </DirectoryRef>
  </Fragment>


  <Fragment>
    <ComponentGroup Id="CG_ADD_TO_PATH" Directory="INSTALL_ROOT">
      <Component Id="CM_ADD_TO_PATH" Guid="208034b8-7cc5-4718-9b99-ac50201c3f90"
             KeyPath="yes">
        <Environment Id="ENV_PATH" Name="MINIFI_HOME" Value="[INSTALL_ROOT]minifi-agent\"
            Permanent="no" Part="last" Action="set" System="no" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>
