• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java GenericUrl类的典型用法代码示例

java 13次浏览

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

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

示例1: deleteInstanceId

点赞 4

import com.google.api.client.http.GenericUrl; //导入依赖的package包/类
private Task<Void> deleteInstanceId(final String instanceId) {
  checkArgument(!Strings.isNullOrEmpty(instanceId), "instance ID must not be null or empty");
  return ImplFirebaseTrampolines.submitCallable(app, new Callable<Void>(){
    @Override
    public Void call() throws Exception {
      String url = String.format(
          "%s/project/%s/instanceId/%s", IID_SERVICE_URL, projectId, instanceId);
      HttpRequest request = requestFactory.buildDeleteRequest(new GenericUrl(url));
      request.setParser(new JsonObjectParser(jsonFactory));
      request.setResponseInterceptor(interceptor);
      HttpResponse response = null;
      try {
        response = request.execute();
        ByteStreams.exhaust(response.getContent());
      } catch (Exception e) {
        handleError(instanceId, e);
      } finally {
        if (response != null) {
          response.disconnect();
        }
      }
      return null;
    }
  });
}
 

开发者ID:firebase,
项目名称:firebase-admin-java
代码行数:26,
代码来源:FirebaseInstanceId.java

示例2: signInWithCustomToken

点赞 4

import com.google.api.client.http.GenericUrl; //导入依赖的package包/类
private String signInWithCustomToken(String customToken) throws IOException {
  GenericUrl url = new GenericUrl(ID_TOOLKIT_URL + "?key="
      + IntegrationTestUtils.getApiKey());
  Map<String, Object> content = ImmutableMap.<String, Object>of(
      "token", customToken, "returnSecureToken", true);
  HttpRequest request = transport.createRequestFactory().buildPostRequest(url,
      new JsonHttpContent(jsonFactory, content));
  request.setParser(new JsonObjectParser(jsonFactory));
  HttpResponse response = request.execute();
  try {
    GenericJson json = response.parseAs(GenericJson.class);
    return json.get("idToken").toString();
  } finally {
    response.disconnect();
  }
}
 

开发者ID:firebase,
项目名称:firebase-admin-java
代码行数:17,
代码来源:FirebaseAuthIT.java

示例3: getPublicKeysJson

点赞 3

import com.google.api.client.http.GenericUrl; //导入依赖的package包/类
/**
 *
 * @return
 * @throws IOException
 */
private JsonObject getPublicKeysJson() throws IOException {
    // get public keys
    URI uri = URI.create(pubKeyUrl);
    GenericUrl url = new GenericUrl(uri);
    HttpTransport http = new NetHttpTransport();
    HttpResponse response = http.createRequestFactory().buildGetRequest(url).execute();

    // store json from request
    String json = response.parseAsString();
    // disconnect
    response.disconnect();

    // parse json to object
    JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();

    return jsonObject;
}
 

开发者ID:rvep,
项目名称:dev_backend,
代码行数:23,
代码来源:FirebaseAuthVerifier.java

示例4: createThumbnail

点赞 3

import com.google.api.client.http.GenericUrl; //导入依赖的package包/类
/**
 * Richiede ad Alfresco la creazione di una <i>thumbnail</i>.
 * <p>
 * Si tenga presente che in caso di creazione asincrona la <i>thumbnail</i> potrebbe non essere
 * subito disponibile anche se il metodo ha restituito informazioni valide.
 * 
 * @param pContentId
 *            L'id del contenuto.
 * @param pThumbDefinition
 *            Il nome della <i>thumbnail</i> di cui si richiede la crezione.
 * @param pAsync
 *            Se la crazione deve essere sincrona ({@code true} o asincrona ({@false}).
 * 
 * @return La <i>thumbnail</i> richiesta o {@code null} se il tipo di <i>thumbnail</i> di cui si
 *         è richiesta la creazione non è valido per il contenuto specificato.
 * 
 * @throws IOException
 */
public Thumbnail createThumbnail(String pContentId, String pThumbDefinition, boolean pAsync) throws IOException {
	/*
	 * POST <base>/content{property}/thumbnails?as={async?}
	 * 
	 * {
	 *     "thumbnailName": <name>
	 * }
	 */
	GenericUrl lUrl = getContentUrl(pContentId);
	lUrl.appendRawPath(URL_RELATIVE_THUMBNAILS);
	lUrl.set("as", pAsync);

	// Recupero delle definizioni valide
	// Purtroppo Alfresco restituisce successo anche se viene richiesta la generazione di una
	// thumbnail non possibile. Controllando preventivamente si può restituire null.
	List<String> lThumbDefinitions = getThumbnailDefinitions(pContentId);
	if (!lThumbDefinitions.contains(pThumbDefinition)) {
		return null;
	}

	JsonHttpContent lContent = new JsonHttpContent(JSON_FACTORY, new Thumbnail(pThumbDefinition));

	HttpHeaders lRequestHeaders = new HttpHeaders().setContentType("application/json");
	HttpRequest lRequest =
	        mHttpRequestFactory.buildPostRequest(lUrl, lContent).setHeaders(lRequestHeaders);

	HttpResponse lResponse = lRequest.execute();
	Thumbnail lThumbnail = lResponse.parseAs(Thumbnail.class);

	return lThumbnail;
}
 

开发者ID:MakeITBologna,
项目名称:zefiro,
代码行数:50,
代码来源:NodeService.java

示例5: initiateResumableUpload

点赞 3

import com.google.api.client.http.GenericUrl; //导入依赖的package包/类
/**
 * Initiate a resumable upload direct to the cloud storage API. Providing an origin will enable
 * CORS requests to the upload URL from the specified origin.
 *
 * @param bucket      the cloud storage bucket to upload to
 * @param name        the name of the resource that will be uploaded
 * @param contentType the resource's content/mime type
 * @param origin      the origin to allow for CORS requests
 * @return the upload URL
 * @see <a href="https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload">Performing a Resumable Upload</a>
 */
public String initiateResumableUpload(String bucket, String name, String contentType, String origin) {
    String uploadUrl = String.format("%s/upload/storage/v1/b/%s/o", BASE_GOOGLE_API_URL, bucket);

    GenericUrl url = new GenericUrl(uploadUrl);
    url.put("uploadType", "resumable");
    url.put("name", name);

    HttpHeaders headers = new HttpHeaders();
    headers.put("X-Upload-Content-Type", contentType);
    if (origin != null) {
        headers.put("Origin", origin);  // Add origin header for CORS support
    }

    HttpResponse response;
    try {
        response = httpRequestFactory
            .buildPostRequest(url, null)
            .setHeaders(headers)
            .execute();
    } catch (IOException e) {
        throw new GoogleCloudStorageException(e, "Cannot initiate upload: %s", e.getMessage());
    }

    return response.getHeaders().getLocation();
}
 

开发者ID:3wks,
项目名称:generator-thundr-gae-react,
代码行数:37,
代码来源:GoogleCloudStorageJsonApiClient.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)