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.web.indexing.solr; 017 018import java.util.Collections; 019import java.util.Set; 020 021import org.apache.solr.common.SolrInputDocument; 022 023import org.ametys.cms.indexing.solr.AbstractSolrHierarchicalRightIndexer; 024import org.ametys.core.right.RightManager; 025import org.ametys.plugins.repository.AmetysObject; 026import org.ametys.web.repository.page.Page; 027import org.ametys.web.repository.sitemap.Sitemap; 028 029/** 030 * Component indexing rights for a page. 031 */ 032public class SolrPageRightIndexer extends AbstractSolrHierarchicalRightIndexer<AmetysObject> 033{ 034 /** The component role. */ 035 public static final String ROLE = SolrPageRightIndexer.class.getName(); 036 037 /** 038 * Index the ACL for READER profile for a page 039 * @param page The page to index 040 * @param document The document to index 041 */ 042 public void indexPageAccess(Page page, SolrInputDocument document) 043 { 044 Set<String> profiles = Collections.singleton(RightManager.READER_PROFILE_ID); 045 046 indexAcls(page, document, profiles); 047 } 048 049 @Override 050 protected Set<AmetysObject> _getParents(AmetysObject pageOrSitemap) 051 { 052 AmetysObject parent = pageOrSitemap.getParent(); 053 if (parent instanceof Sitemap || parent instanceof Page) 054 { 055 return Collections.singleton(parent); 056 } 057 else 058 { 059 return null; 060 } 061 } 062}