use of com.liferay.portal.kernel.model.Layout in project liferay-db-setup-core by ableneo.
the class SetupPages method setCustomFields.
private static void setCustomFields(final long groupId, final long company, final PageType page, final Layout layout) {
Class clazz = Layout.class;
String resolverHint = "Resolving customized value for page " + page.getFriendlyUrl() + " " + "failed for key " + "%%key%% and value %%value%%";
for (CustomFieldSetting cfs : page.getCustomFieldSetting()) {
String key = cfs.getKey();
String value = cfs.getValue();
CustomFieldSettingUtil.setExpandoValue(resolverHint.replace("%%key%%", key).replace("%%value%%", value), groupId, company, clazz, layout.getPlid(), key, value);
}
}
use of com.liferay.portal.kernel.model.Layout in project liferay-db-setup-core by ableneo.
the class SetupPages method addPages.
/**
* @param pages
* @param groupId
* @param isPrivate
* @param parentLayoutId
* @param company
* @param userId
*
* @throws SystemException
* @throws PortalException
*/
private static void addPages(final List<PageType> pages, String defaultLayout, String defaultLayoutContainedInThemeWithId, final long groupId, final boolean isPrivate, final long parentLayoutId, final long company, final long userId) throws PortalException {
for (PageType page : pages) {
Layout layout = null;
try {
layout = LayoutLocalServiceUtil.getFriendlyURLLayout(groupId, isPrivate, page.getFriendlyUrl());
LOG.info(String.format("Setup: Page %1$s already exist, not creating...", page.getName()));
if (layout != null && page.isDeleteExistingPages()) {
LayoutLocalServiceUtil.deleteLayout(layout);
if (page.getLinkToUrl() == null || page.getLinkToUrl().equals("")) {
layout = createPage(groupId, page, parentLayoutId, isPrivate);
} else {
layout = createLinkPage(page, groupId, parentLayoutId, userId);
}
} else if (layout != null && (page.getLinkToUrl() != null && !page.getLinkToUrl().equals(""))) {
updateLinkPage(page, groupId);
} else {
LOG.warn(String.format("Setup: unhandled 'else' while creatng page[%1$s]/layout[%2$s]", page.getName(), page.getLayout()));
}
} catch (NoSuchLayoutException e) {
if (page.getLinkToUrl() == null || page.getLinkToUrl().equals("")) {
layout = createPage(groupId, page, parentLayoutId, isPrivate);
} else {
layout = createLinkPage(page, groupId, parentLayoutId, userId);
}
LOG.info(String.format("Setup: Page %1$s created...", page.getName()));
} catch (Exception ex) {
LOG.error(ex);
}
// subtree
if (page.getLayout() == null) {
page.setLayout(defaultLayout);
page.setLayoutThemeId(defaultLayoutContainedInThemeWithId);
} else {
defaultLayout = page.getLayout();
defaultLayoutContainedInThemeWithId = page.getLayoutThemeId();
}
setupLiferayPage(layout, page, defaultLayout, defaultLayoutContainedInThemeWithId, groupId, isPrivate, company, userId, null);
}
}
use of com.liferay.portal.kernel.model.Layout in project sw360 by eclipse.
the class ProjectPortletUtils method createVulnerabilityFriendlyUrl.
public static String createVulnerabilityFriendlyUrl(ResourceRequest request) {
Portlet portlet = PortletLocalServiceUtil.getPortletById(PortalConstants.VULNERABILITIES_PORTLET_NAME);
Optional<Layout> layout = LayoutLocalServiceUtil.getLayouts(portlet.getCompanyId()).stream().filter(l -> ("/vulnerabilities").equals(l.getFriendlyURL())).findFirst();
if (layout.isPresent()) {
long plId = layout.get().getPlid();
LiferayPortletURL vulUrl = PortletURLFactoryUtil.create(request, PortalConstants.VULNERABILITIES_PORTLET_NAME, plId, PortletRequest.RENDER_PHASE);
vulUrl.setParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_DETAIL);
vulUrl.setParameter(PortalConstants.VULNERABILITY_ID, "replacewithexternalid");
return vulUrl.toString();
}
return "";
}
use of com.liferay.portal.kernel.model.Layout in project sw360 by eclipse.
the class ProjectPortletUtils method createProjectPortletUrlWithViewSizeFriendlyUrl.
public static String createProjectPortletUrlWithViewSizeFriendlyUrl(RenderRequest request, String projectId) {
Portlet portlet = PortletLocalServiceUtil.getPortletById(PortalConstants.PROJECT_PORTLET_NAME);
Optional<Layout> layout = LayoutLocalServiceUtil.getLayouts(portlet.getCompanyId()).stream().filter(l -> ("/projects").equals(l.getFriendlyURL())).findFirst();
if (layout.isPresent()) {
long plId = layout.get().getPlid();
LiferayPortletURL projUrl = PortletURLFactoryUtil.create(request, PortalConstants.PROJECT_PORTLET_NAME, plId, PortletRequest.RENDER_PHASE);
projUrl.setParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_DETAIL);
projUrl.setParameter(PortalConstants.PROJECT_ID, projectId);
projUrl.setParameter(PortalConstants.VIEW_SIZE, "replacewithviewsize");
return projUrl.toString();
}
return "";
}
use of com.liferay.portal.kernel.model.Layout in project sw360 by eclipse.
the class ModerationPortletUtils method getProjectPortletUrl.
private static LiferayPortletURL getProjectPortletUrl(PortletRequest request, String projectId) {
Portlet portlet = PortletLocalServiceUtil.getPortletById(PortalConstants.PROJECT_PORTLET_NAME);
Optional<Layout> layout = LayoutLocalServiceUtil.getLayouts(portlet.getCompanyId()).stream().filter(l -> ("/" + PortalConstants.PROJECTS.toLowerCase()).equals(l.getFriendlyURL())).findFirst();
if (layout.isPresent()) {
long plId = layout.get().getPlid();
LiferayPortletURL projectUrl = PortletURLFactoryUtil.create(request, PortalConstants.PROJECT_PORTLET_NAME, plId, PortletRequest.RENDER_PHASE);
projectUrl.setParameter(PortalConstants.PROJECT_ID, projectId);
projectUrl.setParameter(PortalConstants.PAGENAME, PortalConstants.PAGENAME_DETAIL);
return projectUrl;
}
return null;
}
Aggregations