List of usage examples for com.liferay.portal.kernel.model LayoutRevision getLayoutBranch
public LayoutBranch getLayoutBranch() throws com.liferay.portal.kernel.exception.PortalException;
From source file:com.liferay.layout.admin.web.internal.asset.LayoutRevisionAssetRenderer.java
License:Open Source License
public LayoutRevisionAssetRenderer(LayoutRevision layoutRevision) { _layoutRevision = layoutRevision;//from w w w . ja va 2 s.com try { _layoutBranch = layoutRevision.getLayoutBranch(); _layoutSetBranch = LayoutSetBranchLocalServiceUtil .getLayoutSetBranch(_layoutRevision.getLayoutSetBranchId()); } catch (Exception e) { throw new IllegalStateException(e); } }
From source file:com.liferay.layout.admin.web.internal.exportimport.data.handler.LayoutStagedModelDataHandler.java
License:Open Source License
protected void populateElementLayoutMetadata(Element layoutElement, Layout layout) throws Exception { LayoutStagingHandler layoutStagingHandler = LayoutStagingUtil.getLayoutStagingHandler(layout); if (layoutStagingHandler != null) { LayoutRevision layoutRevision = layoutStagingHandler.getLayoutRevision(); if (layoutRevision != null) { layoutElement.addAttribute("layout-revision-id", String.valueOf(layoutRevision.getLayoutRevisionId())); layoutElement.addAttribute("layout-branch-id", String.valueOf(layoutRevision.getLayoutBranchId())); LayoutBranch layoutBranch = layoutRevision.getLayoutBranch(); layoutElement.addAttribute("layout-branch-name", String.valueOf(layoutBranch.getName())); }/*from w w w. j a v a 2s . co m*/ } layoutElement.addAttribute("layout-uuid", layout.getUuid()); layoutElement.addAttribute("layout-id", String.valueOf(layout.getLayoutId())); layoutElement.addAttribute("layout-priority", String.valueOf(layout.getPriority())); String layoutPrototypeUuid = layout.getLayoutPrototypeUuid(); if (Validator.isNotNull(layoutPrototypeUuid)) { LayoutPrototype layoutPrototype = _layoutPrototypeLocalService .getLayoutPrototypeByUuidAndCompanyId(layoutPrototypeUuid, layout.getCompanyId()); layoutElement.addAttribute("layout-prototype-uuid", layoutPrototypeUuid); layoutElement.addAttribute("layout-prototype-name", layoutPrototype.getName(LocaleUtil.getDefault())); } }
From source file:com.liferay.layout.internal.util.LayoutsTreeImpl.java
License:Open Source License
private JSONObject _toJSONObject(HttpServletRequest request, long groupId, LayoutTreeNodes layoutTreeNodes, LayoutSetBranch layoutSetBranch) throws Exception { if (_log.isDebugEnabled()) { StringBundler sb = new StringBundler(5); sb.append("_toJSON(groupId="); sb.append(groupId);//from w ww .j a v a 2 s . c om sb.append(", layoutTreeNodes="); sb.append(layoutTreeNodes); sb.append(StringPool.CLOSE_PARENTHESIS); _log.debug(sb.toString()); } ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); boolean hasManageLayoutsPermission = GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), groupId, ActionKeys.MANAGE_LAYOUTS); boolean mobile = BrowserSnifferUtil.isMobile(request); for (LayoutTreeNode layoutTreeNode : layoutTreeNodes) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONObject childrenJSONObject = _toJSONObject(request, groupId, layoutTreeNode.getChildLayoutTreeNodes(), layoutSetBranch); jsonObject.put("children", childrenJSONObject); Layout layout = layoutTreeNode.getLayout(); jsonObject.put("contentDisplayPage", layout.isContentDisplayPage()); jsonObject.put("deleteable", _isDeleteable(layout, themeDisplay, layoutSetBranch)); jsonObject.put("friendlyURL", layout.getFriendlyURL()); if (layout instanceof VirtualLayout) { VirtualLayout virtualLayout = (VirtualLayout) layout; jsonObject.put("groupId", virtualLayout.getSourceGroupId()); } else { jsonObject.put("groupId", layout.getGroupId()); } jsonObject.put("hasChildren", layout.hasChildren()); jsonObject.put("layoutId", layout.getLayoutId()); jsonObject.put("name", layout.getName(themeDisplay.getLocale())); jsonObject.put("parentable", LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.ADD_LAYOUT)); jsonObject.put("parentLayoutId", layout.getParentLayoutId()); jsonObject.put("plid", layout.getPlid()); jsonObject.put("priority", layout.getPriority()); jsonObject.put("privateLayout", layout.isPrivateLayout()); jsonObject.put("regularURL", layout.getRegularURL(request)); jsonObject.put("sortable", hasManageLayoutsPermission && !mobile && SitesUtil.isLayoutSortable(layout)); jsonObject.put("type", layout.getType()); jsonObject.put("updateable", LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.UPDATE)); jsonObject.put("uuid", layout.getUuid()); LayoutRevision layoutRevision = LayoutStagingUtil.getLayoutRevision(layout); if (layoutRevision != null) { long layoutSetBranchId = layoutRevision.getLayoutSetBranchId(); if (_staging.isIncomplete(layout, layoutSetBranchId)) { jsonObject.put("incomplete", true); } LayoutSetBranch boundLayoutSetBranch = _layoutSetBranchLocalService .getLayoutSetBranch(layoutSetBranchId); LayoutBranch layoutBranch = layoutRevision.getLayoutBranch(); if (!layoutBranch.isMaster()) { jsonObject.put("layoutBranchId", layoutBranch.getLayoutBranchId()); jsonObject.put("layoutBranchName", layoutBranch.getName()); } if (layoutRevision.isHead()) { jsonObject.put("layoutRevisionHead", true); } jsonObject.put("layoutRevisionId", layoutRevision.getLayoutRevisionId()); jsonObject.put("layoutSetBranchId", layoutSetBranchId); jsonObject.put("layoutSetBranchName", boundLayoutSetBranch.getName()); } jsonArray.put(jsonObject); } JSONObject responseJSONObject = JSONFactoryUtil.createJSONObject(); responseJSONObject.put("layouts", jsonArray); responseJSONObject.put("total", layoutTreeNodes.getTotal()); return responseJSONObject; }