本文整理匯總了Java中org.eclipse.jetty.http.HttpStatus.OK_200屬性的典型用法代碼示例。如果您正苦於以下問題:Java HttpStatus.OK_200屬性的具體用法?Java HttpStatus.OK_200怎麽用?Java HttpStatus.OK_200使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.eclipse.jetty.http.HttpStatus
的用法示例。
在下文中一共展示了HttpStatus.OK_200屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseSendirResponse
private void parseSendirResponse(final ContentResponse response) {
final String responseContent = response.getContentAsString();
if ((responseContent == null) || responseContent.isEmpty()) {
throw new CommunicationException("Empty response received!");
}
if (responseContent.startsWith(SENDIR_SUCCESS)) {
return;
}
if (responseContent.startsWith(SENDIR_BUSY)) {
throw new DeviceBusyException("Device is busy!");
}
if ((response.getStatus() != HttpStatus.OK_200) || responseContent.startsWith(SENDIR_ERROR)) {
throw new CommunicationException(String.format("Failed to send IR code: %s", responseContent));
}
}
示例2: rawRequest
protected String rawRequest(String url, Map<String, String> params) throws InterruptedException, ExecutionException, TimeoutException, UnsupportedEncodingException {
Request req = httpClient.newRequest(new String(url.getBytes("UTF-8"), "UTF-8"))
.header(HttpHeader.CONTENT_ENCODING, "UTF-8")
.method(HttpMethod.GET)
.header(HttpHeader.ACCEPT_ENCODING, "UTF-8");
req = req.param("app_token", APIKeys.getAPPKey());
if (params != null) {
for (String key : params.keySet()) {
req = req.param(key, params.get(key));
}
}
Main.log.info("GET {}, {}, {}", req, req.getQuery(), req.getParams());
ContentResponse resp = req.send();
if (resp.getStatus() != HttpStatus.OK_200) {
throw new HttpRequestException(
"Request ended with non-OK status: "
+ HttpStatus.getMessage(resp.getStatus()),
resp.getRequest()
);
}
return resp.getContentAsString();
}
示例3: getRun
@GET
@Path("/{runId}")
@UnitOfWork
@ApiOperation(value = "Get a specific run")
@ApiResponses({
@ApiResponse(code = HttpStatus.OK_200, response = RunApiEntity.class, message = "OK"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, response = ErrorMessage.class, message = "Not found"),
@ApiResponse(
code = HttpStatus.CONFLICT_409,
response = ErrorMessage.class,
message = "Event ID and Run ID are mismatched"
)
})
public RunApiEntity getRun(
@PathParam("eventId") @ApiParam(value = "Event ID", required = true) String eventId,
@PathParam("runId") @ApiParam(value = "Run ID", required = true) String runId
) throws EntityMismatchException, EntityNotFoundException {
Run domainRun = runEntityService.getByEventIdAndRunId(eventId, runId);
return runMapper.toApiEntity(domainRun);
}
示例4: getRegistration
@GET
@Path("/{registrationId}")
@UnitOfWork
@ApiOperation(value = "Get a specific registration")
@ApiResponses({
@ApiResponse(code = HttpStatus.OK_200, response = RegistrationApiEntity.class, message = "OK"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, response = ErrorMessage.class, message = "Not found"),
@ApiResponse(
code = HttpStatus.CONFLICT_409,
response = ErrorMessage.class,
message = "Event ID and Registration ID are mismatched"
)
})
public RegistrationApiEntity getRegistration(
@PathParam("eventId") @ApiParam(value = "Event ID", required = true) String eventId,
@PathParam("registrationId") @ApiParam(value = "Registration ID", required = true) String registrationId
) throws EntityMismatchException, EntityNotFoundException {
Registration domainRegistration = eventRegistrationService.getByEventIdAndRegistrationId(
eventId,
registrationId
);
return registrationMapper.toApiEntity(domainRegistration);
}
示例5: addHandicapGroupToHandicapGroupSet
@POST
@Path("/{handicapGroupSetId}/handicapGroups/{handicapGroupId}")
@UnitOfWork
@ApiOperation(value = "Add a Handicap Group to a Handicap Group Set", response = HandicapGroupSetApiEntity.class)
@ApiResponses({
@ApiResponse(code = HttpStatus.OK_200, response = HandicapGroupSetApiEntity.class, message = "OK"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, response = ErrorMessage.class, message = "Not found"),
})
public HandicapGroupSetApiEntity addHandicapGroupToHandicapGroupSet(
@PathParam("handicapGroupSetId") @ApiParam(value = "Handicap Group Set ID", required = true)
String handicapGroupSetId,
@PathParam("handicapGroupId") @ApiParam(value = "Handicap Group ID", required = true)
String handicapGroupId
) throws EntityNotFoundException {
HandicapGroupSet domainSetEntity = handicapGroupSetService.getById(handicapGroupSetId);
HandicapGroup domainEntity = handicapGroupEntityService.getById(handicapGroupId);
handicapGroupSetService.addToHandicapGroups(domainSetEntity, domainEntity);
return handicapGroupSetMapper.toApiEntity(domainSetEntity);
}
示例6: addCompetitionGroupToCompetitionGroupSet
@POST
@Path("/{competitionGroupSetId}/competitionGroups/{competitionGroupId}")
@UnitOfWork
@ApiOperation(
value = "Add a Competition Group to a Competition Group Set",
response = CompetitionGroupSetApiEntity.class
)
@ApiResponses({
@ApiResponse(code = HttpStatus.OK_200, response = CompetitionGroupSetApiEntity.class, message = "OK"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, response = ErrorMessage.class, message = "Not found"),
})
public CompetitionGroupSetApiEntity addCompetitionGroupToCompetitionGroupSet(
@PathParam("competitionGroupSetId") @ApiParam(value = "Competition Group Set ID", required = true)
String competitionGroupSetId,
@PathParam("competitionGroupId") @ApiParam(value = "Competition Group ID", required = true)
String competitionGroupId
) throws EntityNotFoundException {
CompetitionGroupSet domainSetEntity = competitionGroupSetService.getById(competitionGroupSetId);
CompetitionGroup domainEntity = competitionGroupEntityService.getById(competitionGroupId);
competitionGroupSetService.addToCompetitionGroups(domainSetEntity, domainEntity);
return competitionGroupSetMapper.toApiEntity(domainSetEntity);
}
示例7: recycle
protected void recycle()
{
_status = HttpStatus.OK_200;
_reason = null;
_locale = null;
_mimeType = null;
_characterEncoding = null;
_contentType = null;
_outputType = OutputType.NONE;
_contentLength = -1;
_out.recycle();
_fields.clear();
_explicitEncoding=false;
}
示例8: getCACertificate
@Override
public String getCACertificate() {
ContentResponse response = null;
try {
response = httpClient.GET(x509CertUri);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOGGER.error("getCACertificate: unable to fetch requested uri '" + x509CertUri + "': "
+ e.getMessage());
return null;
}
if (response.getStatus() != HttpStatus.OK_200) {
LOGGER.error("getCACertificate: unable to fetch requested uri '" + x509CertUri +
"' status: " + response.getStatus());
return null;
}
String data = response.getContentAsString();
if (data == null || data.isEmpty()) {
LOGGER.error("getCACertificate: received empty response from uri '" + x509CertUri +
"' status: " + response.getStatus());
return null;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("getCACertificate: CA Certificate" + data);
}
X509CertSignObject pemCert = null;
try {
pemCert = JSON.fromString(data, X509CertSignObject.class);
} catch (Exception ex) {
LOGGER.error("getCACertificate: unable to decode object from '" + x509CertUri +
"' error: " + ex.getMessage());
}
return (pemCert != null) ? pemCert.getPem() : null;
}
示例9: getCompetitionGroup
@GET
@Path("/{competitionGroupId}")
@UnitOfWork
@ApiOperation(value = "Get a Competition Group", response = CompetitionGroupApiEntity.class)
@ApiResponses({
@ApiResponse(code = HttpStatus.OK_200, response = CompetitionGroupApiEntity.class, message = "OK"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, response = ErrorMessage.class, message = "Not found")
})
public CompetitionGroupApiEntity getCompetitionGroup(
@PathParam("competitionGroupId") @ApiParam(value = "Competition Group ID", required = true) String id
) throws EntityNotFoundException {
CompetitionGroup domainEntity = competitionGroupEntityService.getById(id);
return competitionGroupMapper.toApiEntity(domainEntity);
}
示例10: getEvent
@GET
@Path("/{eventId}")
@UnitOfWork
@ApiOperation(value = "Get an Event")
@ApiResponses({
@ApiResponse(code = HttpStatus.OK_200, response = EventApiEntity.class, message = "OK"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, response = ErrorMessage.class, message = "Not found")
})
public EventApiEntity getEvent(
@PathParam("eventId") @ApiParam(value = "Event ID", required = true) String id
) throws EntityNotFoundException {
Event domainEntity = eventEntityService.getById(id);
return eventMapper.toApiEntity(domainEntity);
}
示例11: getHandicapGroupSet
@GET
@Path("/{handicapGroupSetId}")
@UnitOfWork
@ApiOperation(value = "Get a Handicap Group Set", response = HandicapGroupSetApiEntity.class)
@ApiResponses({
@ApiResponse(code = HttpStatus.OK_200, response = HandicapGroupSetApiEntity.class, message = "OK"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, response = ErrorMessage.class, message = "Not found")
})
public HandicapGroupSetApiEntity getHandicapGroupSet(
@PathParam("handicapGroupSetId")
@ApiParam(value = "Handicap Group Set ID", required = true) String id
) throws EntityNotFoundException {
HandicapGroupSet domainEntity = handicapGroupSetService.getById(id);
return handicapGroupSetMapper.toApiEntity(domainEntity);
}
示例12: getCompetitionGroupSet
@GET
@Path("/{competitionGroupSetId}")
@UnitOfWork
@ApiOperation(value = "Get a Competition Group Set", response = CompetitionGroupSetApiEntity.class)
@ApiResponses({
@ApiResponse(code = HttpStatus.OK_200, response = CompetitionGroupSetApiEntity.class, message = "OK"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, response = ErrorMessage.class, message = "Not found")
})
public CompetitionGroupSetApiEntity getCompetitionGroupSet(
@PathParam("competitionGroupSetId")
@ApiParam(value = "Competition Group Set ID", required = true) String id
) throws EntityNotFoundException {
CompetitionGroupSet domainEntity = competitionGroupSetService.getById(id);
return competitionGroupSetMapper.toApiEntity(domainEntity);
}
示例13: getHandicapGroup
@GET
@Path("/{handicapGroupId}")
@UnitOfWork
@ApiOperation(value = "Get a Handicap Group", response = HandicapGroupApiEntity.class)
@ApiResponses({
@ApiResponse(code = HttpStatus.OK_200, response = HandicapGroupApiEntity.class, message = "OK"),
@ApiResponse(code = HttpStatus.NOT_FOUND_404, response = ErrorMessage.class, message = "Not found")
})
public HandicapGroupApiEntity getHandicapGroup(
@PathParam("handicapGroupId") @ApiParam(value = "Handicap Group ID", required = true) String id
) throws EntityNotFoundException {
HandicapGroup domainEntity = handicapGroupEntityService.getById(id);
return handicapGroupMapper.toApiEntity(domainEntity);
}
示例14: isAuthorised
@Override
public boolean isAuthorised(final ServiceUser serviceUser,
final DocRef docRef,
final String permissionName) {
Response response;
try {
final Map<String, Object> request = new HashMap<>();
request.put("docRef", new DocRef.Builder()
.uuid(docRef.getUuid())
.type(docRef.getType())
.build()); // stripping out the name
request.put("permission", permissionName);
response = httpClient
.target(this.isAuthorisedUrl)
.request()
.header("Authorization", "Bearer " + serviceUser.getJwt())
.post(Entity.json(request));
} catch (final Exception e) {
LOGGER.error("Could not request authorisation " + e.getLocalizedMessage());
return false;
}
boolean isUserAuthorised;
switch (response.getStatus()) {
case HttpStatus.UNAUTHORIZED_401:
isUserAuthorised = false;
break;
case HttpStatus.OK_200:
isUserAuthorised = true;
break;
case HttpStatus.NOT_FOUND_404:
isUserAuthorised = false;
LOGGER.error("Received a 404 when trying to access the authorisation service! I am unable to check authorisation so all requests will be rejected until this is fixed. Is the service location correctly configured? Is the service running? The URL I tried was: {}", this.isAuthorisedUrl);
break;
default:
isUserAuthorised = false;
LOGGER.error("Tried to check authorisation for a user but got an unknown response!",
response.getStatus());
}
return isUserAuthorised;
}
示例15: getSSHCertificate
@Override
public String getSSHCertificate(String type) {
ContentResponse response = null;
try {
response = httpClient.GET(sshCertUri);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
LOGGER.error("getSSHCertificate: unable to fetch requested uri '" + sshCertUri + "': "
+ e.getMessage());
return null;
}
if (response.getStatus() != HttpStatus.OK_200) {
LOGGER.error("getSSHCertificate: unable to fetch requested uri '" + sshCertUri +
"' status: " + response.getStatus());
return null;
}
String data = response.getContentAsString();
if (data == null || data.isEmpty()) {
LOGGER.error("getSSHCertificate: received empty response from uri '" + sshCertUri +
"' status: " + response.getStatus());
return null;
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("getSSHCertificate: SSH Certificate" + data);
}
SSHCertificates sshCerts = null;
try {
sshCerts = JSON.fromString(data, SSHCertificates.class);
} catch (Exception ex) {
LOGGER.error("getSSHCertificate: unable to decode object from '" + sshCertUri +
"' error: " + ex.getMessage());
return null;
}
if (sshCerts != null && sshCerts.getCerts() != null) {
for (SSHCertificate sshCert : sshCerts.getCerts()) {
if (sshCert.getType().equals(type)) {
return sshCert.getOpensshkey();
}
}
}
return null;
}