Refactor AccountManager to remove dependency on webapp.util.UIUtil.

git-svn-id: http://scm.dspace.org/svn/repo/trunk@1962 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Mark Diggory
2007-05-23 18:36:35 +00:00
parent 9e96b0dfdb
commit 22e15ada14
2 changed files with 10 additions and 12 deletions

View File

@@ -46,7 +46,6 @@ import java.util.Calendar;
import java.util.Locale;
import javax.mail.MessagingException;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeException;
@@ -57,7 +56,6 @@ import org.dspace.core.I18nUtil;
import org.dspace.core.Utils;
import org.dspace.storage.rdbms.DatabaseManager;
import org.dspace.storage.rdbms.TableRow;
import org.dspace.app.webui.util.UIUtil;
/**
* Methods for handling registration by email and forgotten passwords. When
@@ -96,11 +94,11 @@ public class AccountManager
* @param email
* Email address to send the registration email to
*/
public static void sendRegistrationInfo(HttpServletRequest request, Context context, String email)
public static void sendRegistrationInfo(Context context, String email)
throws SQLException, IOException, MessagingException,
AuthorizeException
{
sendInfo(request, context, email, true, true);
sendInfo(context, email, true, true);
}
/**
@@ -116,11 +114,11 @@ public class AccountManager
* @param email
* Email address to send the forgot-password email to
*/
public static void sendForgotPasswordInfo(HttpServletRequest request, Context context, String email)
public static void sendForgotPasswordInfo(Context context, String email)
throws SQLException, IOException, MessagingException,
AuthorizeException
{
sendInfo(request, context, email, false, true);
sendInfo(context, email, false, true);
}
/**
@@ -222,7 +220,7 @@ public class AccountManager
* registration; otherwise, it is for forgot-password @param send If true,
* send email; otherwise do not send any email
*/
protected static TableRow sendInfo(HttpServletRequest request, Context context, String email,
protected static TableRow sendInfo(Context context, String email,
boolean isRegister, boolean send) throws SQLException, IOException,
MessagingException, AuthorizeException
{
@@ -255,7 +253,7 @@ public class AccountManager
if (send)
{
sendEmail(request, email, isRegister, rd);
sendEmail(context, email, isRegister, rd);
}
return rd;
@@ -279,7 +277,7 @@ public class AccountManager
* @exception IOException
* If an error occurs while reading the email template.
*/
private static void sendEmail(HttpServletRequest request, String email, boolean isRegister, TableRow rd)
private static void sendEmail(Context context, String email, boolean isRegister, TableRow rd)
throws MessagingException, IOException, SQLException
{
String base = ConfigurationManager.getProperty("dspace.url");
@@ -290,7 +288,7 @@ public class AccountManager
isRegister ? "register" : "forgot").append("?")
.append("token=").append(rd.getStringColumn("token"))
.toString();
Locale locale = UIUtil.obtainContext(request).getCurrentLocale();
Locale locale = context.getCurrentLocale();
Email bean = ConfigurationManager.getEmail(I18nUtil.getEmailFilename(locale, isRegister ? "register"
: "change_password"));
bean.addRecipient(email);