public OdlOnem2mHttpRequestPrimitiveBuilder setOperationCreate() { onem2mRequest.httpRequest.setMethod("post"); return this; } public OdlOnem2mHttpRequestPrimitiveBuilder setOperationRetrieve() {
public OdlOnem2mHttpRequestPrimitiveBuilder setOperationRetrieve() { onem2mRequest.httpRequest.setMethod("get"); return this; } public OdlOnem2mHttpRequestPrimitiveBuilder setOperationUpdate() {
public OdlOnem2mHttpRequestPrimitiveBuilder setOperationUpdate() { onem2mRequest.httpRequest.setMethod("put"); return this; } public OdlOnem2mHttpRequestPrimitiveBuilder setOperationDelete() {
public OdlOnem2mHttpRequestPrimitiveBuilder setOperationDelete() { onem2mRequest.httpRequest.setMethod("delete"); return this; } public OdlOnem2mHttpRequestPrimitiveBuilder setTo(String value) {
public void setMethod(String method) { ce.setMethod(method); }
@Override public Future<Document> execute() throws IOException { final SettableFuture<Document> future = SettableFuture.create(); ContentExchange exchange = new ContentExchange() { protected void onResponseComplete() throws IOException { super.onResponseComplete(); String responseContent = this.getResponseContent(); try { future.set(db.parse(new InputSource(responseContent))); } catch (SAXException e) { future.setException(e); } } }; exchange.setRequestHeader("Accept", "text/xml, application/xml"); exchange.setMethod("GET"); exchange.setURL(url.toExternalForm()); // start the exchange client.send(exchange); return future; } }
/** * HTTP notifications will be set out to subscribers interested in resources from the tree where they have have hung * onem2m subscription resources * @param url where do i send this onem2m notify message * @param payload contents of the notification */ @Override public void sendNotification(String url, String payload) { ContentExchange ex = new ContentExchange(); ex.setURL(url); ex.setRequestContentSource(new ByteArrayInputStream(payload.getBytes())); ex.setRequestContentType(Onem2m.ContentType.APP_VND_NTFY_JSON); Integer cl = payload != null ? payload.length() : 0; ex.setRequestHeader("Content-Length", cl.toString()); ex.setMethod("post"); LOG.debug("HTTP: Send notification uri: {}, payload: {}:", url, payload); try { client.send(ex); } catch (IOException e) { LOG.error("Dropping notification: uri: {}, payload: {}", url, payload); } }
exchange.setMethod("GET"); exchange.setURL(url.toString());
exchange.setMethod("POST"); exchange.setURL(url);
ex.setMethod(translateOperationToMethod(request.getPrimitive(RequestPrimitive.OPERATION)));