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;
 }
  /** Harvests all the triplets from each URI in the @rdfUris list */
  private void harvestFromDumps() {
    for (String uri : rdfUris) {
      if (uri.isEmpty()) continue;

      logger.info("Harvesting uri [{}]", uri);

      Model model = ModelFactory.createDefaultModel();
      try {
        RDFDataMgr.read(model, uri.trim(), RDFLanguages.RDFXML);
        BulkRequestBuilder bulkRequest = client.prepareBulk();
        addModelToES(model, bulkRequest, true);
      } catch (RiotException re) {
        logger.error("Illegal xml character [{}]", re.getLocalizedMessage());
      } catch (Exception e) {
        logger.error(
            "Exception when harvesting url: {}. Details: {}", uri, e.getLocalizedMessage());
      }
    }
  }