Skip to content
Snippets Groups Projects
Commit bc6a33eb authored by Mike McKay's avatar Mike McKay
Browse files

XNAT-4463 Made PAR requests not fail when one project owner had an invalid...

XNAT-4463 Made PAR requests not fail when one project owner had an invalid email (also prevented similar failures on PAR acceptance/denial).
parent f0ec3417
No related branches found
No related tags found
No related merge requests found
...@@ -101,8 +101,7 @@ public class ProcessAccessRequest extends SecureAction { ...@@ -101,8 +101,7 @@ public class ProcessAccessRequest extends SecureAction {
try { try {
XDAT.getMailService().sendHtmlMessage(from, other.getEmail(), user.getEmail(), XDAT.getSiteConfigPreferences().getAdminEmail(), subject, message); XDAT.getMailService().sendHtmlMessage(from, other.getEmail(), user.getEmail(), XDAT.getSiteConfigPreferences().getAdminEmail(), subject, message);
} catch (Exception e) { } catch (Exception e) {
logger.error("Unable to send mail",e); logger.error("Unable to send denial email",e);
throw e;
} }
} }
...@@ -151,7 +150,7 @@ public class ProcessAccessRequest extends SecureAction { ...@@ -151,7 +150,7 @@ public class ProcessAccessRequest extends SecureAction {
} }
try { try {
for (Map.Entry<String, UserGroupI> entry:Groups.getGroupsForUser(user).entrySet()){ for (Map.Entry<String, UserGroupI> entry:Groups.getGroupsForUser(other).entrySet()){
if (entry.getValue()!=null && entry.getValue().getTag()!=null && entry.getValue().getTag().equals(project.getId())){ if (entry.getValue()!=null && entry.getValue().getTag()!=null && entry.getValue().getTag().equals(project.getId())){
Groups.removeUserFromGroup(other, user, entry.getValue().getId(), c); Groups.removeUserFromGroup(other, user, entry.getValue().getId(), c);
} }
...@@ -197,12 +196,23 @@ public class ProcessAccessRequest extends SecureAction { ...@@ -197,12 +196,23 @@ public class ProcessAccessRequest extends SecureAction {
template.merge(context,sw); template.merge(context,sw);
String message= sw.toString(); String message= sw.toString();
try { try {
XDAT.getMailService().sendHtmlMessage(from, to, cc, bcc, subject, message); XDAT.getMailService().sendHtmlMessage(from, to, cc, bcc, subject, message);
} catch (Exception e) { } catch (Exception exception) {
logger.error("Unable to send mail",e); logger.error("Send failed. Retrying by sending each email individually.", exception);
throw e; int successfulSends = 0;
} for (String recipient : to) {
try {
XDAT.getMailService().sendHtmlMessage(from, new String[]{recipient}, null, bcc, subject, message);
successfulSends++;
} catch (Exception e) {
logger.error("Unable to send mail to " + recipient + ".", e);
}
}
if (successfulSends == 0) {
logger.error("Unable to send mail", exception);
}
}
} }
/* (non-Javadoc) /* (non-Javadoc)
......
...@@ -10,11 +10,6 @@ ...@@ -10,11 +10,6 @@
*/ */
package org.nrg.xnat.turbine.modules.actions; package org.nrg.xnat.turbine.modules.actions;
import java.io.StringWriter;
import java.util.ArrayList;
import javax.mail.MessagingException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.turbine.util.RunData; import org.apache.turbine.util.RunData;
import org.apache.velocity.Template; import org.apache.velocity.Template;
...@@ -24,12 +19,14 @@ import org.nrg.xdat.XDAT; ...@@ -24,12 +19,14 @@ import org.nrg.xdat.XDAT;
import org.nrg.xdat.display.DisplayManager; import org.nrg.xdat.display.DisplayManager;
import org.nrg.xdat.om.XnatProjectdata; import org.nrg.xdat.om.XnatProjectdata;
import org.nrg.xdat.turbine.modules.actions.SecureAction; import org.nrg.xdat.turbine.modules.actions.SecureAction;
import org.nrg.xdat.turbine.utils.AdminUtils;
import org.nrg.xdat.turbine.utils.TurbineUtils; import org.nrg.xdat.turbine.utils.TurbineUtils;
import org.nrg.xft.security.UserI; import org.nrg.xft.security.UserI;
import org.nrg.xnat.turbine.utils.ArcSpecManager; import org.nrg.xnat.turbine.utils.ArcSpecManager;
import org.nrg.xnat.turbine.utils.ProjectAccessRequest; import org.nrg.xnat.turbine.utils.ProjectAccessRequest;
import java.io.StringWriter;
import java.util.ArrayList;
public class RequestAccess extends SecureAction { public class RequestAccess extends SecureAction {
static Logger logger = Logger.getLogger(RequestAccess.class); static Logger logger = Logger.getLogger(RequestAccess.class);
...@@ -74,7 +71,7 @@ public class RequestAccess extends SecureAction { ...@@ -74,7 +71,7 @@ public class RequestAccess extends SecureAction {
throw exception; throw exception;
} }
String[] to = null; String[] to = {};
if (ownerEmails != null && ownerEmails.size() > 0) { if (ownerEmails != null && ownerEmails.size() > 0) {
to = ownerEmails.toArray(new String[ownerEmails.size()]); to = ownerEmails.toArray(new String[ownerEmails.size()]);
} }
...@@ -89,11 +86,22 @@ public class RequestAccess extends SecureAction { ...@@ -89,11 +86,22 @@ public class RequestAccess extends SecureAction {
try { try {
XDAT.getMailService().sendHtmlMessage(from, to, null, bcc, subject, message); XDAT.getMailService().sendHtmlMessage(from, to, null, bcc, subject, message);
} catch (MessagingException exception) { } catch (Exception exception) {
logger.error("Unable to send mail", exception); logger.error("Send failed. Retrying by sending each email individually.", exception);
throw exception; int successfulSends = 0;
for (String recipient : to) {
try {
XDAT.getMailService().sendHtmlMessage(from, new String[]{recipient}, null, bcc, subject, message);
successfulSends++;
} catch (Exception e) {
logger.error("Unable to send mail to " + recipient + ".", e);
}
}
if (successfulSends == 0) {
logger.error("Unable to send mail", exception);
}
} }
data.setMessage("Access request sent."); data.setMessage("Access request sent.");
data.setScreenTemplate("Index.vm"); data.setScreenTemplate("Index.vm");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment