001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.events;
016    
017    import com.liferay.portal.kernel.events.Action;
018    import com.liferay.portal.kernel.events.ActionException;
019    import com.liferay.portal.kernel.util.ServerDetector;
020    import com.liferay.portal.model.Layout;
021    import com.liferay.portal.model.LayoutSet;
022    import com.liferay.portal.theme.ThemeDisplay;
023    import com.liferay.portal.util.PropsValues;
024    import com.liferay.portal.util.WebKeys;
025    
026    import javax.servlet.http.HttpServletRequest;
027    import javax.servlet.http.HttpServletResponse;
028    
029    /**
030     * @author Daniel Sanz
031     */
032    public class ParallelRenderPreAction extends Action {
033    
034            @Override
035            public void run(HttpServletRequest request, HttpServletResponse response)
036                    throws ActionException {
037    
038                    if (!PropsValues.LAYOUT_PARALLEL_RENDER_ENABLE ||
039                            !ServerDetector.isTomcat()) {
040    
041                            return;
042                    }
043    
044                    try {
045                            _servicePre(request);
046                    }
047                    catch (Exception e) {
048                            throw new ActionException(e);
049                    }
050            }
051    
052            private void _servicePre(HttpServletRequest request) throws Exception {
053                    ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
054                            WebKeys.THEME_DISPLAY);
055    
056                    if (themeDisplay == null) {
057                            return;
058                    }
059    
060                    Layout layout = themeDisplay.getLayout();
061    
062                    if (layout == null) {
063                            return;
064                    }
065    
066                    layout.getTypeSettingsProperties();
067    
068                    LayoutSet layoutSet = layout.getLayoutSet();
069    
070                    if (layoutSet != null) {
071                            layoutSet.getSettingsProperties();
072                    }
073            }
074    
075    }