throws IOException
{
// this is a special one: once cached (hence consumed), temp file get's deleted
final FileContentLocator fileContentLocator = new FileContentLocator("text/xml");
try (OutputStream buffer = fileContentLocator.getOutputStream()) {
final MXSerializer mx = new MXSerializer();
mx.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-indentation", " ");
mx.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n");
final String encoding = "UTF-8";
mx.setOutput(buffer, encoding);
mx.startDocument(encoding, null);
if (hack != null) {
mx.processingInstruction(hack);
}
metadata.writeToSerializer(null, mx);
mx.flush();
}
final ResourceStoreRequest request = new ResourceStoreRequest(path);
request.getRequestContext().setParentContext(context);
final DefaultStorageFileItem result =