protected void replaceResourceWithStream(
      final FedoraResource resource,
      final InputStream requestBodyStream,
      final MediaType contentType,
      final RdfStream resourceTriples)
      throws MalformedRdfException {
    final Lang format = contentTypeToLang(contentType.toString());

    final Model inputModel = createDefaultModel();
    try {
      inputModel.read(
          requestBodyStream, getUri(resource).toString(), format.getName().toUpperCase());

    } catch (final RiotException e) {
      throw new BadRequestException("RDF was not parsable: " + e.getMessage(), e);

    } catch (final RuntimeIOException e) {
      if (e.getCause() instanceof JsonParseException) {
        throw new MalformedRdfException(e.getCause());
      }
      throw new RepositoryRuntimeException(e);
    }

    resource.replaceProperties(translator(), inputModel, resourceTriples);
  }
 /**
  * Try Read content returned by text/plain
  *
  * @param uri
  * @return
  */
 private Model tryRead(String uri) {
   Model m = ModelFactory.createDefaultModel();
   try {
     m = RDFDataMgr.loadModel(uri, Lang.NTRIPLES);
   } catch (RiotException r) {
     Log.debug("Resource could not be parsed:", r.getMessage());
   }
   return m;
 }