Package org.restlet.data

Examples of org.restlet.data.Form


        };
    }

    /** @see FormTestResource#checkUnmodifiable(java.util.List) */
    public void testCheckUnmodifiable() {
        Form form = new Form();
        form.add("a", "b");
        form.add("a", "c");
        Response response = post("checkUnmodifiable", form
                .getWebRepresentation());
        sysOutEntityIfError(response);
        assertTrue(
                "The List annotated with @FormParam must not be modifiable. Status is "
                        + response.getStatus(), response.getStatus()
View Full Code Here


public class ProviderTest extends JaxRsTestCase {

    public static final boolean LATER = true;

    private static Form createForm() {
        Form form = new Form();
        form.add("firstname", "Angela");
        form.add("lastname", "Merkel");
        return form;
    }
View Full Code Here

     * @param resourceRef
     *            The resource reference.
     * @return The canonicalized resource name.
     */
    private static String getCanonicalizedResourceName(Reference resourceRef) {
        Form form = resourceRef.getQueryAsForm();

        Parameter param = form.getFirst("comp", true);
        if (param != null) {
            StringBuilder sb = new StringBuilder(resourceRef.getPath());
            return sb.append("?").append("comp=").append(param.getValue())
                    .toString();
        }
View Full Code Here

    @GET
    @Path("form")
    @Produces("application/x-www-form-urlencoded")
    public Form formGet() {
        final Form form = new Form();
        form.add("firstname", "Angela");
        form.add("lastname", "Merkel");
        return form;
    }
View Full Code Here

    @Override
    public int verify(Request request, Response response) {
        if (request.getChallengeResponse() == null)
            return RESULT_MISSING;

        Form headers = (Form) request.getAttributes().get(
                "org.restlet.http.headers");
        String userId = getIdentifier(request, response);

        if (userId == null || (userId.length() == 0))
            return RESULT_MISSING;

        // A date header is always required
        if (headers.getFirstValue(HeaderConstants.HEADER_DATE, true) == null)
            return RESULT_INVALID;

        // Make sure the date is not stale
        if (getMaxRequestAge() > 0) {
            Long date = DateUtils.parse(
                    headers.getFirstValue(HeaderConstants.HEADER_DATE, true))
                    .getTime();
            Long now = System.currentTimeMillis();
            if (now - date > getMaxRequestAge())
                return RESULT_STALE;
        }
View Full Code Here

     * @param secret
     *            The user secret to sign with
     * @return The AWS S3 compatible signature
     */
    public static String getSignature(Request request, char[] secret) {
        Form headers = (Form) request.getAttributes().get(
                "org.restlet.http.headers");
        return getSignature(request, headers, secret);
    }
View Full Code Here

     * @param request
     *            The request to generate the signature string from
     * @return The string to sign
     */
    public static String getStringToSign(Request request) {
        Form headers = (Form) request.getAttributes().get(
                "org.restlet.http.headers");
        return getStringToSign(request, headers);
    }
View Full Code Here

        assertFalse(ref3.hasMatrix());

        assertEquals("b=2;c=4", ref1.getMatrix());
        assertEquals("b=2;c=4;d", ref2.getMatrix());

        final Form form1 = ref1.getMatrixAsForm();
        assertEquals("2", form1.getFirstValue("b"));
        assertEquals("4", form1.getFirstValue("c"));

        final Form form2 = ref1.getMatrixAsForm();
        assertEquals("2", form2.getFirstValue("b"));
        assertEquals("4", form2.getFirstValue("c"));
        assertNull(form2.getFirstValue("d"));

        final Form newForm = new Form();
        newForm.add("a", "1");
        newForm.add("b", "2");
        newForm.add("c", "4");
        assertEquals("a=1;b=2;c=4", newForm.getMatrixString());
    }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public static Series<? extends Parameter> unmodifiableSeries(
            Series<? extends Parameter> series) {
        if (Edition.CURRENT != Edition.GWT) {
            return new Form(java.util.Collections.unmodifiableList(series
                    .getDelegate()));
        }

        return new Form((List<Parameter>) series.getDelegate());
    }
View Full Code Here

        Reference ref1 = new Reference(
                "http://localhost/search?q=anythingelse%");
        String query = ref1.getQuery();
        assertEquals("q=anythingelse%25", query);

        Form queryForm = ref1.getQueryAsForm();
        assertEquals("anythingelse%", queryForm.getFirstValue("q"));

        Form extJsQuery = new Form(
                "&_dc=1244741620627&callback=stcCallback1001");
        assertEquals("1244741620627", extJsQuery.getFirstValue("_dc"));
        assertEquals("stcCallback1001", extJsQuery.getFirstValue("callback"));

        Reference ref = new Reference("http://localhost/v1/projects/13404");
        ref.addQueryParameter("dyn", "true");
        assertEquals("http://localhost/v1/projects/13404?dyn=true",
                ref.toString());
View Full Code Here

TOP

Related Classes of org.restlet.data.Form

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.