Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Response


        this.preparePipeline(environment);


        // See if we need to set an "Expires:" header
        if (this.expires != 0) {
            Response res = ObjectModelHelper.getResponse(environment.getObjectModel());
            res.setDateHeader("Expires", System.currentTimeMillis() + expires);
            res.setHeader("Cache-Control", "max-age=" + expires/1000 + ", public");
            if (this.getLogger().isDebugEnabled())
                this.getLogger().debug("Setting a new Expires object for this resource");
            environment.getObjectModel().put(ObjectModelHelper.EXPIRES_OBJECT,
                 new Long(expires + System.currentTimeMillis()));
        }
View Full Code Here


            }
        }

        // store in a cookie if so configured
        if (storeInCookie) {
            Response response = ObjectModelHelper.getResponse(objectModel);

            response.addCookie(response.createCookie(localeAttr, lc));
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("created cookies");
            }
        }
View Full Code Here

                                    String      media,
                                    String      contextID)
    throws IOException, SAXException, ProcessingException {
        // synchronized not req.
        this.setup();
        Response response = ContextHelper.getResponse(this.componentContext);

        XMLUtils.startElement(consumer, PortalConstants.ELEMENT_CONFIGURATION);

        // set the portal-page uri:
        StringBuffer buffer = new StringBuffer(requestURI);
        buffer.append((requestURI.indexOf('?') == -1 ? '?' : '&'))
            .append(PortalManagerImpl.REQ_PARAMETER_PROFILE)
            .append('=')
            .append(profileID);
        String uri = response.encodeURL(buffer.toString());
        XMLUtils.startElement(consumer, "uri");
        XMLUtils.data(consumer, uri);
        XMLUtils.endElement(consumer, "uri");

        Map config = this.getConfiguration();
        String portalURI = response.encodeURL((String)config.get(PortalConstants.CONF_PORTAL_URI));

        XMLUtils.startElement(consumer, "portal");
        XMLUtils.data(consumer, portalURI);
        XMLUtils.endElement(consumer, "portal");
View Full Code Here

                                          queryString,
                                          this,
                                          rawMode);
        this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, this.request);
        if (wrapResponse) {
            Response response = new ResponseWrapper(ObjectModelHelper.getResponse(oldObjectModel));
            this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, response);
        }
    }
View Full Code Here

            resultSet = statement.executeQuery();
            if (!resultSet.next()) {
                throw new ResourceNotFoundException("There is no resource with that key");
            }

            Response response = ObjectModelHelper.getResponse(objectModel);
            Request request = ObjectModelHelper.getRequest(objectModel);

            if (modifiedSince(resultSet, request, response)) {
                this.resource = resultSet.getBinaryStream(1);
                if (this.resource == null) {
View Full Code Here

     * Lastly, the <code>key</code> value is derived from the value of
     * the <code>source</code> string.
     */
    public void generate() throws ProcessingException, SAXException, IOException {
        try {
            Response response = ObjectModelHelper.getResponse(objectModel);
            serialize(response);
        } catch (IOException e) {
            getLogger().warn("Assuming client reset stream");
            this.doCommit = false;
        } catch (Exception e) {
View Full Code Here

            Map objectModel,
            String src,
            Parameters parameters)
        throws Exception {

        Response res = ObjectModelHelper.getResponse(objectModel);

        /*
         *  check response validity
         */
        if (res == null) {
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("COOKIECREATOR: no response object");
            }
            return null;
        }

        String cookieName = null;

        String
                cookieValue = null;

        String
                cookieComment = null;

        String
                cookieDomain = null;

        String
                cookiePath = null;

        try {
            cookieName = parameters.getParameter("name");
        } catch (Exception e) {
            if (getLogger().isDebugEnabled()) {
                getLogger().debug("COOKIECREATOR: cannot retrieve cookie name attribute");
            }
            return null;
        }

        cookieValue = parameters.getParameter("value", "");

        Cookie cookie = res.createCookie(cookieName, cookieValue);

        try {
            if ((cookieComment = parameters.getParameter("comment")) != null) {
                cookie.setComment(cookieComment);
            }
        } catch (ParameterException ignore) {
        }

        try {
            if ((cookieDomain = parameters.getParameter("domain")) != null) {
                cookie.setDomain(cookieDomain);
            }
        } catch (ParameterException ignore) {
        }

        try {
            if ((cookiePath = parameters.getParameter("path")) != null) {
                cookie.setPath(cookiePath);
            }
        } catch (ParameterException ignore) {
        }

        cookie.setSecure(parameters.getParameterAsBoolean("secure", false));
        cookie.setMaxAge(parameters.getParameterAsInteger("maxage", 0));
        cookie.setVersion(parameters.getParameterAsInteger("version", 0));

        res.addCookie(cookie);

        if (getLogger().isDebugEnabled()) {
            if (cookie.getMaxAge() == 0) {
                getLogger().debug("COOKIECREATOR: '" + cookieName
                         + "' cookie has been removed");
View Full Code Here

    /**
     * Generates the requested resource.
     */
    public void generate()
    throws IOException, ProcessingException {
        final Response response = ObjectModelHelper.getResponse(this.objectModel);

        final long expires = parameters.getParameterAsInteger("expires", -1);

        if (expires > 0) {
            response.setDateHeader("Expires", System.currentTimeMillis() + expires);
        }

        long contentLength = this.inputSource.getContentLength();
        if (contentLength != -1) {
            // FIXME (VG): Environment has setContentLength, and
            // Response interface has not. Strange.
            response.setHeader("Content-Length", Long.toString(contentLength));
        }

        // Bug #9539: This resource reader does not support ranges
        response.setHeader("Accept-Ranges", "none");

        byte[] buffer = new byte[8192];
        int length = -1;

        InputStream inputStream = this.inputSource.getInputStream();
View Full Code Here

            PreparedStatement statement = con.prepareStatement(getQuery());
            statement.setString(1, this.source);
            ResultSet set = statement.executeQuery();
            if (!set.next()) throw new ResourceNotFoundException("There is no resource with that key");

            Response response = ObjectModelHelper.getResponse(objectModel);
            Request request = ObjectModelHelper.getRequest(objectModel);

            if (this.modifiedSince(set, request, response)) {
                this.resource = set.getBlob(1);
View Full Code Here

     * Lastly, the <code>key</code> value is derived from the value of
     * the <code>source</code> string.
     */
    public void generate() throws ProcessingException, SAXException, IOException {
        try {
            Response response = ObjectModelHelper.getResponse(objectModel);
            this.serialize(response);
        } catch (IOException ioe) {
            getLogger().debug("Assuming client reset stream");

            this.doCommit = false;
View Full Code Here

TOP

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

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.