001/*
002 *  Copyright 2012 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.odf.oai;
017
018import org.apache.avalon.framework.service.ServiceException;
019import org.apache.avalon.framework.service.ServiceManager;
020import org.apache.cocoon.environment.ObjectModelHelper;
021import org.apache.cocoon.environment.Request;
022import org.xml.sax.SAXException;
023
024import org.ametys.odf.cdmfr.ExportCDMfrManager;
025import org.ametys.odf.program.Program;
026
027/**
028 * Generator for the <code>ListRecords</code> verb.
029 */
030public class ListRecordsGenerator extends ListIdentifiersGenerator
031{
032    private ExportCDMfrManager _exportCDMfrManager;
033    
034    @Override
035    public void service(ServiceManager serviceManager) throws ServiceException
036    {
037        super.service(serviceManager);
038        _exportCDMfrManager = (ExportCDMfrManager) serviceManager.lookup(ExportCDMfrManager.ROLE);
039    }
040    
041    @Override
042    protected String getTagName()
043    {
044        return "ListRecords";
045    }
046    
047    /**
048     * Generate the program information.
049     * @param program the program
050     * @throws SAXException if an error occurred while SAXing
051     */
052    @Override
053    protected void saxProgram(Program program) throws SAXException
054    {
055        Request request = ObjectModelHelper.getRequest(objectModel);
056        
057        String metadataPrefix = request.getParameter("metadataPrefix");
058        
059        RecordHelper.saxProgram(program, contentHandler, metadataPrefix, _exportCDMfrManager);
060    }
061}