OutputTransform ot = t.getOutputTransform(in, mMeta);
appliedTransforms.add(ot);
in = ot.getEncodedInputStream();
}
} catch(TransformException e) {
throw new AtmosException("Could not transform data: " + e, e);
} catch (IOException e) {
throw new AtmosException("Error transforming data: " + e, e);
}
// Overwrite the object
int c = 0;
int pos = 0;
byte[] buffer = new byte[bufferSize];
// Read the first chunk and send it with the create request.
try {
c = fillBuffer(buffer, in);
} catch (IOException e) {
throw new AtmosException("Error reading input data: " + e, e);
}
if(c == -1) {
// EOF already
request.setContent(null);
// Optmization -- send metadata now with create request and return
try {
in.close();
} catch (IOException e) {
throw new AtmosException("Error closing input: " + e, e);
}
for(OutputTransform ot : appliedTransforms) {
mMeta.putAll(ot.getEncodedMetadata());
}
Set<Metadata> metadata = request.getUserMetadata();
if(metadata == null) {
metadata = new HashSet<Metadata>();
}
updateMetadata(mMeta, metadata);
request.setUserMetadata(metadata);
return delegate.updateObject(request);
} else {
request.setContent(new BufferSegment(buffer, 0, c));
}
BasicResponse resp = delegate.updateObject(request);
pos = c;
// Append until EOF.
try {
while((c = fillBuffer(buffer, in)) != -1) {
UpdateObjectRequest uor = new UpdateObjectRequest();
uor.setIdentifier(request.getIdentifier());
uor.setContentType(request.getContentType());
uor.setRange(new Range(pos, pos+c-1));
uor.setContent(new BufferSegment(buffer, 0, c));
pos += c;
delegate.updateObject(uor);
}
} catch (IOException e) {
throw new AtmosException("Error reading input data: " + e, e);
}
try {
in.close();
} catch (IOException e) {
throw new AtmosException("Error closing stream: " + e, e);
}
String transformConfig = "";
// Update the object with the transformed metadata.
for(OutputTransform ot : appliedTransforms) {