本文整理汇总了Java中org.apache.http.HttpStatus.SC_NOT_FOUND属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.SC_NOT_FOUND属性的具体用法?Java HttpStatus.SC_NOT_FOUND怎么用?Java HttpStatus.SC_NOT_FOUND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.SC_NOT_FOUND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendConnectionErrorMessage
public static void sendConnectionErrorMessage(IDiscordClient client, IChannel channel, String command, @Nullable String message, @NotNull HttpStatusException httpe) throws RateLimitException, DiscordException, MissingPermissionsException {
@NotNull String problem = message != null ? message + "\n" : "";
if (httpe.getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE) {
problem += "Service unavailable, please try again latter.";
} else if (httpe.getStatusCode() == HttpStatus.SC_FORBIDDEN) {
problem += "Acess dennied.";
} else if (httpe.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
problem += "Not Found";
} else {
problem += httpe.getStatusCode() + SPACE + httpe.getMessage();
}
new MessageBuilder(client)
.appendContent("Error during HTTP Connection ", MessageBuilder.Styles.BOLD)
.appendContent("\n")
.appendContent(EventManager.MAIN_COMMAND_NAME, MessageBuilder.Styles.BOLD)
.appendContent(SPACE)
.appendContent(command, MessageBuilder.Styles.BOLD)
.appendContent("\n")
.appendContent(problem, MessageBuilder.Styles.BOLD)
.withChannel(channel)
.send();
}
示例2: shouldRetryGetStatus
private boolean shouldRetryGetStatus(WebClientOutput output, String frameworkName) {
if (output.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
// Specified Framework's Status does not exist.
// This may due to specified Framework is not Requested or
// the Framework Requested but the Status has not been initialized by backend.
// So, the Client is expected to retry for the latter case.
try {
getFrameworkRequest(frameworkName);
return true;
} catch (Exception e) {
return false;
}
} else {
// At last, consider all UNKNOWN Failure as NON_TRANSIENT
return false;
}
}
示例3: isVersioningEnabled
@Override
public boolean isVersioningEnabled() throws StorageAdapterException {
// Try to get the versions of a random (made up) file.
// There are 3 possible scenarios:
// a) versioning is enabled, and the file exsists, so the call will succeed without error
// b) versioning is enabled and the file does NOT exist. We'll get a 404 NOT FOUND returned
// c) versioning is not enabled, regardless whether the file exists or not, we'll get a 400
// BAD REQUEST
try {
ArcMoverDirectory dir = getVersions("/HCP_dummy_filename_used_by_Data_Migrator_may_or_may_not_exist");
dir.getFileListIterator(true, true);
return true;
} catch (StorageAdapterException e) {
Integer statusCode = e.getStatusCode();
if (statusCode != null && statusCode == HttpStatus.SC_BAD_REQUEST) { // 400
return false;
} else if (statusCode != null && statusCode == HttpStatus.SC_NOT_FOUND) { // 404
return true;
} else {
throw e;
}
}
}
示例4: deleteShortUrl
/**
* This method deletes the url for code
*
* @param code
*/
public void deleteShortUrl(String code) {
try {
// get the object
ObjectMetadata metaData = this.s3Client.getObjectMetadata(this.bucket, code);
String url = metaData.getUserMetaDataOf("url");
logger.info("The url to be deleted {}", url);
this.s3Client.deleteObject(this.bucket, code);
this.s3Client.deleteObject(this.bucket + "-dummy", code + Base64.encodeBase64String(url.getBytes()));
} catch (AmazonS3Exception ex) {
if (ex.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
return;
}
logger.warn("Unable to get object status", ex);
throw ex;
}
}
示例5: fetchPage
public Page<URI, Artifact> fetchPage(URI uri)
throws ClientProtocolException, IOException, URISyntaxException, ParseException, NotOkResponseException {
HttpGet request = new HttpGet(uri);
try (CloseableHttpResponse response = this.client.execute(request)) {
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
return new Page<>(Optional.empty(), Collections.emptyList());
}
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
throw new NotOkResponseException(
String.format("Service response not ok %s %s %s", response.getStatusLine(),
response.getAllHeaders(), EntityUtils.toString(response.getEntity())));
}
Document document = Jsoup.parse(EntityUtils.toString(response.getEntity()), uri.toString());
Optional<URI> next = Optional.empty();
Elements nexts = document.select(".search-nav li:last-child a[href]");
if (!nexts.isEmpty()) {
next = Optional.of(new URI(nexts.first().attr("abs:href")));
}
List<Artifact> artifacts = document.select(".im .im-subtitle").stream()
.map(element -> new DefaultArtifact(element.select("a:nth-child(1)").first().text(),
element.select("a:nth-child(2)").first().text(), null, null))
.collect(Collectors.toList());
return new Page<>(next, artifacts);
}
}
示例6: waitForServerReady
/**
* Wait for the server is ready.
*/
private void waitForServerReady() throws IOException, InterruptedException {
final HttpGet httpget = new HttpGet(getPingUri());
HttpResponse response = new BasicHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_FOUND, ""));
int counter = 0;
while (true) {
try {
response = httpclient.execute(httpget);
final int status = response.getStatusLine().getStatusCode();
if (status == HttpStatus.SC_OK) {
break;
}
checkRetries(counter);
} catch (final HttpHostConnectException ex) { // NOSONAR - Wait, and check later
log.info("Check failed, retrying...");
checkRetries(counter);
} finally {
EntityUtils.consume(response.getEntity());
}
counter++;
}
}
示例7: isFileExisting
/**
* A method that returns true if a correct s3 URI was provided and false otherwise.
*
* @param uri The provided URI for the file.
* @return a boolean value that shows whether the correct URI was provided
*/
boolean isFileExisting(AmazonS3URI uri) {
boolean exist = true;
try {
aws.getObjectMetadata(uri.getBucket(), uri.getKey());
} catch (AmazonS3Exception e) {
if (e.getStatusCode() == HttpStatus.SC_FORBIDDEN
|| e.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
exist = false;
} else {
throw e;
}
}
return exist;
}
示例8: checkBatchResponseBody
/**
* 不正な認証情報を使用してすべてのユーザがread可能なコレクションに対して$batchをした場合処理が受付けられること.
* batchの実行順
* 1.POST(登録)
* 2.GET(一覧取得)
* 3.GET(取得)
* 4.PUT(更新)
* 5.DELETE(削除)
*/
@Test
public final void 不正な認証情報を使用してすべてのユーザがread可能なコレクションに対して$batchをした場合処理が受付けられること() {
// 認証トークン取得
String invalidToken = "invalid token";
// ACL設定
String path = String.format("%s/%s/%s", TEST_CELL1, BOX_NAME, COL_NAME);
DavResourceUtils.setACLPrincipalAll(TEST_CELL1, MASTER_TOKEN, HttpStatus.SC_OK,
path, "<D:read />", "");
// READ→OK WRITE→403
TResponse res = UserDataUtils.batch(TEST_CELL1, BOX_NAME, COL_NAME, BOUNDARY, TEST_BODY,
invalidToken, HttpStatus.SC_ACCEPTED);
// 期待するレスポンスコード
int[] expectedCodes = new int[] {HttpStatus.SC_FORBIDDEN,
HttpStatus.SC_OK,
HttpStatus.SC_NOT_FOUND,
HttpStatus.SC_FORBIDDEN,
HttpStatus.SC_FORBIDDEN };
// レスポンスボディのチェック(ステータス)
checkBatchResponseBody(res, expectedCodes);
}
示例9: getInstanceInfo
@Override
public Response getInstanceInfo(UUID instanceUUID, SecurityContext securityContext) throws NotFoundException {
InstanceStatus stat = ctx.instanceManager().getInstanceStatus(instanceUUID);
if (stat != null) {
return Response.ok().entity(stat).build();
} else {
throw new NotFoundException(HttpStatus.SC_NOT_FOUND, "Instance not found");
}
}
示例10: getInstanceState
@Override
public Response getInstanceState(UUID instanceUUID, SecurityContext securityContext) throws NotFoundException {
InstanceState state = ctx.instanceManager().getInstanceState(instanceUUID);
if (state != null) {
return Response.ok().entity(state).build();
} else {
throw new NotFoundException(HttpStatus.SC_NOT_FOUND, "Instance not found");
}
}
示例11: toResponse
@Override
public Response toResponse(Exception e) {
// Don't catch this as filter forward on 404
// (ServletContainer.FEATURE_FILTER_FORWARD_ON_404)
// won't work and the web UI won't work!
if (e instanceof com.sun.jersey.api.NotFoundException) {
return ((com.sun.jersey.api.NotFoundException) e).getResponse();
}
// clear content type
response.setContentType(null);
// Map response status
String logPrefix = "Http request failed due to: ";
final int statusCode;
if (e instanceof NotFoundException) {
LOGGER.logInfo(e, logPrefix + "Not Found");
statusCode = HttpStatus.SC_NOT_FOUND;
} else if (e instanceof BadRequestException ||
e instanceof JsonProcessingException ||
e instanceof WebApplicationException) {
LOGGER.logInfo(e, logPrefix + "Bad Request");
statusCode = HttpStatus.SC_BAD_REQUEST;
} else if (e instanceof ThrottledRequestException) {
LOGGER.logInfo(e, logPrefix + "Throttled Request");
statusCode = WebCommon.SC_TOO_MANY_REQUESTS;
} else {
LOGGER.logWarning(e, logPrefix + "Service Unavailable");
statusCode = HttpStatus.SC_SERVICE_UNAVAILABLE;
}
// let jaxb handle marshalling data out in the same format requested
RemoteExceptionData exception = new RemoteExceptionData(
e.getClass().getSimpleName(),
StringUtils.stringifyException(e),
e.getClass().getName());
return Response.status(statusCode).entity(exception)
.build();
}
示例12: getObjectCode
private String getObjectCode() {
while (true) {
String code = Util.generate();
try {
this.s3Client.getObjectMetadata(this.bucket, code);
} catch (AmazonS3Exception ex) {
if (ex.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
return code;
}
logger.warn("Unable to get object status", ex);
throw ex;
}
}
}
示例13: map
public BackgroundException map(final Throwable failure, final StringBuilder buffer, final int statusCode) {
switch(statusCode) {
case HttpStatus.SC_UNAUTHORIZED:
return new LoginFailureException(buffer.toString(), failure);
case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
return new ProxyLoginFailureException(buffer.toString(), failure);
case HttpStatus.SC_FORBIDDEN:
case HttpStatus.SC_NOT_ACCEPTABLE:
return new AccessDeniedException(buffer.toString(), failure);
case HttpStatus.SC_CONFLICT:
return new ConflictException(buffer.toString(), failure);
case HttpStatus.SC_NOT_FOUND:
case HttpStatus.SC_GONE:
case HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE:
return new NotfoundException(buffer.toString(), failure);
case HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE:
case HttpStatus.SC_INSUFFICIENT_STORAGE:
case HttpStatus.SC_PAYMENT_REQUIRED:
return new QuotaException(buffer.toString(), failure);
case HttpStatus.SC_UNPROCESSABLE_ENTITY:
case HttpStatus.SC_BAD_REQUEST:
case HttpStatus.SC_REQUEST_URI_TOO_LONG:
case HttpStatus.SC_METHOD_NOT_ALLOWED:
case HttpStatus.SC_NOT_IMPLEMENTED:
return new InteroperabilityException(buffer.toString(), failure);
case HttpStatus.SC_REQUEST_TIMEOUT:
case HttpStatus.SC_GATEWAY_TIMEOUT:
case HttpStatus.SC_BAD_GATEWAY:
return new ConnectionTimeoutException(buffer.toString(), failure);
case HttpStatus.SC_INTERNAL_SERVER_ERROR:
case HttpStatus.SC_SERVICE_UNAVAILABLE:
case 429:
// Too Many Requests. Rate limiting
case 509:
// Bandwidth Limit Exceeded
return new RetriableAccessDeniedException(buffer.toString(), failure);
default:
return new InteroperabilityException(buffer.toString(), failure);
}
}
示例14: handleWebApplicationException
private Response handleWebApplicationException(final WebApplicationException webappException) {
Response res = webappException.getResponse();
if (HttpStatus.SC_METHOD_NOT_ALLOWED == res.getStatus()) {
return this.handlePersoniumCoreException(PersoniumCoreException.Misc.METHOD_NOT_ALLOWED);
} else if (HttpStatus.SC_NOT_FOUND == res.getStatus()) {
return this.handlePersoniumCoreException(PersoniumCoreException.Misc.NOT_FOUND);
}
return res;
}
示例15: NotFoundException
public NotFoundException(String msg) {
super(HttpStatus.SC_NOT_FOUND, msg);
}