<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
  ~ /*
  ~  * Copyright (C) 2003-2015 eXo Platform SAS.
  ~  *
  ~  * This program is free software; you can redistribute it and/or
  ~ * modify it under the terms of the GNU Affero General Public License
  ~ * as published by the Free Software Foundation; either version 3
  ~ * of the License, or (at your option) any later version.
  ~ *
  ~ * This program is distributed in the hope that it will be useful,
  ~ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  ~ * GNU General Public License for more details.
  ~ *
  ~ * You should have received a copy of the GNU General Public License
  ~ * along with this program; if not, see<http://www.gnu.org/licenses/>.
  ~  */
  -->

<configuration
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"
        xmlns="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd">

  <component>
    <type>org.exoplatform.commons.persistence.impl.EntityManagerService</type>
  </component>

  <component>
    <type>org.exoplatform.wiki.jpa.dao.WikiDAO</type>
  </component>
  <component>
    <type>org.exoplatform.wiki.jpa.dao.PageDAO</type>
  </component>
  <component>
    <type>org.exoplatform.wiki.jpa.dao.PageAttachmentDAO</type>
  </component>
  <component>
    <type>org.exoplatform.wiki.jpa.dao.DraftPageAttachmentDAO</type>
  </component>
  <component>
    <type>org.exoplatform.wiki.jpa.dao.DraftPageDAO</type>
  </component>
  <component>
    <type>org.exoplatform.wiki.jpa.dao.PageVersionDAO</type>
  </component>
  <component>
    <type>org.exoplatform.wiki.jpa.dao.PageMoveDAO</type>
  </component>
  <component>
    <type>org.exoplatform.wiki.jpa.dao.TemplateDAO</type>
  </component>
  <component>
    <type>org.exoplatform.wiki.jpa.dao.EmotionIconDAO</type>
  </component>

  <component>
    <type>org.exoplatform.wiki.jpa.search.WikiElasticSearchServiceConnector</type>
    <init-params>
      <properties-param>
        <name>constructor.params</name>
        <property name="index" value="wiki"/>
        <property name="type" value="wiki,wiki-page,wiki-attachment"/>
        <property name="searchFields" value="name,title,content,comment,file"/>
      </properties-param>
    </init-params>
  </component>

  <!-- Data Initialization -->
  <external-component-plugins>
    <target-component>org.exoplatform.commons.api.persistence.DataInitializer</target-component>
    <component-plugin>
      <name>WikiChangeLogsPlugin</name>
      <set-method>addChangeLogsPlugin</set-method>
      <type>org.exoplatform.commons.persistence.impl.ChangeLogsPlugin</type>
      <init-params>
        <values-param>
          <name>changelogs</name>
          <description>Change logs of wiki</description>
          <value>db/changelog/wiki.db.changelog-1.0.0.xml</value>
        </values-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <!-- SEARCH - Override default wiki search connector (use same type 'wiki') -->
  <external-component-plugins>
    <target-component>org.exoplatform.commons.api.search.SearchService</target-component>
    <component-plugin>
      <name>ElasticSearchConnector</name>
      <set-method>addConnector</set-method>
      <type>org.exoplatform.wiki.jpa.search.WikiElasticUnifiedSearchServiceConnector</type>
      <description>Wiki ElasticSearch Connector</description>
      <init-params>
        <properties-param>
          <name>constructor.params</name>
          <property name="searchType" value="wiki"/>
          <property name="displayName" value="Wiki"/>
          <property name="index" value="wiki"/>
          <property name="type" value="wiki,wiki-page,wiki-attachment"/>
          <property name="enable" value="${exo.unified-search.connector.wiki.enable:true}"/>
          <property name="titleField" value="title"/>
          <property name="searchFields" value="name,title,content,comment,file"/>
        </properties-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <!-- INDEXING -->
  <external-component-plugins>
    <target-component>org.exoplatform.addons.es.index.IndexingOperationProcessor</target-component>
    <component-plugin>
      <name>WikiPageIndexingConnector</name>
      <set-method>addConnector</set-method>
      <type>org.exoplatform.wiki.jpa.search.WikiPageIndexingServiceConnector</type>
      <description>Wiki Page ElasticSearch Indexing Connector</description>
      <init-params>
        <properties-param>
          <name>constructor.params</name>
          <property name="index" value="wiki"/>
          <property name="type" value="wiki-page"/>
        </properties-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>
  <external-component-plugins>
    <target-component>org.exoplatform.addons.es.index.IndexingOperationProcessor</target-component>
    <component-plugin>
      <name>AttachmentIndexingConnector</name>
      <set-method>addConnector</set-method>
      <type>org.exoplatform.wiki.jpa.search.AttachmentIndexingServiceConnector</type>
      <description>Attachment ElasticSearch Indexing Connector</description>
      <init-params>
        <properties-param>
          <name>constructor.params</name>
          <property name="index" value="wiki"/>
          <property name="type" value="wiki-attachment"/>
        </properties-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <external-component-plugins>
    <target-component>org.exoplatform.wiki.service.WikiService</target-component>
    <component-plugin>
      <name>PageIndexingListener</name>
      <set-method>addComponentPlugin</set-method>
      <type>org.exoplatform.wiki.jpa.search.PageIndexingListener</type>
    </component-plugin>
  </external-component-plugins>

  <external-component-plugins>
    <target-component>org.exoplatform.wiki.service.WikiService</target-component>
    <component-plugin>
      <name>AttachmentIndexingListener</name>
      <set-method>addComponentPlugin</set-method>
      <type>org.exoplatform.wiki.jpa.search.AttachmentIndexingListener</type>
    </component-plugin>
  </external-component-plugins>

  <!-- Organization Listener -->
  <external-component-plugins>
    <target-component>org.exoplatform.services.organization.OrganizationService</target-component>
    <component-plugin>
      <name>WikiUserEventListener</name>
      <set-method>addListenerPlugin</set-method>
      <type>org.exoplatform.wiki.jpa.organization.WikiUserEventListener</type>
    </component-plugin>
    <component-plugin>
      <name>WikiGroupEventListener</name>
      <set-method>addListenerPlugin</set-method>
      <type>org.exoplatform.wiki.jpa.organization.WikiGroupEventListener</type>
    </component-plugin>
  </external-component-plugins>

</configuration>
