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.content.indexing.solr; 017 018import java.util.Collections; 019import java.util.Set; 020 021import org.apache.avalon.framework.service.ServiceException; 022import org.apache.avalon.framework.service.ServiceManager; 023import org.apache.solr.common.SolrInputDocument; 024 025import org.ametys.cms.indexing.solr.AbstractSolrHierarchicalRightIndexer; 026import org.ametys.cms.repository.Content; 027import org.ametys.core.right.RightManager; 028 029/** 030 * Component indexing rights for a content. 031 */ 032public class SolrContentRightIndexer extends AbstractSolrHierarchicalRightIndexer<Object> 033{ 034 /** The component role. */ 035 public static final String ROLE = SolrContentRightIndexer.class.getName(); 036 037 /** The extension point of this implementation */ 038 protected SolrContentRightIndexerExtensionPoint _solrContentRightIndexerExtensionPoint; 039 040 @Override 041 public void service(ServiceManager serviceManager) throws ServiceException 042 { 043 super.service(serviceManager); 044 _solrContentRightIndexerExtensionPoint = (SolrContentRightIndexerExtensionPoint) serviceManager.lookup(SolrContentRightIndexerExtensionPoint.ROLE); 045 } 046 047 /** 048 * Index the ACL for READER profile for a content 049 * @param content The content to index 050 * @param document The document to index 051 */ 052 public void indexContentAccess(Content content, SolrInputDocument document) 053 { 054 Set<String> profiles = Collections.singleton(RightManager.READER_PROFILE_ID); 055 056 indexAcls(content, document, profiles); 057 } 058 059 @Override 060 protected Set<Object> _getParents(Object contentOrRootContent) 061 { 062 return _solrContentRightIndexerExtensionPoint.getParents(contentOrRootContent); 063 } 064}