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.odfweb.repository; 017 018import org.apache.avalon.framework.service.ServiceException; 019import org.apache.avalon.framework.service.ServiceManager; 020 021import org.ametys.odf.ODFHelper; 022import org.ametys.plugins.odfweb.observation.solr.AbstractSolrODFObserver; 023import org.ametys.web.data.type.ModelItemTypeExtensionPoint; 024import org.ametys.web.repository.page.virtual.AbstractConfigurableVirtualPageFactory; 025 026/** 027 * Common class for factories of ODF virtual pages 028 */ 029public abstract class AbstractOdfPageFactory extends AbstractConfigurableVirtualPageFactory 030{ 031 /** The odf page handler */ 032 protected OdfPageHandler _odfPageHandler; 033 /** The odf page cache */ 034 protected ODFPageCache _pageCache; 035 /** The ODF helper */ 036 protected ODFHelper _odfHelper; 037 038 @Override 039 public void service(ServiceManager manager) throws ServiceException 040 { 041 super.service(manager); 042 043 _odfHelper = (ODFHelper) manager.lookup(ODFHelper.ROLE); 044 _odfPageHandler = (OdfPageHandler) manager.lookup(OdfPageHandler.ROLE); 045 _pageCache = (ODFPageCache) manager.lookup(ODFPageCache.ROLE); 046 } 047 048 ODFPageCache getODFPageCache() 049 { 050 return _pageCache; 051 } 052 053 OdfPageHandler getODFPageHandler() 054 { 055 return _odfPageHandler; 056 } 057 058 ModelItemTypeExtensionPoint getZoneDataTypeEP() 059 { 060 return _pageDataTypeExtensionPoint; 061 } 062 063 ModelItemTypeExtensionPoint getZoneItemDataTypeEP() 064 { 065 return _pageDataTypeExtensionPoint; 066 } 067 068 FirstLevelPageFactory getFirstLevelPageFactory() 069 { 070 return (FirstLevelPageFactory) _ametysObjectFactoryEP.getExtension(FirstLevelPageFactory.class.getName()); 071 } 072 073 SecondLevelPageFactory getSecondLevelPageFactory() 074 { 075 return (SecondLevelPageFactory) _ametysObjectFactoryEP.getExtension(SecondLevelPageFactory.class.getName()); 076 } 077 078 ProgramPageFactory getProgramPageFactory() 079 { 080 return (ProgramPageFactory) _ametysObjectFactoryEP.getExtension(ProgramPageFactory.class.getName()); 081 } 082 083 CoursePageFactory getCoursePageFactory() 084 { 085 return (CoursePageFactory) _ametysObjectFactoryEP.getExtension(CoursePageFactory.class.getName()); 086 } 087 088 boolean isIndexing() 089 { 090 Boolean indexing = (Boolean) getRequest().getAttribute(AbstractSolrODFObserver.REQUEST_ATTRIBUTE_INDEXING); 091 return indexing != null && indexing.booleanValue(); 092 } 093}