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

  Copyright (C) 2015 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">

  <!-- Dropbox namespace for use within JCR -->
  <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="dropbox" value="http://www.exoplatform.com/jcr/dropbox/1.0/" />
        </properties-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <!-- Dropbox connector plugin -->
  <external-component-plugins>
    <target-component>org.exoplatform.clouddrive.CloudDriveService</target-component>
    <component-plugin>
      <name>add.clouddriveprovider</name>
      <set-method>addPlugin</set-method>
      <type>org.exoplatform.clouddrive.dropbox.DropboxConnector</type>
      <init-params>
        <properties-param>
          <name>drive-configuration</name>
          <!-- 
           Set JVM variables clouddrive.dropbox.client.id and clouddrive.dropbox.client.secret 
           in Platform's configuration.properties 
          -->
          <property name="provider-id" value="dropbox" />
          <property name="provider-name" value="Dropbox" />
          <property name="provider-client-id" value="${clouddrive.dropbox.client.id}" />
          <property name="provider-client-secret" value="${clouddrive.dropbox.client.secret}" />
          <property name="connector-host" value="${clouddrive.service.host}" />
          <property name="connector-schema" value="${clouddrive.service.schema:http}" />
          <property name="disable" value="${clouddrive.dropbox.disable:false}" />
        </properties-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <!--
  Dedicated ECMS menu action for Dropbox provider.
  -->
  <external-component-plugins>
    <target-component>org.exoplatform.webui.ext.UIExtensionManager</target-component>
    <component-plugin>
      <name>Add CloudDrive CMIS Actions</name>
      <set-method>registerUIExtensionPlugin</set-method>
      <type>org.exoplatform.webui.ext.UIExtensionPlugin</type>
      <init-params>
        <object-param>
          <name>ConnectDropbox</name>
          <object type="org.exoplatform.webui.ext.UIExtension">
            <field name="type">
              <string>org.exoplatform.ecm.dms.UIActionBar</string>
            </field>
            <field name="name">
              <string>ConnectDropbox</string>
            </field>
            <field name="component">
              <string>org.exoplatform.clouddrive.dropbox.ecms.ConnectDropboxActionComponent</string>
            </field>
            <field name="extendedFilters">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.clouddrive.ecms.filters.PersonalDocumentsFilter"></object>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>ShowDropboxText</name>
          <object type="org.exoplatform.webui.ext.UIExtension">
            <field name="type">
              <string>org.exoplatform.ecm.dms.FileViewer</string>
            </field>
            <field name="name">
              <string>ShowDropboxText</string>
            </field>
            <field name="component">
              <string>org.exoplatform.clouddrive.ecms.viewer.TextViewer</string>
            </field>
            <field name="category">
              <string>FileViewer</string>
            </field>
            <field name="rank">
              <int>40</int>
            </field>
            <field name="extendedFilters">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.clouddrive.ecms.filters.CloudFileFilter">
                    <field name="providers">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>dropbox</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
                <value>
                  <object type="org.exoplatform.clouddrive.ecms.filters.FileTypeFilter">
                    <field name="mimeTypes">
                      <collection type="java.util.LinkedHashSet"> 
                        <!-- text/rtf, text/csv and others like that should be filtered by UI comp with lower rank! -->
                        <value>
                          <string>text/</string>
                        </value>
                        <value>
                          <string>application/x-</string>
                        </value>
                        <!-- value><string>text/html</string></value>
                        <value><string>text/plain</string></value>
                        <value><string>text/xml</string></value>
                        <value><string>text/css</string></value>
                        <value><string>text/javascript</string></value>
                        <value><string>text/ecmascript</string></value -->
                        <value>
                          <string>application/xml</string>
                        </value>
                        <value>
                          <string>application/xhtml</string>
                        </value>
                        <value>
                          <string>application/xhtml+xml</string>
                        </value>
                        <value>
                          <string>application/xml+dtd</string>
                        </value>
                        <value>
                          <string>application/rss+xml</string>
                        </value>
                        <value>
                          <string>application/atom+xml</string>
                        </value>
                        <value>
                          <string>application/xop+xml</string>
                        </value>
                        <value>
                          <string>application/rdf+xml</string>
                        </value>
                        <value>
                          <string>application/soap+xml</string>
                        </value>
                        <value>
                          <string>application/javascript</string>
                        </value>
                        <value>
                          <string>application/json</string>
                        </value>
                        <value>
                          <string>application/ecmascript</string>
                        </value>
                        <value>
                          <string>application/php</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>ShowDropboxImage</name>
          <object type="org.exoplatform.webui.ext.UIExtension">
            <field name="type">
              <string>org.exoplatform.ecm.dms.FileViewer</string>
            </field>
            <field name="name">
              <string>ShowDropboxImage</string>
            </field>
            <field name="component">
              <string>org.exoplatform.clouddrive.ecms.viewer.ImageViewer</string>
            </field>
            <field name="category">
              <string>FileViewer</string>
            </field>
            <field name="rank">
              <int>40</int>
            </field>
            <field name="extendedFilters">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.clouddrive.ecms.filters.CloudFileFilter">
                    <field name="providers">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>dropbox</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
                <value>
                  <object type="org.exoplatform.webui.ext.filter.impl.FileFilter">
                    <field name="mimeTypes">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>image/jpeg</string>
                        </value>
                        <value>
                          <string>image/png</string>
                        </value>
                        <value>
                          <string>image/gif</string>
                        </value>
                        <value>
                          <string>image/bmp</string>
                        </value>
                        <value>
                          <string>image/x-windows-bmp</string>
                        </value>
                        <value>
                          <string>image/x-icon</string>
                        </value>
                        <!-- value><string>image/tiff</string></value>
                        <value><string>image/x-tiff</string></value -->
                        <value>
                          <string>image/webp</string>
                        </value>
                        <value>
                          <string>image/pjpeg</string>
                        </value>
                        <value>
                          <string>image/svg+xml</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>ShowDropboxPDF</name>
          <object type="org.exoplatform.webui.ext.UIExtension">
            <field name="type">
              <string>org.exoplatform.ecm.dms.FileViewer</string>
            </field>
            <field name="name">
              <string>ShowDropboxPDF</string>
            </field>
            <field name="component">
              <string>org.exoplatform.clouddrive.ecms.viewer.PDFViewer</string>
            </field>
            <field name="category">
              <string>FileViewer</string>
            </field>
            <field name="rank">
              <int>40</int>
            </field>
            <field name="extendedFilters">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.clouddrive.ecms.filters.CloudFileFilter">
                    <field name="providers">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>dropbox</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
                <value>
                  <object type="org.exoplatform.webui.ext.filter.impl.FileFilter">
                    <field name="mimeTypes">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>application/pdf</string>
                        </value>
                        <value>
                          <string>application/msword</string>
                        </value>
                        <value>
                          <string>application/xls</string>
                        </value>
                        <value>
                          <string>application/xlt</string>
                        </value>
                        <value>
                          <string>application/vnd.ms-excel</string>
                        </value>
                        <value>
                          <string>application/ppt</string>
                        </value>
                        <value>
                          <string>application/vnd.ms-powerpoint</string>
                        </value>
                        <value>
                          <string>application/rtf</string>
                        </value>
                        <value>
                          <string>application/vnd.oasis.opendocument.graphics</string>
                        </value>
                        <value>
                          <string>application/vnd.oasis.opendocument.presentation</string>
                        </value>
                        <value>
                          <string>application/vnd.oasis.opendocument.spreadsheet</string>
                        </value>
                        <value>
                          <string>application/vnd.oasis.opendocument.spreadsheet-template</string>
                        </value>
                        <value>
                          <string>application/vnd.oasis.opendocument.text</string>
                        </value>
                        <value>
                          <string>application/vnd.openxmlformats-officedocument.presentationml.presentation</string>
                        </value>
                        <value>
                          <string>application/vnd.openxmlformats-officedocument.spreadsheetml.sheet</string>
                        </value>
                        <value>
                          <string>application/vnd.openxmlformats-officedocument.wordprocessingml.document</string>
                        </value>
                        <value>
                          <string>application/vnd.openxmlformats-officedocument.spreadsheetml.template</string>
                        </value>
                        <value>
                          <string>application/vnd.openxmlformats-officedocument.presentationml.template</string>
                        </value>
                        <value>
                          <string>application/vnd.openxmlformats-officedocument.wordprocessingml.template</string>
                        </value>
                        <value>
                          <string>application/vnd.sun.xml.impress</string>
                        </value>
                        <value>
                          <string>application/vnd.sun.xml.writer</string>
                        </value>
                        <value>
                          <string>application/wordperfect</string>
                        </value>
                        <value>
                          <string>application/x-pdf</string>
                        </value>
                        <value>
                          <string>text/pdf</string>
                        </value>
                        <value>
                          <string>text/csv</string>
                        </value>
                        <value>
                          <string>text/rtf</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>ShowDropboxFlash</name>
          <object type="org.exoplatform.webui.ext.UIExtension">
            <field name="type">
              <string>org.exoplatform.ecm.dms.FileViewer</string>
            </field>
            <field name="name">
              <string>ShowDropboxFlash</string>
            </field>
            <field name="component">
              <string>org.exoplatform.clouddrive.ecms.viewer.FlashViewer</string>
            </field>
            <field name="category">
              <string>FileViewer</string>
            </field>
            <field name="rank">
              <int>40</int>
            </field>
            <field name="extendedFilters">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.clouddrive.ecms.filters.CloudFileFilter">
                    <field name="providers">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>dropbox</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
                <value>
                  <object type="org.exoplatform.webui.ext.filter.impl.FileFilter">
                    <field name="mimeTypes">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>application/x-shockwave-flash</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>ShowDropboxH264Video</name>
          <object type="org.exoplatform.webui.ext.UIExtension">
            <field name="type">
              <string>org.exoplatform.ecm.dms.FileViewer</string>
            </field>
            <field name="name">
              <string>ShowDropboxH264Video</string>
            </field>
            <field name="component">
              <string>org.exoplatform.clouddrive.ecms.viewer.H264VideoViewer</string>
            </field>
            <field name="category">
              <string>FileViewer</string>
            </field>
            <field name="rank">
              <int>40</int>
            </field>
            <field name="extendedFilters">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.clouddrive.ecms.filters.CloudFileFilter">
                    <field name="providers">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>dropbox</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
                <value>
                  <object type="org.exoplatform.webui.ext.filter.impl.FileFilter">
                    <field name="mimeTypes">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>video/mp4</string>
                        </value>
                        <value>
                          <string>video/ogg</string>
                        </value>
                        <value>
                          <string>video/ogv</string>
                        </value>
                        <value>
                          <string>video/webm</string>
                        </value>
                        <value>
                          <string>video/quicktime</string>
                        </value>
                        <value>
                          <string>video/avi</string>
                        </value>
                        <value>
                          <string>video/msvideo</string>
                        </value>
                        <value>
                          <string>video/x-msvideo</string>
                        </value>
                        <value>
                          <string>audio/wav</string>
                        </value>
                        <value>
                          <string>audio/x-wav</string>
                        </value>
                        <value>
                          <string>audio/x-ms-wma</string>
                        </value>
                        <value>
                          <string>audio/flac</string>
                        </value>
                        <value>
                          <string>audio/x-flac</string>
                        </value>
                        <value>
                          <string>video/3gpp</string>
                        </value>
                        <value>
                          <string>video/3gpp2</string>
                        </value>
                        <value>
                          <string>audio/3gpp</string>
                        </value>
                        <value>
                          <string>audio/3gpp2</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>ShowDropboxMpegVideo</name>
          <object type="org.exoplatform.webui.ext.UIExtension">
            <field name="type">
              <string>org.exoplatform.ecm.dms.FileViewer</string>
            </field>
            <field name="name">
              <string>ShowDropboxMpegVideo</string>
            </field>
            <field name="component">
              <string>org.exoplatform.clouddrive.ecms.viewer.MpegVideoViewer</string>
            </field>
            <field name="category">
              <string>FileViewer</string>
            </field>
            <field name="rank">
              <int>40</int>
            </field>
            <field name="extendedFilters">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.clouddrive.ecms.filters.CloudFileFilter">
                    <field name="providers">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>dropbox</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
                <value>
                  <object type="org.exoplatform.webui.ext.filter.impl.FileFilter">
                    <field name="mimeTypes">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>video/mpg</string>
                        </value>
                        <value>
                          <string>video/mpeg</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
        <object-param>
          <name>ShowDropboxVideoAudio</name>
          <object type="org.exoplatform.webui.ext.UIExtension">
            <field name="type">
              <string>org.exoplatform.ecm.dms.FileViewer</string>
            </field>
            <field name="name">
              <string>ShowDropboxVideoAudio</string>
            </field>
            <field name="component">
              <string>org.exoplatform.clouddrive.ecms.viewer.VideoAudioViewer</string>
            </field>
            <field name="category">
              <string>FileViewer</string>
            </field>
            <field name="rank">
              <int>40</int>
            </field>
            <field name="extendedFilters">
              <collection type="java.util.ArrayList">
                <value>
                  <object type="org.exoplatform.clouddrive.ecms.filters.CloudFileFilter">
                    <field name="providers">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>dropbox</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
                <value>
                  <object type="org.exoplatform.webui.ext.filter.impl.FileFilter">
                    <field name="mimeTypes">
                      <collection type="java.util.ArrayList">
                        <value>
                          <string>video/x-flv</string>
                        </value>
                        <value>
                          <string>video/x-f4v</string>
                        </value>
                        <value>
                          <string>audio/mp3</string>
                        </value>
                        <value>
                          <string>audio/mpeg</string>
                        </value>
                        <value>
                          <string>audio/mpeg3</string>
                        </value>
                        <value>
                          <string>audio/x-mpeg</string>
                        </value>
                      </collection>
                    </field>
                  </object>
                </value>
              </collection>
            </field>
          </object>
        </object-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>

  <!--
  ResourceBundleService with texts for Dropbox UI support.
  -->
  <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.clouddrive.CloudDrive-dropbox</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.clouddrive.CloudDrive-dropbox</value>
        </values-param>
      </init-params>
    </component-plugin>
  </external-component-plugins>
</configuration>