Beispiel #1
0
 public boolean saveFile(DocumentFile df) throws IOException {
   HttpResponse response = core.post(getFileUrl(df), SerializationUtils.toJson(df));
   int code = response.getStatusLine().getStatusCode();
   if (code == HttpStatus.SC_OK || code == HttpStatus.SC_NO_CONTENT) {
     EntityUtils.consume(response.getEntity());
     return true;
   } else {
     logUnexpected(response);
     return false;
   }
 }
Beispiel #2
0
 private String getFileUrl(String fileName, Object docid) throws UnsupportedEncodingException {
   return fileUrl
       + "&"
       + RemotePipeline.FILENAME_PARAM
       + "="
       + fileName
       + "&"
       + RemotePipeline.DOCID_PARAM
       + "="
       + URLEncoder.encode(SerializationUtils.toJson(docid), "UTF-8");
 }
Beispiel #3
0
  @SuppressWarnings("unchecked")
  public List<String> getFileNames(Object docid) throws IOException {
    HttpResponse response =
        core.get(
            fileUrl
                + "&"
                + RemotePipeline.DOCID_PARAM
                + "="
                + URLEncoder.encode(SerializationUtils.toJson(docid), "UTF-8"));

    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
      try {
        return (List<String>)
            SerializationUtils.toObject(EntityUtils.toString(response.getEntity()));
      } catch (JsonException e) {
        throw new IOException(e);
      }
    } else {
      logUnexpected(response);
      return null;
    }
  }