Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Cookie


        // 3. First matching cookie parameter 'locale' within each cookie sent
        Cookie[] cookies = request.getCookies();

        if (cookies != null) {
            for (int i = 0; i < cookies.length; ++i) {
                Cookie cookie = cookies[i];
                if (cookie.getName().equals(LOCALE))
                    return cookie.getValue();
            }
        }

        // 4. Locale setting of the requesting object/server
        return request.getLocale().toString();
View Full Code Here


        Cookie[] cookies = request.getCookies();
        HashMap result = null;

        if (cookies != null) {
            for (int i = 0; i < cookies.length; i++) {
                Cookie cookie = cookies[i];
                if (cookie.getName().equals(pattern)) {
                    result = new HashMap();
                    result.put("1", cookie.getValue());
                    break;
                }
            }
        }
View Full Code Here

        // 3. First matching cookie parameter 'locale' within each cookie sent
        Cookie[] cookies = request.getCookies();
        if (cookies != null) {
            for (int i = 0; i < cookies.length; i++) {
                Cookie cookie = cookies[i];
                if (cookie.getName().equals(attribute)) {
                    localeStr = cookie.getValue();
                    locale = parseLocale(localeStr);
                    if (test == null || test.test("cookie", locale)) {
                        return locale;
                    }
                    break;
View Full Code Here

    public static void addCookie(Map objectModel, String name, String value,
                                    String comment, String domain, int maxage, String path,
                                    String secure, int version)
    {
        Response response = ObjectModelHelper.getResponse(objectModel);
        Cookie cookieToSet = response.createCookie(name,value);

        if ((comment.trim()).length() > 0)
            cookieToSet.setComment(comment);

        if ((domain.trim()).length() > 0)
            cookieToSet.setDomain(domain);

        if (maxage > 0)
            cookieToSet.setMaxAge(maxage);

        if ((path.trim()).length() > 0)
            cookieToSet.setPath("/");

        cookieToSet.setSecure(BooleanUtils.toBoolean(secure));
        cookieToSet.setVersion(version);
        response.addCookie(cookieToSet);
    }
View Full Code Here

        boolean matchFound = false;

        int count = 0;

        Request request = ObjectModelHelper.getRequest(objectModel);
        Cookie currentCookie = null;

        if (cookieName != null) {
            retrieveByName = true;
        } else if (cookieIndex >=0) {
            retrieveByIndex =  true;
        }

        Cookie[] cookies = request.getCookies();
        if (cookies != null && retrieveByName) {
            for(count = 0; count < cookies.length; count++) {
                currentCookie = cookies[count];
                if (currentCookie.getName().equals(cookieName)) {
                    matchFound = true;
                    break;
                }
            }
        } else if(cookies != null && retrieveByIndex) {
View Full Code Here

    private static String returnCookieProperty(Map objectModel,
                                               String cookieName,
                                               int cookieIndex,
                                               String propertyPrefix)
    {
        Cookie currentCookie = getCookie(objectModel, cookieName, cookieIndex);

        String returnValue = null;
        if (currentCookie != null) {
            if(propertyPrefix.equals("C"))
                returnValue = currentCookie.getComment();
            else if(propertyPrefix.equals("D"))
                returnValue = currentCookie.getDomain();
            else if(propertyPrefix.equals("M"))
                returnValue = Integer.toString(currentCookie.getMaxAge());
            else if(propertyPrefix.equals("N"))
                returnValue = currentCookie.getName();
            else if(propertyPrefix.equals("P"))
                returnValue = currentCookie.getPath();
            else if(propertyPrefix.equals("S"))
                returnValue = String.valueOf(currentCookie.getSecure());
            else if(propertyPrefix.equals("V"))
                returnValue = currentCookie.getValue();
            else if(propertyPrefix.equals("Ve"))
                returnValue = Integer.toString(currentCookie.getVersion());
        }

        return returnValue;
    }
View Full Code Here

        Cookie[] cookies = request.getCookies();
        HashMap result = null;

        if (cookies != null) {
            for (int i = 0; i < cookies.length; i++) {
                Cookie cookie = cookies[i];
                if (cookie.getName().equals(pattern)) {
                    result = new HashMap();
                    result.put("1", cookie.getValue());
                    break;
                }
            }
        }
View Full Code Here

        Request request = ObjectModelHelper.getRequest(objectModel);
       
        Cookie[] cookies = request.getCookies();
        if (cookies != null) {
            for(int count = 0; count < cookies.length; count++) {
                Cookie currentCookie = cookies[count];
                if (currentCookie.getName().equals(cookieName)) {
                    return currentCookie;
                }
            }
        }
       
View Full Code Here

        Element cookiesElement = doc.createElementNS(null, "cookies");
        root.appendChild(cookiesElement);

        Cookie[] cookies = this.request.getCookies();
        if (cookies != null) {
            Cookie current;
            Element node;
            Element parent;
            for(int i = 0; i < cookies.length; i++) {
                current = cookies[i];
                parent = doc.createElementNS(null, "cookie");
                parent.setAttributeNS(null, "name", current.getName());
                cookiesElement.appendChild(parent);
                node = doc.createElementNS(null, "comment");
                node.appendChild(this.createTextNode(doc, current.getComment()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "domain");
                node.appendChild(this.createTextNode(doc, current.getDomain()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "maxAge");
                node.appendChild(this.createTextNode(doc, "" + current.getMaxAge()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "name");
                node.appendChild(this.createTextNode(doc, current.getName()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "path");
                node.appendChild(this.createTextNode(doc, current.getPath()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "secure");
                node.appendChild(doc.createTextNode(BooleanUtils.toStringTrueFalse(current.getSecure())));
                parent.appendChild(node);
                node = doc.createElementNS(null, "value");
                node.appendChild(this.createTextNode(doc, current.getValue()));
                parent.appendChild(node);
                node = doc.createElementNS(null, "version");
                node.appendChild(this.createTextNode(doc, "" + current.getVersion()));
                parent.appendChild(node);
            }
        }
    }
View Full Code Here

            }
        }

        if (this._useCookies) {
            Request request = ObjectModelHelper.getRequest(objectModel);
            Cookie cookies[] = request.getCookies();
            if (cookies != null) {
                for (int i = 0; i < cookies.length; i++) {
                    String name = cookies[i].getName();
                    if (isValidXSLTParameterName(name)) {
                        String value = cookies[i].getValue();
View Full Code Here

TOP

Related Classes of org.apache.cocoon.environment.Cookie

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.