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.cms.indexing.solr; 017 018import java.util.ArrayList; 019import java.util.Collection; 020import java.util.List; 021 022import org.apache.avalon.framework.service.ServiceException; 023import org.apache.avalon.framework.service.ServiceManager; 024import org.apache.avalon.framework.service.Serviceable; 025 026import org.ametys.cms.search.solr.schema.SchemaDefinition; 027import org.ametys.cms.search.solr.schema.SchemaDefinitionProvider; 028import org.ametys.runtime.plugin.component.AbstractLogEnabled; 029 030/** 031 * Provides all the schema elements defined by additional property indexers. 032 */ 033public class AdditionalPropertyIndexerSchemaDefinitionProvider extends AbstractLogEnabled implements SchemaDefinitionProvider, Serviceable 034{ 035 036 /** The additional property indexer extension point. */ 037 protected AdditionalPropertyIndexerExtensionPoint _additionalPropertyIndexerEP; 038 039 @Override 040 public void service(ServiceManager manager) throws ServiceException 041 { 042 _additionalPropertyIndexerEP = (AdditionalPropertyIndexerExtensionPoint) manager.lookup(AdditionalPropertyIndexerExtensionPoint.ROLE); 043 } 044 045 @Override 046 public Collection<SchemaDefinition> getDefinitions() 047 { 048 List<SchemaDefinition> definitions = new ArrayList<>(); 049 050 for (String id : _additionalPropertyIndexerEP.getExtensionsIds()) 051 { 052 AdditionalPropertyIndexer indexer = _additionalPropertyIndexerEP.getExtension(id); 053 054 definitions.addAll(indexer.getSchemaDefinitions()); 055 } 056 057 return definitions; 058 } 059 060}