001/*
002 *  Copyright 2016 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.contentio.synchronize;
017
018import java.util.List;
019import java.util.Map;
020
021import org.slf4j.Logger;
022
023import org.ametys.cms.repository.Content;
024import org.ametys.runtime.i18n.I18nizableText;
025
026/**
027 * Extension which enables to transform the remote values of a {@link SynchronizableContentsCollection} before synchronizing metadata via {@link #transform(Map, Logger)} method
028 * and to make some additional operations after synchronization via {@link #additionalOperation(Content, Map, Logger)} method.
029 */
030public interface SynchronizingContentOperator
031{
032    /**
033     * Get the label of this component
034     * @return the label
035     */
036    public I18nizableText getLabel();
037    
038    /**
039     * Transforms the remote values of a {@link SynchronizableContentsCollection} before synchronizing metadata.
040     * @param remoteValues The remote values to transform
041     * @param logger The logger
042     * @return The transfromed remote values
043     */
044    public Map<String, List<Object>> transform(Map<String, List<Object>> remoteValues, Logger logger);
045    
046    /**
047     * Make some additionnal operations after synchronization
048     * @param content The content which was synchronized
049     * @param remoteValues The transformed remote values
050     * @param logger The logger
051     */
052    public void additionalOperation(Content content, Map<String, List<Object>> remoteValues, Logger logger);
053}