test and fix stream closing in get(Raw)Artifact
test simple writing to artifact repository
397355 Never add bad artifacts to LocalArtifactRepository index

- Don't add artifacts to the index if the source detected problems in
  the written data (e.g. a bad MD5). Only change the index after the
  artifact has been completely written and checked. This means that we
  can be sure that the index always only contains good artifacts - an
  important prerequisite for multithreaded access to the
  LocalMavenRepository instance.
- This change does not include the necessary changes to the callers
  (e.g. MavenMirrorRequest) which need to take special care to set the
  status on the output stream (cf. p2 bug TODO).

Bug: 397355
Bug: 393004
Change-Id: I3f76571121168f4a348dba704c2c3d18a41c90be