001
014
015 package com.liferay.portal.service;
016
017 import com.liferay.portal.kernel.bean.BeanReference;
018 import com.liferay.portal.kernel.exception.PortalException;
019 import com.liferay.portal.kernel.util.StringPool;
020 import com.liferay.portal.kernel.util.WebKeys;
021 import com.liferay.portal.model.Layout;
022 import com.liferay.portal.model.LayoutConstants;
023 import com.liferay.portal.service.persistence.LayoutPersistence;
024 import com.liferay.portal.theme.ThemeDisplay;
025 import com.liferay.portal.util.PortalUtil;
026
027 import javax.servlet.http.HttpServletRequest;
028
029
032 public abstract class BaseLocalServiceImpl implements BaseLocalService {
033
034 protected ClassLoader getClassLoader() {
035 Class<?> clazz = getClass();
036
037 return clazz.getClassLoader();
038 }
039
040 protected String getLayoutURL(
041 Layout layout, ServiceContext serviceContext) {
042
043 HttpServletRequest request = serviceContext.getRequest();
044
045 if (request == null) {
046 return StringPool.BLANK;
047 }
048
049 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
050 WebKeys.THEME_DISPLAY);
051
052 try {
053 return PortalUtil.getLayoutURL(layout, themeDisplay);
054 }
055 catch (Exception e) {
056 return StringPool.BLANK;
057 }
058 }
059
060 protected String getLayoutURL(
061 long groupId, String portletId, ServiceContext serviceContext)
062 throws PortalException {
063
064 long plid = serviceContext.getPlid();
065
066 long controlPanelPlid = PortalUtil.getControlPanelPlid(
067 serviceContext.getCompanyId());
068
069 if (plid == controlPanelPlid) {
070 plid = PortalUtil.getPlidFromPortletId(groupId, portletId);
071 }
072
073 String layoutURL = StringPool.BLANK;
074
075 if (plid != LayoutConstants.DEFAULT_PLID) {
076 Layout layout = layoutPersistence.findByPrimaryKey(plid);
077
078 layoutURL = getLayoutURL(layout, serviceContext);
079 }
080
081 return layoutURL;
082 }
083
084 @BeanReference(type = LayoutPersistence.class)
085 protected LayoutPersistence layoutPersistence;
086
087 }