Package com.volantis.shared.net.http

Examples of com.volantis.shared.net.http.HTTPMessageEntity


        assertTrue("The header that was put is not contained in this entities",
                entities.containsIdentity(header.getIdentity()));


        HTTPMessageEntity retrieved [] =
                entities.retrieve(header.getIdentity());

        assertEquals("There can be only one", 1, retrieved.length);

        assertEquals("The retreived HTTPMessageEntity is not equal to the" +
View Full Code Here


        HeaderImpl header1 = new HeaderImpl(headerName);
        header1.setValue(value1);

        entities.put(header1);

        HTTPMessageEntity retrieved [] = entities.retrieve(header1.getIdentity());

        assertEquals(value1, retrieved[0].getValue());

        HeaderImpl header2 = new HeaderImpl(headerName);
        header2.setValue(value2);
View Full Code Here

        // Putting the headers array should replace header1, header2 and
        // header3 and return these three replaced entities. In addition
        // entities should consist of the three headers in the headers array
        // and header4.

        HTTPMessageEntity replaced [] = entities.put(headers);

        assertEquals("Expected 3 replaced entities", 3, replaced.length);

        assertEquals("Expected there to be 4 entities in entities", 4,
                entities.size());
View Full Code Here

        entities.add(header3);

        // Removing name1 headers should remove header1 and header2
        // leaving only header3.

        HTTPMessageEntity removed [] = entities.remove(header1.getIdentity());

        assertEquals("Two entities should have been removed", 2,
                removed.length);

        assertEquals("One entity should remain", 1, entities.size());
View Full Code Here

        header1.setValue("value1");
        entities.add(header2);
        header2.setValue("value2");
        entities.add(header3);

        HTTPMessageEntity retrieved [] =
                entities.retrieve(header1.getIdentity());

        assertEquals("Two entities should have been retrieved", 2,
                retrieved.length);
View Full Code Here

            DerivableHTTPMessageEntity entity,
            HTTPMessageEntities requestEntities,
            HTTPMessageEntityMerger merger)
            throws HTTPException {

        HTTPMessageEntity values [] = null;

        String from = entity.getFrom();
        if (from == null || requestEntities == null) {
            if (entity.getName() == null && (from == null)) {
                throw new HTTPException(
                        "Entity " + entity + " has neither a name " +
                        "nor a from property. This is not valid");
            }
            if (requestEntities == null && from != null) {
                logger.warn("request-entities-null-ignoring-from-property",
                            entity.getName());
            }

            values = (HTTPMessageEntity[])
                Array.newInstance(entity.getClass(), 1);
            values[0] = entity;

        } else {
            // Find the alternative or source entitites in the request that
            // are specified by the "from" property. We need to create an
            // identity for this whose name is derived from "from" and whose
            // other identity properties if any are derived from entity e.g.
            // for cookies.
            HTTPMessageEntity requestEntityArray [] =
                    requestEntities.retrieve(entity.getFromIdentity());

            if (requestEntityArray.length == 0) {
                throw new HTTPException(
                        "Entity " + entity.getName() + "has neither " +
                        "a from nor a value property. This is not valid");
            }

            values = (HTTPMessageEntity[]) Array.newInstance(entity.getClass(),
                                                             requestEntityArray.length);
            // Now merge each requestEntity with the original entity.
            for (int i = 0; i < requestEntityArray.length; i++) {
                HTTPMessageEntity merged =
                        merger.mergeHTTPMessageEntities(entity,
                                                        requestEntityArray[i]);
                values[i] = merged;
            }
        }
View Full Code Here

                        sb.append('&');
                    }
                   
                    Iterator it = requestParameters.iterator();
                    while (it.hasNext()) {
                        HTTPMessageEntity e = (HTTPMessageEntity) it.next();
                       
                        // Add the parameter name.
                        sb.append(manager.encodeWithinQuery(
                                e.getName(), encoding));
                       
                        // Add the parameter value (if there was one).
                        String value = e.getValue();
                        if (value != null) {
                            value = value.trim();
                            sb.append("=");
                            sb.append(manager.encodeWithinQuery(
                                    value, encoding));
View Full Code Here

    // javadoc inherited
    public boolean equals(Object o) {
        boolean equals = o != null && o instanceof HTTPMessageEntityImpl;
        if (equals) {
            HTTPMessageEntity entity = (HTTPMessageEntity)o;
            equals = getClass().equals(entity.getClass()) &&
                    this.getIdentity().identityEquals(entity.getIdentity());
            if (equals) {
                equals = getValue() == null ? entity.getValue() == null :
                        getValue().equals(entity.getValue());
            }
        }

        return equals;
    }
View Full Code Here

            javax.servlet.http.Cookie cookie) {

        if (LOG.isDebugEnabled()) {
            LOG.debug("Converting Volantis cookie to Servlet cookie");
        }
        HTTPMessageEntity result = null;

        if (cookie != null) {
            Cookie c = factory.createCookie(
                    cookie.getName(), cookie.getDomain(), cookie.getPath());
            c.setComment(cookie.getComment());
View Full Code Here

    public static List removeJSessionIDCookies(HTTPMessageEntities cookies) {

        List results = new ArrayList();
        Iterator entities = cookies.iterator();
        while (entities.hasNext()) {
            HTTPMessageEntity entity = (HTTPMessageEntity) entities.next();
            if (entity.getName().equalsIgnoreCase(JSESSIONID_STRING)) {
                results.add(entity);
            }
        }

        // iterate over the entities identified for removal and remove them
View Full Code Here

TOP

Related Classes of com.volantis.shared.net.http.HTTPMessageEntity

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.