001/* 002 * Copyright 2015 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 */ 016 017package org.ametys.plugins.maps; 018 019import java.io.IOException; 020 021import org.apache.avalon.framework.service.ServiceException; 022import org.apache.avalon.framework.service.ServiceManager; 023import org.apache.cocoon.ProcessingException; 024import org.apache.cocoon.environment.ObjectModelHelper; 025import org.apache.cocoon.environment.Request; 026import org.apache.cocoon.generation.ServiceableGenerator; 027import org.apache.cocoon.xml.XMLUtils; 028import org.xml.sax.SAXException; 029 030import org.ametys.plugins.repository.data.holder.ModelAwareDataHolder; 031import org.ametys.web.repository.page.ZoneItem; 032 033/** 034 * Generates a map. 035 */ 036public class MapGenerator extends ServiceableGenerator 037{ 038 @Override 039 public void service(ServiceManager serviceManager) throws ServiceException 040 { 041 super.service(serviceManager); 042 } 043 044 @Override 045 public void generate() throws IOException, SAXException, ProcessingException 046 { 047 Request request = ObjectModelHelper.getRequest(objectModel); 048 ZoneItem zoneItem = (ZoneItem) request.getAttribute(ZoneItem.class.getName()); 049 ModelAwareDataHolder dataHolder = zoneItem.getServiceParameters(); 050 051 contentHandler.startDocument(); 052 XMLUtils.startElement(contentHandler, "map"); 053 054 dataHolder.dataToSAX(contentHandler); 055 056 XMLUtils.endElement(contentHandler, "map"); 057 contentHandler.endDocument(); 058 } 059}