本文整理了Java中org.restlet.Response.setStatus
方法的一些代码示例,展示了Response.setStatus
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.setStatus
方法的具体详情如下:
包路径:org.restlet.Response
类名称:Response
方法名:setStatus
[英]Sets the status.
[中]设置状态。
代码示例来源:origin: uber/chaperone
@Override
@Delete
public Representation delete() {
final String topicName = (String) getRequest().getAttributes().get("topicName");
if (_autoTopicWhitelistingManager != null) {
_autoTopicWhitelistingManager.addIntoBlacklist(topicName);
}
if (!_helixMirrorMakerManager.isTopicExisted(topicName)) {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation(
String.format("Failed to delete not existed topic: %s", topicName));
}
try {
_helixMirrorMakerManager.deleteTopicInMirrorMaker(topicName);
return new StringRepresentation(
String.format("Successfully finished delete topic: %s", topicName));
} catch (Exception e) {
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
LOGGER.error("Failed to delete topic: {}, with exception: {}", topicName, e);
return new StringRepresentation(
String.format("Failed to delete topic: %s, with exception: %s", topicName, e));
}
}
代码示例来源:origin: uber/chaperone
return new StringRepresentation(responseJson.toJSONString());
} else {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation(String
.format("Failed to get ExternalView for topic: %s, it is not existed!", topicName));
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation(String
.format("Failed to get ExternalView for topic: %s, with exception: %s", topicName, e));
代码示例来源:origin: uber/chaperone
@Override
@Put("json")
public Representation put(Representation entity) {
try {
String jsonRequest = entity.getText();
TopicPartition topicPartitionInfo = TopicPartition.init(jsonRequest);
if (_autoTopicWhitelistingManager != null) {
_autoTopicWhitelistingManager.removeFromBlacklist(topicPartitionInfo.getTopic());
}
if (_helixMirrorMakerManager.isTopicExisted(topicPartitionInfo.getTopic())) {
_helixMirrorMakerManager.expandTopicInMirrorMaker(topicPartitionInfo);
return new StringRepresentation(
String.format("Successfully expand topic: %s", topicPartitionInfo));
} else {
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation(String.format(
"Failed to expand topic, topic: %s is not existed!", topicPartitionInfo.getTopic()));
}
} catch (IOException e) {
LOGGER.error("Got error during processing Put request", e);
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation(
String.format("Failed to expand topic, with exception: %s", e));
}
}
代码示例来源:origin: uber/chaperone
getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return new StringRepresentation(String.format(
"Failed to add new topic: %s, it is already existed!", topicPartitionInfo.getTopic()));
getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
return new StringRepresentation(
String.format("Failed to add new topic, with exception: %s", e));
代码示例来源:origin: org.restlet.osgi/org.restlet
@Override
public void handle(Request request, Response response) {
response.setStatus(Status.CLIENT_ERROR_NOT_FOUND,
"No virtual host could handle the request");
}
};
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Permanently redirects the client to a target URI. The client is expected
* to reuse the same method for the new request.
*
* @param targetRef
* The target URI reference.
*/
public void redirectPermanent(Reference targetRef) {
setLocationRef(targetRef);
setStatus(Status.REDIRECTION_PERMANENT);
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Sets the status.
*
* @param status
* The status to set (code and reason phrase).
* @param description
* The longer status description.
*/
public void setStatus(Status status, String description) {
setStatus(new Status(status, description));
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Sets the status.
*
* @param status
* The status to set.
* @param throwable
* The related error or exception.
*/
public void setStatus(Status status, Throwable throwable) {
setStatus(new Status(status, throwable));
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Temporarily redirects the client to a target URI. The client is expected
* to reuse the same method for the new request.
*
* @param targetRef
* The target reference.
*/
public void redirectTemporary(Reference targetRef) {
setLocationRef(targetRef);
setStatus(Status.REDIRECTION_TEMPORARY);
}
代码示例来源:origin: icclab/cyclops
public Response prepareResponse(Response response, boolean withEnvelope) {
if (response == null || status == null || description == null) return null;
// fill status with description and make sure entity is of type JSON
response.setStatus(status, description);
Gson gson = new Gson();
if (!withEnvelope && result != null) response.setEntity(gson.toJson(result), MEDIA_TYPE);
else response.setEntity(gson.toJson(this), MEDIA_TYPE);
return response;
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.apispark
@Override
protected int thresholdReached(Request request, Response response,
CounterResult counterResult) {
Context.getCurrentLogger().log(
Level.FINE,
"The current request has been blocked because \""
+ counterResult.getCountedValue()
+ "\" issued too many requests.");
response.setStatus(Status.CLIENT_ERROR_TOO_MANY_REQUESTS);
return Filter.SKIP;
}
代码示例来源:origin: org.restlet.gae/org.restlet.ext.platform
@Override
protected int thresholdReached(Request request, Response response,
CounterResult counterResult) {
Context.getCurrentLogger().log(
Level.FINE,
"The current request has been blocked because \""
+ counterResult.getCountedValue()
+ "\" issued too many requests.");
response.setStatus(Status.CLIENT_ERROR_TOO_MANY_REQUESTS);
return Filter.SKIP;
}
代码示例来源:origin: org.restlet.jse/org.restlet.ext.platform
@Override
protected int thresholdReached(Request request, Response response,
CounterResult counterResult) {
Context.getCurrentLogger().log(
Level.FINE,
"The current request has been blocked because \""
+ counterResult.getCountedValue()
+ "\" issued too many requests.");
response.setStatus(Status.CLIENT_ERROR_TOO_MANY_REQUESTS);
return Filter.SKIP;
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.platform
@Override
protected int thresholdReached(Request request, Response response,
CounterResult counterResult) {
Context.getCurrentLogger().log(
Level.FINE,
"The current request has been blocked because \""
+ counterResult.getCountedValue()
+ "\" issued too many requests.");
response.setStatus(Status.CLIENT_ERROR_TOO_MANY_REQUESTS);
return Filter.SKIP;
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth
private int sendErrorPage(Response response, Exception ex) {
response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST, ex.getMessage());
response.setEntity(getErrorPage(ex));
return STOP;
}
代码示例来源:origin: org.metaeffekt.dcc/dcc-agent-core
@Override
public void handle(Request request, Response response) {
LOG.debug("MethodRouter [{}] received request method: [{}]"
, uriPattern, request.getMethod());
Restlet target = routes.get(request.getMethod());
if (target != null) {
target.handle(request, response);
} else {
LOG.debug("No route for request method: [{}]", request.getMethod());
response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
}
}
代码示例来源:origin: apache/attic-polygene-java
private void put( Request request, Response response )
{
execute( request, response, resource -> {
T value = convertToObject( identityType, request );
resource.put( value );
response.setStatus( Status.SUCCESS_OK );
} );
}
代码示例来源:origin: org.restlet.jse/org.restlet.example
@Override
public void challenge(Response response, boolean stale) {
// Load the FreeMarker template
Representation ftl = new ClientResource(
LocalReference.createClapReference(getClass().getPackage())
+ "/Login.ftl").get();
// Wraps the bean with a FreeMarker representation
response.setEntity(new TemplateRepresentation(ftl, response
.getRequest().getResourceRef(), MediaType.TEXT_HTML));
response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
}
代码示例来源:origin: org.restlet.osgi/org.restlet.ext.oauth
@Override
protected void doCatch(Throwable t) {
final OAuthException oex = OAuthException.toOAuthException(t);
// XXX: Generally, we only communicate with TokenVerifier. So we don't
// need HTTP 400 code.
// getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
getResponse().setStatus(Status.SUCCESS_OK);
getResponse().setEntity(responseErrorRepresentation(oex));
}
代码示例来源:origin: apache/attic-polygene-java
private void post( final Request request, final Response response )
{
execute( request, response, resource -> {
RestForm form = createRestForm( request );
RestLink link = resource.post( form );
response.setLocationRef( link.path().get() );
response.setStatus( Status.REDIRECTION_SEE_OTHER );
} );
}
内容来源于网络,如有侵权,请联系作者删除!