本文整理了Java中org.restlet.Request.getEntity
方法的一些代码示例,展示了Request.getEntity
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getEntity
方法的具体详情如下:
包路径:org.restlet.Request
类名称:Request
方法名:getEntity
暂无
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
/**
* @see org.restlet.ext.jaxrs.internal.wrappers.params.ParameterList.ParamGetter#getValue()
*/
public Object getValue() throws InvocationTargetException,
ConvertRepresentationException, WebApplicationException {
return Request.getCurrent().getEntity();
}
代码示例来源:origin: apache/attic-polygene-java
private <K> K convertToObject( Class<K> type, Request request )
{
try
{
return converter.toObject( request.getEntity(), type, null );
}
catch( IOException e )
{
throw new ConversionException( request.getEntityAsText() );
}
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns the entity representation.
*
* @return The entity representation.
*/
@Override
public Representation getEntity() {
return getWrappedRequest().getEntity();
}
代码示例来源:origin: org.qi4j.library/org.qi4j.library.rest-server
private boolean shouldShowCommandForm( Method interactionMethod )
{
// Show form on GET/HEAD
if( Request.getCurrent().getMethod().isSafe() )
{
return true;
}
if( interactionMethod.getParameterTypes().length > 0 )
{
return !( interactionMethod.getParameterTypes()[ 0 ].equals( Response.class ) || Request.getCurrent()
.getEntity()
.isAvailable() || Request.getCurrent().getEntityAsText() != null || Request.getCurrent()
.getResourceRef()
.getQuery() != null );
}
return false;
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Indicates if the request entity should be chunked.
*
* @return True if the request should be chunked
*/
protected boolean shouldRequestBeChunked(Request request) {
return request.isEntityAvailable()
&& (request.getEntity() != null)
&& !request.getEntity().hasKnownSize();
}
}
代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.rest-server
private boolean shouldShowCommandForm( Method interactionMethod )
{
// Show form on GET/HEAD
if( Request.getCurrent().getMethod().isSafe() )
{
return true;
}
if( interactionMethod.getParameterTypes().length > 0 )
{
return !( interactionMethod.getParameterTypes()[ 0 ].equals( Response.class ) || Request.getCurrent()
.getEntity()
.isAvailable() || Request.getCurrent().getEntityAsText() != null || Request.getCurrent()
.getResourceRef()
.getQuery() != null );
}
return false;
}
代码示例来源:origin: stackoverflow.com
Filter filter = new Filter(getContext()) {
@Override
protected int beforeHandle(Request request, Response response) {
try {
JsonRepresentation jrep = new JsonRepresentation(request.getEntity());
JSONObject jo = jrep.getJsonObject();
String token = jo.getString("token");
System.out.println(token);
request.setEntity(new JsonRepresentation(jo));
} catch (JSONException | IOException e) {
throw new ResourceException(Status.SERVER_ERROR_INTERNAL);
}
return super.beforeHandle(request, response);
}
};
代码示例来源:origin: stackoverflow.com
Filter filter = new Filter(getContext()) {
@Override
protected int beforeHandle(Request request, Response response) {
try {
JsonRepresentation jrep = new JsonRepresentation(request.getEntity());
String token = jrep.getJsonObject().getString("token");
System.out.println(token);
request.setEntity(jrep);
} catch (JSONException | IOException e) {
throw new ResourceException(Status.SERVER_ERROR_INTERNAL);
}
return super.beforeHandle(request, response);
}
};
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
/**
* Get the media type of the request entity
*
* @return the media type or null if there is no request entity.
* @throws java.lang.IllegalStateException
* if called outside the scope of a request
* @see HttpHeaders#getMediaType()
*/
public MediaType getMediaType() {
if (this.mediaType == null) {
org.restlet.data.MediaType rmt = request.getEntity().getMediaType();
CharacterSet rCharSet = request.getEntity().getCharacterSet();
this.mediaType = Converter.toJaxRsMediaType(rmt, rCharSet);
}
return this.mediaType;
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
/**
* @return the character set of the current entity, or null, if no entity or
* no character set is available.
*/
private CharacterSet getCurrentRequestEntityCharacterSet() {
Representation entity = Request.getCurrent().getEntity();
if (entity == null)
return null;
return entity.getCharacterSet();
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
/**
* @return the character set of the current entity, or null, if no entity or
* no character set is available.
*/
private CharacterSet getCurrentRequestEntityCharacterSet() {
Representation entity = Request.getCurrent().getEntity();
if (entity == null)
return null;
return entity.getCharacterSet();
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns the request entity representation.
*
* @return The request entity representation.
*/
public Representation getRequestEntity() {
return getRequest() == null ? null : getRequest().getEntity();
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.xml
@Override
protected int beforeHandle(Request request, Response response) {
if ((getMode() == MODE_REQUEST) && canTransform(request.getEntity())) {
request.setEntity(transform(request.getEntity()));
}
return CONTINUE;
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
@Override
public InputStream getInputStream() {
try {
return getRequest().getEntity().getStream();
} catch (IOException e) {
Context.getCurrentLogger().log(Level.WARNING,
"Unable to get the request entity input stream.", e);
return null;
}
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
/**
* @see HttpHeaders#getLanguage()
*/
public Locale getLanguage() {
if (this.language == null) {
final Representation entity = this.request.getEntity();
if (entity == null) {
return null;
}
final List<Language> languages = entity.getLanguages();
if (languages.isEmpty()) {
return null;
}
this.language = Converter.toLocale(Util.getFirstElement(languages));
}
return this.language;
}
代码示例来源:origin: org.restlet.osgi/org.restlet
private Status replaceFile(Request request, File file) {
File tmp = null;
try {
tmp = File.createTempFile("restlet-upload", "bin");
if (request.isEntityAvailable()) {
Files.copy(request.getEntity().getStream(), tmp.toPath(), REPLACE_EXISTING);
}
} catch (IOException ioe) {
getLogger().log(WARNING, "Unable to create the temporary file", ioe);
cleanTemporaryFileIfUploadNotResumed(tmp);
return new Status(SERVER_ERROR_INTERNAL, "Unable to create a temporary file");
}
return replaceFileByTemporaryFile(request, file, tmp);
}
代码示例来源:origin: org.restlet.osgi/org.restlet
/**
* Returns the representation provided by the client.
*
* @return The representation provided by the client.
*/
@Override
public Representation getEntity() {
if (!this.entityAdded) {
setEntity(((ServerCall) getHttpCall()).getRequestEntity());
this.entityAdded = true;
}
return super.getEntity();
}
代码示例来源:origin: org.restlet.jse/org.restlet.ext.lucene
/**
* Constructor.
*
* @param request
* The Restlet request to wrap.
* @param core
* The Solr core.
*/
public SolrRestletQueryRequest(Request request, SolrCore core) {
super(core, new SolrRestletParams(request));
getContext().put("path", request.getResourceRef().getPath());
ArrayList<ContentStream> _streams = new ArrayList<ContentStream>(1);
_streams.add(new SolrRepresentationContentStream(request.getEntity()));
setContentStreams(_streams);
}
代码示例来源:origin: org.codeartisans.qipki/qipki-ca-http
protected final String ensureFormFirstValue( String key, Status ifAbsent )
{
String value = new Form( getRequest().getEntity() ).getFirstValue( key );
if ( Strings.isEmpty( value ) ) {
LOGGER.trace( "{}: No form first value named {}", ifAbsent, key );
throw new ResourceException( ifAbsent );
}
return value;
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jaxrs
@Override
public Object getParamValue() {
if (form == null && this.tlContext.get().getRequest().isEntityAvailable()) {
form = new Form(this.tlContext.get().getRequest().getEntity(), false);
}
if (form == null) {
return null;
}
final String paramName = this.formParam.value();
try {
return super.getParamValue(form, paramName);
} catch (ConvertParameterException e) {
throw new ConvertQueryParamException(e);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!