Movie movie = getRobustMovie(RobustMovieDecoder.DECODE_RULE_NULLS);
try {
movie.decodeFromStream(payloadResource);
} catch (DataFormatException e1) {
throw new BadContentException(e1.getLocalizedMessage());
}
Movie outMovie = new Movie(movie);
List<MovieTag> inTags = movie.getObjects();
ArrayList<MovieTag> outTags = new ArrayList<MovieTag>();
for (MovieTag tag : inTags) {
outTags.add(rewriteTag(rw, tag));
}
outMovie.setObjects(outTags);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
outMovie.encodeToStream(baos);
} catch (DataFormatException e) {
throw new BadContentException(e.getLocalizedMessage());
}
// put the new corrected length:
headers.put(HttpHeaderOperation.HTTP_LENGTH_HEADER,
String.valueOf(baos.size()));