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 java.io.IOException; 019import java.util.Arrays; 020import java.util.Collection; 021 022import org.apache.cocoon.ProcessingException; 023import org.apache.cocoon.xml.XMLUtils; 024import org.xml.sax.SAXException; 025 026/** 027 * Generator for the <code>ListMetadataFormat</code> verb.<br> 028 * Returns oai_dc and cdm formats. 029 */ 030public class ListMetadataFormatsGenerator extends AbstractOAIVerbGenerator 031{ 032 @Override 033 protected Collection<String> getRequiredParameters() 034 { 035 return Arrays.asList("verb"); 036 } 037 038 @Override 039 protected Collection<String> getAllowedParameters() 040 { 041 return Arrays.asList("verb", "identifier"); 042 } 043 044 @Override 045 protected void generateVerb() throws IOException, SAXException, ProcessingException 046 { 047 XMLUtils.startElement(contentHandler, "ListMetadataFormats"); 048 049 XMLUtils.startElement(contentHandler, "metadataFormat"); 050 XMLUtils.createElement(contentHandler, "metadataPrefix", "oai_dc"); 051 XMLUtils.createElement(contentHandler, "schema", "http://www.openarchives.org/OAI/2.0/oai_dc.xsd"); 052 XMLUtils.createElement(contentHandler, "metadataNamespace", "http://www.openarchives.org/OAI/2.0/oai_dc/"); 053 XMLUtils.endElement(contentHandler, "metadataFormat"); 054 055 XMLUtils.startElement(contentHandler, "metadataFormat"); 056 XMLUtils.createElement(contentHandler, "metadataPrefix", "cdm"); 057 XMLUtils.createElement(contentHandler, "schema", "http://cdm-fr.fr/2011/schemas/CDMFR.xsd"); 058 XMLUtils.createElement(contentHandler, "metadataNamespace", "http://cdm-fr.fr/2011/CDM"); 059 XMLUtils.endElement(contentHandler, "metadataFormat"); 060 061 XMLUtils.endElement(contentHandler, "ListMetadataFormats"); 062 } 063}