Example usage for com.liferay.portal.kernel.servlet HttpHeaders CACHE_CONTROL_DEFAULT_VALUE

List of usage examples for com.liferay.portal.kernel.servlet HttpHeaders CACHE_CONTROL_DEFAULT_VALUE

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet HttpHeaders CACHE_CONTROL_DEFAULT_VALUE.

Prototype

String CACHE_CONTROL_DEFAULT_VALUE

To view the source code for com.liferay.portal.kernel.servlet HttpHeaders CACHE_CONTROL_DEFAULT_VALUE.

Click Source Link

Usage

From source file:com.liferay.wsrp.consumer.portlet.ConsumerPortlet.java

License:Open Source License

protected void processResourceResponse(ResourceRequest resourceRequest, ResourceResponse resourceResponse,
        WSRPConsumerManager wsrpConsumerManager, ServiceHolder serviceHolder,
        oasis.names.tc.wsrp.v2.types.ResourceResponse wsrpResourceResponse) throws Exception {

    PortletSession portletSession = resourceRequest.getPortletSession();

    PortletContext portletContext = wsrpResourceResponse.getPortletContext();

    if (portletContext != null) {
        portletSession.setAttribute(WebKeys.PORTLET_CONTEXT, portletContext);
    }/* w  w w. ja va 2 s  .c o m*/

    SessionContext sessionContext = wsrpResourceResponse.getSessionContext();

    updateSessionContext(portletSession, serviceHolder, sessionContext);

    ResourceContext resourceContext = wsrpResourceResponse.getResourceContext();

    CacheControl cacheControl = resourceContext.getCacheControl();

    if (cacheControl != null) {
        if (cacheControl.getExpires() == 0) {
            resourceResponse.setProperty(HttpHeaders.CACHE_CONTROL, HttpHeaders.CACHE_CONTROL_NO_CACHE_VALUE);
        } else if (cacheControl.getExpires() > 0) {
            resourceResponse.setProperty(HttpHeaders.CACHE_CONTROL, "max-age=" + cacheControl.getExpires());
        } else {
            resourceResponse.setProperty(HttpHeaders.CACHE_CONTROL, HttpHeaders.CACHE_CONTROL_DEFAULT_VALUE);
        }
    }

    NamedString[] clientAttributes = resourceContext.getClientAttributes();

    if (clientAttributes != null) {
        for (NamedString clientAttribute : clientAttributes) {
            String name = clientAttribute.getName();
            String value = clientAttribute.getValue();

            if (StringUtil.equalsIgnoreCase(name, HttpHeaders.CONTENT_DISPOSITION)) {

                resourceResponse.setProperty(HttpHeaders.CONTENT_DISPOSITION, value);

                break;
            }
        }
    }

    processMimeResponse(resourceRequest, resourceResponse, resourceContext);
}