Package com.volantis.mcs.context

Examples of com.volantis.mcs.context.ResponseCachingDirectives


     * @throws PAPIException If there was a problem setting the cache expiry.
     */
    private void applyCacheExpires(
            MarinerRequestContext context, String content)
            throws PAPIException {
        final ResponseCachingDirectives cachingDirectives =
                getCachingDirectives(context);

        if (cachingDirectives != null) {
            // Determine cache expiry as Time
            try {
                Date httpDate = HttpDateParser.parse(content);
                if (httpDate == null) {
                    // If string didn't parse to long property, throw an exception
                    // reusing existing localised message, saying that Time was
                    // expected, but String was encountered.
                    throw new PAPIException(EXCEPTION_LOCALIZER.format(
                            "invalid-meta-content-type", new Object[]{
                            Time.class.getName(), String.class.getName()}));
                }

                Time expires = Time.inMilliSeconds(httpDate.getTime());

                cachingDirectives.setExpires(expires,
                        ResponseCachingDirectives.PRIORITY_HIGH);
                cachingDirectives.enable();
            } catch (NumberFormatException e) {

            }
        }
    }
View Full Code Here


     * @param content The String representation of the cache-max-age duration.
     * @throws PAPIException If there was a problem setting the cache-max-age.
     */
    private void applyCacheMaxAge(MarinerRequestContext context, String content)
            throws PAPIException {
        final ResponseCachingDirectives cachingDirectives =
                getCachingDirectives(context);

        if (cachingDirectives != null) {
            // Determine max-age as Period
            try {
                Period maxage = Period.inSeconds(Long.parseLong(content));

                cachingDirectives.setMaxAge(maxage,
                        ResponseCachingDirectives.PRIORITY_HIGH);
                cachingDirectives.enable();
            } catch (NumberFormatException e) {
                // If string didn't parse to long property, throw an exception
                // reusing existing localised message, saying that Period was
                // expected, but String was encountered.
                throw new PAPIException(EXCEPTION_LOCALIZER.format(
View Full Code Here

     *
     * @param context The MarinerRequestContext within which this meta element is
     *                being processed.
     */
    private void applyNoCache(MarinerRequestContext context) {
        final ResponseCachingDirectives cachingDirectives =
                getCachingDirectives(context);

        if (cachingDirectives != null) {
            cachingDirectives.disable();
        }
    }
View Full Code Here

     *
     * @param context The MarinerRequestContext within which this meta element is
     *                being processed.
     */
    private void applyCacheAuto(MarinerRequestContext context) {
        final ResponseCachingDirectives cachingDirectives =
                getCachingDirectives(context);

        if (cachingDirectives != null) {
            cachingDirectives.enable();
        }
    }
View Full Code Here

     *         directives cannot be located for this <code>MarinerRequestContext</code>.
     */
    private ResponseCachingDirectives getCachingDirectives(
            MarinerRequestContext context) {

        ResponseCachingDirectives directives = null;

        // Lookup caching directives
        final EnvironmentContext environmentContext =
                ContextInternals.getEnvironmentContext(context);
        directives = environmentContext.getCachingDirectives();
View Full Code Here

                dataHandlingStrategy, context);

        final EnvironmentContext environmentContext =
            ContextInternals.getEnvironmentContext(
                context.getInitialRequestContext());
        final ResponseCachingDirectives cachingDirectives =
            environmentContext.getCachingDirectives();
        if (cachingDirectives != null) {
            cachingDirectives.disable();
        }
    }
View Full Code Here

        marinerRequestContextMock.expects.getMarinerPageContext()
                .returns(marinerPageContextMock).any();
        final EnvironmentContextMock environmentContextMock =
            new EnvironmentContextMock("environmentContextMock", expectations);
        cachingDirectives = new ResponseCachingDirectives(SystemClock.getDefaultInstance());
        cachingDirectives.enable();
        assertTrue(cachingDirectives.isEnabled());

        environmentContextMock.expects.getCachingDirectives().returns(
            cachingDirectives).any();
View Full Code Here

        // From new XFGroupElementImpl(context);
        context.expects.getCurrentElement().returns(null);
        context.expects.getInitialRequestContext().returns(requestContext);
        final EnvironmentContextMock environmentContextMock =
            new EnvironmentContextMock("environmentContextMock", expectations);
        final ResponseCachingDirectives cachingDirectives =
            new ResponseCachingDirectives(SystemClock.getDefaultInstance());
        cachingDirectives.enable();
        assertTrue(cachingDirectives.isEnabled());

        environmentContextMock.expects.getCachingDirectives().returns(
            cachingDirectives);
        requestContext.expects.getEnvironmentContext().returns(
            environmentContextMock);

        XFGroupElementImpl group = new XFGroupElementImpl(context);

        assertFalse(cachingDirectives.isEnabled());

        // Set expectations.
        // From StylableXDIMEElement#styleElementStart
        context.expects.getInitialRequestContext().returns(requestContext);
        requestContext.expects.getMarinerPageContext().returns(pageContext);
View Full Code Here

        context.expects.getCurrentElement().returns(null);
        context.expects.getInitialRequestContext().returns(requestContext);
        final EnvironmentContextMock environmentContextMock =
            new EnvironmentContextMock("environmentContextMock", expectations);
        final ResponseCachingDirectives cachingDirectives =
            new ResponseCachingDirectives(SystemClock.getDefaultInstance());
        cachingDirectives.enable();
        assertTrue(cachingDirectives.isEnabled());

        environmentContextMock.expects.getCachingDirectives().returns(
            cachingDirectives);
        requestContext.expects.getEnvironmentContext().returns(
            environmentContextMock);

        XFGroupElementImpl group = new XFGroupElementImpl(context);

        assertFalse(cachingDirectives.isEnabled());

        // Set expectations.

        model.expects.isActive().returns(activeBefore);
        model.expects.popElementOutputState().returns(outputState);
View Full Code Here

        final MarinerPageContextMock marinerPageContextMock =
            new MarinerPageContextMock("marinerPageContextMock", expectations);
        final EnvironmentContextMock environmentContextMock =
            new EnvironmentContextMock("environmentContextMock", expectations);
        cachingDirectives =
            new ResponseCachingDirectives(SystemClock.getDefaultInstance());
        cachingDirectives.enable();
        assertTrue(cachingDirectives.isEnabled());

        environmentContextMock.expects.getCachingDirectives().returns(
            cachingDirectives).any();
View Full Code Here

TOP

Related Classes of com.volantis.mcs.context.ResponseCachingDirectives

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.