001
014
015 package com.liferay.portlet.messageboards.model;
016
017 import com.liferay.portal.exception.ModelListenerException;
018 import com.liferay.portal.kernel.comment.CommentManagerUtil;
019 import com.liferay.portal.model.BaseModelListener;
020 import com.liferay.portal.model.Layout;
021 import com.liferay.portal.util.PropsValues;
022
023
026 public class LayoutModelListener extends BaseModelListener<Layout> {
027
028 @Override
029 public void onAfterCreate(Layout layout) throws ModelListenerException {
030 if (PropsValues.LAYOUT_COMMENTS_ENABLED) {
031 try {
032 CommentManagerUtil.addDiscussion(
033 layout.getUserId(), layout.getGroupId(),
034 Layout.class.getName(), layout.getPlid(),
035 layout.getUserName());
036 }
037 catch (Exception e) {
038 throw new ModelListenerException(e);
039 }
040 }
041 }
042
043 @Override
044 public void onBeforeRemove(Layout layout) throws ModelListenerException {
045 try {
046 CommentManagerUtil.deleteDiscussion(
047 Layout.class.getName(), layout.getPlid());
048 }
049 catch (Exception e) {
050 throw new ModelListenerException(e);
051 }
052 }
053
054 }