本文整理匯總了Java中org.springframework.extensions.webscripts.connector.HttpMethod類的典型用法代碼示例。如果您正苦於以下問題:Java HttpMethod類的具體用法?Java HttpMethod怎麽用?Java HttpMethod使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HttpMethod類屬於org.springframework.extensions.webscripts.connector包,在下文中一共展示了HttpMethod類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: remoteCall
import org.springframework.extensions.webscripts.connector.HttpMethod; //導入依賴的package包/類
private void remoteCall(HttpServletRequest request, JSONObject auditSample) throws JSONException, URIException,
UnsupportedEncodingException {
Connector connector;
try {
connector = FrameworkUtil.getConnector(request.getSession(true), auditSample.getString(AUDIT_USER_ID),
AlfrescoUserFactory.ALFRESCO_ENDPOINT_ID);
ConnectorContext postContext = new ConnectorContext(null, buildDefaultHeaders());
postContext.setMethod(HttpMethod.POST);
postContext.setContentType("text/plain;charset=UTF-8");
InputStream in = new ByteArrayInputStream(auditSample.toString().getBytes("UTF-8"));
// Webscript call
connector.call("/share-stats/insert-audit", postContext, in);
} catch (ConnectorServiceException e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
}
}
示例2: remoteCall
import org.springframework.extensions.webscripts.connector.HttpMethod; //導入依賴的package包/類
private void remoteCall(HttpServletRequest request, JSONObject auditSample) throws JSONException, URIException,
UnsupportedEncodingException {
Connector connector;
try {
connector = FrameworkUtil.getConnector(request.getSession(true), auditSample.getString(AUDIT_USER_ID),
AlfrescoUserFactory.ALFRESCO_ENDPOINT_ID);
// if (parameters == null), we use the 'inputstream'
// The webscript is called with the audit converted into JSON.
ConnectorContext postContext = new ConnectorContext(null, buildDefaultHeaders());
postContext.setMethod(HttpMethod.POST);
postContext.setContentType("text/plain;charset=UTF-8");
InputStream in = new ByteArrayInputStream(auditSample.toString().getBytes("UTF-8"));
// Webscript call
connector.call("/share-stats/insert-audit", postContext, in);
} catch (ConnectorServiceException e) {
if (logger.isDebugEnabled()) {
logger.debug(e.getMessage(), e);
}
}
}
示例3: retrieveFormDefinition
import org.springframework.extensions.webscripts.connector.HttpMethod; //導入依賴的package包/類
/**
* Retrieves the form definition from the repository FormService for the
* given item.
*
* @param itemKind The form item kind
* @param itemId The form item id
* @param visibleFields The list of field names to return or null
* to return all fields
* @param formConfig The form configuration
* @return Response object from the remote call
*/
protected Response retrieveFormDefinition(String itemKind, String itemId,
List<String> visibleFields, FormConfigElement formConfig)
{
Response response = null;
try
{
// setup the connection
ConnectorService connService = FrameworkUtil.getConnectorService();
RequestContext requestContext = ThreadLocalRequestContext.getRequestContext();
String currentUserId = requestContext.getUserId();
HttpSession currentSession = ServletUtil.getSession(true);
Connector connector = connService.getConnector(ENDPOINT_ID, currentUserId, currentSession);
ConnectorContext context = new ConnectorContext(HttpMethod.POST, null, buildDefaultHeaders());
context.setContentType("application/json");
// call the form service
response = connector.call("/api/formdefinitions", context, generateFormDefPostBody(itemKind,
itemId, visibleFields, formConfig));
if (logger.isDebugEnabled())
logger.debug("Response status: " + response.getStatus().getCode());
}
catch (Exception e)
{
if (logger.isErrorEnabled())
logger.error("Failed to get form definition: ", e);
}
return response;
}