001/*
002 *  Copyright 2019 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.odfsync.cdmfr;
017
018import java.util.List;
019import java.util.Map;
020import java.util.Set;
021
022import org.apache.avalon.framework.configuration.Configuration;
023import org.apache.avalon.framework.configuration.ConfigurationException;
024import org.apache.avalon.framework.service.ServiceException;
025import org.apache.avalon.framework.service.ServiceManager;
026import org.slf4j.Logger;
027
028import org.ametys.cms.data.ContentSynchronizationResult;
029import org.ametys.cms.repository.Content;
030import org.ametys.cms.repository.ModifiableContent;
031import org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection;
032import org.ametys.plugins.odfsync.cdmfr.components.ImportCDMFrComponent;
033import org.ametys.plugins.repository.AmetysObjectIterable;
034
035/**
036 * Abstract class to import CDMFr contents
037 */
038public abstract class AbstractCDMFrSynchronizableContentsCollection extends AbstractSynchronizableContentsCollection
039{
040    /** The import CDMFr component */
041    protected ImportCDMFrComponent _importCDMFrComponent;
042    
043    @Override
044    public void service(ServiceManager manager) throws ServiceException
045    {
046        super.service(manager);
047        _importCDMFrComponent = (ImportCDMFrComponent) manager.lookup(ImportCDMFrComponent.ROLE);
048    }
049    
050    @Override
051    public String getIdField()
052    {
053        return _importCDMFrComponent.getIdField();
054    }
055
056    public Set<String> getLocalAndExternalFields(Map<String, Object> additionalParameters)
057    {
058        return _importCDMFrComponent.getLocalAndExternalFields(additionalParameters);
059    }
060    
061    public ContentSynchronizationResult additionalCommonOperations(ModifiableContent content, Map<String, Object> additionalParameters, Logger logger)
062    {
063        return _importCDMFrComponent.additionalOperations(content, additionalParameters, logger);
064    }
065
066    @Override
067    protected void configureDataSource(Configuration configuration) throws ConfigurationException
068    {
069        // Do Nothing
070    }
071    
072    @Override
073    protected void configureSearchModel()
074    {
075        // Do Nothing
076    }
077    
078    @Override
079    public void synchronizeContent(ModifiableContent content, Logger logger) throws Exception
080    {
081        throw new UnsupportedOperationException("synchronizeContent() method is not supported for CDM-fr synchronizable contents collections.");
082    }
083
084    @Override
085    public ModifiableContent getContent(String lang, String idValue)
086    {
087        throw new UnsupportedOperationException("getContent() method is not supported for CDM-fr synchronizable contents collections.");
088    }
089
090    @Override
091    public Map<String, Map<String, Object>> search(Map<String, Object> searchParameters, int offset, int limit, List<Object> sort, Logger logger)
092    {
093        throw new UnsupportedOperationException("search() method is not supported for CDM-fr synchronizable contents collections.");
094    }
095
096    @Override
097    public void updateSyncInformations(ModifiableContent content, String syncCode, Logger logger) throws Exception
098    {
099        throw new UnsupportedOperationException("updateSyncInformations() method is not supported for CDM-fr synchronizable contents collections.");
100    }
101
102    @Override
103    public int getTotalCount(Map<String, Object> searchParameters, Logger logger)
104    {
105        throw new UnsupportedOperationException("getTotalCount() method is not supported for CDM-fr synchronizable contents collections.");
106    }
107
108    @Override
109    protected List<Content> _getContentsToRemove(AmetysObjectIterable<ModifiableContent> contents)
110    {
111        throw new UnsupportedOperationException("_getContentsToRemove() method is not supported for CDM-fr synchronizable contents collections.");
112    }
113
114    @Override
115    protected List<ModifiableContent> _internalPopulate(Logger logger)
116    {
117        throw new UnsupportedOperationException("_internalPopulate() method is not supported for CDM-fr synchronizable contents collections.");
118    }
119}