(Nathan Sarr)

- One invalid email address no longer aborts whole subscription email process.  Error is logged and emailing continues.  SF patch #1246158; fixes SF bug #1245223


git-svn-id: http://scm.dspace.org/svn/repo/trunk@1264 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Robert Tansley
2005-07-28 17:20:40 +00:00
parent 2755a89506
commit 6f3d4af82f

View File

@@ -74,7 +74,7 @@ import org.dspace.storage.rdbms.TableRowIterator;
public class Subscribe public class Subscribe
{ {
/** log4j logger */ /** log4j logger */
private static Logger log = Logger.getLogger(Group.class); private static Logger log = Logger.getLogger(Subscribe.class);
/** /**
* Subscribe an e-person to a collection. An e-mail will be sent every day a * Subscribe an e-person to a collection. An e-mail will be sent every day a
@@ -237,7 +237,7 @@ public class Subscribe
* DSpace context object * DSpace context object
*/ */
public static void processDaily(Context context) throws SQLException, public static void processDaily(Context context) throws SQLException,
MessagingException, IOException IOException
{ {
// Grab the subscriptions // Grab the subscriptions
TableRowIterator tri = DatabaseManager.query(context, TableRowIterator tri = DatabaseManager.query(context,
@@ -258,9 +258,19 @@ public class Subscribe
{ {
// New e-person. Send mail for previous e-person // New e-person. Send mail for previous e-person
if (currentEPerson != null) if (currentEPerson != null)
{
try
{ {
sendEmail(context, currentEPerson, collections); sendEmail(context, currentEPerson, collections);
} }
catch (MessagingException me)
{
log.error("Failed to send subscription to eperson_id="
+ currentEPerson.getID());
log.error(me);
}
}
currentEPerson = EPerson.find(context, row currentEPerson = EPerson.find(context, row
.getIntColumn("eperson_id")); .getIntColumn("eperson_id"));
@@ -273,9 +283,18 @@ public class Subscribe
// Process the last person // Process the last person
if (currentEPerson != null) if (currentEPerson != null)
{
try
{ {
sendEmail(context, currentEPerson, collections); sendEmail(context, currentEPerson, collections);
} }
catch (MessagingException me)
{
log.error("Failed to send subscription to eperson_id="
+ currentEPerson.getID());
log.error(me);
}
}
} }
/** /**
@@ -401,12 +420,27 @@ public class Subscribe
* @param argv * @param argv
* command-line arguments, none used yet * command-line arguments, none used yet
*/ */
public static void main(String[] argv) throws Exception public static void main(String[] argv)
{ {
Context context = new Context(); Context context = null;
processDaily(context);
try
{
context = new Context();
processDaily(context);
context.complete();
}
catch( Exception e )
{
log.fatal(e);
}
finally
{
if( context != null && context.isValid() )
{
// Nothing is actually written // Nothing is actually written
context.abort(); context.abort();
} }
}
}
} }