/*
 * $Id$
 * $URL$
 */

package org.subethamail.web.action;

import lombok.Getter;
import lombok.Setter;

import org.hibernate.validator.constraints.Length;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.subethamail.entity.i.Validator;
import org.subethamail.web.Backend;
import org.subethamail.web.action.auth.AuthRequired;
import org.subethamail.web.model.ErrorMapModel;

/**
 * Injects a piece of mail into the system via a web form.  One of msgId or listId
 * will be specified to indicate reply or post, respectively.
 * 
 * @author Jon Stevens
 * @author Jeff Schnitzer
 */
public class PostMessage extends AuthRequired 
{
	/** */
	@SuppressWarnings("unused")
	private final static Logger log = LoggerFactory.getLogger(PostMessage.class);

	public class Model extends ErrorMapModel
	{
		@Getter @Setter Long msgId;
		@Getter @Setter Long listId;

		@Length(min=1, max=Validator.MAX_MAIL_SUBJECT)
		@Getter @Setter String subject;

		@Length(min=1, max=Validator.MAX_MAIL_CONTENT)
		@Getter @Setter String message;
	}
	
	/** */
	public void initialize()
	{
		this.getCtx().setModel(new Model());
	}
	
	/** */
	public void authExecute() throws Exception
	{
		Model model = (Model)this.getCtx().getModel();
		
		model.validate();

		if (model.getErrors().isEmpty())
		{
			// Reply
			if (model.msgId != null)
			{
				model.listId = Backend.instance().getArchiver().reply(this.getAuthName(), model.msgId, model.subject, model.message);
			}
			else
			{
				Backend.instance().getArchiver().post(this.getAuthName(), model.listId, model.subject, model.message);
			}
		}
	}
}

@@ -107,16 +107,48 @@
 Setter;%0D
+%0Aimport lombok.extern.java.Log;%0D
 %0A%0D%0Aimpor
@@ -198,67 +198,8 @@
 h;%0D%0A
-import org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory;%0D%0A
 impo
@@ -593,16 +593,22 @@
 r%0D%0A */%0D%0A
+@Log%0D%0A
 public c
@@ -654,129 +654,8 @@
 %0A%7B%0D%0A
-%09/** */%0D%0A%09@SuppressWarnings(%22unused%22)%0D%0A%09private final static Logger log = LoggerFactory.getLogger(PostMessage.class);%0D%0A%0D%0A
 %09pub

switch logging framework