package org.opencps.dossiermgt.listenner;

import com.liferay.portal.kernel.exception.ModelListenerException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.BaseModelListener;
import com.liferay.portal.kernel.model.ModelListener;

import org.apache.commons.lang3.StringEscapeUtils;
import org.opencps.dossiermgt.model.DossierTemplate;
import org.osgi.service.component.annotations.Component;

@Component(immediate = true, service = ModelListener.class)
public class DossierTemplateTempListener extends BaseModelListener<DossierTemplate> {

	@Override
	public void onAfterCreate(DossierTemplate model) throws ModelListenerException {
	}

	@Override
	public void onAfterUpdate(DossierTemplate model) throws ModelListenerException {
	}

	@Override
	public void onBeforeCreate(DossierTemplate model) throws ModelListenerException {
		try {
			model.setTemplateName(StringEscapeUtils.escapeHtml4(model.getTemplateName()));
			model.setTemplateNo(StringEscapeUtils.escapeHtml4(model.getTemplateNo()));
			model.setDescription(StringEscapeUtils.escapeHtml4(model.getDescription()));

		} catch (Exception e) {
			_log.error(e);
		}
	}

	@Override
	public void onBeforeUpdate(DossierTemplate model) throws ModelListenerException {
		try {
			model.setTemplateName(StringEscapeUtils.escapeHtml4(model.getTemplateName()));
			model.setTemplateNo(StringEscapeUtils.escapeHtml4(model.getTemplateNo()));
			model.setDescription(StringEscapeUtils.escapeHtml4(model.getDescription()));

		} catch (Exception e) {
			_log.error(e);
		}
	}


	private Log _log = LogFactoryUtil.getLog(DossierTemplateTempListener.class.getName());
}

@@ -904,32 +904,34 @@
 Exception %7B%0A
+//
 %09%09try %7B%0A
 %09%09%09model.set
@@ -910,32 +910,34 @@
 ion %7B%0A//%09%09try %7B%0A
+//
 %09%09%09model.setTemp
@@ -994,32 +994,34 @@
 mplateName()));%0A
+//
 %09%09%09model.setTemp
@@ -1074,32 +1074,34 @@
 TemplateNo()));%0A
+//
 %09%09%09model.setDesc
@@ -1156,33 +1156,37 @@
 escription()));%0A
-%0A
+//%0A//
 %09%09%7D catch (Excep
@@ -1187,32 +1187,34 @@
 (Exception e) %7B%0A
+//
 %09%09%09_log.error(e)
@@ -1207,32 +1207,34 @@
 %09_log.error(e);%0A
+//
 %09%09%7D%0A%09%7D%0A%0A%09@Overri
@@ -1319,24 +1319,26 @@
 ption %7B%0A
+//
 %09%09try %7B%0A
 %09%09%09model
@@ -1329,16 +1329,18 @@
 %09%09try %7B%0A
+//
 %09%09%09model
@@ -1409,24 +1409,26 @@
 teName()));%0A
+//
 %09%09%09model.set
@@ -1493,16 +1493,18 @@
 No()));%0A
+//
 %09%09%09model
@@ -1575,17 +1575,21 @@
 on()));%0A
-%0A
+//%0A//
 %09%09%7D catc
@@ -1606,16 +1606,18 @@
 on e) %7B%0A
+//
 %09%09%09_log.
@@ -1626,16 +1626,18 @@
 ror(e);%0A
+//
 %09%09%7D%0A%09%7D%0A%0A

update listener