/** * Returns the optionnally decoded query component. * * @param decode * Indicates if the result should be decoded using the {@link #decode(String)} method. * @return The optionnally decoded query component. * @see #getQuery() */ public String getQuery(boolean decode) { return decode ? decode(getQuery()) : getQuery(); }
/** * Returns the optionnally decoded query component. * * @param decode * Indicates if the result should be decoded using the * {@link #decode(String)} method. * @return The optionnally decoded query component. * @see #getQuery() */ public String getQuery(boolean decode) { return decode ? decode(getQuery()) : getQuery(); }
/** * Returns the optionnally decoded query component. * * @param decode * Indicates if the result should be decoded using the * {@link #decode(String)} method. * @return The optionnally decoded query component. * @see #getQuery() */ public String getQuery(boolean decode) { return decode ? decode(getQuery()) : getQuery(); }
/** * Returns the optional query component as a form. * * @return The optional query component as a form. */ public Form getQueryAsForm() { return new Form(getQuery()); }
/** * Returns the optional query component as a form submission. * * @param characterSet * The supported character encoding. * @return The optional query component as a form submission. */ public Form getQueryAsForm(CharacterSet characterSet) { return new Form(getQuery(), characterSet); }
/** * Returns the optional query component as a form. * * @return The optional query component as a form. */ public Form getQueryAsForm() { return new Form(getQuery()); }
/** * Returns the optional query component as a form. * * @param decode * Indicates if the names and values should be automatically * decoded. * @return The optional query component as a form. */ public Form getQueryAsForm(boolean decode) { return new Form(getQuery(), decode); }
/** * Returns the optional query component as a form submission. * * @param characterSet * The supported character encoding. * @return The optional query component as a form submission. */ public Form getQueryAsForm(CharacterSet characterSet) { return new Form(getQuery(), characterSet); }
/** * Returns the optional query component as a form. * * @return The optional query component as a form. */ public Form getQueryAsForm() { return new Form(getQuery()); }
/** * Returns the optional query component as a form. * * @param decode * Indicates if the names and values should be automatically * decoded. * @return The optional query component as a form. */ public Form getQueryAsForm(boolean decode) { return new Form(getQuery(), decode); }
/** * Returns the optional query component as a form submission. * * @param characterSet * The supported character encoding. * @return The optional query component as a form submission. */ public Form getQueryAsForm(CharacterSet characterSet) { return new Form(getQuery(), characterSet); }
/** * Get the URI query parameters of the current request. * * @param decode * controls whether sequences of escaped octets in parameter * names and values are decoded (true) or not (false). * @param caseSensitive * should the parameter name should keep their case, set to true * @return an unmodifiable map of query parameter names and values * @throws java.lang.IllegalStateException * if called outside the scope of a request * @see UriInfo#getQueryParameters(boolean) */ public MultivaluedMap<String, String> getQueryParameters(boolean decode, boolean caseSensitive) { if (decode) { return getQueryParameters(); } if (this.queryParametersEncoded == null) { Form queryForm = Converter.toFormEncoded(this.referenceOriginal .getQuery()); this.queryParametersEncoded = UnmodifiableMultivaluedMap .getFromSeries(queryForm, caseSensitive); } return this.queryParametersEncoded; }
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; }
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; }
@Override public Object getParamValue() { final Reference resourceRef = this.tlContext.get().getRequest() .getResourceRef(); final String queryString = resourceRef.getQuery(); final Form form = Converter.toFormEncoded(queryString); final String paramName = this.queryParam.value(); try { return super.getParamValue(form, paramName); } catch (ConvertParameterException e) { throw new ConvertQueryParamException(e); } } }
/** * GET request. Returns a JSON response from the translation service specified */ @Get public Representation translate() throws ResourceException { // get the params from try { // No alternate versions supported. But if we did: String version = (String) getRequest().getAttributes().get("version"); if ( version == null ) { version = LayerConfiguration.DEFAULT_VERSION; } // decode and build JSONObject from request parameters JSONObject decodedQueryParams = QueryParamDecoder.decode( getRequest().getResourceRef().getQuery() ); return new JsonRepresentation( _service.getTranslation(decodedQueryParams) ); } catch ( Exception e) { throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unable to translate text. Check parameters.", e); } } }
@Override public Representation handle() { if (!this.directoryRedirection) { return super.handle(); } // detected a directory, but the current reference lacks the trailing "/", let's redirect. Reference directoryReference = (this.originalRef != null) ? this.originalRef : getReference().getTargetRef(); if (directoryReference.hasQuery()) { redirectSeeOther(directoryReference.toString(false, false) + "/?" + directoryReference.getQuery()); } else { redirectSeeOther(directoryReference.toString(false, false) + "/"); } return null; }
/** * @param ref * @param b * @return * @throws IllegalArgumentException */ private UriBuilder fillUriBuilder(Reference ref, final UriBuilder b) throws IllegalArgumentException { b.scheme(ref.getScheme(false)); b.userInfo(ref.getUserInfo(false)); b.host(ref.getHostDomain(false)); b.port(ref.getHostPort()); b.path(ref.getPath(false)); b.replaceQuery(ref.getQuery(false)); b.fragment(ref.getFragment(false)); return b; }
/** * Adds a parameter to the query component. The name and value are * automatically URL encoded if necessary. * * @param name * The parameter name. * @param value * The optional parameter value. * @return The updated reference. */ public Reference addQueryParameter(String name, String value) { String query = getQuery(); if (query == null) { if (value == null) { setQuery(encode(name)); } else { setQuery(encode(name) + '=' + encode(value)); } } else { if (value == null) { setQuery(query + '&' + encode(name)); } else { setQuery(query + '&' + encode(name) + '=' + encode(value)); } } return this; }