<?xml version="1.0" encoding="ISO-8859-1"?>
<!--

  Copyright (C) 2016 eXo Platform SAS.
  
  This is free software; you can redistribute it and/or modify it
  under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation; either version 2.1 of
  the License, or (at your option) any later version.
  
  This software 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
  Lesser General Public License for more details.
  
  You should have received a copy of the GNU Lesser General Public
  License along with this software; if not, write to the Free
  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  02110-1301 USA, or see the FSF site: http://www.fsf.org.

-->

<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>
    <key>org.exoplatform.outlook.OutlookService</key>
    <type>org.exoplatform.outlook.OutlookServiceImpl</type>
  </component>

  <component>
    <key>org.exoplatform.outlook.jcr.NodeFinder</key>
    <type>org.exoplatform.outlook.jcr.CMSNodeFinder</type>
  </component>

  <component>
    <key>org.exoplatform.outlook.jcr.ContentLink</key>
    <type>org.exoplatform.outlook.jcr.ContentLink</type>
    <!-- Use below configuration to introduce explicit settings for content link URLs -->
    <!-- init-params>
      <properties-param>
        <name>link-configuration</name>
        <property name="server-host" value="${outlook.exo.server.host:}" />
        <property name="server-schema" value="${outlook.exo.server.schema:http}" />
      </properties-param>
    </init-params -->
  </component>

  <component>
    <type>org.exoplatform.outlook.rest.ContentService</type>
  </component>

  <component>
    <key>org.exoplatform.outlook.security.OutlookTokenService</key>
    <type>org.exoplatform.outlook.security.OutlookTokenService</type>
    <init-params>
      <values-param>
        <name>service.configuration</name>
        <value>jcr-token</value>
        <value>90</value>
        <value>DAY</value>
        <value>outlooklogin</value>
      </values-param>
    </init-params>
  </component>

  <external-component-plugins>
    <target-component>org.exoplatform.services.cache.CacheService</target-component>
    <component-plugin>
      <name>addExoCacheConfig</name>
      <set-method>addExoCacheConfig</set-method>
      <type>org.exoplatform.services.cache.ExoCacheConfigPlugin</type>
      <description></description>
      <init-params>
        <object-param>
          <name>OutlookContentLinkCache</name>
          <description></description>
          <object type="org.exoplatform.services.cache.ExoCacheConfig">
            <field name="name">
              <string>OutlookContentLinkCache</string>
            </field>
            <field name="maxSize">
              <int>${cache.exo.outlook.ContentLinkCache.Capacity:50000}</int>
            </field>
            <field name="liveTime">
              <long>${cache.exo.outlook.ContentLinkCache.TimeToLive:60}</long>
            </field>
            <field name="implementation">
              <string>org.exoplatform.services.cache.concurrent.ConcurrentFIFOExoCache</string>
            </field>
          </object>
        </object-param>
        <object-param profiles="cluster">
          <name>OutlookContentLinkCache</name>
          <description>The JBoss Cache configuration for the IdentityCache</description>
          <object type="org.exoplatform.services.cache.impl.infinispan.generic.GenericExoCacheConfig">
            <field name="name">
              <string>OutlookContentLinkCache</string>
            </field>
            <field name="strategy">
              <string>LIRS</string>
            </field>
            <field name="maxEntries">
              <int>${cache.exo.outlook.ContentLinkCache.Capacity:50000}</int>
            </field>
            <field name="lifespan">
              <long>${cache.exo.outlook.ContentLinkCache.TimeToLive:60}</long>
            </field>
            <field name="replicated">
              <boolean>true</boolean>
            </field>
          </object>
        </object-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <external-component-plugins>
    <target-component>org.exoplatform.commons.chromattic.ChromatticManager</target-component>
    <component-plugin>
      <name>chromattic</name>
      <set-method>addLifeCycle</set-method>
      <type>org.exoplatform.commons.chromattic.ChromatticLifeCycle</type>
      <init-params>
        <value-param>
          <name>domain-name</name>
          <value>outlooklogin</value>
        </value-param>
        <value-param>
          <name>workspace-name</name>
          <value>portal-work</value>
        </value-param>
        <values-param>
          <name>entities</name>
          <value>org.exoplatform.web.security.security.TokenContainer</value>
          <value>org.exoplatform.web.security.security.TokenEntry</value>
          <value>org.exoplatform.web.security.security.HashedToken</value>
        </values-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <external-component-plugins>
    <target-component>org.exoplatform.web.filter.ExtensibleFilter</target-component>
    <component-plugin>
      <name>Outlook login page filter Plugin</name>
      <set-method>addFilterDefinitions</set-method>
      <type>org.exoplatform.web.filter.FilterDefinitionPlugin</type>
      <init-params>
        <object-param>
          <name>Outlook Resource Filter</name>
          <object type="org.exoplatform.web.filter.FilterDefinition">
            <field name="filter">
              <object type="org.exoplatform.outlook.server.filter.OutlookResourceFilter" />
            </field>
            <field name="patterns">
              <collection type="java.util.ArrayList" item-type="java.lang.String">
                <value>
                  <string>/scripts/.*/outlookViewGRP.*</string>
                </value>
                <value>
                  <string>/scripts/.*/outlookGRP.*</string>
                </value>
                <value>
                  <string>/skins/.*/outlook-view.*</string>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>Outlook Login Filter</name>
          <object type="org.exoplatform.web.filter.FilterDefinition">
            <field name="filter">
              <object type="org.exoplatform.outlook.server.filter.OutlookLoginFilter" />
            </field>
            <field name="patterns">
              <collection type="java.util.ArrayList" item-type="java.lang.String">
                <value>
                  <!-- string>^(/login\?initialURI=%2Fportal%2Fintranet%2Foutlook(.*)){1}$</string -->
                  <string>/login</string>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>Outlook Remember-Me Filter</name>
          <object type="org.exoplatform.web.filter.FilterDefinition">
            <field name="filter">
              <object type="org.exoplatform.outlook.server.filter.OutlookRememberMeFilter" />
            </field>
            <field name="patterns">
              <collection type="java.util.ArrayList" item-type="java.lang.String">
                <value>
                  <string>/intranet/outlook.*</string>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>Outlook Context Filter</name>
          <object type="org.exoplatform.web.filter.FilterDefinition">
            <field name="filter">
              <object type="org.exoplatform.outlook.webui.OutlookContextFilter" />
            </field>
            <field name="patterns">
              <collection type="java.util.ArrayList" item-type="java.lang.String">
                <value>
                  <string>/intranet/outlook.*</string>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <external-component-plugins>
    <target-component>org.exoplatform.webui.ext.UIExtensionManager</target-component>
    <component-plugin>
      <name>add.action</name>
      <set-method>registerUIExtensionPlugin</set-method>
      <type>org.exoplatform.webui.ext.UIExtensionPlugin</type>
      <init-params>
        <object-param>
          <name>Outlook Message Activity</name>
          <object type="org.exoplatform.social.webui.activity.UIActivityExtension">
            <field name="type">
              <string>org.exoplatform.social.webui.activity.BaseUIActivity</string>
            </field>
            <field name="name">
              <string>outlook:message</string>
            </field>
            <field name="component">
              <string>org.exoplatform.outlook.social.OutlookMessageActivity</string>
            </field>
            <field name="activityBuiderClass">
              <string>org.exoplatform.wcm.ext.component.activity.FileUIActivityBuilder</string>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>Outlook Attachment Activity</name>
          <object type="org.exoplatform.social.webui.activity.UIActivityExtension">
            <field name="type">
              <string>org.exoplatform.social.webui.activity.BaseUIActivity</string>
            </field>
            <field name="name">
              <string>outlook:attachment</string>
            </field>
            <field name="component">
              <string>org.exoplatform.outlook.social.OutlookAttachmentActivity</string>
            </field>
            <field name="activityBuiderClass">
              <string>org.exoplatform.outlook.social.OutlookActivityBuilder</string>
            </field>
          </object>
        </object-param>

        <object-param>
          <name>ShowOutlookMessage</name>
          <object type="org.exoplatform.webui.ext.UIExtension">
            <field name="type">
              <string>org.exoplatform.ecm.dms.FileViewer</string>
            </field>
            <field name="name">
              <string>ShowOutlookMessage</string>
            </field>
            <field name="component">
              <string>org.exoplatform.outlook.social.OutlookMessageViewer</string>
            </field>
            <field name="category">
              <string>FileViewer</string>
            </field>
            <field name="rank">
              <int>10</int>
            </field>
          </object>
        </object-param>

      </init-params>
    </component-plugin>
  </external-component-plugins>

  <external-component-plugins>
    <target-component>org.exoplatform.services.jcr.RepositoryService</target-component>
    <component-plugin>
      <name>add.namespaces</name>
      <set-method>addPlugin</set-method>
      <type>org.exoplatform.services.jcr.impl.AddNamespacesPlugin</type>
      <init-params>
        <properties-param>
          <name>namespaces</name>
          <property name="mso" value="http://www.exoplatform.com/jcr/microsoftoffice/1.0/" />
        </properties-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <external-component-plugins>
    <target-component>org.exoplatform.services.jcr.RepositoryService</target-component>
    <component-plugin>
      <name>add.gadget.services.nodeType</name>
      <set-method>addPlugin</set-method>
      <type>org.exoplatform.services.jcr.impl.AddNodeTypePlugin</type>
      <init-params>
        <values-param>
          <name>autoCreatedInNewRepository</name>
          <description>Outlook node types configuration file</description>
          <value>jar:/conf/portal/jcr/outlook-nodetypes.xml</value>
        </values-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <external-component-plugins>
    <target-component>org.exoplatform.services.resources.ResourceBundleService</target-component>
    <component-plugin>
      <name>ResourceBundle Plugin</name>
      <set-method>addResourceBundle</set-method>
      <type>org.exoplatform.services.resources.impl.BaseResourceBundlePlugin</type>
      <init-params>
        <values-param>
          <name>init.resources</name>
          <description>Store the following resources into the db for the first launch</description>
          <value>locale.outlook.Outlook</value>
          <value>locale.outlook.Login</value>
        </values-param>
        <values-param>
          <name>portal.resource.names</name>
          <description>The properties files of the portal , those file will be merged into one ResoruceBundle
            properties</description>
          <value>locale.outlook.Outlook</value>
          <value>locale.outlook.Login</value>
          <!-- we need Forum's i18n for message conversion to Forum -->
          <!-- value>locale.portlet.forum.ForumPortlet</value -->
        </values-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <import>war:/conf/outlook/portal-configuration.xml</import>

</configuration>