/******************************************************************************* * Copyright (c) 2012-2013 University of Stuttgart. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * and the Apache License 2.0 which both accompany this distribution, * and are available at http://www.eclipse.org/legal/epl-v10.html * and http://www.apache.org/licenses/LICENSE-2.0 *******************************************************************************/ /* * Modifications Copyright 2016-2017 ZTE Corporation. */ /** * This class wraps HTTP-Method functionality and thereby abstracts from low * level code to simplify the usage. */ package org.opentosca.bpel4restlight.rest; import org.apache.commons.httpclient.HttpMethodBase; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.methods.DeleteMethod; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHeaders; public class HighLevelRestApi { protected static final Log log = LogFactory.getLog(HighLevelRestApi.class); /** * This method implements the HTTP Put Method * * @param uri * Resource URI * @param requestPayload * Content which has to be put into the Resource * @return ResponseCode of HTTP Interaction */ @SuppressWarnings("deprecation") public static HttpResponseMessage Put(String uri, String requestPayload, String acceptHeaderValue, String contentTypeHeader) { PutMethod method = new PutMethod(uri); // requestPayload = "" + // requestPayload; HighLevelRestApi.setHeader(method, acceptHeaderValue, contentTypeHeader); method.setRequestBody(requestPayload); HttpResponseMessage responseMessage = LowLevelRestApi.executeHttpMethod(method); // kill ", ""); responseMessage.setResponseBody(temp); } } }