本文整理了Java中org.restlet.data.Request.getEntity
方法的一些代码示例,展示了Request.getEntity
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getEntity
方法的具体详情如下:
包路径:org.restlet.data.Request
类名称:Request
方法名:getEntity
暂无
代码示例来源:origin: org.restlet/org.restlet
/**
* Returns the entity representation.
*
* @return The entity representation.
*/
@Override
public Representation getEntity() {
return getWrappedRequest().getEntity();
}
代码示例来源:origin: org.geoserver/rest
/**
* Handles an upload using the EXTERNAL method.
*
* @param request
* @throws IOException
*/
public static File handleEXTERNALUpload(Request request) throws IOException {
//get the URL for this file to upload
final InputStream inStream=request.getEntity().getStream();
final String stringURL=IOUtils.getStringFromStream(inStream);
final URL fileURL=new URL(stringURL);
final File inputFile= IOUtils.URLToFile(fileURL);
if(inputFile!=null && inputFile.exists() && inputFile.canRead()) {
return inputFile;
}
return null;
}
代码示例来源:origin: org.restlet/org.restlet
@Override
protected int beforeHandle(Request request, Response response) {
if (getMode() == MODE_REQUEST) {
request.setEntity(transform(request.getEntity()));
}
return CONTINUE;
}
代码示例来源:origin: org.restlet/org.restlet.ext.xml
@Override
protected int beforeHandle(Request request, Response response) {
if (getMode() == MODE_REQUEST) {
request.setEntity(transform(request.getEntity()));
}
return CONTINUE;
}
代码示例来源:origin: org.geoserver/rest
final InputStream inStream=request.getEntity().getStream();
final String stringURL=IOUtils.getStringFromStream(inStream);
final URL fileURL=new URL(stringURL);
代码示例来源:origin: org.geowebcache/gwc-rest
protected TileLayer deserializeAndCheckLayer(Request req, Response resp, boolean isPut)
throws RestletException, IOException {
// TODO UTF-8 may not always be right here
String layerName = ServletUtils.URLDecode((String) req.getAttributes().get("layer"),
"UTF-8");
String formatExtension = (String) req.getAttributes().get("extension");
InputStream is = req.getEntity().getStream();
// If appropriate, check whether this layer exists
if (!isPut) {
findTileLayer(layerName, layerDispatcher);
}
return deserializeAndCheckLayerInternal(layerName, formatExtension, is);
}
代码示例来源:origin: org.geowebcache/gwc-rest
/**
* Method responsible for handling incoming POSTs. It will parse the XML document and
* deserialize it into a SeedRequest, then create a SeedTask and forward it to the thread pool
* executor.
*/
public void doPost(Request req, Response resp) throws RestletException, IOException {
String formatExtension = (String) req.getAttributes().get("extension");
SeedRequest sr = null;
XStream xs = xmlConfig.getConfiguredXStream(new XStream(new DomDriver()));
if (formatExtension.equalsIgnoreCase("xml")) {
sr = (SeedRequest) xs.fromXML(req.getEntity().getStream());
} else if (formatExtension.equalsIgnoreCase("json")) {
sr = (SeedRequest) xs.fromXML(convertJson(req.getEntity().getText()));
} else {
throw new RestletException("Format extension unknown or not specified: "
+ formatExtension, Status.CLIENT_ERROR_BAD_REQUEST);
}
String layerName = null;
try {
layerName = URLDecoder.decode((String) req.getAttributes().get("layer"), "UTF-8");
} catch (UnsupportedEncodingException uee) {
}
try {
seeder.seed(layerName, sr);
} catch (IllegalArgumentException e) {
throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
} catch (GeoWebCacheException e) {
throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL);
}
}
代码示例来源:origin: org.geoserver/rest
/**
* Reads content from the body of a request and writes it to a file.
*
* @param fileName The name of the file to write out.
* @param directory The directory to write the file to.
* @param deleteDirectoryContent Delete directory content if the file already exists.
* @param request The request.
*
* @return The file object representing the newly written file.
*
* @throws IOException Any I/O errors that occur.
*
* TODO: move this to IOUtils.
*/
public static File handleBinUpload(String fileName, File directory, boolean deleteDirectoryContent, Request request)
throws IOException {
final File newFile = new File(directory, fileName);
if (deleteDirectoryContent && newFile.exists()) {
FileUtils.cleanDirectory(directory);
}
final ReadableByteChannel source =request.getEntity().getChannel();
final FileChannel outputChannel = IOUtils.getOuputChannel(newFile);
IOUtils.copyChannel(1024*1024, source,outputChannel );
IOUtils.closeQuietly(source);
IOUtils.closeQuietly(outputChannel);
return newFile;
}
代码示例来源:origin: org.restlet/org.restlet
/**
* Handles a POST call by invoking the
* {@link #acceptRepresentation(Representation)} method. It also logs a
* trace if there is no entity posted.
*/
@Override
public void handlePost() {
if (!getRequest().isEntityAvailable()) {
getLogger()
.fine(
"POST request received without any entity. Continuing processing.");
}
post(getRequest().getEntity());
}
代码示例来源:origin: org.geowebcache/gwc-rest
InputStream input = req.getEntity().getStream();
XmlFilterUpdate fu = XMLConfiguration.parseXMLFilterUpdate(input);
ZipFilterUpdate fu = new ZipFilterUpdate(req.getEntity().getStream());
代码示例来源:origin: org.geoserver/restconfig
private File doFileUpload() {
try {
getResponse().setStatus(Status.SUCCESS_ACCEPTED);
File directory = catalog.getResourceLoader().findOrCreateDirectory(getDirectoryPath(getRequest()));
if (LOGGER.isLoggable(Level.INFO)) {
MediaType mediaType = getRequest().getEntity().getMediaType();
LOGGER.info("PUT file: mimetype=" + mediaType + ", path=" + directory.getAbsolutePath());
}
return RESTUtils.handleBinUpload(getAttribute("template") + "." + MEDIATYPE_FTL_EXTENSION, directory, false, getRequest());
} catch (IOException e) {
throw new RestletException(e.getMessage(), Status.SERVER_ERROR_INTERNAL, e);
}
}
代码示例来源:origin: org.geoserver/rest
/**
* Handles a request using the PUT method.
* <p>
* This method operates by de-serializing the map representation of the target object and
* then calling {@link #putMap(Map)}.
* </p>
*/
@Override
public void handlePut() {
DataFormat format = getFormatPostOrPut();
Map map = (Map) format.toObject(getRequest().getEntity());
try {
putMap(map);
}
catch (Exception e) {
throw new RestletException( "", Status.SERVER_ERROR_INTERNAL, e );
}
}
代码示例来源:origin: org.geoserver/rest
/**
* Handles a request using the POST method.
* <p>
* This method operates by de-serializing the map representation of the target object and
* then calling {@link #postMap(Map)}.
* </p>
*/
@Override
public void handlePost() {
DataFormat format = getFormatPostOrPut();
Map map = (Map) format.toObject(getRequest().getEntity());
try {
postMap(map);
}
catch (Exception e) {
throw new RestletException( "", Status.SERVER_ERROR_INTERNAL, e );
}
}
代码示例来源:origin: org.geoserver/rest
/**
* Handles a PUT request by de-serializing the content of the request into an instance
* of the target object.
* <p>
* This method operates by:
* <ol>
* <li>Determining the serialization format from {@link #getFormatPostOrPut()}
* <li>De-serializing to an instance of the target object.
* <li>Passing the target object to {@link #handleObjectPut(Object)}
* </ol>
* </p>
*
* @see #handleObjectPost(Object)
*/
@Override
public final void handlePut() {
DataFormat format = getFormatPostOrPut();
Object object = format.toObject( getRequest().getEntity() );
try {
handleObjectPut(object);
}
catch (Exception e) {
handleException(e);
}
}
代码示例来源:origin: org.geoserver/rest
MediaType type = getRequest().getEntity().getMediaType();
if ( type != null ) {
代码示例来源:origin: org.geoserver/rest
public final void handlePost() {
DataFormat format = getFormatPostOrPut();
Object object = format.toObject( getRequest().getEntity() );
String location = null;
try {
代码示例来源:origin: org.sonatype.nexus.plugins/nexus-restlet1x-plugin
@Override
public Object upload(Context context, Request request, Response response, List<FileItem> files)
throws ResourceException
{
// NEXUS-4151: Do not accept upload/deploy requests with media type (Content-Type) of
// "application/x-www-form-urlencoded", since ad 1, it's wrong, ad 2, we do know
// Jetty's Request object "eats" up it's body to parse request parameters, invoked
// way earlier in security filters
if (request.isEntityAvailable()) {
MediaType mt = request.getEntity().getMediaType();
if (mt != null && MediaType.APPLICATION_WWW_FORM.isCompatible(mt)) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Content-type of \"" + mt.toString()
+ "\" is not acceptable for uploads!");
}
}
try {
final ResourceStoreRequest req = getResourceStoreRequest(request);
for (FileItem fileItem : files) {
getResourceStore(request).storeItem(req, fileItem.getInputStream(), null);
}
}
catch (Exception t) {
handleException(request, response, t);
}
return null;
}
代码示例来源:origin: org.sonatype.nexus/nexus-rest-api
MediaType mt = request.getEntity().getMediaType();
代码示例来源:origin: org.restlet/org.restlet
put(getRequest().getEntity());
代码示例来源:origin: org.restlet/org.restlet.ext.httpclient
final Representation entity = request.getEntity();
内容来源于网络,如有侵权,请联系作者删除!