當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpStatus.SC_NOT_FOUND屬性代碼示例

本文整理匯總了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();
}
 
開發者ID:ViniciusArnhold,項目名稱:ProjectAltaria,代碼行數:23,代碼來源:EventUtils.java

示例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;
  }
}
 
開發者ID:Microsoft,項目名稱:pai,代碼行數:17,代碼來源:LauncherClientInternal.java

示例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;
        }
    }
}
 
開發者ID:Hitachi-Data-Systems,項目名稱:Open-DM,代碼行數:23,代碼來源:Hcp5AuthNamespaceAdapter.java

示例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;
	}

}
 
開發者ID:weblegit,項目名稱:urlshortner,代碼行數:23,代碼來源:UrlShortnerService.java

示例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);
	}
}
 
開發者ID:maenu,項目名稱:kowalski,代碼行數:25,代碼來源:Dependent.java

示例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++;
	}
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:24,代碼來源:AbstractRestTest.java

示例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;
}
 
開發者ID:epam,項目名稱:htsjdk-s3-plugin,代碼行數:22,代碼來源:S3Client.java

示例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);

}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:33,代碼來源:AuthBatchTest.java

示例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");
  }
}
 
開發者ID:uber,項目名稱:AthenaX,代碼行數:9,代碼來源:InstancesApiServiceImpl.java

示例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");
  }
}
 
開發者ID:uber,項目名稱:AthenaX,代碼行數:9,代碼來源:InstancesApiServiceImpl.java

示例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();
}
 
開發者ID:Microsoft,項目名稱:pai,代碼行數:39,代碼來源:LauncherExceptionHandler.java

示例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;
		}
	}
}
 
開發者ID:weblegit,項目名稱:urlshortner,代碼行數:14,代碼來源:UrlShortnerService.java

示例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);
    }
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:40,代碼來源:HttpResponseExceptionMappingService.java

示例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;
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:9,代碼來源:PersoniumCoreExceptionMapper.java

示例15: NotFoundException

public NotFoundException(String msg) {
    super(HttpStatus.SC_NOT_FOUND, msg);
}
 
開發者ID:wu191287278,項目名稱:sc-generator,代碼行數:3,代碼來源:NotFoundException.java


注:本文中的org.apache.http.HttpStatus.SC_NOT_FOUND屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。