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