本文整理汇总了Java中com.liferay.portal.kernel.model.Layout.getLayoutType方法的典型用法代码示例。如果您正苦于以下问题:Java Layout.getLayoutType方法的具体用法?Java Layout.getLayoutType怎么用?Java Layout.getLayoutType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.kernel.model.Layout
的用法示例。
在下文中一共展示了Layout.getLayoutType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSearchLayouts
import com.liferay.portal.kernel.model.Layout; //导入方法依赖的package包/类
/**
* Returns a list of layouts that contains the search portlet. Only layouts with the same private/public status and
* groupId as the given layout are searched for.
*
* @param currentLayout The layout from which to start the search.
* @return The list of layouts that contains the search portlet
*/
private List<Layout> getSearchLayouts(Layout currentLayout) {
long groupId = currentLayout.getGroupId();
boolean privateLayout = currentLayout.isPrivateLayout();
List<Layout> siteLayouts = this.layoutService.getLayouts(groupId, privateLayout, LayoutConstants.TYPE_PORTLET);
List<Layout> searchLayouts = new ArrayList<>();
for(Layout layout : siteLayouts) {
// We can safely type cast because we specify the layout type in the query above
LayoutTypePortlet layoutType = (LayoutTypePortlet) layout.getLayoutType();
if(layoutType.hasPortletId(FlashlightSearchPortletKeys.PORTLET_NAME)) {
searchLayouts.add(layout);
}
}
return searchLayouts;
}
示例2: findDefaultAssetPublisherInstanceId
import com.liferay.portal.kernel.model.Layout; //导入方法依赖的package包/类
/**
* Try to find an asset publisher instance id on a layout
*
* @param layout
* @return portlet instance id
* @throws PortalException
* @throws SystemException
*/
public static String findDefaultAssetPublisherInstanceId(Layout layout)
throws PortalException, SystemException {
LayoutTypePortlet layoutType =
(LayoutTypePortlet) layout.getLayoutType();
List<Portlet> portlets = layoutType.getAllPortlets();
for (Portlet p : portlets) {
if (AssetPublisherPortletKeys.ASSET_PUBLISHER.equals(
p.getRootPortletId())) {
return p.getInstanceId();
}
}
throw new PortalException(
"Couldn't find asset publisher on page " + layout.getFriendlyURL() +
". Please check configuration.");
}
示例3: removePortlet
import com.liferay.portal.kernel.model.Layout; //导入方法依赖的package包/类
@Override
public boolean removePortlet(Layout layout, String portletRemoveId) throws PortalException {
boolean removed = false;
List<Portlet> portlets = this.getPortlets(layout);
for(Portlet p : portlets) {
LayoutTypePortlet layoutType = (LayoutTypePortlet) layout.getLayoutType();
String portletId = p.getPortletId();
Company company = this.companyService.getCompanyById(layout.getCompanyId());
User defaultUser = company.getDefaultUser();
if(portletId != null && portletId.equals(portletRemoveId)) {
layoutType.removePortletId(defaultUser.getUserId(), portletId);
this.layoutService.updateLayout(
layout.getGroupId(),
layout.isPrivateLayout(),
layout.getLayoutId(),
layout.getTypeSettings()
);
removed = true;
break;
}
}
return removed;
}
示例4: generateSearchUrl
import com.liferay.portal.kernel.model.Layout; //导入方法依赖的package包/类
/**
* Returns a list of search URLs to be put in the request attributes
*
* @param themeDisplay The theme display
* @param layout The current page
* @return A list of search URLs to be put in the request attributes
*/
private List<SearchUrl> generateSearchUrl(HttpServletRequest request, ThemeDisplay themeDisplay, Layout layout) {
LayoutTypePortlet layoutType = (LayoutTypePortlet) layout.getLayoutType();
UnicodeProperties props = layoutType.getTypeSettingsProperties();
return layoutType.getPortlets().stream()
.filter(portlet -> portlet.getPortletName().equals(FlashlightSearchPortletKeys.PORTLET_NAME))
.map(portletInstance -> {
String columnId = StringPool.BLANK;
for(Entry<String, String> entry : props.entrySet()) {
if(entry.getValue().equals(portletInstance.getPortletId())) {
columnId = entry.getKey();
break;
}
}
String portletUrl;
try {
portletUrl = this.portal.getLayoutFriendlyURL(layout, themeDisplay);
} catch (PortalException e) {
portletUrl = StringPool.BLANK;
LOG.error(e);
}
SearchUrlRequestParameter[] params = new SearchUrlRequestParameter[] {
new SearchUrlRequestParameter(PARAM_PORTLET_ID, portletInstance.getPortletId()),
new SearchUrlRequestParameter(PARAM_PORTLET_LIFECYCLE, LIFECYCLE_RENDER),
new SearchUrlRequestParameter(PARAM_PORTLET_MODE, PortletMode.VIEW.toString()),
new SearchUrlRequestParameter(PARAM_PORTLET_COLUMN_ID, columnId),
new SearchUrlRequestParameter(PARAM_PORTLET_COLUMN_COUNT, Integer.toString(layoutType.getNumOfColumns()))
};
String portletNamespace = this.portal.getPortletNamespace(portletInstance.getPortletId());
return new SearchUrl(layout, portletUrl, params, portletNamespace);
})
.collect(Collectors.toList());
}
示例5: getPortlets
import com.liferay.portal.kernel.model.Layout; //导入方法依赖的package包/类
@Override
public List<Portlet> getPortlets(Layout l) {
List<Portlet> portlets;
LayoutType layoutTypeBase = l.getLayoutType();
// Obtain a list of portlets only if we are on a Portlet layout
if(layoutTypeBase instanceof LayoutTypePortlet) {
LayoutTypePortlet layoutType = (LayoutTypePortlet) layoutTypeBase;
portlets = layoutType.getAllPortlets();
} else {
portlets = Collections.emptyList();
}
return portlets;
}
示例6: doGet
import com.liferay.portal.kernel.model.Layout; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String portletId = request.getParameter("portlet-id");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1> Portlet ID: " + portletId + "</h1>");
Company company = _companyLocalService.getCompanies().get(0);
Group guestGroup = null;
if (_layouts == null) {
_layouts = new ArrayList<>();
}
try {
guestGroup = _groupLocalService.getGroup(
company.getCompanyId(), "Guest");
User defaultUser = _userLocalService.getDefaultUser(
company.getCompanyId());
UUID uuid = UUID.randomUUID();
Layout layout = _layoutLocalService.addLayout(
defaultUser.getUserId(), guestGroup.getGroupId(), false, 0,
uuid.toString(), null, null, "portlet", false,
"/" + uuid.toString(), new ServiceContext());
_layouts.add(layout);
LayoutTypePortlet layoutTypePortlet =
(LayoutTypePortlet)layout.getLayoutType();
layoutTypePortlet.setLayoutTemplateId(
defaultUser.getUserId(), "1_column");
String portletIdAdded = layoutTypePortlet.addPortletId(
defaultUser.getUserId(), portletId, false);
long ownerId = 0;
int ownerType = 3;
PortletPreferences prefs =
_portletPreferencesLocalService.getPreferences(
company.getCompanyId(), ownerId, ownerType,
layout.getPlid(), portletIdAdded);
_portletPreferencesLocalService.updatePreferences(
ownerId, ownerType, layout.getPlid(), portletIdAdded, prefs);
_layoutLocalService.updateLayout(
layout.getGroupId(), layout.isPrivateLayout(),
layout.getLayoutId(), layout.getTypeSettings());
response.sendRedirect("/"+uuid.toString());
}
catch (PortalException pe) {
_logger.log(Level.SEVERE, pe.getMessage(), pe);
}
}
示例7: doGet
import com.liferay.portal.kernel.model.Layout; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String portletId = request.getParameter("portlet-id");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1> Portlet ID: " + portletId + "</h1>");
Company company = _companyLocalService.getCompanies().get(0);
Group guestGroup = null;
if (_layouts == null) {
_layouts = new ArrayList<>();
}
try {
guestGroup = _groupLocalService.getGroup(
company.getCompanyId(), "Guest");
User defaultUser = _userLocalService.getDefaultUser(
company.getCompanyId());
UUID uuid = UUID.randomUUID();
Layout layout = _layoutLocalService.addLayout(
defaultUser.getUserId(), guestGroup.getGroupId(), false, 0,
uuid.toString(), null, null, "portlet", false,
"/" + uuid.toString(), new ServiceContext());
_layouts.add(layout);
LayoutTypePortlet layoutTypePortlet =
(LayoutTypePortlet)layout.getLayoutType();
layoutTypePortlet.setLayoutTemplateId(
defaultUser.getUserId(), "1_column");
String portletIdAdded = layoutTypePortlet.addPortletId(
defaultUser.getUserId(), portletId, false);
long ownerId = 0;
int ownerType = 3;
PortletPreferences prefs =
_portletPreferencesLocalService.getPreferences(
company.getCompanyId(), ownerId, ownerType,
layout.getPlid(), portletIdAdded);
_portletPreferencesLocalService.updatePreferences(
ownerId, ownerType, layout.getPlid(), portletIdAdded, prefs);
_layoutLocalService.updateLayout(
layout.getGroupId(), layout.isPrivateLayout(),
layout.getLayoutId(), layout.getTypeSettings());
response.sendRedirect("/"+uuid.toString());
}
catch (PortalException e) {
_logger.log(Level.SEVERE, e.getMessage(), e);
}
}