本文整理了Java中org.restlet.data.Response.setEntity
方法的一些代码示例,展示了Response.setEntity
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.setEntity
方法的具体详情如下:
包路径:org.restlet.data.Response
类名称:Response
方法名:setEntity
暂无
代码示例来源:origin: internetarchive/heritrix3
@Override
public void acceptRepresentation(Representation entity) throws ResourceException {
Form form = getRequest().getEntityAsForm();
chosenEngine = form.getFirstValue("engine");
String script = form.getFirstValue("script");
if(StringUtils.isBlank(script)) {
script="";
}
ScriptEngine eng = MANAGER.getEngineByName(chosenEngine);
scriptingConsole.bind("scriptResource", this);
scriptingConsole.execute(eng, script);
scriptingConsole.unbind("scriptResource");
//TODO: log script, results somewhere; job log INFO?
getResponse().setEntity(represent());
}
代码示例来源:origin: stackoverflow.com
Restlet sayHello = new Restlet() {
@Override
public void handle(Request request, Response response) {
response.setEntity("Hello World!", MediaType.TEXT_PLAIN);
}
};
new Server(Protocol.HTTP, 80, sayHello).start();
代码示例来源:origin: org.restlet/org.restlet
/**
* Sets the entity representation.
*
* @param entity
* The entity representation.
*/
@Override
public void setEntity(Representation entity) {
getWrappedResponse().setEntity(entity);
}
代码示例来源:origin: org.restlet/org.restlet
/**
* Sets a textual entity.
*
* @param value
* The represented string.
* @param mediaType
* The representation's media type.
*/
@Override
public void setEntity(String value, MediaType mediaType) {
getWrappedResponse().setEntity(value, mediaType);
}
代码示例来源:origin: org.geowebcache/gwc-rest
private void handleDoGet(Response response, TileLayer tl, boolean listAllTasks) {
response.setEntity(makeFormPage(tl, listAllTasks), MediaType.TEXT_HTML);
}
代码示例来源:origin: org.geoserver.community/gs-sfs
@Override
public void handleGet() {
Representation representation = new StringRepresentation(String.valueOf(count),
MediaType.TEXT_PLAIN);
getResponse().setEntity(representation);
}
}
代码示例来源:origin: stackoverflow.com
Component c = new Component();
c.getServers().add(Protocol.HTTP, 8182);
VirtualHost host = new VirtualHost();
host.setHostDomain("localhost");
c.getHosts().add(host);
host.attach(new Restlet() {
@Override
public void handle(Request request, Response response) {
response.setEntity("hello, world", MediaType.TEXT_PLAIN);
}
});
c.start();
代码示例来源:origin: stackoverflow.com
TemplateRoute route = component.getDefaultHost().attach(
"/test", new Restlet() {
@Override
public void handle(Request request, Response response) {
response.setEntity("test", MediaType.TEXT_PLAIN);
}
});
// Default matching mode
int defaultMatching = route.getMatchingMode();
// Set another matching mode
route.setMatchingMode(Template.MODE_EQUALS);
代码示例来源:origin: org.geowebcache/gwc-rest
private void handleKillThreadPost(Form form, TileLayer tl, Response resp) {
String id = form.getFirstValue("thread_id");
StringBuilder doc = new StringBuilder();
makeHeader(doc);
if (seeder.terminateGWCTask(Long.parseLong(id))) {
doc.append("<ul><li>Requested to terminate task " + id + ".</li></ul>");
} else {
doc.append("<ul><li>Sorry, either task "
+ id
+ " has not started yet, or it is a truncate task that cannot be interrutped.</li></ul>");
;
}
if (tl != null) {
doc.append("<p><a href=\"./" + tl.getName() + "\">Go back</a></p>\n");
}
resp.setEntity(doc.toString(), MediaType.TEXT_HTML);
}
代码示例来源:origin: org.restlet/org.restlet
@Override
protected void afterHandle(Request request, Response response) {
if (getMode() == MODE_RESPONSE) {
response.setEntity(transform(response.getEntity()));
}
}
代码示例来源:origin: org.geoserver.community/gs-sfs
@Override
public void handleGet() {
Representation represeentation = new DescribeJSONFormat().toRepresentation(featureType);
getResponse().setEntity(represeentation);
}
代码示例来源:origin: org.restlet/org.restlet.ext.xml
@Override
protected void afterHandle(Request request, Response response) {
if (getMode() == MODE_RESPONSE) {
response.setEntity(transform(response.getEntity()));
}
}
代码示例来源:origin: org.geoserver.community/gs-sfs
@Override
public void handleGet() {
Representation representation = new FeaturesJSONFormat().toRepresentation(features);
getResponse().setEntity(representation);
}
代码示例来源:origin: org.geoserver.community/gs-sfs
@Override
public void handleGet() {
Representation representation = new CapabilitiesJSONFormat().toRepresentation(catalog);
getResponse().setEntity(representation);
}
代码示例来源:origin: org.geoserver/restconfig
@Override
public void handleGet() {
getResponse().setEntity(new FileRepresentation(getTemplateFile(), MEDIATYPE_FTL, 0));
}
代码示例来源:origin: org.geowebcache/gwc-rest
public void handle(Request request, Response response) {
Method met = request.getMethod();
try {
if (met.equals(Method.POST)) {
doPost(request, response);
} else {
throw new RestletException("Method not allowed",
Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
}
} catch (RestletException re) {
response.setEntity(re.getRepresentation());
response.setStatus(re.getStatus());
} catch (IOException ioe) {
response.setEntity("Encountered IO error " + ioe.getMessage(), MediaType.TEXT_PLAIN);
response.setStatus(Status.SERVER_ERROR_INTERNAL);
}
}
代码示例来源:origin: org.archive.heritrix/heritrix-engine
@Override
public void acceptRepresentation(Representation entity) throws ResourceException {
Form form = getRequest().getEntityAsForm();
chosenEngine = form.getFirstValue("engine");
String script = form.getFirstValue("script");
if(StringUtils.isBlank(script)) {
script="";
}
ScriptEngine eng = MANAGER.getEngineByName(chosenEngine);
scriptingConsole.bind("scriptResource", this);
scriptingConsole.execute(eng, script);
scriptingConsole.unbind("scriptResource");
//TODO: log script, results somewhere; job log INFO?
getResponse().setEntity(represent());
}
代码示例来源:origin: org.geoserver.community/gs-sfs
@Override
public void handleGet() {
String bbox = "[" + bounds.getMinX() + ", " + bounds.getMinY() + ", " + bounds.getMaxX()
+ ", " + bounds.getMaxY() + "]";
Representation representation = new StringRepresentation(bbox, MediaType.APPLICATION_JSON);
getResponse().setEntity(representation);
}
}
代码示例来源:origin: org.restlet/org.restlet.ext.freemarker
@Override
protected void afterHandle(Request request, Response response) {
if (response.isEntityAvailable()
&& response.getEntity().getEncodings().contains(
Encoding.FREEMARKER)) {
final TemplateRepresentation representation = new TemplateRepresentation(
response.getEntity(), this.configuration, response
.getEntity().getMediaType());
if (this.dataModel == null) {
representation.setDataModel(request, response);
} else {
representation.setDataModel(this.dataModel);
}
response.setEntity(representation);
}
}
代码示例来源:origin: org.geowebcache/gwc-rest
public void handle(Request request, Response response) {
Method met = request.getMethod();
try {
if (met.equals(Method.POST)) {
doPost(request, response);
} else {
throw new RestletException("Method not allowed",
Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
}
} catch (RestletException re) {
response.setEntity(re.getRepresentation());
response.setStatus(re.getStatus());
}
}
内容来源于网络,如有侵权,请联系作者删除!