本文整理汇总了Java中com.google.api.client.http.json.JsonHttpContent类的典型用法代码示例。如果您正苦于以下问题:Java JsonHttpContent类的具体用法?Java JsonHttpContent怎么用?Java JsonHttpContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonHttpContent类属于com.google.api.client.http.json包,在下文中一共展示了JsonHttpContent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: signInWithCustomToken
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的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
示例2: createThumbnail
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的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
示例3: postRequest
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
protected <E> E postRequest(String path, Object body, Class<E> responseType){
try {
URI uri = uri(path);
GenericUrl url = new GenericUrl(uri);
if ( logger.isDebugEnabled() ){
logger.debug("Request POSTed into botframework api " + uri + ":");
logger.debug(JSON_FACTORY.toPrettyString(body));
}
HttpContent content = new JsonHttpContent(JSON_FACTORY,body);
HttpRequest request = requestFactory.buildPostRequest(url,content);
E response = (E) request.execute().parseAs(responseType);
if ( logger.isDebugEnabled() ){
logger.debug("Response back from botframework api:");
logger.debug(JSON_FACTORY.toPrettyString(response));
}
return response;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:bots4j,项目名称:msbotframework,代码行数:22,代码来源:ConnectorClient.java
示例4: postRequestAsync
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
protected Future<HttpResponse> postRequestAsync(String path, Object body){
try {
URI uri = uri(path);
GenericUrl url = new GenericUrl();
if ( logger.isDebugEnabled() ){
logger.debug("Request POSTed into botframework api " + uri + ":");
logger.debug(JSON_FACTORY.toPrettyString(body));
}
HttpContent content = new JsonHttpContent(JSON_FACTORY,body);
HttpRequest request = requestFactory.buildPostRequest(url,content);
if ( this.executor != null ){
return request.executeAsync(this.executor);
}
else{
return request.executeAsync();
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:bots4j,项目名称:msbotframework,代码行数:22,代码来源:ConnectorClient.java
示例5: post
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <T> T post(String path, Object request, Type responseType)
throws RepoException, ValidationException {
HttpRequestFactory requestFactory = getHttpRequestFactory(getCredentials());
GenericUrl url = new GenericUrl(URI.create(API_URL + "/" + path));
try {
HttpRequest httpRequest = requestFactory.buildPostRequest(url,
new JsonHttpContent(JSON_FACTORY, request));
HttpResponse response = httpRequest.execute();
return (T) response.parseAs(responseType);
} catch (IOException e) {
throw new RepoException("Error running GitHub API operation " + path, e);
}
}
开发者ID:google,项目名称:copybara,代码行数:17,代码来源:GitHubApiTransportImpl.java
示例6: requestUploadLocation
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
private String requestUploadLocation(java.io.File fileToUpload, String mimeType, HttpRequestFactory requestFactory, com.google.api.services.drive.model.File remoteFile) throws IOException {
GenericUrl initializationUrl = new GenericUrl("https://www.googleapis.com/upload/drive/v2/files");
initializationUrl.put("uploadType", "resumable");
HttpRequest httpRequest = createHttpRequest(requestFactory, HttpMethods.POST, initializationUrl, new JsonHttpContent(DriveFactory.getJsonFactory(), remoteFile));
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.put("X-Upload-Content-Type", mimeType);
httpHeaders.put("X-Upload-Content-Length", fileToUpload.length());
httpRequest.getHeaders().putAll(httpHeaders);
LOGGER.log(Level.FINE, "Executing initial upload location request.");
HttpResponse httpResponse = executeHttpRequest(httpRequest);
if(!httpResponse.isSuccessStatusCode()) {
throw new IOException("Request for upload location was not successful. Status-Code: " + httpResponse.getStatusCode());
}
String location = httpResponse.getHeaders().getLocation();
LOGGER.log(Level.FINE, "URL for resumable upload: " + location);
return location;
}
开发者ID:siom79,项目名称:jdrivesync,代码行数:18,代码来源:ResumableUpload.java
示例7: createFolder
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public OneDriveItem createFolder(OneDriveItem parent, File target) throws IOException {
WriteFolderFacet newFolder = new WriteFolderFacet(target.getName());
HttpRequest request = requestFactory.buildPostRequest(
OneDriveUrl.children(parent.getId()),
new JsonHttpContent(JSON_FACTORY, newFolder));
Item response = request.execute().parseAs(Item.class);
OneDriveItem item = OneDriveItem.FACTORY.create(response);
// Set the remote timestamps
BasicFileAttributes attr = Files.readAttributes(target.toPath(), BasicFileAttributes.class);
item = updateFile(item, new Date(attr.creationTime().toMillis()), new Date(attr.lastModifiedTime().toMillis()));
return item;
}
开发者ID:wooti,项目名称:onedrive-java-client,代码行数:18,代码来源:RWOneDriveProvider.java
示例8: create
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public boolean create(String name, String rules) throws VaultException {
Map<String, Object> data = new HashMap<>();
data.put("rules", rules);
HttpContent content = new JsonHttpContent(getJsonFactory(), data);
try {
HttpRequest request = getRequestFactory().buildRequest(
"POST",
new GenericUrl(getConf().getAddress() + "/v1/sys/policy/" + name),
content
);
HttpResponse response = request.execute();
if (!response.isSuccessStatusCode()) {
LOG.error("Request failed status: {} message: {}", response.getStatusCode(), response.getStatusMessage());
}
return response.isSuccessStatusCode();
} catch (IOException e) {
LOG.error(e.toString(), e);
throw new VaultException("Failed to authenticate: " + e.toString(), e);
}
}
开发者ID:streamsets,项目名称:datacollector,代码行数:24,代码来源:Policy.java
示例9: putDroplets
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public void putDroplets(String userName, List<Droplet> droplets) throws Exception {
try {
System.out.println("Perform droplet search ....");
HttpRequestFactory httpRequestFactory = createRequestFactory(transport);
HttpContent content = new JsonHttpContent(new JacksonFactory(), droplets);
HttpRequest request = httpRequestFactory.buildPostRequest(
new GenericUrl(DROPLET_POST_URL + userName),
content);
HttpResponse response = request.execute();
System.out.println(response.getStatusCode());
} catch (HttpResponseException e) {
System.err.println(e.getStatusMessage());
throw e;
}
}
开发者ID:ZanyGnu,项目名称:GeoNote,代码行数:19,代码来源:DropletServer.java
示例10: Post
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
protected Post(AnalyzeInput input) {
super(AmbiverseApiClient.this,
"POST",
PATH,
new JsonHttpContent(AmbiverseApiClient.this.getJsonFactory(), input),
com.ambiverse.api.model.AnalyzeOutput.class);
}
开发者ID:ambi-verse,项目名称:nlu-api-client-java,代码行数:8,代码来源:AmbiverseApiClient.java
示例11: sendGCMSync
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public static boolean sendGCMSync(String userId, String senderId) {
if(Constants.GCM_API_KEY == null) {
log.info("GCM not set up, see readme for how to configure");
return false;
}
try {
GCMMessage message = new GCMMessage(userId);
log.info("message:" + message);
log.info("gson:" + gson.toJson(message));
GenericData body = new GenericData();
GenericData data = new GenericData();
body.put("to", "/topics/" + userId);
if(senderId != null) {
data.put("senderId",senderId);
body.put("data", data);
}
//why does this only take a generic map?
HttpRequest request = requestFactory.buildPostRequest(new GenericUrl(GCM_HOST),
new JsonHttpContent(gsonFactory, body))
.setUnsuccessfulResponseHandler(new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()))
.setHeaders(new HttpHeaders().setAuthorization("key=" + Constants.GCM_API_KEY));
request.getContent().writeTo(System.out);
HttpResponse response = request.execute();
log.info("response" + response);
return true;
} catch(IOException e) {
log.info("could not send http message:");
e.printStackTrace();
return false;
}
}
开发者ID:saucenet,项目名称:sync,代码行数:33,代码来源:Networker.java
示例12: post
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
@Override
public <T> T post(String path, Object request, Type responseType)
throws RepoException, ValidationException {
HttpRequestFactory requestFactory = getHttpRequestFactory(getCredentials(uri.toString()));
GenericUrl url = getUrl(path);
try {
return execute(responseType, requestFactory.buildPostRequest(
url, new JsonHttpContent(JSON_FACTORY, request)));
} catch (IOException e) {
throw new RepoException("Error running Gerrit API operation " + url, e);
}
}
开发者ID:google,项目名称:copybara,代码行数:13,代码来源:GerritApiTransportImpl.java
示例13: executeSessionInitiationRequest
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
private HttpResponse executeSessionInitiationRequest(Drive drive, File remoteFile) throws IOException {
GenericUrl url = new GenericUrl("https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable");
JsonHttpContent metadataContent = new JsonHttpContent(drive.getJsonFactory(), remoteFile);
HttpRequest httpRequest = drive.getRequestFactory().buildPostRequest(url, metadataContent);
LOGGER.log(Level.FINE, "Executing session initiation request to URL " + url);
return httpRequest.execute();
}
开发者ID:siom79,项目名称:jdrivesync,代码行数:8,代码来源:GoogleDriveAdapter.java
示例14: uploadFile
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public OneDriveItem uploadFile(OneDriveItem parent, File file) throws IOException {
if (!parent.isDirectory()) {
throw new IllegalArgumentException("Parent is not a folder");
}
// Generate the update item
BasicFileAttributes attr = Files.readAttributes(file.toPath(), BasicFileAttributes.class);
FileSystemInfoFacet fsi = new FileSystemInfoFacet();
fsi.setLastModifiedDateTime(JsonDateSerializer.INSTANCE.serialize(new Date(attr.lastModifiedTime().toMillis())));
fsi.setCreatedDateTime(JsonDateSerializer.INSTANCE.serialize(new Date(attr.creationTime().toMillis())));
WriteItemFacet itemToWrite = new WriteItemFacet(file.getName(), fsi, true, false);
MultipartContent content = new MultipartContent()
.addPart(new MultipartContent.Part(
new HttpHeaders()
.set("Content-ID", "<metadata>")
.setAcceptEncoding(null),
new JsonHttpContent(JSON_FACTORY, itemToWrite)))
.addPart(new MultipartContent.Part(
new HttpHeaders()
.set("Content-ID", "<content>")
.setAcceptEncoding(null),
new FileContent(null, file)));
HttpRequest request = requestFactory.buildPostRequest(
OneDriveUrl.postMultiPart(parent.getId()), content);
request.setLoggingEnabled(true);
return OneDriveItem.FACTORY.create(request.execute().parseAs(Item.class));
}
开发者ID:wooti,项目名称:onedrive-java-client,代码行数:33,代码来源:RWOneDriveProvider.java
示例15: startUploadSession
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
@Override
public OneDriveUploadSession startUploadSession(OneDriveItem parent, File file) throws IOException {
HttpRequest request = requestFactory.buildPostRequest(
OneDriveUrl.createUploadSession(parent.getId(), file.getName()),
new JsonHttpContent(JSON_FACTORY, new UploadSessionFacet(file.getName())));
UploadSession session = request.execute().parseAs(UploadSession.class);
return new OneDriveUploadSession(parent, file, session.getUploadUrl(), session.getNextExpectedRanges());
}
开发者ID:wooti,项目名称:onedrive-java-client,代码行数:12,代码来源:RWOneDriveProvider.java
示例16: updateFile
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public OneDriveItem updateFile(OneDriveItem item, Date createdDate, Date modifiedDate) throws IOException {
FileSystemInfoFacet fileSystem = new FileSystemInfoFacet();
fileSystem.setCreatedDateTime(JsonDateSerializer.INSTANCE.serialize(createdDate));
fileSystem.setLastModifiedDateTime(JsonDateSerializer.INSTANCE.serialize(modifiedDate));
WriteItemFacet updateItem = new WriteItemFacet(item.getName(), fileSystem, false, item.isDirectory());
HttpRequest request = requestFactory.buildPatchRequest(
OneDriveUrl.item(item.getId()),
new JsonHttpContent(JSON_FACTORY, updateItem));
Item response = request.execute().parseAs(Item.class);
return OneDriveItem.FACTORY.create(response);
}
开发者ID:wooti,项目名称:onedrive-java-client,代码行数:16,代码来源:RWOneDriveProvider.java
示例17: write
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public Secret write(String path, Map<String, Object> params) throws VaultException {
HttpContent content = new JsonHttpContent(
getJsonFactory(),
params
);
return getSecret("/v1/" + path, "POST", content);
}
开发者ID:streamsets,项目名称:datacollector,代码行数:8,代码来源:Logical.java
示例18: enable
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public boolean enable(String path, String type, String description) throws VaultException {
Map<String, Object> data = new HashMap<>();
data.put("type", type);
if (description != null) {
data.put("description", description);
}
HttpContent content = new JsonHttpContent(getJsonFactory(), data);
try {
HttpRequest request = getRequestFactory().buildRequest(
"POST",
new GenericUrl(getConf().getAddress() + "/v1/sys/auth/" + path),
content
);
HttpResponse response = request.execute();
if (!response.isSuccessStatusCode()) {
LOG.error("Request failed status: {} message: {}", response.getStatusCode(), response.getStatusMessage());
}
return response.isSuccessStatusCode();
} catch (IOException e) {
LOG.error(e.toString(), e);
throw new VaultException("Failed to authenticate: " + e.toString(), e);
}
}
开发者ID:streamsets,项目名称:datacollector,代码行数:28,代码来源:Auth.java
示例19: mount
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public boolean mount(String path, String type, String description, Map<String, String> config) throws VaultException {
Map<String, Object> data = new HashMap<>();
data.put("type", type);
if (description != null) {
data.put("description", description);
}
if (config != null) {
data.put("config", config);
}
HttpContent content = new JsonHttpContent(getJsonFactory(), data);
try {
HttpRequest request = getRequestFactory().buildRequest(
"POST",
new GenericUrl(getConf().getAddress() + "/v1/sys/mounts/" + path),
content
);
HttpResponse response = request.execute();
if (!response.isSuccessStatusCode()) {
LOG.error("Request failed status: {} message: {}", response.getStatusCode(), response.getStatusMessage());
}
return response.isSuccessStatusCode();
} catch (IOException e) {
LOG.error(e.toString(), e);
throw new VaultException("Failed to authenticate: " + e.toString(), e);
}
}
开发者ID:streamsets,项目名称:datacollector,代码行数:32,代码来源:Mounts.java
示例20: appRole
import com.google.api.client.http.json.JsonHttpContent; //导入依赖的package包/类
public Secret appRole(String roleId, String secretId) throws VaultException {
HttpContent content = new JsonHttpContent(
getJsonFactory(),
ImmutableMap.of("role_id", roleId, "secret_id", secretId)
);
return getSecret("/v1/auth/approle/login", "POST", content);
}
开发者ID:streamsets,项目名称:datacollector,代码行数:8,代码来源:Authenticate.java
注:本文中的com.google.api.client.http.json.JsonHttpContent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论