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.ModifiableContent; 030import org.ametys.core.schedule.progression.ContainerProgressionTracker; 031import org.ametys.odf.cdmfr.CDMFRHandler; 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 /** The CDM-fr handler */ 045 protected CDMFRHandler _cdmfrHandler; 046 047 @Override 048 public void service(ServiceManager manager) throws ServiceException 049 { 050 super.service(manager); 051 _importCDMFrComponent = (ImportCDMFrComponent) manager.lookup(ImportCDMFrComponent.ROLE); 052 _cdmfrHandler = (CDMFRHandler) manager.lookup(CDMFRHandler.ROLE); 053 } 054 055 @Override 056 public String getIdField() 057 { 058 return _importCDMFrComponent.getIdField(); 059 } 060 061 public Set<String> getLocalAndExternalFields(Map<String, Object> additionalParameters) 062 { 063 return _importCDMFrComponent.getLocalAndExternalFields(additionalParameters); 064 } 065 066 public ContentSynchronizationResult additionalCommonOperations(ModifiableContent content, Map<String, Object> additionalParameters, Logger logger) 067 { 068 return _importCDMFrComponent.additionalOperations(content, additionalParameters, logger); 069 } 070 071 @Override 072 protected void configureDataSource(Configuration configuration) throws ConfigurationException 073 { 074 // Do Nothing 075 } 076 077 @Override 078 protected void configureSearchModel() 079 { 080 // Do Nothing 081 } 082 083 @Override 084 public void synchronizeContent(ModifiableContent content, Logger logger) throws Exception 085 { 086 throw new UnsupportedOperationException("synchronizeContent() method is not supported for CDM-fr synchronizable contents collections."); 087 } 088 089 @Override 090 public ModifiableContent getContent(String lang, String idValue, boolean forceStrictCheck) 091 { 092 throw new UnsupportedOperationException("getContent() method is not supported for CDM-fr synchronizable contents collections."); 093 } 094 095 @Override 096 public Map<String, Map<String, Object>> search(Map<String, Object> searchParameters, int offset, int limit, List<Object> sort, Logger logger) 097 { 098 throw new UnsupportedOperationException("search() method is not supported for CDM-fr synchronizable contents collections."); 099 } 100 101 @Override 102 public void updateSyncInformations(ModifiableContent content, String syncCode, Logger logger) throws Exception 103 { 104 throw new UnsupportedOperationException("updateSyncInformations() method is not supported for CDM-fr synchronizable contents collections."); 105 } 106 107 @Override 108 public int getTotalCount(Map<String, Object> searchParameters, Logger logger) 109 { 110 throw new UnsupportedOperationException("getTotalCount() method is not supported for CDM-fr synchronizable contents collections."); 111 } 112 113 @Override 114 protected List<ModifiableContent> _getContentsToRemove(AmetysObjectIterable<ModifiableContent> contents) 115 { 116 throw new UnsupportedOperationException("_getContentsToRemove() method is not supported for CDM-fr synchronizable contents collections."); 117 } 118 119 @Override 120 protected List<ModifiableContent> _internalPopulate(Logger logger, ContainerProgressionTracker progressionTracker) 121 { 122 throw new UnsupportedOperationException("_internalPopulate() method is not supported for CDM-fr synchronizable contents collections."); 123 } 124 125 /** 126 * Start handle CDM-fr treatments 127 */ 128 protected void _startHandleCDMFR() 129 { 130 _cdmfrHandler.suspendCDMFRObserver(); 131 } 132 133 /** 134 * End handle CDM-fr treatments 135 * @param udpatedContentIds the updated contents ids 136 */ 137 protected void _endHandleCDMFR(Set<String> udpatedContentIds) 138 { 139 _cdmfrHandler.unsuspendCDMFRObserver(udpatedContentIds); 140 } 141}