本文整理汇总了Java中org.jclouds.http.HttpResponse类的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse类的具体用法?Java HttpResponse怎么用?Java HttpResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpResponse类属于org.jclouds.http包,在下文中一共展示了HttpResponse类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldRetryRequest
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public boolean shouldRetryRequest(final HttpCommand command, final HttpResponse response) {
command.incrementFailureCount();
byte[] data = closeClientButKeepContentStream(response);
String message = data != null ? new String(data) : null;
// Do not retry client errors that are not retryable errors
if (response.getStatusCode() != 400 &&
(!message.contains("RESOURCE_BUSY") || !message.contains("UNEXPECTED_ERROR"))) {
return false;
} else if (!command.isReplayable()) {
logger.error("Cannot retry after server error, command is not replayable: %1$s", command);
return false;
} else if (command.getFailureCount() > retryCountLimit) {
logger.error("Cannot retry after server error, command has exceeded retry limit %1$d: %2$s", retryCountLimit,
command);
return false;
} else {
imposeBackoffExponentialDelay(command.getFailureCount(), "server error: " + command.toString());
return true;
}
}
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:23,代码来源:DimensionDataCloudControllerRetryHandler.java
示例2: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public void apply(String virtualMachineId) {
// try to workaround jcloud issue
// https://issues.apache.org/jira/browse/JCLOUDS-1155
try {
jcloudsDeleteVirtualMachineStrategy.apply(virtualMachineId);
} catch (org.jclouds.http.HttpResponseException e) {
final HttpResponse response = e.getResponse();
if (response.getStatusCode() == 400) {
if (e.getContent().contains("Security Group") && e.getContent()
.contains("in use")) {
//silently error error
return;
}
}
throw e;
}
}
开发者ID:cloudiator,项目名称:sword,代码行数:19,代码来源:OpenstackDeleteVirtualMachineStrategy.java
示例3: generatePutTempURL
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
private void generatePutTempURL() throws IOException {
System.out.format("Generate PUT Temp URL%n");
// Create the Payload
String data = "This object will be public for 10 minutes.";
ByteSource source = ByteSource.wrap(data.getBytes());
Payload payload = Payloads.newByteSourcePayload(source);
// Create the Blob
Blob blob = blobStore.blobBuilder(FILENAME).payload(payload).contentType("text/plain").build();
HttpRequest request = blobStoreContext.getSigner(REGION).signPutBlob(CONTAINER, blob, TEN_MINUTES);
System.out.format(" %s %s%n", request.getMethod(), request.getEndpoint());
// PUT the file using jclouds
HttpResponse response = blobStoreContext.utils().http().invoke(request);
int statusCode = response.getStatusCode();
if (statusCode >= 200 && statusCode < 299) {
System.out.format(" PUT Success (%s)%n", statusCode);
}
else {
throw new HttpResponseException(null, response);
}
}
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:26,代码来源:GenerateTempURL.java
示例4: generateDeleteTempURL
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
private void generateDeleteTempURL() throws IOException {
System.out.format("Generate DELETE Temp URL%n");
HttpRequest request = blobStoreContext.getSigner(REGION).signRemoveBlob(CONTAINER, FILENAME);
System.out.format(" %s %s%n", request.getMethod(), request.getEndpoint());
// DELETE the file using jclouds
HttpResponse response = blobStoreContext.utils().http().invoke(request);
int statusCode = response.getStatusCode();
if (statusCode >= 200 && statusCode < 299) {
System.out.format(" DELETE Success (%s)%n", statusCode);
}
else {
throw new HttpResponseException(null, response);
}
}
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:19,代码来源:GenerateTempURL.java
示例5: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public MutableBlobProperties apply(HttpResponse response) {
StringWriter writer = new StringWriter();
MutableBlobProperties properties = null;
try {
IOUtils.copy(response.getPayload().getInput(), writer);
String theString = writer.toString();
properties = mapper.readValue(theString, MutableBlobProperties.class);
} catch (IOException e) {
System.out.println(response.getMessage());
e.printStackTrace();
}
return properties;
}
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:17,代码来源:MetadataResponseParser.java
示例6: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public Blob apply(HttpResponse response) {
final StringWriter writer = new StringWriter();
MutableBlobProperties properties = null;
try {
IOUtils.copy(response.getPayload().getInput(), writer);
final String theString = writer.toString();
properties = this.mapper.readValue(theString, MutableBlobProperties.class);
final OrionBlob orionBlob = this.orionBlobProvider.create(properties);
if (properties.getType() == BlobType.FILE_BLOB) {
final HttpResponse payloadRes = this.api.getBlobContents(getOrionUtils().getUserWorkspace(), properties.getContainer(),
properties.getParentPath(), properties.getName());
orionBlob.setPayload(payloadRes.getPayload());
}
return this.orionBlob2Blob.apply(orionBlob);
} catch (final IOException e) {
System.out.println(response.getMessage());
e.printStackTrace();
}
return null;
}
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:25,代码来源:BlobResponseParser.java
示例7: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public RequestStatus apply(final HttpResponse input) {
final int statusCode = input.getStatusCode();
if (statusCode >= 200 && statusCode < 400) {
return RequestStatus.create(true, null);
} else {
throw new RuntimeException(input.getStatusLine());
}
}
开发者ID:cdancy,项目名称:bitbucket-rest,代码行数:10,代码来源:RequestStatusParser.java
示例8: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public RawContent apply(final HttpResponse input) {
try (final InputStream inputStream = input.getPayload().openStream()) {
final String value = Strings2.toStringAndClose(inputStream);
return RawContent.create(value, null);
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
开发者ID:cdancy,项目名称:bitbucket-rest,代码行数:10,代码来源:RawContentParser.java
示例9: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public RequestStatus apply(final HttpResponse input) {
final int statusCode = input.getStatusCode();
if (statusCode >= 200 && statusCode < 400) {
if (statusCode == 204) {
throw new ResourceNotFoundException("The repository does not exist in this project.");
} else {
return RequestStatus.create(true, null);
}
} else {
throw new RuntimeException(input.getStatusLine());
}
}
开发者ID:cdancy,项目名称:bitbucket-rest,代码行数:14,代码来源:DeleteRepositoryParser.java
示例10: parseMessage
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
private String parseMessage(final HttpCommand command, final HttpResponse response) {
if (response.getPayload() != null) {
try {
return Strings2.toStringAndClose(response.getPayload().openStream());
} catch (IOException e) {
throw Throwables.propagate(e);
}
} else {
return new StringBuffer(command.getCurrentRequest().getRequestLine())
.append(" -> ")
.append(response.getStatusLine())
.toString();
}
}
开发者ID:cdancy,项目名称:bitbucket-rest,代码行数:15,代码来源:BitbucketErrorHandler.java
示例11: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public Boolean apply(HttpResponse response) {
if (String.valueOf(response.getStatusCode()).startsWith("2")) {
return true;
}
return false;
}
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:8,代码来源:FileExistsResponseParser.java
示例12: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public PageSet<? extends StorageMetadata> apply(HttpResponse res) {
final List<OrionStorageMetadata> storageDataList = Lists.transform(this.folderListParser.apply(res),
this.childMetadataToStorageMetadata);
return new OrionPageSet(storageDataList);
}
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:8,代码来源:ListContainersResponseParser.java
示例13: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public Boolean apply(HttpResponse response) {
if ((response.getStatusCode() == 200) || (response.getStatusCode() == 201)) {
return true;
} else {
return false;
}
}
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:9,代码来源:CreationResponseParser.java
示例14: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public Boolean apply(HttpResponse res) {
if (res.getStatusLine().startsWith("4")) {
return false;
} else if (res.getStatusLine().startsWith("2")) {
JsonObject responseObject = (JsonObject) (new JsonParser()).parse(res.getMessage());
if (responseObject.get("Directory").getAsBoolean()) {
return true;
}
}
return false;
}
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:13,代码来源:FolderMetadataResponseParser.java
示例15: OrionResponseException
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
/**
* @param command
* @param response
*/
public OrionResponseException(HttpCommand command, HttpResponse response, OrionError error) {
super(command, response);
orionError = error;
}
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:10,代码来源:OrionResponseException.java
示例16: apply
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
@Override
public List<OrionChildMetadata> apply(HttpResponse res) {
return listMetadata2ChildrenList.apply(res);
}
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:5,代码来源:FolderListResposeParser.java
示例17: formLogin
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
/**
* Form authentication request
*
* @param userName
* @param pass
* @return
*/
@POST
@Path(OrionConstantValues.ORION_AUTH_PATH)
@Headers(keys = { OrionHttpFields.IGNORE_AUTHENTICATION, OrionHttpFields.ORION_VERSION_FIELD }, values = { "",
OrionConstantValues.ORION_VERSION })
HttpResponse formLogin(@FormParam(value = OrionHttpFields.USERNAME) String userName,
@FormParam(value = OrionHttpFields.PASSWORD) String pass);
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:14,代码来源:OrionApi.java
示例18: getBlobContents
import org.jclouds.http.HttpResponse; //导入依赖的package包/类
/**
* This method is used to get the blob contents
*
* @param userWorkspace
* @param containerName
* @param parentPath
* @param blob
* @return
*/
@GET
@Path(OrionConstantValues.ORION_FILE_PATH + "{userWorkspace}/{containerName}/{parentPath}{blobName}")
@Headers(keys = { OrionHttpFields.ORION_VERSION_FIELD }, values = { OrionConstantValues.ORION_VERSION })
HttpResponse getBlobContents(@PathParam("userWorkspace") String userWorkspace,
@PathParam("containerName") String containerName,
@PathParam("parentPath") @ParamParser(EncodeBlobParentPathParamParser.class) String parentPath,
@PathParam("blobName") @ParamParser(EncodeBlobNameParamParser.class) String blob);
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:17,代码来源:OrionApi.java
注:本文中的org.jclouds.http.HttpResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论