Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/Record.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/Record.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/Record.java	(revision 1914)
@@ -49,5 +49,8 @@
      */
     public List<String> getSetSpecs();
-    
-    public void writeRecord(XMLStreamWriter writer) throws XMLStreamException;
+
+    public boolean supportsFormat(MetadataFormat format);
+
+    public void writeRecord(XMLStreamWriter writer, MetadataFormat format)
+            throws XMLStreamException, OAIException;
 } // interface Record
Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/Repository.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/Repository.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/Repository.java	(revision 1914)
@@ -223,5 +223,5 @@
      * <em>ListRecords</em> and <em>ListIdentifiers</em> verbs.
      * 
-     * @param prefix
+     * @param format
      *            requested metadata format (e.g "oai_dc")
      * @param from
@@ -242,5 +242,5 @@
      * @see RecordList
      */
-    public RecordList getRecords(String prefix, Date from, Date until,
+    public RecordList getRecords(MetadataFormat format, Date from, Date until,
             String set, int offset, int limit) throws OAIException;
 
@@ -249,5 +249,5 @@
      * <em>ListRecords</em> and <em>ListIdentifiers</em> verbs.
      * 
-     * @param prefix
+     * @param format
      *            requested metadata format (e.g "oai_dc")
      * @param from
@@ -268,6 +268,6 @@
      * @see RecordList
      */
-    public RecordList getRecordHeaders(String prefix, Date from, Date until,
-            String set, int offset, int limit) throws OAIException;
+    public RecordList getRecordHeaders(MetadataFormat format, Date from,
+            Date until, String set, int offset, int limit) throws OAIException;
 
 } // interface Repository
Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/ext/OAIOutputStream.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/ext/OAIOutputStream.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/ext/OAIOutputStream.java	(revision 1914)
@@ -9,4 +9,6 @@
 import javax.xml.stream.XMLStreamWriter;
 
+import eu.clarin.oai.provider.MetadataFormat;
+import eu.clarin.oai.provider.OAIException;
 import eu.clarin.oai.provider.Record;
 
@@ -76,5 +78,6 @@
     public void writeRecordHeader(Record record) throws XMLStreamException;
     
-    public void writeRecord(Record record) throws XMLStreamException;
+    public void writeRecord(Record record, MetadataFormat format)
+            throws XMLStreamException, OAIException;
 
 } // interface OAIOutputStream
Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/ext/RepositoryAdapter.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/ext/RepositoryAdapter.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/ext/RepositoryAdapter.java	(revision 1914)
@@ -36,5 +36,5 @@
     public Set<MetadataFormat> getMetadataFormats();
 
-    public Set<MetadataFormat> getMetadataFormats(Record record);
+//    public Set<MetadataFormat> getMetadataFormats(Record record);
 
     public MetadataFormat getMetadataFormatByPrefix(String prefix);
@@ -52,9 +52,9 @@
     public Record getRecordHeader(Object localId) throws OAIException;
 
-    public RecordList getRecords(String prefix, Date from, Date until,
+    public RecordList getRecords(MetadataFormat format, Date from, Date until,
             String set, int offset) throws OAIException;
 
-    public RecordList getRecordHeaders(String prefix, Date from, Date until,
-            String set, int offset) throws OAIException;
+    public RecordList getRecordHeaders(MetadataFormat format, Date from,
+            Date until, String set, int offset) throws OAIException;
 
     public ResumptionToken createResumptionToken();
Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/OAIOutputStreamImpl.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/OAIOutputStreamImpl.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/OAIOutputStreamImpl.java	(revision 1914)
@@ -16,4 +16,6 @@
 import org.apache.commons.lang.time.FastDateFormat;
 
+import eu.clarin.oai.provider.MetadataFormat;
+import eu.clarin.oai.provider.OAIException;
 import eu.clarin.oai.provider.Record;
 import eu.clarin.oai.provider.Repository;
@@ -253,5 +255,6 @@
 
     @Override
-    public void writeRecord(Record record) throws XMLStreamException {
+    public void writeRecord(Record record, MetadataFormat format)
+            throws XMLStreamException, OAIException {
         writer.writeStartElement("record");
         writeRecordHeader(record);
@@ -259,5 +262,5 @@
             writer.writeStartElement("metadata");
             // FIXME: re-work!
-            record.writeRecord(writer);
+            record.writeRecord(writer, format);
             writer.writeEndElement(); // metadata element
         }
Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/RepositoryAdapterImpl.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/RepositoryAdapterImpl.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/RepositoryAdapterImpl.java	(revision 1914)
@@ -1,5 +1,4 @@
 package eu.clarin.oai.provider.impl;
 
-import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
@@ -151,22 +150,22 @@
     }
 
-    @Override
-    public Set<MetadataFormat> getMetadataFormats(Record record) {
-        // FIXME: re-work
-//        final Class<?> clazz = record.getItem().getClass();
-        Set<MetadataFormat> result = null;
-//        for (MetadataFormat format : metadataFormats) {
-//            if (format.canWriteClass(clazz)) {
-//                if (result == null) {
-//                    result = new HashSet<MetadataFormat>();
-//                }
-//                result.add(format);
-//            }
-//        }
-        if ((result == null) || result.isEmpty()) {
-            result = Collections.emptySet();
-        }
-        return result;
-    }
+//    @Override
+//    public Set<MetadataFormat> getMetadataFormats(Record record) {
+//        // FIXME: re-work
+////        final Class<?> clazz = record.getItem().getClass();
+//        Set<MetadataFormat> result = null;
+////        for (MetadataFormat format : metadataFormats) {
+////            if (format.canWriteClass(clazz)) {
+////                if (result == null) {
+////                    result = new HashSet<MetadataFormat>();
+////                }
+////                result.add(format);
+////            }
+////        }
+//        if ((result == null) || result.isEmpty()) {
+//            result = Collections.emptySet();
+//        }
+//        return result;
+//    }
 
     @Override
@@ -227,5 +226,5 @@
 
     @Override
-    public RecordList getRecords(String prefix, Date from, Date until,
+    public RecordList getRecords(MetadataFormat format, Date from, Date until,
             String set, int offset) throws OAIException {
         /*
@@ -237,5 +236,5 @@
         }
         try {
-            return repository.getRecords(prefix, from, until, set, offset, limit);
+            return repository.getRecords(format, from, until, set, offset, limit);
         } catch (OAIException e) {
             throw e;
@@ -246,6 +245,6 @@
 
     @Override
-    public RecordList getRecordHeaders(String prefix, Date from, Date until,
-            String set, int offset) throws OAIException {
+    public RecordList getRecordHeaders(MetadataFormat format, Date from,
+            Date until, String set, int offset) throws OAIException {
         /*
          * XXX: maybe add a OAIProvider defined upper limit?
@@ -256,5 +255,6 @@
         }
         try {
-            return repository.getRecordHeaders(prefix, from, until, set, offset, limit);
+            return repository.getRecordHeaders(format, from, until,
+                    set, offset, limit);
         } catch (OAIException e) {
             throw e;
Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbEnumerateRecord.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbEnumerateRecord.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbEnumerateRecord.java	(revision 1914)
@@ -81,5 +81,5 @@
             } else {
                 // fetch records
-                final RecordList result = doGetRecords(repository, prefix,
+                final RecordList result = doGetRecords(repository, format,
                         from, until, set, offset);
 
@@ -113,6 +113,13 @@
                             }
 
-                            public void writeRecord(XMLStreamWriter writer)
-                                    throws XMLStreamException {
+                            @Override
+                            public boolean supportsFormat(MetadataFormat format) {
+                                return true;
+                            }
+
+                            @Override
+                            public void writeRecord(XMLStreamWriter writer,
+                                    MetadataFormat format)
+                                    throws XMLStreamException, OAIException {
                                 result.writeRecord(writer);
                             }
@@ -165,10 +172,10 @@
 
     protected abstract RecordList doGetRecords(RepositoryAdapter repository,
-            String prefix, Date from, Date until, String set, int offset)
+            MetadataFormat format, Date from, Date until, String set, int offset)
             throws OAIException;
 
     protected abstract void doWriteRecord(RepositoryAdapter repository,
             OAIOutputStream out, MetadataFormat format, Record record)
-            throws XMLStreamException;
+            throws XMLStreamException, OAIException;
 
 } // abstract class VerbEnumerateRecord
Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbGetRecord.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbGetRecord.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbGetRecord.java	(revision 1914)
@@ -44,14 +44,16 @@
                 (String) ctx.getArgument(DefaultArguments.ARG_METADATAPREFIX);
             MetadataFormat format = null;
-            for (MetadataFormat f : repository.getMetadataFormats(record)) {
-                if (prefix.equals(f.getPrefix())) {
+            // FIXME: re-work
+            for (MetadataFormat f : repository.getMetadataFormats()) {
+                if (f.getPrefix().equals(prefix) && record.supportsFormat(f)) {
                     format = f;
                     break;
                 }
             }
+
             if (format != null) {
                 OAIOutputStream out = ctx.getOutputStream();
                 out.writeStartElement("GetRecord");
-                out.writeRecord(record);
+                out.writeRecord(record, format);
                 out.writeEndElement(); // GetRecord element
                 out.close();
Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbListIdentifiers.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbListIdentifiers.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbListIdentifiers.java	(revision 1914)
@@ -21,7 +21,7 @@
     @Override
     protected RecordList doGetRecords(RepositoryAdapter repository,
-            String prefix, Date from, Date until, String set, int offset)
+            MetadataFormat format, Date from, Date until, String set, int offset)
             throws OAIException {
-        return repository.getRecordHeaders(prefix, from, until, set, offset);
+        return repository.getRecordHeaders(format, from, until, set, offset);
     }
 
@@ -29,5 +29,5 @@
     protected void doWriteRecord(RepositoryAdapter repository,
             OAIOutputStream out, MetadataFormat format, Record record)
-            throws XMLStreamException {
+            throws XMLStreamException, OAIException {
         out.writeRecordHeader(record);
     }
Index: /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbListRecords.java
===================================================================
--- /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbListRecords.java	(revision 1913)
+++ /OAIProvider/trunk/src/main/java/eu/clarin/oai/provider/impl/VerbListRecords.java	(revision 1914)
@@ -23,16 +23,15 @@
     @Override
     protected RecordList doGetRecords(RepositoryAdapter repository,
-            String prefix, Date from, Date until, String set, int offset)
+            MetadataFormat format, Date from, Date until, String set, int offset)
             throws OAIException {
-        return repository.getRecords(prefix, from, until, set, offset);
+        return repository.getRecords(format, from, until, set, offset);
     }
 
-
+    
     @Override
     protected void doWriteRecord(RepositoryAdapter repository,
             OAIOutputStream out, MetadataFormat format, Record record)
-            throws XMLStreamException {
-        // FIXME: rework (send MetadataFormat?)
-        out.writeRecord(record);
+            throws XMLStreamException, OAIException {
+        out.writeRecord(record, format);
     }
 
