Examples of MultivaluedStringMap


Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

                            in);
                } catch (final IOException e) {
                    throw new FormDataParamException(e, parameter.getSourceName(), parameter.getDefaultValue());
                }
            } else if (extractor != null) {
                final MultivaluedMap<String, String> map = new MultivaluedStringMap();
                try {
                    if (formDataBodyPart != null) {
                        for (final FormDataBodyPart p : formDataBodyParts) {
                            mediaType = p.getMediaType();

                            reader = messageBodyWorkers.getMessageBodyReader(
                                    String.class,
                                    String.class,
                                    parameter.getAnnotations(),
                                    mediaType);

                            @SuppressWarnings("unchecked") final String value = (String) reader.readFrom(
                                    String.class,
                                    String.class,
                                    parameter.getAnnotations(),
                                    mediaType,
                                    request.getHeaders(),
                                    ((BodyPartEntity) p.getEntity()).getInputStream());

                            map.add(parameter.getSourceName(), value);
                        }
                    }
                    return extractor.extract(map);
                } catch (final IOException | ExtractorException ex) {
                    throw new FormDataParamException(ex, extractor.getName(), extractor.getDefaultValueString());
View Full Code Here

Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

        return Optional.fromNullable(value);
    }

    private MultivaluedMap<String, String> getCookies() {
        final Map<String, Cookie> requestCookies = getContainerRequest().getCookies();
        final MultivaluedMap<String, String> cookies = new MultivaluedStringMap(requestCookies.size());

        for (Map.Entry<String, Cookie> e : requestCookies.entrySet()) {
            cookies.putSingle(e.getKey(), e.getValue().getValue());
        }

        return cookies;
    }
View Full Code Here

Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

    }

    @Test
    public void shouldReturnDefaultMessageWhenMessageIsNotPresent() throws IOException {
        final String defaultMessage = "Default Message";
        final Response response = target("/optional/message").request().post(Entity.form(new MultivaluedStringMap()));

        assertThat(response.readEntity(String.class)).isEqualTo(defaultMessage);
    }
View Full Code Here

Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

    }

    @Test
    public void shouldReturnDefaultMessageWhenMyMessageIsNotPresent() throws IOException {
        final String defaultMessage = "My Default Message";
        final Response response = target("/optional/my-message").request().post(Entity.form(new MultivaluedStringMap()));

        assertThat(response.readEntity(String.class)).isEqualTo(defaultMessage);
    }
View Full Code Here

Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

    }

    @Test
    public void shouldReturnDefaultUUIDWhenUUIDIsNotPresent() throws IOException {
        final String defaultUUID = "d5672fa8-326b-40f6-bf71-d9dacf44bcdc";
        final Response response = target("/optional/uuid").request().post(Entity.form(new MultivaluedStringMap()));

        assertThat(response.readEntity(String.class)).isEqualTo(defaultUUID);
    }
View Full Code Here

Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

        }
    }

    @Test
    public void testFormMultivaluedMapRepresentation() {
        final MultivaluedMap<String, String> fp = new MultivaluedStringMap();
        fp.add("Email", "johndoe@gmail.com");
        fp.add("Passwd", "north 23AZ");
        fp.add("service", "cl");
        fp.add("source", "Gulp-CalGul-1.05");
        fp.add("source", "foo.java");
        fp.add("source", "bar.java");

        final WebTarget target = target("FormMultivaluedMapResource");
        final MultivaluedMap _fp = target.request().post(Entity.entity(fp, "application/x-www-form-urlencoded"), MultivaluedMap.class);
        assertEquals(fp, _fp);
    }
View Full Code Here

Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

     * Test checks that POST on the '/form' resource gives a response page
     * with the entered data.
     */
    @Test
    public void testPostOnForm() {
        MultivaluedMap<String, String> formData = new MultivaluedStringMap();
        formData.add("name", "testName");
        formData.add("colour", "red");
        formData.add("hint", "re");

        Response response = target().path("form").request().post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatusInfo().getStatusCode());

        // check that the generated response is the expected one
View Full Code Here

Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

        this.authority = that.authority;
        this.userInfo = that.userInfo;
        this.host = that.host;
        this.port = that.port;
        this.path = new StringBuilder(that.path);
        this.matrixParams = that.matrixParams == null ? null : new MultivaluedStringMap(that.matrixParams);
        this.query = new StringBuilder(that.query);
        this.queryParams = that.queryParams == null ? null : new MultivaluedStringMap(that.queryParams);
        this.fragment = that.fragment;
    }
View Full Code Here

Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

     * @param decode true of the query parameters of the query component
     *               should be in decoded form.
     * @return the multivalued map of query parameters.
     */
    public static MultivaluedMap<String, String> decodeQuery(String q, boolean decode) {
        MultivaluedMap<String, String> queryParameters = new MultivaluedStringMap();

        if (q == null || q.length() == 0) {
            return queryParameters;
        }

View Full Code Here

Examples of org.glassfish.jersey.internal.util.collection.MultivaluedStringMap

     * @param decode      true if the matrix parameters of the path segment component
     *                    should be in decoded form.
     * @return the multivalued map of matrix parameters.
     */
    public static MultivaluedMap<String, String> decodeMatrix(String pathSegment, boolean decode) {
        MultivaluedMap<String, String> matrixMap = new MultivaluedStringMap();

        // Skip over path segment
        int s = pathSegment.indexOf(';') + 1;
        if (s == 0 || s == pathSegment.length()) {
            return matrixMap;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.