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