{
IOUtils.closeQuietly(pw);
if (!isComplete) {
// we don't want to overwrite the current OBR with bad data
throw new StorageException("OBR metadata is not complete");
}
final ResourceStoreRequest request = new ResourceStoreRequest(path);
final ContentLocator content = new FileContentLocator(file,
mimeSupport.guessMimeTypeFromPath(file.getAbsolutePath()));
try {
repository.storeItem(false, new DefaultStorageFileItem(repository, request, true, true, content));
}
catch (final IllegalOperationException e) {
throw new StorageException(e);
}
catch (final UnsupportedStorageOperationException e) {
throw new StorageException(e);
}
if (!file.delete()) {
file.deleteOnExit(); // see if we can delete it later...
}