Created
July 22, 2020 17:28
-
-
Save fabian-bouche-liferay/82b92893a8abfde10bab270957c3aac2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.liferay.samples.fbo.custom; | |
| import java.util.List; | |
| import org.osgi.service.component.annotations.Component; | |
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import com.liferay.portal.kernel.exception.PortalException; | |
| import com.liferay.portal.kernel.model.Layout; | |
| import com.liferay.portal.kernel.security.auth.GuestOrUserUtil; | |
| import com.liferay.portal.kernel.security.auth.PrincipalException; | |
| import com.liferay.portal.kernel.service.LayoutServiceWrapper; | |
| import com.liferay.portal.kernel.service.ServiceWrapper; | |
| @Component( | |
| immediate = true, | |
| property = { | |
| }, | |
| service = ServiceWrapper.class | |
| ) | |
| public class LayoutServiceOverride extends LayoutServiceWrapper { | |
| private static final Logger LOG = LoggerFactory.getLogger(LayoutServiceOverride.class); | |
| public LayoutServiceOverride() { | |
| super(null); | |
| } | |
| @Override | |
| public List<Layout> getLayouts(long groupId, boolean privateLayout) { | |
| long userId; | |
| try { | |
| userId = GuestOrUserUtil.getUserId(); | |
| LOG.info("METHOD 1: " + userId); | |
| } catch (PrincipalException e) { | |
| LOG.warn("Cannot identify user"); | |
| } | |
| return super.getLayouts(groupId, privateLayout); | |
| } | |
| @Override | |
| public List<Layout> getLayouts(long groupId, boolean privateLayout, long parentLayoutId) throws PortalException { | |
| long userId; | |
| try { | |
| userId = GuestOrUserUtil.getUserId(); | |
| LOG.info("METHOD 2: " + userId); | |
| } catch (PrincipalException e) { | |
| LOG.warn("Cannot identify user"); | |
| } | |
| return super.getLayouts(groupId, privateLayout, parentLayoutId); | |
| } | |
| @Override | |
| public List<Layout> getLayouts(long groupId, boolean privateLayout, String type) throws PortalException { | |
| long userId; | |
| try { | |
| userId = GuestOrUserUtil.getUserId(); | |
| LOG.info("METHOD 3: " + userId); | |
| } catch (PrincipalException e) { | |
| LOG.warn("Cannot identify user"); | |
| } | |
| return super.getLayouts(groupId, privateLayout, type); | |
| } | |
| @Override | |
| public List<Layout> getLayouts(long groupId, boolean privateLayout, long parentLayoutId, boolean incomplete, | |
| int start, int end) throws PortalException { | |
| long userId; | |
| try { | |
| userId = GuestOrUserUtil.getUserId(); | |
| LOG.info("METHOD 4: " + userId); | |
| } catch (PrincipalException e) { | |
| LOG.warn("Cannot identify user"); | |
| } | |
| return super.getLayouts(groupId, privateLayout, parentLayoutId, incomplete, start, end); | |
| } | |
| @Override | |
| public List<Layout> getLayouts(long groupId, String type) { | |
| long userId; | |
| try { | |
| userId = GuestOrUserUtil.getUserId(); | |
| LOG.info("METHOD 5: " + userId); | |
| } catch (PrincipalException e) { | |
| LOG.warn("Cannot identify user"); | |
| } | |
| return super.getLayouts(groupId, type); | |
| } | |
| @Override | |
| public List<Layout> getLayouts(long groupId, String type, int start, int end) { | |
| long userId; | |
| try { | |
| userId = GuestOrUserUtil.getUserId(); | |
| LOG.info("METHOD 6: " + userId); | |
| } catch (PrincipalException e) { | |
| LOG.warn("Cannot identify user"); | |
| } | |
| return super.getLayouts(groupId, type, start, end); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment