• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java EmptyContent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.api.client.http.EmptyContent的典型用法代码示例。如果您正苦于以下问题:Java EmptyContent类的具体用法?Java EmptyContent怎么用?Java EmptyContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EmptyContent类属于com.google.api.client.http包,在下文中一共展示了EmptyContent类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: serverErrorCallback

import com.google.api.client.http.EmptyContent; //导入依赖的package包/类
/**
 * {@link Beta} <br/>
 * The call back method that will be invoked on a server error or an I/O
 * exception during resumable upload inside {@link #upload}.
 *
 * <p>
 * This method changes the current request to query the current status of
 * the upload to find how many bytes were successfully uploaded before the
 * server error occurred.
 * </p>
 */
@Beta
void serverErrorCallback() throws IOException {
	Preconditions.checkNotNull(currentRequest,
			"The current request should not be null");

	// Query the current status of the upload by issuing an empty PUT
	// request on the upload URI.
	currentRequest.setContent(new EmptyContent());
	currentRequest
			.getHeaders()
			.setContentRange(
					"bytes */"
							+ (isMediaLengthKnown() ? getMediaContentLength()
									: "*"));
}
 
开发者ID:roikku,项目名称:drive-uploader,代码行数:27,代码来源:MediaHttpUploader.java


示例2: addChildToGroup

import com.google.api.client.http.EmptyContent; //导入依赖的package包/类
public static boolean addChildToGroup(HttpRequestFactory pHttpRequestFactory, AlfrescoConfig pConfig,
        String pStrGroupId, String pStrChildId) {
	mLog.debug("START addChildToGroup(String, String)");

	boolean lRet = false;

	GroupsUrl lUrl = new GroupsUrl(pConfig.getHost());
	lUrl.addChild(pStrGroupId, pStrChildId);
	try {
		// FIXME (Alessio): bisognerebbe trasferire altrove questo codice ripetitivo
		HttpHeaders lRequestHeaders = new HttpHeaders().setContentType("application/json");
		HttpRequest lRequest =
		        pHttpRequestFactory.buildPostRequest(lUrl, new EmptyContent()).setHeaders(lRequestHeaders);

		// TODO (Alessio): la risposta è completamente ignorata! Vanno gestiti i diversi casi
		// possibili.
		// L'implementazione dovrebbe prima controllare se l'utente è già parte del gruppo,
		// quindi eventualmente effettuare l'aggiunta.
		int lStatusCode = lRequest.execute().getStatusCode();
		if (200 <= lStatusCode && lStatusCode < 300) {
			lRet = true;
		}

	} catch (Exception e) {
		// TODO (Alessio): gestione decente delle eccezioni
		// mLog.error("Unexpected failure", e);
		lRet = false;
	}

	mLog.debug("END addChildToGroup(String, String)");
	return lRet;
}
 
开发者ID:MakeITBologna,项目名称:zefiro,代码行数:33,代码来源:AlfrescoHelper.java


示例3: executeUploadInitiation

import com.google.api.client.http.EmptyContent; //导入依赖的package包/类
/**
 * This method sends a POST request with empty content to get the unique
 * upload URL.
 *
 * @param initiationRequestUrl
 *            The request URL where the initiation request will be sent
 */
private HttpResponse executeUploadInitiation(GenericUrl initiationRequestUrl)
		throws IOException {
	updateStateAndNotifyListener(UploadState.INITIATION_STARTED);

	initiationRequestUrl.put("uploadType", "resumable");
	HttpContent content = metadata == null ? new EmptyContent() : metadata;
	HttpRequest request = requestFactory.buildRequest(
			initiationRequestMethod, initiationRequestUrl, content);
	initiationHeaders.set(CONTENT_TYPE_HEADER, mediaContent.getType());
	if (isMediaLengthKnown()) {
		initiationHeaders.set(CONTENT_LENGTH_HEADER,
				getMediaContentLength());
	}
	request.getHeaders().putAll(initiationHeaders);
	HttpResponse response = executeCurrentRequest(request);
	boolean notificationCompleted = false;

	try {
		updateStateAndNotifyListener(UploadState.INITIATION_COMPLETE);
		notificationCompleted = true;
	} finally {
		if (!notificationCompleted) {
			response.disconnect();
		}
	}
	return response;
}
 
开发者ID:roikku,项目名称:drive-uploader,代码行数:35,代码来源:MediaHttpUploader.java


示例4: executeCurrentRequest

import com.google.api.client.http.EmptyContent; //导入依赖的package包/类
/**
 * Executes the current request with some common code that includes
 * exponential backoff and GZip encoding.
 *
 * @param request
 *            current request
 * @return HTTP response
 */
private HttpResponse executeCurrentRequest(HttpRequest request)
		throws IOException {
	// enable GZip encoding if necessary
	if (!disableGZipContent
			&& !(request.getContent() instanceof EmptyContent)) {
		request.setEncoding(new GZipEncoding());
	}
	// execute request
	HttpResponse response = executeCurrentRequestWithoutGZip(request);
	return response;
}
 
开发者ID:roikku,项目名称:drive-uploader,代码行数:20,代码来源:MediaHttpUploader.java


示例5: buildHttpRequest

import com.google.api.client.http.EmptyContent; //导入依赖的package包/类
private HttpRequest buildHttpRequest() throws IOException {
	final HttpRequest httpRequest = getGracenote().getRequestFactory().buildRequest(HttpMethods.POST, buildHttpRequestUrl(), httpContent);
	httpRequest.setParser(getGracenote().getObjectParser());
	
	if (httpContent == null) {
		httpRequest.setContent(new EmptyContent());
	}
	
	return httpRequest;
}
 
开发者ID:bwgz,项目名称:gracenote,代码行数:11,代码来源:GracenoteRequest.java


示例6: initiateResumableUpload

import com.google.api.client.http.EmptyContent; //导入依赖的package包/类
/**
 * Initiates the resumable upload by sending a request to Google Cloud Storage.
 *
 * @param batchJobUploadUrl the {@code uploadUrl} of a {@code BatchJob}
 * @return the URI for the initiated resumable upload
 */
private URI initiateResumableUpload(URI batchJobUploadUrl) throws BatchJobException {
  // This follows the Google Cloud Storage guidelines for initiating resumable uploads:
  // https://cloud.google.com/storage/docs/resumable-uploads-xml
  HttpRequestFactory requestFactory =
      httpTransport.createRequestFactory(new HttpRequestInitializer() {
        @Override
        public void initialize(HttpRequest request) throws IOException {
          HttpHeaders headers = createHttpHeaders();
          headers.setContentLength(0L);
          headers.set("x-goog-resumable", "start");
          request.setHeaders(headers);
          request.setLoggingEnabled(true);
        }
      });

  try {
    HttpRequest httpRequest =
        requestFactory.buildPostRequest(new GenericUrl(batchJobUploadUrl), new EmptyContent());
    HttpResponse response = httpRequest.execute();
    if (response.getHeaders() == null || response.getHeaders().getLocation() == null) {
      throw new BatchJobException(
          "Initiate upload failed. Resumable upload URI was not in the response.");
    }
    return URI.create(response.getHeaders().getLocation());
  } catch (IOException e) {
    throw new BatchJobException("Failed to initiate upload", e);
  }
}
 
开发者ID:googleads,项目名称:googleads-java-lib,代码行数:35,代码来源:BatchJobUploader.java



注:本文中的com.google.api.client.http.EmptyContent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RestActions类代码示例发布时间:2022-05-22
下一篇:
Java AnnotationMap类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap