Installation Stop the server Download jar from plugin and add it (ametys- plugin-content-io-3 .1.0.jar ) in the WEB-INF/lib directory of your application. Ametys Start server Personalization To customize your application and add buttons for importing and synchronizing content. We recommend that you create your own plugin (follow the instructions on the page Architecture of a plugin Ametys ). You can then create your buttons and declare your ribbon override in plugin.xml and add buttons to the ribbon in ribbon/cms-ribbon.xml .
When customization is complete, you need to restart the application.
Ribbon overload declaration Add the following feature to the plugin.xml file of your custom plugin in order to place the buttons you are going to create in the ribbon :
Declaration of ribbon overload
Oops! Copy to clipboard failed. Open the code and copy it manually.<feature name="myplugin.ribbon.imports">
<extensions>
<extension id="fr.ametys.myplugin.ribbon.Imports"
point="org.ametys.core.ui.RibbonImportManager"
class="org.ametys.core.ui.StaticRibbonImportManager">
<workspace match="cms|web">
<file>ribbon/cms-ribbon.xml</file>
</workspace>
</extension>
</extensions>
</feature> <feature name="myplugin.ribbon.imports">
<extensions>
<extension id="fr.ametys.myplugin.ribbon.Imports"
point="org.ametys.core.ui.RibbonImportManager"
class="org.ametys.core.ui.StaticRibbonImportManager">
<workspace match="cms|web">
<file>ribbon/cms-ribbon.xml</file>
</workspace>
</extension>
</extensions>
</feature> Voir le code
<feature name="myplugin.ribbon.imports">
<extensions>
<extension id="fr.ametys.myplugin.ribbon.Imports"
point="org.ametys.core.ui.RibbonImportManager"
class="org.ametys.core.ui.StaticRibbonImportManager">
<workspace match="cms|web">
<file>ribbon/cms-ribbon.xml</file>
</workspace>
</extension>
</extensions>
</feature> Creating an import button Create a button for importing content into plugin.xml in this form :
Creation of a content import button
Oops! Copy to clipboard failed. Open the code and copy it manually.<extension id="fr.ametys.myplugin.ImportSomething"
point="org.ametys.core.ui.RibbonControlsManager"
class="org.ametys.plugins.contentio.synchronize.clientsideelement.SCCClientSideElement">
<class name="Ametys.ribbon.element.ui.button.OpenToolButtonController">
<opentool-id>uitool-scc-import</opentool-id>
<sccModelId>org.ametys.plugins.contentio.synchronize.collection.ldap</sccModelId>
<label i18n="false">Import something</label>
<description i18n="false">Open a tool to import something manually</description>
<icon-glyph>ametysicon-blank32</icon-glyph>
<icon-decorator>decorator-ametysicon-upload119</icon-decorator>
</class>
<depends>
<org.ametys.core.ui.UIToolsFactoriesManager>uitool-scc-import</org.ametys.core.ui.UIToolsFactoriesManager>
</depends>
</extension> <extension id="fr.ametys.myplugin.ImportSomething"
point="org.ametys.core.ui.RibbonControlsManager"
class="org.ametys.plugins.contentio.synchronize.clientsideelement.SCCClientSideElement">
<class name="Ametys.ribbon.element.ui.button.OpenToolButtonController">
<opentool-id>uitool-scc-import</opentool-id>
<sccModelId>org.ametys.plugins.contentio.synchronize.collection.ldap</sccModelId>
<label i18n="false">Import something</label>
<description i18n="false">Open a tool to import something manually</description>
<icon-glyph>ametysicon-blank32</icon-glyph>
<icon-decorator>decorator-ametysicon-upload119</icon-decorator>
</class>
<depends>
<org.ametys.core.ui.UIToolsFactoriesManager>uitool-scc-import</org.ametys.core.ui.UIToolsFactoriesManager>
</depends>
</extension> Voir le code
<extension id="fr.ametys.myplugin.ImportSomething"
point="org.ametys.core.ui.RibbonControlsManager"
class="org.ametys.plugins.contentio.synchronize.clientsideelement.SCCClientSideElement">
<class name="Ametys.ribbon.element.ui.button.OpenToolButtonController">
<opentool-id>uitool-scc-import</opentool-id>
<sccModelId>org.ametys.plugins.contentio.synchronize.collection.ldap</sccModelId>
<label i18n="false">Import something</label>
<description i18n="false">Open a tool to import something manually</description>
<icon-glyph>ametysicon-blank32</icon-glyph>
<icon-decorator>decorator-ametysicon-upload119</icon-decorator>
</class>
<depends>
<org.ametys.core.ui.UIToolsFactoriesManager>uitool-scc-import</org.ametys.core.ui.UIToolsFactoriesManager>
</depends>
</extension> In this example, the button's ID is ametys.myplugin.ImportSomething , and it is used to import content that complies with the Data Source synchronizable content model LDAP (identified by org.ametys.plugins.contentio.synchronize.collection.ldap ).
As it stands, this button is displayed if at least one synchronizable content collection exists; if at least one exists, it uses the first one found in the list. In the future, a more comprehensive button will display all available collections in list form.
Add the button to the ribbon by writing the following code in ribbon/cms-ribbon.xml :
Import button added to ribbon
Oops! Copy to clipboard failed. Open the code and copy it manually.<tab label="plugin.cms:RIBBON_TABS_TAB_ADMINISTRATION_LABEL" override="true">
<groups>
<group label="plugin.cms:RIBBON_TABS_TAB_ADMINISTRATION_GROUPS_GROUP_TOOLS_LABEL" override="true" controlsOrder="0.10">
<control id="fr.ametys.myplugin.ImportSomething"/>
</group>
</groups>
</tab> <tab label="plugin.cms:RIBBON_TABS_TAB_ADMINISTRATION_LABEL" override="true">
<groups>
<group label="plugin.cms:RIBBON_TABS_TAB_ADMINISTRATION_GROUPS_GROUP_TOOLS_LABEL" override="true" controlsOrder="0.10">
<control id="fr.ametys.myplugin.ImportSomething"/>
</group>
</groups>
</tab>
<tab label="plugin.cms:RIBBON_TABS_TAB_ADMINISTRATION_LABEL" override="true">
<groups>
<group label="plugin.cms:RIBBON_TABS_TAB_ADMINISTRATION_GROUPS_GROUP_TOOLS_LABEL" override="true" controlsOrder="0.10">
<control id="fr.ametys.myplugin.ImportSomething"/>
</group>
</groups>
</tab> In this example, the button is added to the Administration tab in the Tools section, in the last position.
Creating a synchronization button Create a button to synchronize a single content in the file plugin.xml in this form :
Creating a content synchronization button
Oops! Copy to clipboard failed. Open the code and copy it manually.<extension id="fr.ametys.myplugin.SynchronizeSomething"
point="org.ametys.core.ui.RibbonControlsManager"
class="org.ametys.plugins.contentio.synchronize.clientsideelement.SCCSmartContentClientSideElement">
<class name="Ametys.plugins.cms.content.controller.SmartContentController">
<action>Ametys.plugins.contentio.search.SynchronizeContentAction.act</action>
<sccModelId>org.ametys.plugins.contentio.synchronize.collection.ldap</sccModelId>
<label i18n="false">Synchronize my something content</label>
<description i18n="false">Launch a synchronization of the content</description>
<field-label i18n="false">Please enter the synchronization code :</field-label>
<selection-target-id>^content$</selection-target-id>
<selection-target-parameter>
<name>^types$</name>
<value>^content-type.Something$</value>
</selection-target-parameter>
<selection-enable-multiselection>false</selection-enable-multiselection>
<icon-glyph>odficon-blank32</icon-glyph>
<icon-decorator>decorator-ametysicon-arrow123</icon-decorator>
<selection-description-empty i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_NOCONTENT</selection-description-empty>
<selection-description-nomatch i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_NOCONTENT</selection-description-nomatch>
<selection-description-multiselectionforbidden i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_MANYCONTENT</selection-description-multiselectionforbidden>
<allright-start-description i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_START</allright-start-description>
<allright-end-description i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_END</allright-end-description>
<allright-content-description i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_START</allright-content-description>
<error-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_ERROR</error-description>
<enabled-on-unlock-only>true</enabled-on-unlock-only>
<locked-start-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_START</locked-start-description>
<locked-end-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_END</locked-end-description>
<locked-content-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_CONTENT</locked-content-description>
</class>
<scripts>
<file plugin="cms">js/Ametys/plugins/cms/content/controller/SmartContentController.js</file>
<file plugin="contentio">js/Ametys/plugins/contentio/search/SynchronizeContentAction.js</file>
</scripts>
<depends>
<org.ametys.core.ui.UIToolsFactoriesManager>uitool-server-logs</org.ametys.core.ui.UIToolsFactoriesManager>
</depends>
</extension> <extension id="fr.ametys.myplugin.SynchronizeSomething"
point="org.ametys.core.ui.RibbonControlsManager"
class="org.ametys.plugins.contentio.synchronize.clientsideelement.SCCSmartContentClientSideElement">
<class name="Ametys.plugins.cms.content.controller.SmartContentController">
<action>Ametys.plugins.contentio.search.SynchronizeContentAction.act</action>
<sccModelId>org.ametys.plugins.contentio.synchronize.collection.ldap</sccModelId>
<label i18n="false">Synchronize my something content</label>
<description i18n="false">Launch a synchronization of the content</description>
<field-label i18n="false">Please enter the synchronization code :</field-label>
<selection-target-id>^content$</selection-target-id>
<selection-target-parameter>
<name>^types$</name>
<value>^content-type.Something$</value>
</selection-target-parameter>
<selection-enable-multiselection>false</selection-enable-multiselection>
<icon-glyph>odficon-blank32</icon-glyph>
<icon-decorator>decorator-ametysicon-arrow123</icon-decorator>
<selection-description-empty i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_NOCONTENT</selection-description-empty>
<selection-description-nomatch i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_NOCONTENT</selection-description-nomatch>
<selection-description-multiselectionforbidden i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_MANYCONTENT</selection-description-multiselectionforbidden>
<allright-start-description i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_START</allright-start-description>
<allright-end-description i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_END</allright-end-description>
<allright-content-description i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_START</allright-content-description>
<error-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_ERROR</error-description>
<enabled-on-unlock-only>true</enabled-on-unlock-only>
<locked-start-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_START</locked-start-description>
<locked-end-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_END</locked-end-description>
<locked-content-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_CONTENT</locked-content-description>
</class>
<scripts>
<file plugin="cms">js/Ametys/plugins/cms/content/controller/SmartContentController.js</file>
<file plugin="contentio">js/Ametys/plugins/contentio/search/SynchronizeContentAction.js</file>
</scripts>
<depends>
<org.ametys.core.ui.UIToolsFactoriesManager>uitool-server-logs</org.ametys.core.ui.UIToolsFactoriesManager>
</depends>
</extension> Voir le code
<extension id="fr.ametys.myplugin.SynchronizeSomething"
point="org.ametys.core.ui.RibbonControlsManager"
class="org.ametys.plugins.contentio.synchronize.clientsideelement.SCCSmartContentClientSideElement">
<class name="Ametys.plugins.cms.content.controller.SmartContentController">
<action>Ametys.plugins.contentio.search.SynchronizeContentAction.act</action>
<sccModelId>org.ametys.plugins.contentio.synchronize.collection.ldap</sccModelId>
<label i18n="false">Synchronize my something content</label>
<description i18n="false">Launch a synchronization of the content</description>
<field-label i18n="false">Please enter the synchronization code :</field-label>
<selection-target-id>^content$</selection-target-id>
<selection-target-parameter>
<name>^types$</name>
<value>^content-type.Something$</value>
</selection-target-parameter>
<selection-enable-multiselection>false</selection-enable-multiselection>
<icon-glyph>odficon-blank32</icon-glyph>
<icon-decorator>decorator-ametysicon-arrow123</icon-decorator>
<selection-description-empty i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_NOCONTENT</selection-description-empty>
<selection-description-nomatch i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_NOCONTENT</selection-description-nomatch>
<selection-description-multiselectionforbidden i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_MANYCONTENT</selection-description-multiselectionforbidden>
<allright-start-description i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_START</allright-start-description>
<allright-end-description i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_END</allright-end-description>
<allright-content-description i18n="false">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_START</allright-content-description>
<error-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_ERROR</error-description>
<enabled-on-unlock-only>true</enabled-on-unlock-only>
<locked-start-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_START</locked-start-description>
<locked-end-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_END</locked-end-description>
<locked-content-description i18n="true">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_CONTENT</locked-content-description>
</class>
<scripts>
<file plugin="cms">js/Ametys/plugins/cms/content/controller/SmartContentController.js</file>
<file plugin="contentio">js/Ametys/plugins/contentio/search/SynchronizeContentAction.js</file>
</scripts>
<depends>
<org.ametys.core.ui.UIToolsFactoriesManager>uitool-server-logs</org.ametys.core.ui.UIToolsFactoriesManager>
</depends>
</extension> In this example, the button identifier is en.ametys.myplugin.SynchronizeSomething , and is used to synchronize Something content that complies with the LDAP data source synchronizable content model (identified by org.ametys.plugins.contentio.synchronize.collection.ldap ).
As it stands, this button is displayed if at least one synchronizable content collection exists; if at least one exists, it uses the first one found in the list. In the future, a more comprehensive button will display all available collections in list form.
Add the button to the ribbon by writing the following code in ribbon/cms-ribbon.xml :
Import button added to ribbon
Oops! Copy to clipboard failed. Open the code and copy it manually.<tab label="plugin.cms:RIBBON_TABS_TAB_CONTENT_LABEL" override="true">
<groups>
<group label="plugin.cms:RIBBON_TABS_TAB_CONTENT_GROUPS_GROUP_ACTION_LABEL" override="true" controlsOrder="0.10">
<control id="fr.ametys.myplugin.SynchronizeSomething"/>
</group>
</groups>
</tab> <tab label="plugin.cms:RIBBON_TABS_TAB_CONTENT_LABEL" override="true">
<groups>
<group label="plugin.cms:RIBBON_TABS_TAB_CONTENT_GROUPS_GROUP_ACTION_LABEL" override="true" controlsOrder="0.10">
<control id="fr.ametys.myplugin.SynchronizeSomething"/>
</group>
</groups>
</tab>
<tab label="plugin.cms:RIBBON_TABS_TAB_CONTENT_LABEL" override="true">
<groups>
<group label="plugin.cms:RIBBON_TABS_TAB_CONTENT_GROUPS_GROUP_ACTION_LABEL" override="true" controlsOrder="0.10">
<control id="fr.ametys.myplugin.SynchronizeSomething"/>
</group>
</groups>
</tab> In this example, the button is added to the Content contextual tab in the Actions section in the last position.
Operators When synchronizing, you can define a specific operator that performs additional actions for each content item:
To do this, go to plugin and define the operator as follows:
Oops! Copy to clipboard failed. Open the code and copy it manually.<extensions>
<extension id="org.ametys.plugins.contentio.synchronize.impl.MonOperatorPerso"
class="org.ametys.plugins.contentio.synchronize.impl.MonOperatorPerso"
point="org.ametys.plugins.contentio.synchronize.SynchronizingContentOperatorExtensionPoint">
<label i18n="true">KEY_MON_OPERATEUR_PERSO_LABEL</label>
</extension>
</extensions> <extensions>
<extension id="org.ametys.plugins.contentio.synchronize.impl.MonOperatorPerso"
class="org.ametys.plugins.contentio.synchronize.impl.MonOperatorPerso"
point="org.ametys.plugins.contentio.synchronize.SynchronizingContentOperatorExtensionPoint">
<label i18n="true">KEY_MON_OPERATEUR_PERSO_LABEL</label>
</extension>
</extensions>
<extensions>
<extension id="org.ametys.plugins.contentio.synchronize.impl.MonOperatorPerso"
class="org.ametys.plugins.contentio.synchronize.impl.MonOperatorPerso"
point="org.ametys.plugins.contentio.synchronize.SynchronizingContentOperatorExtensionPoint">
<label i18n="true">KEY_MON_OPERATEUR_PERSO_LABEL</label>
</extension>
</extensions> With the class java org.ametys.plugins.contentio.synchronize.impl.MonOperatorPerso which extends DefaultSynchronizingContentOperator It will be able to implement the two methods :
Oops! Copy to clipboard failed. Open the code and copy it manually.public Map<String, List<Object>> transform(Map<String, List<Object>> remoteValues, Logger logger) public Map<String, List<Object>> transform(Map<String, List<Object>> remoteValues, Logger logger)
public Map<String, List<Object>> transform(Map<String, List<Object>> remoteValues, Logger logger) It transforms the values of remoteValues before content synchronization.
Oops! Copy to clipboard failed. Open the code and copy it manually.public void additionalOperation(Content content, Map<String, List<Object>> remoteValues, Logger logger) public void additionalOperation(Content content, Map<String, List<Object>> remoteValues, Logger logger)
public void additionalOperation(Content content, Map<String, List<Object>> remoteValues, Logger logger) It allows you to perform additional operations on content after synchronization.