Hi,
I have to use http API for Java (TaminoClient) version 3.1.2.1.
I need to insert two documents in one transaction: an xml document and a non-xml (pdf) document. These two are on the same database, but different collections. Is it that possible? If yes, how?
Here is a pseudo-code what I intend to do:
try {
TaminoClient tcXML = new TaminoClient (DATABASE_URL + "/" + XML_COLLECTION);
tcXML.startSession();
TaminoNonXml tcNonXML = new TaminoNonXml (DATABASE_URL + "/" + PDF_COLLECTION);
tcNonXML.setSessionID(txNML.getSessionID()); ....//??! how to make tcNonXML use the same session as tcXML?
Element element = getNextElement(); //get the next "parent" to insert
tcXML.insert(element);
byte[] pdf = getPDF(element);
tcNonXML.setNonXML("pdf/"+FILENAME, "application/pdf", new ByteArrayInputStream(pdf) );//insert the associated pdf
tcXML.commit();
tcXML.endSession();
} catch(Exception e) {
tcXML.rollBack();
tcXML.endSession();
}
protected abstract String getNextElement(); //returns the next parent to insert
protected abstract byte[] getPDF(Element element);//returns pdf to insert