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.impl;
017
018import java.util.List;
019import java.util.Map;
020
021import org.apache.avalon.framework.configuration.Configurable;
022import org.apache.avalon.framework.configuration.Configuration;
023import org.apache.avalon.framework.configuration.ConfigurationException;
024import org.slf4j.Logger;
025
026import org.ametys.cms.contenttype.ContentType;
027import org.ametys.cms.repository.Content;
028import org.ametys.plugins.contentio.synchronize.SynchronizingContentOperator;
029import org.ametys.runtime.i18n.I18nizableText;
030import org.ametys.runtime.plugin.component.PluginAware;
031
032/**
033 * Default implementation of {@link SynchronizingContentOperator} which does nothing.
034 */
035public class DefaultSynchronizingContentOperator implements SynchronizingContentOperator, Configurable, PluginAware
036{
037    /** The label */
038    protected I18nizableText _label;
039    /** The name of plugin hosting this component */
040    protected String _pluginName;
041    
042    @Override
043    public void setPluginInfo(String pluginName, String featureName, String id)
044    {
045        _pluginName = pluginName;
046    }
047    
048    @Override
049    public void configure(Configuration configuration) throws ConfigurationException
050    {
051        _label = I18nizableText.parseI18nizableText(configuration.getChild("label"), "plugin." + _pluginName);
052    }
053    
054    @Override
055    public I18nizableText getLabel()
056    {
057        return _label;
058    }
059    
060    @Override
061    public Map<String, List<Object>> transform(ContentType cType, Map<String, List<Object>> remoteValues, Logger logger)
062    {
063        return remoteValues;
064    }
065    
066    @Override
067    public void additionalOperation(Content content, Map<String, List<Object>> remoteValues, Logger logger)
068    {
069        // Do nothing
070    }
071
072}