/** * @see org.restlet.ext.jaxrs.internal.wrappers.params.ParameterList.ParamGetter#getValue() */ public Object getValue() throws InvocationTargetException, ConvertRepresentationException, WebApplicationException { return Request.getCurrent().getEntity(); }
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() ); } }
/** * Returns the entity representation. * * @return The entity representation. */ @Override public Representation getEntity() { return getWrappedRequest().getEntity(); }
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; }
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; }
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); } };
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); } };
/** * 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; }
/** * @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(); }
/** * @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(); }
/** * Returns the request entity representation. * * @return The request entity representation. */ public Representation getRequestEntity() { return getRequest() == null ? null : getRequest().getEntity(); }
@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; } }
/** * @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; }
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); }
/** * 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(); }
/** * 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); }
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; }
@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); } } }