Package javax.ws.rs.core

Examples of javax.ws.rs.core.Form


    public AccessTokenValidation validateAccessToken(MessageContext mc,
                                                     String authScheme,
                                                     String authSchemeData)
        throws OAuthServiceException {
        WebClient client = WebClient.fromClient(tokenValidatorClient, true);
        Form form = new Form().param(OAuthConstants.AUTHORIZATION_SCHEME_TYPE, authScheme)
                              .param(OAuthConstants.AUTHORIZATION_SCHEME_DATA, authSchemeData);
        return client.post(form, AccessTokenValidation.class);
    }
View Full Code Here


    }
   
    @Test
    public void testResponseHasBeenReceivedWhenAddingNewBook() {
        Response r = createWebClient("/rest/api/bookstore/books").post(
            new Form()
                .param("id", "1234")
                .param("name", "Book 1234"));
        assertEquals(Status.CREATED.getStatusCode(), r.getStatus());
    }
View Full Code Here

    @Test
    public void testAddAndQueryOneBook() {
        final String id = UUID.randomUUID().toString();
       
        Response r = createWebClient("/rest/api/bookstore/books").post(
            new Form()
                .param("id", id)
                .param("name", "Book 1234"));
        assertEquals(Status.CREATED.getStatusCode(), r.getStatus());
       
        r = createWebClient("/rest/api/bookstore/books").path(id).get();
View Full Code Here

    @Test
    public void testAddOneBookWithValidation() {
        final String id = UUID.randomUUID().toString();
       
        Response r = createWebClient("/rest/custom/bookstore/books").post(
            new Form()
                .param("id", id));
        assertEquals(Status.BAD_REQUEST.getStatusCode(), r.getStatus());
    }
View Full Code Here

     * @param formData multivalued map representing the form data.
     * @return {@value javax.ws.rs.core.MediaType#APPLICATION_FORM_URLENCODED}
     *         form entity instance.
     */
    public static Entity<Form> form(final MultivaluedMap<String, String> formData) {
        return new Entity<Form>(new Form(formData), MediaType.APPLICATION_FORM_URLENCODED_TYPE);
    }
View Full Code Here

    @Test
    public void readFromTest() throws IOException {
        ResponseDataProvider<Form> responseDataProvider = new ResponseDataProvider<>();
        String str = "oauth_token=totototot&oauth_token_secret=tststststststs&usd=hashshsh";
        InputStream is = new ByteArrayInputStream(str.getBytes());
        Form form = responseDataProvider.readFrom(Form.class, null, null, null, null, is);
        Assert.assertEquals("totototot", form.asMap().getFirst("oauth_token"));
        Assert.assertEquals("tststststststs", form.asMap().getFirst("oauth_token_secret"));
    }
View Full Code Here

            Annotation annotations[],
            MediaType mediaType,
            MultivaluedMap<String, String> httpHeaders,
            InputStream entityStream) throws IOException {

        return new Form(readFrom(new MultivaluedHashMap<String, String>(), mediaType, decode(annotations), entityStream));
    }
View Full Code Here

            }
        }

        private Form switchUrlEncoding(final ContainerRequest request, final Form otherForm) {
            final Set<Map.Entry<String, List<String>>> entries = otherForm.asMap().entrySet();
            Form newForm = new Form();
            for (Map.Entry<String, List<String>> entry : entries) {
                final String charsetName = ReaderWriter.getCharset(MediaType.valueOf(
                        request.getHeaderString(HttpHeaders.CONTENT_TYPE))).name();

                String key;
                try {
                    key = decode ? URLDecoder.decode(entry.getKey(), charsetName) : URLEncoder.encode(entry.getKey(),
                            charsetName);

                    for (String value : entry.getValue()) {
                        newForm.asMap().add(key, decode ? URLDecoder.decode(value, charsetName) : URLEncoder.encode(value,
                                charsetName));
                    }

                } catch (UnsupportedEncodingException uee) {
                    throw new ProcessingException(LocalizationMessages.ERROR_UNSUPPORTED_ENCODING(charsetName,
View Full Code Here

        }

        private Form getFormParameters(ContainerRequest request) {
            if (MediaTypes.typeEqual(MediaType.APPLICATION_FORM_URLENCODED_TYPE, request.getMediaType())) {
                request.bufferEntity();
                Form form;
                if (decode) {
                    form = request.readEntity(Form.class);
                } else {
                    Annotation[] annotations = new Annotation[1];
                    annotations[0] = encodedAnnotation;
                    form = request.readEntity(Form.class, annotations);
                }

                return (form == null ? new Form() : form);
            } else {
                return new Form();
            }
        }
View Full Code Here

            request.setMethod(override);
            if (override.equals("GET")) {
                if (request.getMediaType() != null &&
                        MediaType.APPLICATION_FORM_URLENCODED_TYPE.getType().equals(request.getMediaType().getType())) {
                    UriBuilder ub = request.getUriInfo().getRequestUriBuilder();
                    Form f = ((ContainerRequest) request).readEntity(Form.class);
                    for (Map.Entry<String, List<String>> param : f.asMap().entrySet()) {
                        ub.queryParam(param.getKey(), param.getValue().toArray());
                    }
                    request.setRequestUri(request.getUriInfo().getBaseUri(), ub.build());
                }
            }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.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.