Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Response


            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.getBinaryStream(1);
                if (this.typeColumn != 0) {
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().warn("Assuming client reset stream");

            this.doCommit = false;
View Full Code Here

            this.getLogger().debug("BEGIN showConfiguration consumer=" + consumer + ", src="+src);
        }

        // get some important information
        Request request = ObjectModelHelper.getRequest(this.objectModel);
        Response response = ObjectModelHelper.getResponse(this.objectModel);
        Session session = request.getSession();
       
        boolean isAdmin = (src == null || src.equals("admin"));

        // now start producing xml:
        AttributesImpl attr = new AttributesImpl();
        consumer.startElement("", "configuration", "configuration", attr);

        // set the conf uri:
        // This is a bug in the servlet 2.2 API!!!
        // It does not contain the context:  String uri = HttpUtils.getRequestURL(this.request).toString();
        // So: ABSOLUTELY USELESS
        String uri = response.encodeURL(request.getRequestURI());
        consumer.startElement("", "uri", "uri", attr);
        consumer.characters(uri.toCharArray(), 0, uri.length());
        consumer.endElement("", "uri", "uri");

        if (isAdmin == true) {
View Full Code Here

        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

            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 {
        Response response = (Response) objectModel.get(Constants.RESPONSE_OBJECT);

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

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

            response.setHeader("Accept-Ranges", "bytes");

            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() == false) throw new ResourceNotFoundException("There is no resource with that key");

            Response response = (Response) objectModel.get(Constants.RESPONSE_OBJECT);
            Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);

            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 = (Response) objectModel.get(Constants.RESPONSE_OBJECT);
            this.serialize(response);
        } catch (IOException ioe) {
            getLogger().debug("Assuming client reset stream");

            this.doCommit = false;
View Full Code Here

            }
        }

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

            response.addCookie(response.createCookie(localeAttr, lc));
            debug("created cookies");
        }

        // set up a map for XPath Substituion
        Map map = new HashMap();
View Full Code Here

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

        try {
            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));
            }
            response.setHeader("Accept-Ranges", "bytes");

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

            InputStream inputStream = this.inputSource.getInputStream();
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.