Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Response


            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 (getLogger().isDebugEnabled()) {
                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(attribute, locale));
        }
    }
View Full Code Here

                this.cachedResponse = null;
            }
        }
        if ( this.cacheExpires > 0
             && (this.reader != null || this.lastConsumer == this.serializer )) {
            Response res = ObjectModelHelper.getResponse(environment.getObjectModel());
            res.setDateHeader("Expires", System.currentTimeMillis() + (this.cacheExpires*1000));
            res.setHeader("Cache-Control", "max-age=" + this.cacheExpires + ", public");
        }
    }
View Full Code Here

    }

    public Map act(Redirector redirector, SourceResolver resolver,
                   Map objectModel, String source, Parameters parameters)
    throws Exception {
        Response response = ObjectModelHelper.getResponse(objectModel);
        Calendar calendar = Calendar.getInstance(DateUtils.UTC_TIME_ZONE);
        Map values = new HashMap(3);

        /* Get the current time and output as the last modified header */
        String value = this.formatter.format(calendar);
        long maxage = calendar.getTime().getTime();
        response.setHeader("Last-Modified", value);
        values.put("last-modified",  value);

        /* Advance the time as much as required */
        calendar.add(Calendar.DATE, this.days);
        calendar.add(Calendar.HOUR, this.hours);
        calendar.add(Calendar.MINUTE, this.minutes);
        calendar.add(Calendar.SECOND, this.seconds);

        /* Recalculate time and age to see what changed */
        maxage = calendar.getTime().getTime() - maxage;

        /* If we got more than one second everything is quite normal */
        if (maxage > 1000) {
            value = this.formatter.format(calendar);
            response.setHeader("Expires", value);
            values.put("expires", value);

            value = "max-age=" + Long.toString(maxage / 1000l);
            response.setHeader("Cache-Control", value);
            values.put("cache-control", value);

        /* If we got less than one second (even negatives) no cache */
        } else {
            /* We still hold the old value from Last-Modified here */
            response.setHeader("Expires", value);
            values.put("expires", value);

            response.setHeader("Cache-Control", "no-cache");
            values.put("cache-control", "no-cache");
        }

        /* Return the headers */
        return(Collections.unmodifiableMap(values));
View Full Code Here

    public Map act(Redirector redirector, SourceResolver resolver,
                   Map objectModel, String source, Parameters parameters)
    throws Exception {
        final Map results = new HashMap();

        final Response response = ObjectModelHelper.getResponse(objectModel);

        // Process local configuration parameters
        final String[] names = parameters.getNames();
        for (int i = 0; i < names.length; i++) {
            response.setHeader(names[i],parameters.getParameter(names[i]));
            results.put(names[i], parameters.getParameter(names[i]));
        }

        // Process global defaults, that are not overridden
        for (int i = 0; i < defaults.length; i++) {
            if (!results.containsKey(this.defaults[i])) {
                response.setHeader((String) this.defaults[i], (String) this.settings.get(defaults[i]));
                results.put(this.defaults[i], this.settings.get(defaults[i]));
            }
        }

        return Collections.unmodifiableMap(results);
View Full Code Here

                                          this,
                                          info.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);
        }

        setURI(info.prefix, info.uri);       
    }
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

    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception {
        Map results = new HashMap();
  HashMap isDone = new HashMap();
  Integer dummy = new Integer(1);

        Response response = (Response)objectModel.get(Constants.RESPONSE_OBJECT);
        String[] names = parameters.getNames();

  // parameters
        for (int i=0; i<names.length; i++) {
      isDone.put(names[i], dummy);
            response.setHeader(names[i],parameters.getParameter(names[i]));
            results.put(names[i],parameters.getParameter(names[i]));
        }
  // defaults, that are not overridden
        for (int i=0; i<defaults.length; i++) {
      if (! isDone.containsKey(defaults[i])) {
    response.setHeader((String) defaults[i], (String) settings.get(defaults[i]));
    results.put((String) defaults[i],(String) settings.get(defaults[i]));
      }
        }

        return Collections.unmodifiableMap(results);
View Full Code Here

            }
        }

        // store in a cookie if so configured
        if (storeInCookie) {
            Response response =
               (Response) objectModel.get(Constants.RESPONSE_OBJECT);

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

        // set up a map for XPath Substituion
        Map map = new HashMap();
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.getBinaryStream(1);
                if (this.typeColumn != 0) {
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.