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.contenttype.ContentType;
024import org.ametys.cms.repository.Content;
025import org.ametys.runtime.i18n.I18nizableText;
026
027/**
028 * Extension which enables to transform the remote values of a {@link SynchronizableContentsCollection} before synchronizing metadata via {@link #transform(ContentType, Map, Logger)} method
029 * and to make some additional operations after synchronization via {@link #additionalOperation(Content, Map, Logger)} method.
030 */
031public interface SynchronizingContentOperator
032{
033    /**
034     * Get the label of this component
035     * @return the label
036     */
037    public I18nizableText getLabel();
038    
039    /**
040     * Transforms the remote values of a {@link SynchronizableContentsCollection} before synchronizing attributes.
041     * @param cType The content type
042     * @param remoteValues The remote values to transform
043     * @param logger The logger
044     * @return The transformed remote values
045     */
046    public Map<String, List<Object>> transform(ContentType cType, Map<String, List<Object>> remoteValues, Logger logger);
047    
048    /**
049     * Make some additional operations after synchronization
050     * @param content The content which was synchronized
051     * @param remoteValues The transformed remote values
052     * @param logger The logger
053     */
054    public void additionalOperation(Content content, Map<String, List<Object>> remoteValues, Logger logger);
055}