for (Object documentObject : searchResult.getDocuments()) {
ConfigDocument document = (ConfigDocument) documentObject;
latest.add(getConfigMaster().get(document.getObjectId(), VersionCorrection.LATEST));
}
FudgeSerializer serializer = new FudgeSerializer(OpenGammaFudgeContext.getInstance());
File directory = new File(getDestinationDirectory(), clazz.getName());
directory.mkdir();
for (ConfigDocument document : latest) {
File documentFile = new File(directory, document.getName() + ".xml");
System.out.println("-- Creating file " + documentFile.getAbsolutePath());
FileOutputStream fos = new FileOutputStream(documentFile);
FudgeXMLStreamWriter xmlStreamWriter = new FudgeXMLStreamWriter(OpenGammaFudgeContext.getInstance(), new OutputStreamWriter(fos));
MutableFudgeMsg msg = serializer.objectToFudgeMsg(document.getConfig().getValue());
FudgeMsgWriter fudgeMsgWriter = new FudgeMsgWriter(xmlStreamWriter);
fudgeMsgWriter.writeMessage(msg);
fudgeMsgWriter.close();
fos.close();
}