// serialize and swap the new metadata
MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(bos);
metadataWriter.write(osw, imd);
mdFile.setContentLocator(new ByteArrayContentLocator(bos.toByteArray(), mdFile.getMimeType()));
}
catch (Exception e) {
log.error("Exception during repository metadata cleansing.", e);
if (backup != null) {
// get backup and continue operation
backup.reset();
mdFile.setContentLocator(new ByteArrayContentLocator(backup1.toByteArray(), mdFile.getMimeType()));
}
}
}
return super.doCacheItem(item);