--- /dev/null
+/**\r
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.\r
+ *\r
+ * This library is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU Lesser General Public License as published by the Free\r
+ * Software Foundation; either version 2.1 of the License, or (at your option)\r
+ * any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful, but WITHOUT\r
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\r
+ * details.\r
+ */\r
+\r
+package com.liferay.portal.model.impl;\r
+\r
+import com.liferay.portal.LayoutFriendlyURLException;\r
+import com.liferay.portal.NoSuchGroupException;\r
+import com.liferay.portal.kernel.exception.PortalException;\r
+import com.liferay.portal.kernel.exception.SystemException;\r
+import com.liferay.portal.kernel.log.Log;\r
+import com.liferay.portal.kernel.log.LogFactoryUtil;\r
+import com.liferay.portal.kernel.util.CharPool;\r
+import com.liferay.portal.kernel.util.HttpUtil;\r
+import com.liferay.portal.kernel.util.ListUtil;\r
+import com.liferay.portal.kernel.util.LocaleUtil;\r
+import com.liferay.portal.kernel.util.StringPool;\r
+import com.liferay.portal.kernel.util.StringUtil;\r
+import com.liferay.portal.kernel.util.UnicodeProperties;\r
+import com.liferay.portal.kernel.util.Validator;\r
+import com.liferay.portal.model.ColorScheme;\r
+import com.liferay.portal.model.Group;\r
+import com.liferay.portal.model.Layout;\r
+import com.liferay.portal.model.LayoutConstants;\r
+import com.liferay.portal.model.LayoutOverride;\r
+import com.liferay.portal.model.LayoutSet;\r
+import com.liferay.portal.model.LayoutType;\r
+import com.liferay.portal.model.LayoutTypePortlet;\r
+import com.liferay.portal.model.LayoutTypePortletConstants;\r
+import com.liferay.portal.model.Portlet;\r
+import com.liferay.portal.model.Theme;\r
+import com.liferay.portal.security.permission.ActionKeys;\r
+import com.liferay.portal.security.permission.PermissionChecker;\r
+import com.liferay.portal.service.GroupLocalServiceUtil;\r
+import com.liferay.portal.service.LayoutLocalServiceUtil;\r
+import com.liferay.portal.service.LayoutSetLocalServiceUtil;\r
+import com.liferay.portal.service.PortletLocalServiceUtil;\r
+import com.liferay.portal.service.ThemeLocalServiceUtil;\r
+import com.liferay.portal.service.permission.LayoutPermissionUtil;\r
+import com.liferay.portal.theme.ThemeDisplay;\r
+import com.liferay.portal.util.CookieKeys;\r
+import com.liferay.portal.util.LayoutClone;\r
+import com.liferay.portal.util.LayoutCloneFactory;\r
+import com.liferay.portal.util.PortalUtil;\r
+import com.liferay.portal.util.PropsValues;\r
+import com.liferay.portal.util.WebKeys;\r
+import com.liferay.portlet.PortletURLImpl;\r
+import com.pentila.entSavoie.utils.ENTMainUtilsLocalServiceUtil;\r
+\r
+import java.io.IOException;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Locale;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import javax.portlet.PortletException;\r
+import javax.portlet.PortletMode;\r
+import javax.portlet.PortletRequest;\r
+import javax.portlet.WindowState;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+\r
+/**\r
+ * @author Brian Wing Shun Chan\r
+ */\r
+public class LayoutImpl extends LayoutBaseImpl implements LayoutOverride {\r
+\r
+ public static int validateFriendlyURL(String friendlyURL) {\r
+ if (friendlyURL.length() < 2) {\r
+ return LayoutFriendlyURLException.TOO_SHORT;\r
+ }\r
+\r
+ if (friendlyURL.length() > LayoutConstants.FRIENDLY_URL_MAX_LENGTH) {\r
+ return LayoutFriendlyURLException.TOO_LONG;\r
+ }\r
+\r
+ if (!friendlyURL.startsWith(StringPool.SLASH)) {\r
+ return LayoutFriendlyURLException.DOES_NOT_START_WITH_SLASH;\r
+ }\r
+\r
+ if (friendlyURL.endsWith(StringPool.SLASH)) {\r
+ return LayoutFriendlyURLException.ENDS_WITH_SLASH;\r
+ }\r
+\r
+ if (friendlyURL.indexOf(StringPool.DOUBLE_SLASH) != -1) {\r
+ return LayoutFriendlyURLException.ADJACENT_SLASHES;\r
+ }\r
+\r
+ for (char c : friendlyURL.toCharArray()) {\r
+ if (!Validator.isChar(c) && !Validator.isDigit(c) &&\r
+ (c != CharPool.DASH) && (c != CharPool.PERCENT) &&\r
+ (c != CharPool.PERIOD) && (c != CharPool.PLUS) &&\r
+ (c != CharPool.SLASH) && (c != CharPool.STAR) &&\r
+ (c != CharPool.UNDERLINE)) {\r
+\r
+ return LayoutFriendlyURLException.INVALID_CHARACTERS;\r
+ }\r
+ }\r
+\r
+ return -1;\r
+ }\r
+\r
+ public static void validateFriendlyURLKeyword(String friendlyURL)\r
+ throws LayoutFriendlyURLException {\r
+\r
+ for (String keyword : PropsValues.LAYOUT_FRIENDLY_URL_KEYWORDS) {\r
+ if (StringUtil.endsWith(\r
+ friendlyURL, StringUtil.quote(keyword, StringPool.SLASH)) ||\r
+ StringUtil.endsWith(\r
+ friendlyURL, StringPool.SLASH + keyword)) {\r
+\r
+ LayoutFriendlyURLException lfurle =\r
+ new LayoutFriendlyURLException(\r
+ LayoutFriendlyURLException.KEYWORD_CONFLICT);\r
+\r
+ lfurle.setKeywordConflict(keyword);\r
+\r
+ throw lfurle;\r
+ }\r
+ }\r
+ }\r
+\r
+ public LayoutImpl() {\r
+ }\r
+\r
+ public List<Layout> getAllChildren() throws SystemException {\r
+ List<Layout> layouts = new ArrayList<Layout>();\r
+\r
+ Iterator<Layout> itr = getChildren().iterator();\r
+\r
+ while (itr.hasNext()) {\r
+ Layout layout = itr.next();\r
+\r
+ layouts.add(layout);\r
+ layouts.addAll(layout.getAllChildren());\r
+ }\r
+\r
+ return layouts;\r
+ }\r
+\r
+ public long getAncestorLayoutId() throws PortalException, SystemException {\r
+ long layoutId = 0;\r
+\r
+ Layout layout = this;\r
+\r
+ while (true) {\r
+ if (!layout.isRootLayout()) {\r
+ layout = LayoutLocalServiceUtil.getLayout(\r
+ layout.getGroupId(), layout.isPrivateLayout(),\r
+ layout.getParentLayoutId());\r
+ }\r
+ else {\r
+ layoutId = layout.getLayoutId();\r
+\r
+ break;\r
+ }\r
+ }\r
+\r
+ return layoutId;\r
+ }\r
+\r
+ public long getAncestorPlid() throws PortalException, SystemException {\r
+ long plid = 0;\r
+\r
+ Layout layout = this;\r
+\r
+ while (true) {\r
+ if (!layout.isRootLayout()) {\r
+ layout = LayoutLocalServiceUtil.getLayout(\r
+ layout.getGroupId(), layout.isPrivateLayout(),\r
+ layout.getParentLayoutId());\r
+ }\r
+ else {\r
+ plid = layout.getPlid();\r
+\r
+ break;\r
+ }\r
+ }\r
+\r
+ return plid;\r
+ }\r
+\r
+ public List<Layout> getAncestors() throws PortalException, SystemException {\r
+ List<Layout> layouts = new ArrayList<Layout>();\r
+\r
+ Layout layout = this;\r
+\r
+ while (true) {\r
+ if (!layout.isRootLayout()) {\r
+ layout = LayoutLocalServiceUtil.getLayout(\r
+ layout.getGroupId(), layout.isPrivateLayout(),\r
+ layout.getParentLayoutId());\r
+\r
+ layouts.add(layout);\r
+ }\r
+ else {\r
+ break;\r
+ }\r
+ }\r
+\r
+ return layouts;\r
+ }\r
+\r
+ public List<Layout> getChildren() throws SystemException {\r
+ return LayoutLocalServiceUtil.getLayouts(\r
+ getGroupId(), isPrivateLayout(), getLayoutId());\r
+ }\r
+\r
+ public List<Layout> getChildren(PermissionChecker permissionChecker)\r
+ throws PortalException, SystemException {\r
+\r
+ List<Layout> layouts = ListUtil.copy(getChildren());\r
+\r
+ Iterator<Layout> itr = layouts.iterator();\r
+\r
+ while (itr.hasNext()) {\r
+ Layout layout = itr.next();\r
+\r
+ if (layout.isHidden() ||\r
+ !LayoutPermissionUtil.contains(\r
+ permissionChecker, layout, ActionKeys.VIEW)) {\r
+\r
+ itr.remove();\r
+ }\r
+ }\r
+\r
+ return layouts;\r
+ }\r
+\r
+ public ColorScheme getColorScheme()\r
+ throws PortalException, SystemException {\r
+\r
+ if (isInheritLookAndFeel()) {\r
+ return getLayoutSet().getColorScheme();\r
+ }\r
+ else {\r
+ return ThemeLocalServiceUtil.getColorScheme(\r
+ getCompanyId(), getTheme().getThemeId(), getColorSchemeId(),\r
+ false);\r
+ }\r
+ }\r
+\r
+ public String getCssText() throws PortalException, SystemException {\r
+ if (isInheritLookAndFeel()) {\r
+ return getLayoutSet().getCss();\r
+ }\r
+ else {\r
+ return getCss();\r
+ }\r
+ }\r
+\r
+ public Group getGroup() throws PortalException, SystemException {\r
+ return GroupLocalServiceUtil.getGroup(getGroupId());\r
+ }\r
+\r
+ public String getHTMLTitle(Locale locale) {\r
+ String localeLanguageId = LocaleUtil.toLanguageId(locale);\r
+\r
+ return getHTMLTitle(localeLanguageId);\r
+ }\r
+\r
+ public String getHTMLTitle(String localeLanguageId) {\r
+ String htmlTitle = getTitle(localeLanguageId);\r
+\r
+ if (Validator.isNull(htmlTitle)) {\r
+ htmlTitle = getName(localeLanguageId);\r
+ }\r
+\r
+ return htmlTitle;\r
+ }\r
+\r
+ public LayoutSet getLayoutSet() throws PortalException, SystemException {\r
+ if (_layoutSet == null) {\r
+ _layoutSet = LayoutSetLocalServiceUtil.getLayoutSet(\r
+ getGroupId(), isPrivateLayout());\r
+ }\r
+\r
+ return _layoutSet;\r
+ }\r
+\r
+ public LayoutType getLayoutType() {\r
+ if (_layoutType == null) {\r
+ _layoutType = new LayoutTypePortletImpl(this);\r
+ }\r
+\r
+ return _layoutType;\r
+ }\r
+\r
+ public long getParentPlid() throws PortalException, SystemException {\r
+ if (getParentLayoutId() == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {\r
+ return 0;\r
+ }\r
+\r
+ Layout layout = LayoutLocalServiceUtil.getLayout(\r
+ getGroupId(), isPrivateLayout(), getParentLayoutId());\r
+\r
+ return layout.getPlid();\r
+ }\r
+\r
+ public String getRegularURL(HttpServletRequest request)\r
+ throws PortalException, SystemException {\r
+\r
+ return _getURL(request, false, false, false);\r
+ }\r
+ \r
+ public String getAjaxURL(HttpServletRequest request)\r
+ throws SystemException, PortalException {\r
+\r
+ return _getURL(request, false, false, true);\r
+ }\r
+\r
+ public String getResetLayoutURL(HttpServletRequest request)\r
+ throws PortalException, SystemException {\r
+\r
+ return _getURL(request, true, true, false);\r
+ }\r
+\r
+ public String getResetMaxStateURL(HttpServletRequest request)\r
+ throws PortalException, SystemException {\r
+\r
+ return _getURL(request, true, false, false);\r
+ }\r
+\r
+ public Group getScopeGroup() throws PortalException, SystemException {\r
+ Group group = null;\r
+\r
+ try {\r
+ group = GroupLocalServiceUtil.getLayoutGroup(\r
+ getCompanyId(), getPlid());\r
+ }\r
+ catch (NoSuchGroupException nsge) {\r
+ }\r
+\r
+ return group;\r
+ }\r
+\r
+ public String getTarget() {\r
+ return PortalUtil.getLayoutTarget(this);\r
+ }\r
+\r
+ public Theme getTheme() throws PortalException, SystemException {\r
+ if (isInheritLookAndFeel()) {\r
+ return getLayoutSet().getTheme();\r
+ }\r
+ else {\r
+ return ThemeLocalServiceUtil.getTheme(\r
+ getCompanyId(), getThemeId(), false);\r
+ }\r
+ }\r
+\r
+ public String getThemeSetting(String key, String device) {\r
+ UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();\r
+\r
+ String value = typeSettingsProperties.getProperty(\r
+ ThemeSettingImpl.namespaceProperty(device, key));\r
+\r
+ if (value != null) {\r
+ return value;\r
+ }\r
+\r
+ try {\r
+ LayoutSet layoutSet = getLayoutSet();\r
+\r
+ value = layoutSet.getThemeSetting(key, device);\r
+ }\r
+ catch (Exception e) {\r
+ }\r
+\r
+ return value;\r
+ }\r
+\r
+ @Override\r
+ public String getTypeSettings() {\r
+ if (_typeSettingsProperties == null) {\r
+ return super.getTypeSettings();\r
+ }\r
+ else {\r
+ return _typeSettingsProperties.toString();\r
+ }\r
+ }\r
+\r
+ public UnicodeProperties getTypeSettingsProperties() {\r
+ if (_typeSettingsProperties == null) {\r
+ _typeSettingsProperties = new UnicodeProperties(true);\r
+\r
+ _typeSettingsProperties.fastLoad(super.getTypeSettings());\r
+ }\r
+\r
+ return _typeSettingsProperties;\r
+ }\r
+\r
+ public String getTypeSettingsProperty(String key) {\r
+ UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();\r
+\r
+ return typeSettingsProperties.getProperty(key);\r
+ }\r
+\r
+ public String getTypeSettingsProperty(String key, String defaultValue) {\r
+ UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();\r
+\r
+ return typeSettingsProperties.getProperty(key, defaultValue);\r
+ }\r
+\r
+ public ColorScheme getWapColorScheme()\r
+ throws PortalException, SystemException {\r
+\r
+ if (isInheritLookAndFeel()) {\r
+ return getLayoutSet().getWapColorScheme();\r
+ }\r
+ else {\r
+ return ThemeLocalServiceUtil.getColorScheme(\r
+ getCompanyId(), getWapTheme().getThemeId(),\r
+ getWapColorSchemeId(), true);\r
+ }\r
+ }\r
+\r
+ public Theme getWapTheme() throws PortalException, SystemException {\r
+ if (isInheritWapLookAndFeel()) {\r
+ return getLayoutSet().getWapTheme();\r
+ }\r
+ else {\r
+ return ThemeLocalServiceUtil.getTheme(\r
+ getCompanyId(), getWapThemeId(), true);\r
+ }\r
+ }\r
+\r
+ public boolean hasAncestor(long layoutId)\r
+ throws PortalException, SystemException {\r
+\r
+ long parentLayoutId = getParentLayoutId();\r
+\r
+ while (parentLayoutId != LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {\r
+ if (parentLayoutId == layoutId) {\r
+ return true;\r
+ }\r
+ else {\r
+ Layout parentLayout = LayoutLocalServiceUtil.getLayout(\r
+ getGroupId(), isPrivateLayout(), parentLayoutId);\r
+\r
+ parentLayoutId = parentLayout.getParentLayoutId();\r
+ }\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ public boolean hasChildren() throws SystemException {\r
+ return LayoutLocalServiceUtil.hasLayouts(\r
+ getGroupId(), isPrivateLayout(), getLayoutId());\r
+ }\r
+\r
+ public boolean hasScopeGroup() throws PortalException, SystemException {\r
+ Group group = getScopeGroup();\r
+\r
+ if (group != null) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isChildSelected(boolean selectable, Layout layout)\r
+ throws PortalException, SystemException {\r
+\r
+ if (selectable) {\r
+ long plid = getPlid();\r
+\r
+ List<Layout> ancestors = layout.getAncestors();\r
+\r
+ for (Layout curLayout : ancestors) {\r
+ if (plid == curLayout.getPlid()) {\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ public boolean isContentDisplayPage() {\r
+ UnicodeProperties typeSettingsProperties = getTypeSettingsProperties();\r
+\r
+ String defaultAssetPublisherPortletId =\r
+ typeSettingsProperties.getProperty(\r
+ LayoutTypePortletConstants.DEFAULT_ASSET_PUBLISHER_PORTLET_ID);\r
+\r
+ if (Validator.isNotNull(defaultAssetPublisherPortletId)) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isFirstChild() {\r
+ if (getPriority() == 0) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isFirstParent() {\r
+ if (isFirstChild() && isRootLayout()) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isInheritLookAndFeel() {\r
+ if (Validator.isNull(getThemeId()) ||\r
+ Validator.isNull(getColorSchemeId())) {\r
+\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isInheritWapLookAndFeel() {\r
+ if (Validator.isNull(getWapThemeId()) ||\r
+ Validator.isNull(getWapColorSchemeId())) {\r
+\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isLayoutPrototypeLinkActive() {\r
+ if (isLayoutPrototypeLinkEnabled() &&\r
+ Validator.isNotNull(getLayoutPrototypeUuid())) {\r
+\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ public boolean isPublicLayout() {\r
+ return !isPrivateLayout();\r
+ }\r
+\r
+ public boolean isRootLayout() {\r
+ if (getParentLayoutId() == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isSelected(\r
+ boolean selectable, Layout layout, long ancestorPlid) {\r
+\r
+ if (selectable) {\r
+ long plid = getPlid();\r
+\r
+ if ((plid == layout.getPlid()) || (plid == ancestorPlid)) {\r
+ return true;\r
+ }\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ public boolean isTypeArticle() {\r
+ if (getType().equals(LayoutConstants.TYPE_ARTICLE)) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isTypeControlPanel() {\r
+ if (getType().equals(LayoutConstants.TYPE_CONTROL_PANEL)) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isTypeEmbedded() {\r
+ if (getType().equals(LayoutConstants.TYPE_EMBEDDED)) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isTypeLinkToLayout() {\r
+ if (getType().equals(LayoutConstants.TYPE_LINK_TO_LAYOUT)) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isTypePanel() {\r
+ if (getType().equals(LayoutConstants.TYPE_PANEL)) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isTypePortlet() {\r
+ if (getType().equals(LayoutConstants.TYPE_PORTLET)) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ public boolean isTypeURL() {\r
+ if (getType().equals(LayoutConstants.TYPE_URL)) {\r
+ return true;\r
+ }\r
+ else {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void setGroupId(long groupId) {\r
+ super.setGroupId(groupId);\r
+\r
+ _layoutSet = null;\r
+ }\r
+\r
+ public void setLayoutSet(LayoutSet layoutSet) {\r
+ _layoutSet = layoutSet;\r
+ }\r
+\r
+ @Override\r
+ public void setPrivateLayout(boolean privateLayout) {\r
+ super.setPrivateLayout(privateLayout);\r
+\r
+ _layoutSet = null;\r
+ }\r
+\r
+ @Override\r
+ public void setTypeSettings(String typeSettings) {\r
+ _typeSettingsProperties = null;\r
+\r
+ super.setTypeSettings(typeSettings);\r
+ }\r
+\r
+ public void setTypeSettingsProperties(\r
+ UnicodeProperties typeSettingsProperties) {\r
+\r
+ _typeSettingsProperties = typeSettingsProperties;\r
+\r
+ super.setTypeSettings(_typeSettingsProperties.toString());\r
+ }\r
+\r
+ private LayoutTypePortlet _getLayoutTypePortletClone(\r
+ HttpServletRequest request)\r
+ throws IOException {\r
+\r
+ LayoutTypePortlet layoutTypePortlet = null;\r
+\r
+ LayoutClone layoutClone = LayoutCloneFactory.getInstance();\r
+\r
+ if (layoutClone != null) {\r
+ String typeSettings = layoutClone.get(request, getPlid());\r
+\r
+ if (typeSettings != null) {\r
+ UnicodeProperties typeSettingsProperties =\r
+ new UnicodeProperties(true);\r
+\r
+ typeSettingsProperties.load(typeSettings);\r
+\r
+ String stateMax = typeSettingsProperties.getProperty(\r
+ LayoutTypePortletConstants.STATE_MAX);\r
+ String stateMin = typeSettingsProperties.getProperty(\r
+ LayoutTypePortletConstants.STATE_MIN);\r
+\r
+ Layout layout = (Layout)this.clone();\r
+\r
+ layoutTypePortlet = (LayoutTypePortlet)layout.getLayoutType();\r
+\r
+ layoutTypePortlet.setStateMax(stateMax);\r
+ layoutTypePortlet.setStateMin(stateMin);\r
+ }\r
+ }\r
+\r
+ if (layoutTypePortlet == null) {\r
+ layoutTypePortlet = (LayoutTypePortlet)getLayoutType();\r
+ }\r
+\r
+ return layoutTypePortlet;\r
+ }\r
+\r
+ private String _getURL(\r
+ HttpServletRequest request, boolean resetMaxState,\r
+ boolean resetRenderParameters, boolean ajaxUrl)\r
+ throws PortalException, SystemException {\r
+\r
+ ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(\r
+ WebKeys.THEME_DISPLAY);\r
+\r
+ if (resetMaxState) {\r
+ Layout layout = themeDisplay.getLayout();\r
+\r
+ LayoutTypePortlet layoutTypePortlet = null;\r
+\r
+ if (layout.equals(this)) {\r
+ layoutTypePortlet = themeDisplay.getLayoutTypePortlet();\r
+ }\r
+ else {\r
+ try {\r
+ layoutTypePortlet = _getLayoutTypePortletClone(request);\r
+ }\r
+ catch (IOException ioe) {\r
+ _log.error("Unable to clone layout settings", ioe);\r
+\r
+ layoutTypePortlet = (LayoutTypePortlet)getLayoutType();\r
+ }\r
+ }\r
+\r
+ if (layoutTypePortlet.hasStateMax()) {\r
+ String portletId = StringUtil.split(\r
+ layoutTypePortlet.getStateMax())[0];\r
+\r
+ PortletURLImpl portletURLImpl = new PortletURLImpl(\r
+ request, portletId, getPlid(), PortletRequest.ACTION_PHASE);\r
+\r
+ try {\r
+ portletURLImpl.setWindowState(WindowState.NORMAL);\r
+ portletURLImpl.setPortletMode(PortletMode.VIEW);\r
+ }\r
+ catch (PortletException pe) {\r
+ throw new SystemException(pe);\r
+ }\r
+\r
+ portletURLImpl.setAnchor(false);\r
+\r
+ if (PropsValues.LAYOUT_DEFAULT_P_L_RESET &&\r
+ !resetRenderParameters) {\r
+\r
+ portletURLImpl.setParameter("p_l_reset", "0");\r
+ }\r
+ else if (!PropsValues.LAYOUT_DEFAULT_P_L_RESET &&\r
+ resetRenderParameters) {\r
+\r
+ portletURLImpl.setParameter("p_l_reset", "1");\r
+ }\r
+\r
+ return portletURLImpl.toString();\r
+ }\r
+ }\r
+\r
+ String portalURL = PortalUtil.getPortalURL(request);\r
+\r
+ String url = PortalUtil.getLayoutURL(this, themeDisplay);\r
+\r
+ if (!CookieKeys.hasSessionId(request) &&\r
+ (url.startsWith(portalURL) || url.startsWith(StringPool.SLASH))) {\r
+\r
+ url = PortalUtil.getURLWithSessionId(\r
+ url, request.getSession().getId());\r
+ }\r
+ \r
+ if (!CookieKeys.hasSessionId(request)) {\r
+ url = PortalUtil.getURLWithSessionId(\r
+ url, request.getSession().getId());\r
+ }\r
+ \r
+ if(ajaxUrl){\r
+ LayoutTypePortlet ltp = (LayoutTypePortlet) this.getLayoutType();\r
+ List<Portlet> portlets = ltp.getAllPortlets();\r
+ if(portlets.size() > 0){\r
+ \r
+ String viewAjaxJSPKey = ENTMainUtilsLocalServiceUtil.getViewAjaxJSPKey();\r
+\r
+ Portlet portlet = null;\r
+ Map<String, String> map = null;\r
+ Set<String> keys = null;\r
+ for(Portlet p: portlets){\r
+ map = p.getInitParams();\r
+ keys = map.keySet();\r
+ if(keys.contains(viewAjaxJSPKey)){\r
+ portlet = p;\r
+ break;\r
+ }\r
+ }\r
+ \r
+ if(Validator.isNotNull(portlet)){\r
+ url = HttpUtil.addParameter(url, "p_p_id", portlet.getPortletId());\r
+ url = HttpUtil.addParameter(url, "p_p_lifecycle", 0);\r
+ url = HttpUtil.addParameter(url, "p_p_state", "exclusive");\r
+ url = HttpUtil.addParameter(url, "p_p_mode", "view");\r
+ url = HttpUtil.addParameter(url, "p_p_col_id", "column-1");\r
+ url = HttpUtil.addParameter(url, "p_p_col_count", 1);\r
+ url = HttpUtil.addParameter(url, "jspPage", map.get(viewAjaxJSPKey));\r
+ }\r
+ }\r
+ }\r
+ \r
+ if (!resetMaxState) {\r
+ return url;\r
+ }\r
+\r
+ if (PropsValues.LAYOUT_DEFAULT_P_L_RESET && !resetRenderParameters) {\r
+ url = HttpUtil.addParameter(url, "p_l_reset", 0);\r
+ }\r
+ else if (!PropsValues.LAYOUT_DEFAULT_P_L_RESET &&\r
+ resetRenderParameters) {\r
+\r
+ url = HttpUtil.addParameter(url, "p_l_reset", 1);\r
+ }\r
+\r
+ return url;\r
+ }\r
+\r
+ private static Log _log = LogFactoryUtil.getLog(LayoutImpl.class);\r
+\r
+ private LayoutSet _layoutSet;\r
+ private LayoutType _layoutType;\r
+ private UnicodeProperties _typeSettingsProperties;\r
+\r
+}
\ No newline at end of file