use of org.openntf.domino.nsfdata.structs.obj.CDResourceEvent in project org.openntf.domino by OpenNTF.
the class AbstractDesignFileResource method getFileDataRaw.
/**
* Reads a FileData Item in RAW-mode
*
* @param itemName
* @return
*/
protected byte[] getFileDataRaw(final String itemName) {
try {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
for (XMLNode rawitemdata : //
getDxl().selectNodes("//item[@name='" + XMLDocument.escapeXPathValue(itemName) + "']/rawitemdata")) {
// $NON-NLS-1$ //$NON-NLS-2$
String rawData = rawitemdata.getText();
byte[] thisData = parseBase64Binary(rawData);
byteStream.write(thisData);
}
if (byteStream.size() > 0) {
byte[] data = byteStream.toByteArray();
CData cdata = new CData(data);
CDObject obj = CDObject.create(cdata);
// Files may be attached either as FILE or as EVENT... (ssjs for example) Damn. This makes everything quite complex
if (obj instanceof CDResourceFile)
return ((CDResourceFile) obj).getFileData();
if (obj instanceof CDResourceEvent)
return ((CDResourceEvent) obj).getFileData();
// $NON-NLS-1$
throw new IllegalStateException("Cannot decode " + obj.getClass().getName());
} else {
byteStream = new ByteArrayOutputStream();
for (XMLNode rawitemdata : //
getDxl().selectNodes("//file[@name='" + XMLDocument.escapeXPathValue(itemName) + "']/filedata")) {
// $NON-NLS-1$ //$NON-NLS-2$
String rawData = rawitemdata.getText();
byte[] thisData = parseBase64Binary(rawData);
byteStream.write(thisData);
}
return byteStream.toByteArray();
}
} catch (IOException ioe) {
DominoUtils.handleException(ioe);
return null;
}
}
Aggregations