/** * Sends an HTTP POST request to the specified URI. * * @param uri The request URI * @param base An Abdera FOM Document or Element object providing the payload of the request * @param options The request options */ public ClientResponse post(String uri, Base base, RequestOptions options) { if (base instanceof Document) { Document d = (Document)base; if (options.getSlug() == null && d.getSlug() != null) options.setSlug(d.getSlug()); } return execute("POST", uri, new BaseRequestEntity(base, options.isUseChunked()), options); }
/** * Sends an HTTP PUT request to the specified URI. * * @param uri The request URI * @param base A FOM Document or Element providing the payload of the request * @param options The request options */ public ClientResponse put(String uri, Base base, RequestOptions options) { if (options == null) options = getDefaultRequestOptions(); if (base instanceof Document) { Document d = (Document)base; if (options.getSlug() == null && d.getSlug() != null) options.setSlug(d.getSlug()); if (options.isConditionalPut()) { if (d.getEntityTag() != null) options.setIfMatch(d.getEntityTag()); else if (d.getLastModified() != null) options.setIfUnmodifiedSince(d.getLastModified()); } } return execute("PUT", uri, new BaseRequestEntity(base, options.isUseChunked()), options); }
private static void toJson(Document document, JSONStream jstream) throws IOException { jstream.startObject(); jstream.writeField("base", document.getBaseUri()); jstream.writeField("content-type", document.getContentType()); jstream.writeField("etag", document.getEntityTag()); jstream.writeField("language", document.getLanguage()); jstream.writeField("slug", document.getSlug()); jstream.writeField("last-modified", document.getLastModified()); Element root = document.getRoot(); if (root != null) { String rootname = root.getQName().getLocalPart(); writeElement(rootname, document.getRoot(), jstream); } jstream.endObject(); }