Hi Vincent,
When I implement the XWikiDocumentConvertOutput, I meet some pb. I
understood that the XWikiDocumentConvertOutput contain a xwiki
document, and it will store the result html to the xwikidocument as
content, store the images to the xwikidocument as the attachments, and
save this xwiki document to the xwiki.
But we should separate the officeconverter from xwiki core, so
XWikiDocumentConvertOutput can't get any information about xwiki
contex, right?
Problems with this design:
1) when I use the saveDocument() method to save the inputstream to
document content, I need convert inputstream to html. But I can't get
the encoding of the xwiki because I can't access the xwiki context.
2) I can't set the attachments' author, because have no idea about the
author without context.
3) I can't save the xwikidocument to the xwiki without the xwiki context.
4) Maybe we can just save everything in the xwiki document and get it
from ConverterOutput and set author, then save it to the xwiki. If so,
we need a method getDocument() in ConverterOutput to get the document.
5) Actually, not all the accessory output is image. So the saveImage
interface is not appropriate.
Why we use ConverterOutput? I think because:
1) the output of conversion(especially convert to html) have no only
one output, so we just use ConverterOutput to save all this outputs
and their names for later use.
2) Maybe the special ConverterOutput like XWikiDocumentConvertOutput
can handle the coversion result to the special destination in special
format.
I think 2) is not right, because it make the office convert connected
to xwiki context.
So I proposal ConverterOutput is just a data structure to store the
output results and their name. My proposal is:
public interface ConverterOutput
{
/**
* Save the target contents in {@link InputStream} to the output
destination. And save the document's name as the
* main output file's name.
*
* @param documentName the name of the source content
* @param documentData the source data
*/
void saveDocument(String documentName, InputStream documentData);
/**
* Save the other output files like images, other htmls to the
output destination. In most case, this method will be
* used when convert office convert to html.
*
* @param accessoryName the accessory name
* @param accessoryData the accessory content
*/
void saveAccessory(String accessoryName, InputStream accessoryData);
/**
* @return the main document
*/
InputStream getDocument();
/**
* @return return the main document's name
*/
String getDocumentName();
/**
* @return the accessories of this document. The map's key is the
accessory's name.
*/
Map<String, InputStream> getAccessories();
}
I implement the office converter with this interface. Please review
the code at your convenience.
--
Thanks
Wang Ning
Show replies by date