/*
 * $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.AuthAction;
import org.subethamail.web.model.ErrorMapModel;

/**
 * Subscribes an anonymous (not logged in) user to a mailing list.
 * 
 * @author Jeff Schnitzer
 */
public class SubscribeAnon extends AuthAction 
{
	/** */
	@SuppressWarnings("unused")
	private final static Logger log = LoggerFactory.getLogger(SubscribeAnon.class);
	
	/** */
	public static class Model extends ErrorMapModel
	{
		/** */
		@Getter @Setter Long listId;
		
		/** */
		@Length(max=Validator.MAX_EMAIL_ADDRESS)
		@Getter @Setter String deliverTo = "";
		
		/** */
		@Length(max=Validator.MAX_PERSON_NAME)
		@Getter @Setter
		String name = "";

		/** */
		@Override
		public void validate() throws IllegalAccessException
		{
			super.validate();
			if (!Validator.validEmail(deliverTo))
				this.setError("deliverTo", "That is not a valid email address");
		}
	}
	
	/** */
	public void initialize()
	{
		this.getCtx().setModel(new Model());
	}
	
	/** */
	public void execute() throws Exception
	{
		Model model = (Model)this.getCtx().getModel();
		
		model.validate();
		
		if (model.getErrors().isEmpty())
		{
			Backend.instance().getAccountMgr().subscribeAnonymousRequest(model.listId, model.deliverTo, model.name);
		}
	}
	
}

@@ -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
@@ -488,16 +488,22 @@
 r%0D%0A */%0D%0A
+@Log%0D%0A
 public c
@@ -558,132 +558,8 @@
 */%0D%0A
-%09@SuppressWarnings(%22unused%22)%0D%0A%09private final static Logger log = LoggerFactory.getLogger(SubscribeAnon.class);%0D%0A%09%0D%0A%09/** */%0D%0A
 %09pub

switch logging framework