Liferay on Private Site to get Public Site Page URL
来源:互联网 发布:学校网络舆情监控制度 编辑:程序博客网 时间:2024/04/19 10:21
This is a very interesting design in our website. We have a private site only for registered member. There's a youbar portlet which list bunches of articles. Members can share those articles in social networks like twitter, facebook, plusone and pinit. When the user in those social networks see the link our member shares, they should see the article detail via the link. But if we use the friendly url of private page, Liferay will link to login page first because it's private page.
Our design is we create a special YouBar page on Public Site which only has youbar portlet on it. And when member shares the articles on private site, we use the public site page friendly url instead of private one.
The thing is how to get YouBar page url. Liferay allows multiple pages with the same name. We can make an unique name for that.
1. our website is an organization website, All member is in the organization or sub-organization. If any member is in sub-organization, we have to get the top parent organization.
2. Every page in Liferay is a Layout. We need to identify the layout name equals "YouBar"
This method is used to get member's top organization in order to get group and get Layout.
public static String getPublicPageURLByName(ThemeDisplay themeDisplay, String pageName) throws Exception{Group group = null;if(themeDisplay.isSignedIn()){User user = themeDisplay.getUser();if(user != null){List<Organization> organizations = user.getOrganizations();if(organizations.size() > 0){for(Organization organization : organizations){while(organization.getParentOrganization() != null){organization = organization.getParentOrganization();}logger.info(organization.getName());group = organization.getGroup();break;}}}}else{group = themeDisplay.getScopeGroup();logger.info(group.getName());}return getPageURLByGroup(themeDisplay, pageName, group);}This method is to get the "YouBar" Page url.
public static String getPageURLByGroup(ThemeDisplay themeDisplay, String pageName, Group group)throws Exception{String pageURL = "";List<Layout> allLayouts = LayoutLocalServiceUtil.getLayouts(group.getGroupId(), false);for(Layout layout : allLayouts){if(layout.getNameCurrentValue().equalsIgnoreCase(pageName)){pageURL = themeDisplay.getPortalURL() + themeDisplay.getPathFriendlyURLPublic() + group.getFriendlyURL() + layout.getFriendlyURL();break;}}return pageURL;}It works only when member logs in. For not log in user, it doesn't work. Because it doesn't belong the special organization. One thing we can do is to search the organization based on organization name.
The other way is to configure partial url in properties file. Because we can get the portal url and public friendly url.
youbar.properties
dev.youbar.url=/web/guest/youbarqa.youbar.url=prod.youbar.url=
Controller.java
@Value("${${spring.profiles.active}.youbar.url}")private String youbarPartialFriendlyURL;
String friendlyURLPrefix = themeDisplay.getPortalURL() + themeDisplay.getPathFriendlyURLPublic() + youbarPartialFriendlyURL;
Then we can use the prefix now.
<c:set var="youbarFullFriendlyURL" value="${youbar_friendlyURL_prefix}/-/youbar/${channelArticle.friendlyUrl}.html" />According to your friendly url setting, you can configure it.
- Liferay on Private Site to get Public Site Page URL
- site
- site
- site
- site
- Site
- Good site on Interview
- On site construction technology
- VPN Site-to-Site Openswan x ASA (Cisco) on centos6.5
- EMule Developers page Web Site
- Get to the Top on Google: Tips and Techniques to Get Your Site to the Top of the Search Engine Ranki
- IE browser use URL to login web site
- IE browser use URL to login web site
- Site-to-site using rsa-encrypted
- CISCO Site-to-Site IPSEC VPN
- 动态地址Site-to-Site VPN
- To install ISCSI on AIX - from NetApp's site
- How to Secure Your Web Site Running on IBM i
- MOSS工作流 InfoPath+WorkFlow+Moss 开发要点
- InfoPath + Workflow + MOSS
- Java中的值传递和引用传递
- 栈之括号匹配问题
- String,StringBuffer与StringBuilder的区别
- Liferay on Private Site to get Public Site Page URL
- Java 学习个人笔记(二)(March 19,2013 )
- JSP页面显示乱码解决方案
- C#Partial Classes
- winform控件验证技术
- 图像处理就业(转)-----本人研究生正攻读本方向,不得不看看
- collision detect--SDL lib
- 2013开始
- 第五章Oracle恢复内部原理(实例恢复)