Revision 36959
Added by Antonis Lempesis over 9 years ago
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/utils/EmailUtils.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.goldoa.service.utils; |
2 | 2 |
|
3 |
import eu.dnetlib.goldoa.domain.*;
|
|
4 |
import eu.dnetlib.goldoa.service.dao.PersonDAO;
|
|
5 |
import org.apache.log4j.Logger;
|
|
6 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
3 |
import eu.dnetlib.goldoa.domain.BudgetInfo;
|
|
4 |
import eu.dnetlib.goldoa.domain.Person;
|
|
5 |
import eu.dnetlib.goldoa.domain.RequestInfo;
|
|
6 |
import eu.dnetlib.goldoa.domain.Role;
|
|
7 | 7 |
|
8 | 8 |
import javax.mail.MessagingException; |
9 |
import java.io.PrintWriter; |
|
10 |
import java.io.StringWriter; |
|
11 |
import java.text.SimpleDateFormat; |
|
12 | 9 |
import java.util.List; |
13 | 10 |
|
14 | 11 |
/** |
15 |
* Created by antleb on 3/9/15.
|
|
12 |
* Created by antleb on 5/6/15.
|
|
16 | 13 |
*/ |
17 |
public class EmailUtils {
|
|
18 |
private static Logger logger = Logger.getLogger(EmailUtils.class);
|
|
14 |
public interface EmailUtils {
|
|
15 |
void sendActivationEmail(Person user, String token) throws MessagingException;
|
|
19 | 16 |
|
20 |
@Autowired |
|
21 |
PersonDAO personDAO; |
|
17 |
void sendResetPasswordEmail(Person user, String password) throws MessagingException; |
|
22 | 18 |
|
23 |
private MailLibrary mailLibrary; |
|
24 |
private String baseAddress; |
|
25 |
private String termsOfAgreementUrl; |
|
19 |
void sendRequesterOKEmail(RequestInfo requestInfo) throws MessagingException; |
|
26 | 20 |
|
27 |
public void sendActivationEmail(Person user, String token) throws MessagingException { |
|
28 |
String link = baseAddress + "/GoldOAPortal.html?token=" + token + "&email=" + user.getEmail() +"#activate"; |
|
29 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Account activation"; |
|
21 |
void sendModeratorOKEmail(RequestInfo requestInfo, Person moderator) throws MessagingException; |
|
30 | 22 |
|
31 |
String message = "Dear " + user.getName() + " " + user.getLastname() + ",\n" + |
|
32 |
"Welcome to the OpenAIRE FP7 post-grant Gold OA Pilot service, \n" + |
|
33 |
"\n" + |
|
34 |
"Thank you for signing up. To verify your account, please click on the link below:\n" + |
|
35 |
link + "\n" + |
|
36 |
"\n" + |
|
37 |
"Best,\n" + |
|
38 |
"The OpenAIRE team"; |
|
23 |
void sendRequesterIFFYEmail(RequestInfo requestInfo) throws MessagingException; |
|
39 | 24 |
|
40 |
mailLibrary.sendEmail(user.getEmail(), subject, message); |
|
41 |
} |
|
25 |
void sendModeratorIFFYEmail(RequestInfo requestInfo, Person moderator) throws MessagingException; |
|
42 | 26 |
|
43 |
public void sendResetPasswordEmail(Person user, String password) throws MessagingException { |
|
44 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] New password"; |
|
45 |
String message = "Dear " + user.getName() + " " + user.getLastname() + ",\n" + |
|
46 |
"Your new password is " + password + |
|
47 |
"\n" + |
|
48 |
"Best,\n" + |
|
49 |
"The OpenAIRE team"; |
|
27 |
void sendRequesterApprovedEmail(RequestInfo requestInfo) throws MessagingException; |
|
50 | 28 |
|
51 |
mailLibrary.sendEmail(user.getEmail(), subject, message); |
|
52 |
} |
|
29 |
void sendRequesterRejectedEmail(RequestInfo requestInfo) throws MessagingException; |
|
53 | 30 |
|
54 |
public void sendRequesterOKEmail(RequestInfo requestInfo) throws MessagingException { |
|
55 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request at " + new SimpleDateFormat("yyyy-MM-dd").format(requestInfo.getDate()); |
|
56 |
String link = baseAddress + "/#existingFundingRequests"; |
|
31 |
void sendModeratorNewBudgetEmail(Person moderator, BudgetInfo budgetInfo) throws MessagingException; |
|
57 | 32 |
|
58 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
59 |
"\n" + |
|
60 |
"We have received a request to fund for the following:\n" + |
|
61 |
"\n" + |
|
62 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
63 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
33 |
void sendUserNewBudgetEmail(BudgetInfo budgetInfo) throws MessagingException; |
|
64 | 34 |
|
65 |
if (requestInfo.getPublication().getJournal() != null) |
|
66 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
67 |
else |
|
68 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
35 |
void sendUserAcceptedBudgetEmail(BudgetInfo budgetInfo) throws MessagingException; |
|
69 | 36 |
|
70 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
71 |
"\n" + |
|
72 |
"At a first glance it seems that this is an eligible request and it will be processed asap. We will notify you if you need to take further actions and we will you keep you posted on its status.\n" + |
|
73 |
"\n" + |
|
74 |
"You may click on the link below at any time to follow the status of your request:\n" + |
|
75 |
link + "\n" + |
|
76 |
" \n" + |
|
77 |
"Best,\n" + |
|
78 |
"The OpenAIRE team"; |
|
37 |
void sendModeratorAcceptedBudgetEmail(Person moderator, BudgetInfo budgetInfo) throws MessagingException; |
|
79 | 38 |
|
80 |
mailLibrary.sendEmail(requestInfo.getUser().getEmail(), subject, text); |
|
81 |
} |
|
39 |
void sendUserRejectedBudgetEmail(BudgetInfo budgetInfo) throws MessagingException; |
|
82 | 40 |
|
83 |
public void sendModeratorOKEmail(RequestInfo requestInfo, Person moderator) throws MessagingException { |
|
84 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] New funding request (" + requestInfo.getId() + ")"; |
|
85 |
String link = baseAddress + "/#monitorFundingRequests"; |
|
41 |
void sendModeratorRejectedBudgetEmail(Person moderator, BudgetInfo budgetInfo) throws MessagingException; |
|
86 | 42 |
|
43 |
void sendUserRoleAcceptedEmail(Person person, Role role) throws MessagingException; |
|
87 | 44 |
|
88 |
String text = "Dear moderator,\n" + |
|
89 |
"\n" + |
|
90 |
"We have received a request to fund for the following:\n" + |
|
91 |
"\n" + |
|
92 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
93 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
45 |
void sendModeratorRoleAcceptedEmail(Person moderator, Person user, Role role) throws MessagingException; |
|
94 | 46 |
|
95 |
if (requestInfo.getPublication().getJournal() != null) |
|
96 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
97 |
else |
|
98 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
47 |
void sendUserRoleRejectedEmail(Person person, Role role) throws MessagingException; |
|
99 | 48 |
|
100 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
101 |
"\n" + |
|
102 |
"At a first glance it seems that this is an eligible request. Please visit the link below to validate and process the request:\n" + |
|
103 |
link + "\n" + |
|
104 |
" \n" + |
|
105 |
"Best,\n" + |
|
106 |
"The OpenAIRE team"; |
|
49 |
void sendModeratorRoleRejectedEmail(Person moderator, Person user, Role role) throws MessagingException; |
|
107 | 50 |
|
108 |
mailLibrary.sendEmail(moderator.getEmail(), subject, text); |
|
109 |
} |
|
51 |
void sendUserRoleRequestedEmail(Person person, List<Role> roles) throws MessagingException; |
|
110 | 52 |
|
111 |
public void sendRequesterIFFYEmail(RequestInfo requestInfo) throws MessagingException { |
|
112 |
String subject = "Your funding request at " + new SimpleDateFormat("yyyy-MM-dd").format(requestInfo.getDate()); |
|
53 |
void sendModeratorRoleRequestedEmail(Person moderator, Person user, List<Role> roles) throws MessagingException; |
|
113 | 54 |
|
114 |
String text = "Hello " + requestInfo.getUser().getName() + ",\n" + |
|
115 |
" your request will be processed soon.The terms of agreement can be found here: " + termsOfAgreementUrl + "\n" + |
|
116 |
" The OpenAIRE Gold Open Access team."; |
|
55 |
void sendRequesterInvoiceNotification(RequestInfo requestInfo) throws MessagingException; |
|
117 | 56 |
|
118 |
mailLibrary.sendEmail(requestInfo.getUser().getEmail(), subject, text); |
|
119 |
} |
|
57 |
void sendPublisherInvoiceNotification(RequestInfo requestInfo) throws MessagingException; |
|
120 | 58 |
|
121 |
public void sendModeratorIFFYEmail(RequestInfo requestInfo, Person moderator) throws MessagingException { |
|
122 |
String subject = "New funding request (" + requestInfo.getId() + ")"; |
|
59 |
void sendAccountingRequestApprovedEmail(Person person, RequestInfo requestInfo) throws MessagingException; |
|
123 | 60 |
|
124 |
String text = "Hello " + moderator.getName() + ",\n" + |
|
125 |
" A new smelly, stinky and iffy request has been submitted. You may inspect it and approve or reject it here...\n" + |
|
126 |
" Thank you !\n The OpenAIRE Gold Open Access team."; |
|
61 |
void sendRequesterPaidEmail(RequestInfo requestInfo) throws MessagingException; |
|
127 | 62 |
|
128 |
mailLibrary.sendEmail(moderator.getEmail(), subject, text); |
|
129 |
} |
|
63 |
void sendPublisherPaidEmail(RequestInfo requestInfo) throws MessagingException; |
|
130 | 64 |
|
131 |
public void sendRequesterApprovedEmail(RequestInfo requestInfo) throws MessagingException { |
|
132 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request at " + new SimpleDateFormat("yyyy-MM-dd").format(requestInfo.getDate()) + "has been approved"; |
|
133 |
String link = baseAddress + "/#existingFundingRequests"; |
|
134 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
135 |
"\n" + |
|
136 |
"The following request is eligible and has been approved for funding:\n" + |
|
137 |
"\n" + |
|
138 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
139 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
65 |
void sendRequesterOnHoldEmail(RequestInfo requestInfo) throws MessagingException; |
|
140 | 66 |
|
141 |
if (requestInfo.getPublication().getJournal() != null) |
|
142 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
143 |
else |
|
144 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
67 |
void sendPublisherOnHoldEmail(RequestInfo requestInfo) throws MessagingException; |
|
145 | 68 |
|
146 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
147 |
"\n" + |
|
148 |
"If no invoice has been uploaded, or the publisher bank information is missing, our accounting office may put the request on hold until all information is in the system.\n" + |
|
149 |
"\n"; |
|
69 |
void sendRequesterDeniedEmail(RequestInfo requestInfo) throws MessagingException; |
|
150 | 70 |
|
151 |
if (requestInfo.getComment() != null) |
|
152 |
text += requestInfo.getComment() + "\n\n"; |
|
71 |
void sendPublisherDeniedEmail(RequestInfo requestInfo) throws MessagingException; |
|
153 | 72 |
|
154 |
text += "You may click on the link below at any time to follow the status of your request:\n" + |
|
155 |
link + "\n" + |
|
156 |
" \n" + |
|
157 |
"Best,\n" + |
|
158 |
"The OpenAIRE team"; |
|
159 |
|
|
160 |
mailLibrary.sendEmail(requestInfo.getUser().getEmail(), subject, text); |
|
161 |
} |
|
162 |
|
|
163 |
public void sendRequesterRejectedEmail(RequestInfo requestInfo) throws MessagingException { |
|
164 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request at " + new SimpleDateFormat("yyyy-MM-dd").format(requestInfo.getDate()) + "has been rejected"; |
|
165 |
String link = baseAddress + "/#existingFundingRequests"; |
|
166 |
|
|
167 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
168 |
"\n" + |
|
169 |
"The following request has been rejected:\n" + |
|
170 |
"\n" + |
|
171 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
172 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
173 |
|
|
174 |
if (requestInfo.getPublication().getJournal() != null) |
|
175 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
176 |
else |
|
177 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
178 |
|
|
179 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
180 |
"\n" + |
|
181 |
"Reason: "; |
|
182 |
|
|
183 |
if (requestInfo.getComment() != null) |
|
184 |
text += requestInfo.getComment() + "\n\n"; |
|
185 |
else |
|
186 |
text += "-\n\n"; |
|
187 |
|
|
188 |
text += "You may click on the link below at any time to find more information:\n" + |
|
189 |
link + "\n" + |
|
190 |
" \n" + |
|
191 |
"Best,\n" + |
|
192 |
"The OpenAIRE team"; |
|
193 |
|
|
194 |
mailLibrary.sendEmail(requestInfo.getUser().getEmail(), subject, text); |
|
195 |
} |
|
196 |
|
|
197 |
public void sendModeratorNewBudgetEmail(Person moderator, BudgetInfo budgetInfo) throws MessagingException { |
|
198 |
String subject = "New budget request"; |
|
199 |
|
|
200 |
String text = "Hello " + moderator.getName() + ",\n" + |
|
201 |
" A new budget request by " + budgetInfo.getUser().getName() + " " + budgetInfo.getUser().getLastname() + " has been submitted!\n" + |
|
202 |
" The OpenAIRE Gold Open Access team."; |
|
203 |
|
|
204 |
mailLibrary.sendEmail(new String[] {moderator.getEmail()}, subject, text); |
|
205 |
} |
|
206 |
|
|
207 |
public void sendUserNewBudgetEmail(BudgetInfo budgetInfo) throws MessagingException { |
|
208 |
String subject = "New budget request"; |
|
209 |
|
|
210 |
String text = "Hello " + budgetInfo.getUser().getName() + ",\n" + |
|
211 |
" Your budget request has been submitted. We'll process it as soon as possible!\n" + |
|
212 |
" The OpenAIRE Gold Open Access team."; |
|
213 |
|
|
214 |
mailLibrary.sendEmail(new String[] {budgetInfo.getUser().getEmail()}, subject, text); |
|
215 |
} |
|
216 |
|
|
217 |
public void sendUserAcceptedBudgetEmail(BudgetInfo budgetInfo) throws MessagingException { |
|
218 |
String subject = "Your budget request"; |
|
219 |
|
|
220 |
String text = "Hello " + budgetInfo.getUser().getName() + ",\n" + |
|
221 |
" Your budget request has been accepted! Spend them wisely!\n" + |
|
222 |
" The OpenAIRE Gold Open Access team."; |
|
223 |
|
|
224 |
mailLibrary.sendEmail(new String[] {budgetInfo.getUser().getEmail()}, subject, text); |
|
225 |
} |
|
226 |
|
|
227 |
public void sendModeratorAcceptedBudgetEmail(Person moderator, BudgetInfo budgetInfo) throws MessagingException { |
|
228 |
String subject = "Budget request accepted"; |
|
229 |
|
|
230 |
String text = "Hello " + moderator.getName() + ",\n" + |
|
231 |
" A budget request by " + budgetInfo.getUser().getName() + " " + budgetInfo.getUser().getLastname() + " has been accepted!\n" + |
|
232 |
" The OpenAIRE Gold Open Access team."; |
|
233 |
|
|
234 |
mailLibrary.sendEmail(new String[] {moderator.getEmail()}, subject, text); |
|
235 |
} |
|
236 |
|
|
237 |
public void sendUserRejectedBudgetEmail(BudgetInfo budgetInfo) throws MessagingException { |
|
238 |
String subject = "Your budget request"; |
|
239 |
|
|
240 |
String text = "Hello " + budgetInfo.getUser().getName() + ",\n" + |
|
241 |
" Your budget request has been rejected :(\n" + |
|
242 |
" The OpenAIRE Gold Open Access team."; |
|
243 |
|
|
244 |
mailLibrary.sendEmail(new String[] {budgetInfo.getUser().getEmail()}, subject, text); |
|
245 |
} |
|
246 |
|
|
247 |
public void sendModeratorRejectedBudgetEmail(Person moderator, BudgetInfo budgetInfo) throws MessagingException { |
|
248 |
String subject = "Budget request rejected"; |
|
249 |
|
|
250 |
String text = "Hello " + moderator.getName() + ",\n" + |
|
251 |
" A budget request by " + budgetInfo.getUser().getName() + " " + budgetInfo.getUser().getLastname() + " has been rejected.\n" + |
|
252 |
" The OpenAIRE Gold Open Access team."; |
|
253 |
|
|
254 |
mailLibrary.sendEmail(new String[] {moderator.getEmail()}, subject, text); |
|
255 |
} |
|
256 |
|
|
257 |
public void sendUserRoleAcceptedEmail(Person person, Role role) throws MessagingException { |
|
258 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] " + role.getName() + " status granted"; |
|
259 |
|
|
260 |
String text = "Dear " + person.getName() + " " + person.getLastname() + ",\n" + |
|
261 |
"\n" + |
|
262 |
"You have been upgraded/granted to the " + role.getName() + " status.\n" + |
|
263 |
"\n" + |
|
264 |
"Best,\n" + |
|
265 |
"The OpenAIRE team"; |
|
266 |
|
|
267 |
mailLibrary.sendEmail(new String[] {person.getEmail()}, subject, text); |
|
268 |
} |
|
269 |
|
|
270 |
public void sendModeratorRoleAcceptedEmail(Person moderator, Person user, Role role) throws MessagingException { |
|
271 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] " + role.getName() + " status granted to user " + user.getName() + " " + user.getLastname(); |
|
272 |
|
|
273 |
String text = "Dear moderator,\n" + |
|
274 |
"\n" + |
|
275 |
"User " + user.getName() + " " + user.getLastname(); |
|
276 |
if (user.getAffiliations().size() > 0 && user.getAffiliations().get(0).getOrganization() != null && user.getAffiliations().get(0).getOrganization().getName() != null) |
|
277 |
text += " from organization " + user.getAffiliations().get(0).getOrganization().getName(); |
|
278 |
text += "has been upgraded/granted the {XXXX} status.\n" + |
|
279 |
" \n" + |
|
280 |
"Best,\n" + |
|
281 |
"The OpenAIRE team"; |
|
282 |
|
|
283 |
mailLibrary.sendEmail(new String[] {moderator.getEmail()}, subject, text); |
|
284 |
} |
|
285 |
|
|
286 |
public void sendUserRoleRejectedEmail(Person person, Role role) throws MessagingException { |
|
287 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] " + role.getName() + " status not granted"; |
|
288 |
// TODO use contact us link when ready |
|
289 |
String link = baseAddress + "/#home"; |
|
290 |
|
|
291 |
String text = "Dear " + person.getName() + " " + person.getLastname() + ",\n" + |
|
292 |
"\n" + |
|
293 |
"You have not been upgraded/granted the " + role.getName() + " status.\n" + |
|
294 |
"\n" + |
|
295 |
"Contact us at " + link + " if you need further information.\n" + |
|
296 |
" \n" + |
|
297 |
"Best,\n" + |
|
298 |
"The OpenAIRE team"; |
|
299 |
|
|
300 |
mailLibrary.sendEmail(new String[] {person.getEmail()}, subject, text); |
|
301 |
} |
|
302 |
|
|
303 |
public void sendModeratorRoleRejectedEmail(Person moderator, Person user, Role role) throws MessagingException { |
|
304 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] " + role.getName() + " status NOT granted to user " + user.getName() + " " + user.getLastname(); |
|
305 |
|
|
306 |
String text = "Dear moderator,\n" + |
|
307 |
"\n" + |
|
308 |
"User " + user.getName() + " " + user.getLastname(); |
|
309 |
if (user.getAffiliations().size() > 0 && user.getAffiliations().get(0).getOrganization() != null && user.getAffiliations().get(0).getOrganization().getName() != null) |
|
310 |
text += " from organization " + user.getAffiliations().get(0).getOrganization().getName(); |
|
311 |
text += "has not been upgraded/granted the {XXXX} status.\n" + |
|
312 |
" \n" + |
|
313 |
"Best,\n" + |
|
314 |
"The OpenAIRE team"; |
|
315 |
|
|
316 |
mailLibrary.sendEmail(new String[]{moderator.getEmail()}, subject, text); |
|
317 |
} |
|
318 |
|
|
319 |
public void sendUserRoleRequestedEmail(Person person, List<Role> roles) throws MessagingException { |
|
320 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] "; |
|
321 |
for (Role role:roles) { |
|
322 |
subject += role.getName() + ", "; |
|
323 |
} |
|
324 |
subject = subject.substring(0, subject.length() - 2); |
|
325 |
subject += " status upgrade requested"; |
|
326 |
// TODO use contact us link when ready |
|
327 |
String link = baseAddress + "/#home"; |
|
328 |
|
|
329 |
String text = "Dear " + person.getName() + " " + person.getLastname() + ",\n" + |
|
330 |
"\n" + |
|
331 |
"You have requested to upgrade your status to "; |
|
332 |
for (Role role:roles) { |
|
333 |
text += role.getName() + ", "; |
|
334 |
} |
|
335 |
text = text.substring(0, text.length() - 2); |
|
336 |
text += "\n" + |
|
337 |
"We will process your request asap.\n" + |
|
338 |
"\n" + |
|
339 |
"If you don't hear us from us within the next few days, or need further information do not hesitate to contact us at " + link + ".\n" + |
|
340 |
" \n" + |
|
341 |
"Best,\n" + |
|
342 |
"The OpenAIRE team"; |
|
343 |
|
|
344 |
mailLibrary.sendEmail(new String[] {person.getEmail()}, subject, text); |
|
345 |
} |
|
346 |
|
|
347 |
public void sendModeratorRoleRequestedEmail(Person moderator, Person user, List<Role> roles) throws MessagingException { |
|
348 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] "; |
|
349 |
for (Role role:roles) { |
|
350 |
subject += role.getName() + ", "; |
|
351 |
} |
|
352 |
subject = subject.substring(0, subject.length() - 2); |
|
353 |
subject += " status upgrade requested by user " + user.getName() + " " + user.getLastname(); |
|
354 |
|
|
355 |
String text = "Dear moderator,\n" + |
|
356 |
"\n" + |
|
357 |
"User " + user.getName() + " " + user.getLastname(); |
|
358 |
if (user.getAffiliations().size() > 0 && user.getAffiliations().get(0).getOrganization() != null && user.getAffiliations().get(0).getOrganization().getName() != null) |
|
359 |
text += " from organization " + user.getAffiliations().get(0).getOrganization().getName(); |
|
360 |
text += "has requested to upgraded/be granted the "; |
|
361 |
for (Role role : roles) { |
|
362 |
text += role.getName() + ", "; |
|
363 |
} |
|
364 |
text = text.substring(0, text.length() - 2); |
|
365 |
text += " status.\n\n" + |
|
366 |
"Best,\n" + |
|
367 |
"The OpenAIRE team"; |
|
368 |
|
|
369 |
mailLibrary.sendEmail(new String[]{moderator.getEmail()}, subject, text); |
|
370 |
} |
|
371 |
|
|
372 |
public void sendRequesterInvoiceNotification(RequestInfo requestInfo) throws MessagingException { |
|
373 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request " + requestInfo.getId() + " - missing invoice"; |
|
374 |
// TODO use contact us link when ready |
|
375 |
String contactLink = baseAddress + "/#home"; |
|
376 |
String requestLink = baseAddress + "/#existingFundingRequests"; |
|
377 |
|
|
378 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
379 |
"\n" + |
|
380 |
"The following request has been approved for funding but we are missing the invoice:\n" + |
|
381 |
"\n" + |
|
382 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
383 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
384 |
|
|
385 |
if (requestInfo.getPublication().getJournal() != null) |
|
386 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
387 |
else |
|
388 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
389 |
|
|
390 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
391 |
"\n" + |
|
392 |
"Please make sure that either you or the publisher uploads the invoice in our system. Unless you do so, the request will be left in a pending state.\n" + |
|
393 |
"\n" + |
|
394 |
"All invoices must be addressed to: \n" + |
|
395 |
"\"\"Athena\"\" Research Centre\n" + |
|
396 |
"Artemidos 6 & Epidavrou\n" + |
|
397 |
"GR-151 25, Athens - GREECE\n" + |
|
398 |
"Phone: +30 210 6875 300 Fax +30 210 6875 485\n" + |
|
399 |
"VAT NUMBER: EL999723442\n" + |
|
400 |
"\n"; |
|
401 |
|
|
402 |
if (requestInfo.getComment() != null) |
|
403 |
text += requestInfo.getComment() + "\n\n"; |
|
404 |
|
|
405 |
text += "Click on the link below at any time to follow the status of your request:\n" + |
|
406 |
requestLink + "\n" + |
|
407 |
"\n" + |
|
408 |
"Feel free to contact us at " + contactLink + " if you need further information.\n" + |
|
409 |
" \n" + |
|
410 |
"Best,\n" + |
|
411 |
"The OpenAIRE team"; |
|
412 |
|
|
413 |
mailLibrary.sendEmail(new String[]{requestInfo.getUser().getEmail()}, subject, text); |
|
414 |
} |
|
415 |
|
|
416 |
public void sendPublisherInvoiceNotification(RequestInfo requestInfo) throws MessagingException { |
|
417 |
Publisher publisher = requestInfo.getPublication().getPublisher() != null?requestInfo.getPublication().getPublisher():requestInfo.getPublication().getJournal().getPublisher(); |
|
418 |
|
|
419 |
if (publisher != null && publisher.getEmail() != null) { |
|
420 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Funding request " + requestInfo.getId() + " - missing invoice"; |
|
421 |
// TODO use contact us link when ready |
|
422 |
String contactLink = baseAddress + "/#home"; |
|
423 |
String requestLink = baseAddress + "/#existingFundingRequests"; |
|
424 |
Person contact; |
|
425 |
String text; |
|
426 |
|
|
427 |
if (publisher.getContact() != null && publisher.getContact().getId() != null) { |
|
428 |
contact = personDAO.getPersonById(publisher.getContact().getId()); |
|
429 |
text = "Dear " + contact.getName() + " " + contact.getLastname() + ",\n"; |
|
430 |
} else { |
|
431 |
text = "Dear Madame/Sir,\n"; |
|
432 |
} |
|
433 |
|
|
434 |
text += "The following request by " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + " has been approved for funding but we are missing the invoice:\n" + |
|
435 |
"\n" + |
|
436 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
437 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
438 |
|
|
439 |
if (requestInfo.getPublication().getJournal() != null) |
|
440 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
441 |
else |
|
442 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
443 |
|
|
444 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
445 |
"\n" + |
|
446 |
"If you haven't done so already, sign in our system and see how to upload the invoice. Unless you or do so, the request will be left in a pending state.\n" + |
|
447 |
"\n" + |
|
448 |
"All invoices must be addressed to: \n" + |
|
449 |
"\"\"Athena\"\" Research Centre\n" + |
|
450 |
"Artemidos 6 & Epidavrou\n" + |
|
451 |
"GR-151 25, Athens - GREECE\n" + |
|
452 |
"Phone: +30 210 6875 300 Fax +30 210 6875 485\n" + |
|
453 |
"VAT NUMBER: EL999723442\n" + |
|
454 |
"\n"; |
|
455 |
|
|
456 |
if (requestInfo.getComment() != null) |
|
457 |
text += requestInfo.getComment() + "\n\n"; |
|
458 |
|
|
459 |
text += "Click on the link below at any time to follow the status of this request:\n" + |
|
460 |
requestLink + "\n" + |
|
461 |
"\n" + |
|
462 |
"Feel free to contact us at " + contactLink + " if you need further information.\n" + |
|
463 |
" \n" + |
|
464 |
"Best,\n" + |
|
465 |
"The OpenAIRE team"; |
|
466 |
|
|
467 |
mailLibrary.sendEmail(new String[]{publisher.getEmail()}, subject, text); |
|
468 |
} |
|
469 |
} |
|
470 |
|
|
471 |
public void sendAccountingRequestApprovedEmail(Person person, RequestInfo requestInfo) throws MessagingException { |
|
472 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Funding request \" + requestInfo.getId() + \" completed"; |
|
473 |
// TODO use contact us link when ready |
|
474 |
String requestLink = baseAddress + "/#accountingMonitorFundingRequests"; |
|
475 |
|
|
476 |
String text = "Dear Accounting Officer,\n" + |
|
477 |
"\n" + |
|
478 |
"The following request has been approved for funding:\n" + |
|
479 |
"\n" + |
|
480 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
481 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
482 |
|
|
483 |
if (requestInfo.getPublication().getJournal() != null) |
|
484 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
485 |
else |
|
486 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
487 |
|
|
488 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
489 |
"\n"; |
|
490 |
text += "Click on the link below to visit the publication data and related accounting info:\n" + |
|
491 |
requestLink + "\n" + |
|
492 |
"\n" + |
|
493 |
"Best,\n" + |
|
494 |
"The OpenAIRE team"; |
|
495 |
|
|
496 |
mailLibrary.sendEmail(new String[]{person.getEmail()}, subject, text); |
|
497 |
} |
|
498 |
|
|
499 |
public void sendRequesterPaidEmail(RequestInfo requestInfo) throws MessagingException { |
|
500 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request " + requestInfo.getId() + " has been paid"; |
|
501 |
String contactLink = baseAddress + "/#home"; |
|
502 |
|
|
503 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
504 |
"\n" + |
|
505 |
"The following request has been completed and APCs have been paid:\n" + |
|
506 |
"\n" + |
|
507 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
508 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
509 |
|
|
510 |
if (requestInfo.getPublication().getJournal() != null) |
|
511 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
512 |
else |
|
513 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
514 |
|
|
515 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
516 |
"\n"; |
|
517 |
text += "Please make sure that you or the researcher\n" + |
|
518 |
"1. update the DOI in our system, and \n" + |
|
519 |
"2. deposit the final manuscript in an OpenAIRE compliant repository (see list here)\n" + |
|
520 |
"\n"; |
|
521 |
if (requestInfo.getComment() != null) |
|
522 |
text += requestInfo.getComment() + "\n\n"; |
|
523 |
|
|
524 |
text += "Feel free to contact us at " + contactLink + " if you need further information.\n\n" + |
|
525 |
"Best,\n" + |
|
526 |
"The OpenAIRE team"; |
|
527 |
|
|
528 |
mailLibrary.sendEmail(new String[]{requestInfo.getUser().getEmail()}, subject, text); |
|
529 |
} |
|
530 |
|
|
531 |
public void sendPublisherPaidEmail(RequestInfo requestInfo) throws MessagingException { |
|
532 |
Publisher publisher = requestInfo.getPublication().getPublisher() != null?requestInfo.getPublication().getPublisher():requestInfo.getPublication().getJournal().getPublisher(); |
|
533 |
|
|
534 |
if (publisher != null && publisher.getEmail() != null) { |
|
535 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Funding request " + requestInfo.getId() + " for invoice " + requestInfo.getInvoice().getNumber() + " has been paid"; |
|
536 |
String contactLink = baseAddress + "/#home"; |
|
537 |
String text; |
|
538 |
Person contact; |
|
539 |
|
|
540 |
if (publisher.getContact() != null && publisher.getContact().getId() != null) { |
|
541 |
contact = personDAO.getPersonById(publisher.getContact().getId()); |
|
542 |
text = "Dear " + contact.getName() + " " + contact.getLastname() + ",\n"; |
|
543 |
} else { |
|
544 |
text = "Dear Madame/Sir,\n"; |
|
545 |
} |
|
546 |
|
|
547 |
text += "\n" + |
|
548 |
"The following request has been completed and APCs have been paid:\n" + |
|
549 |
"\n" + |
|
550 |
"Invoice #: " + requestInfo.getInvoice().getNumber() + "\n" + |
|
551 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
552 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
553 |
|
|
554 |
if (requestInfo.getPublication().getJournal() != null) |
|
555 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
556 |
else |
|
557 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
558 |
|
|
559 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
560 |
"\n"; |
|
561 |
text += "Please make sure that you or the researcher\n" + |
|
562 |
"1. update the DOI in our system, and \n" + |
|
563 |
"2. deposit the final manuscript in an OpenAIRE compliant repository (see list here)\n" + |
|
564 |
"\n"; |
|
565 |
if (requestInfo.getComment() != null) |
|
566 |
text += requestInfo.getComment() + "\n\n"; |
|
567 |
|
|
568 |
text += "Feel free to contact us at " + contactLink + " if you need further information.\n\n" + |
|
569 |
"Best,\n" + |
|
570 |
"The OpenAIRE team"; |
|
571 |
|
|
572 |
mailLibrary.sendEmail(new String[]{publisher.getEmail()}, subject, text); |
|
573 |
} |
|
574 |
} |
|
575 |
|
|
576 |
public void sendRequesterOnHoldEmail(RequestInfo requestInfo) throws MessagingException { |
|
577 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request " + requestInfo.getId() + " has been put on hold"; |
|
578 |
String contactLink = baseAddress + "/#home"; |
|
579 |
String requestLink = baseAddress + "/#existingFundingRequests"; |
|
580 |
|
|
581 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
582 |
"\n" + |
|
583 |
"The following request has been put on hold by our accounting office:\n" + |
|
584 |
"\n" + |
|
585 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
586 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
587 |
|
|
588 |
if (requestInfo.getPublication().getJournal() != null) |
|
589 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
590 |
else |
|
591 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
592 |
|
|
593 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
594 |
"\n"; |
|
595 |
if (requestInfo.getComment() != null) |
|
596 |
text += requestInfo.getComment() + "\n\n"; |
|
597 |
|
|
598 |
text += "Click on the link below at any time to follow the status of your request:\n" + |
|
599 |
requestLink + "\n" + |
|
600 |
"\n" + |
|
601 |
"Feel free to contact us at " + contactLink + " if you need further information.\n\n" + |
|
602 |
"Best,\n" + |
|
603 |
"The OpenAIRE team"; |
|
604 |
|
|
605 |
mailLibrary.sendEmail(new String[]{requestInfo.getUser().getEmail()}, subject, text); |
|
606 |
} |
|
607 |
|
|
608 |
public void sendPublisherOnHoldEmail(RequestInfo requestInfo) throws MessagingException { |
|
609 |
Publisher publisher = requestInfo.getPublication().getPublisher() != null?requestInfo.getPublication().getPublisher():requestInfo.getPublication().getJournal().getPublisher(); |
|
610 |
|
|
611 |
if (publisher != null && publisher.getEmail() != null) { |
|
612 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Funding request " + requestInfo.getId() + " for invoice " + requestInfo.getInvoice().getNumber() + " has been put on hold"; |
|
613 |
String contactLink = baseAddress + "/#home"; |
|
614 |
String requestLink = baseAddress + "/#existingFundingRequests"; |
|
615 |
String text; |
|
616 |
Person contact; |
|
617 |
|
|
618 |
if (publisher.getContact() != null && publisher.getContact().getId() != null) { |
|
619 |
contact = personDAO.getPersonById(publisher.getContact().getId()); |
|
620 |
text = "Dear " + contact.getName() + " " + contact.getLastname() + ",\n"; |
|
621 |
} else { |
|
622 |
text = "Dear Madame/Sir,\n"; |
|
623 |
} |
|
624 |
|
|
625 |
text += "\n" + |
|
626 |
"The following request has been put on hold by our accounting office:\n" + |
|
627 |
"\n" + |
|
628 |
"Invoice #: " + requestInfo.getInvoice().getNumber() + "\n" + |
|
629 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
630 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
631 |
|
|
632 |
if (requestInfo.getPublication().getJournal() != null) |
|
633 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
634 |
else |
|
635 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
636 |
|
|
637 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
638 |
"\n"; |
|
639 |
if (requestInfo.getComment() != null) |
|
640 |
text += requestInfo.getComment() + "\n\n"; |
|
641 |
|
|
642 |
text += "Click on the link below at any time to follow the status of your request:\n" + |
|
643 |
requestLink + "\n" + |
|
644 |
"\n" + |
|
645 |
"Feel free to contact us at " + contactLink + " if you need further information.\n\n" + |
|
646 |
"Best,\n" + |
|
647 |
"The OpenAIRE team"; |
|
648 |
|
|
649 |
mailLibrary.sendEmail(new String[]{publisher.getEmail()}, subject, text); |
|
650 |
} |
|
651 |
} |
|
652 |
|
|
653 |
public void sendRequesterDeniedEmail(RequestInfo requestInfo) throws MessagingException { |
|
654 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request " + requestInfo.getId() + " has been denied payment"; |
|
655 |
String contactLink = baseAddress + "/#home"; |
|
656 |
String requestLink = baseAddress + "/#existingFundingRequests"; |
|
657 |
|
|
658 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
659 |
"\n" + |
|
660 |
"The following request has been denied payment by our accounting office:\n" + |
|
661 |
"\n" + |
|
662 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
663 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
664 |
|
|
665 |
if (requestInfo.getPublication().getJournal() != null) |
|
666 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
667 |
else |
|
668 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
669 |
|
|
670 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
671 |
"\n"; |
|
672 |
if (requestInfo.getComment() != null) |
|
673 |
text += requestInfo.getComment() + "\n\n"; |
|
674 |
|
|
675 |
text += "Click on the link below at any time to follow the status of your request:\n" + |
|
676 |
requestLink + "\n" + |
|
677 |
"\n" + |
|
678 |
"Feel free to contact us at " + contactLink + " if you need further information.\n\n" + |
|
679 |
"Best,\n" + |
|
680 |
"The OpenAIRE team"; |
|
681 |
|
|
682 |
mailLibrary.sendEmail(new String[]{requestInfo.getUser().getEmail()}, subject, text); |
|
683 |
} |
|
684 |
|
|
685 |
public void sendPublisherDeniedEmail(RequestInfo requestInfo) throws MessagingException { |
|
686 |
// |
|
687 |
} |
|
688 |
|
|
689 |
public void sendCoordinatorRequestSubmittedEmail(Person coordinator, RequestInfo requestInfo) throws MessagingException { |
|
690 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] A new funding request (" + requestInfo.getId() + ") has been submitted"; |
|
691 |
String contactLink = baseAddress + "/#home"; |
|
692 |
|
|
693 |
String text = "Dear " + coordinator.getName() + " " + coordinator.getLastname() + ",\n" + |
|
694 |
"We are contacting you in your capacity of project coordinator for project " + requestInfo.getProject().getAcronym() + ".\n" + |
|
695 |
"As you may already know your project is eligible for publising funds from the OpenAIRE FP7 post-grant Gold Open Access Pilot " + contactLink + ".\n"; |
|
696 |
|
|
697 |
|
|
698 |
if (!requestInfo.getUser().getId().equals(requestInfo.getResearcher().getId())) { |
|
699 |
text += requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + " from " + requestInfo.getUser().getAffiliations().get(0).getOrganization().getName() + |
|
700 |
" has requested on behalf of " + requestInfo.getResearcher().getName() + " " + requestInfo.getResearcher().getLastname() + |
|
701 |
" the funding of the following publication:\n"; |
|
702 |
} else { |
|
703 |
text += requestInfo.getResearcher().getName() + " " + requestInfo.getResearcher().getLastname() + " from " + requestInfo.getUser().getAffiliations().get(0).getOrganization().getName() + |
|
704 |
" has requested the funding of the following publication:\n"; |
|
705 |
} |
|
706 |
|
|
707 |
text += "\n"; |
|
708 |
text += "Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
709 |
|
|
710 |
if (requestInfo.getPublication().getJournal() != null) |
|
711 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
712 |
else |
|
713 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
714 |
|
|
715 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
716 |
"\n"; |
|
717 |
|
|
718 |
text += "As there is a limit of 3 publications from each project from this Pilot and would like to ensure a fair use of the fund. For the project's best interests, please let us know if there is any reason why we should not proceed with the requestd funding within the next 3 working days.\n"; |
|
719 |
text += "Feel free to contact us at " + contactLink + " if you need further information.\n\n" + |
|
720 |
"Best,\n" + |
|
721 |
"The OpenAIRE team"; |
|
722 |
|
|
723 |
mailLibrary.sendEmail(coordinator.getEmail(), subject, text); |
|
724 |
} |
|
725 |
|
|
726 |
public MailLibrary getMailLibrary() { |
|
727 |
return mailLibrary; |
|
728 |
} |
|
729 |
|
|
730 |
public void setMailLibrary(MailLibrary mailLibrary) { |
|
731 |
this.mailLibrary = mailLibrary; |
|
732 |
} |
|
733 |
|
|
734 |
public String getBaseAddress() { |
|
735 |
return baseAddress; |
|
736 |
} |
|
737 |
|
|
738 |
public void setBaseAddress(String baseAddress) { |
|
739 |
this.baseAddress = baseAddress; |
|
740 |
} |
|
741 |
|
|
742 |
public String getTermsOfAgreementUrl() { |
|
743 |
return termsOfAgreementUrl; |
|
744 |
} |
|
745 |
|
|
746 |
public void setTermsOfAgreementUrl(String termsOfAgreementUrl) { |
|
747 |
this.termsOfAgreementUrl = termsOfAgreementUrl; |
|
748 |
} |
|
749 |
} |
|
73 |
void sendCoordinatorRequestSubmittedEmail(Person coordinator, RequestInfo requestInfo) throws MessagingException; |
|
74 |
} |
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/utils/EmailUtilsLogger.java | ||
---|---|---|
1 |
package eu.dnetlib.goldoa.service.utils; |
|
2 |
|
|
3 |
import org.aspectj.lang.ProceedingJoinPoint; |
|
4 |
import org.aspectj.lang.annotation.Around; |
|
5 |
import org.aspectj.lang.annotation.Aspect; |
|
6 |
import org.springframework.beans.factory.annotation.Autowired; |
|
7 |
import org.springframework.beans.factory.annotation.Value; |
|
8 |
import org.springframework.stereotype.Component; |
|
9 |
|
|
10 |
import javax.mail.MessagingException; |
|
11 |
import java.io.PrintWriter; |
|
12 |
import java.io.StringWriter; |
|
13 |
|
|
14 |
/** |
|
15 |
* Created by antleb on 5/6/15. |
|
16 |
*/ |
|
17 |
@Component |
|
18 |
@Aspect |
|
19 |
public class EmailUtilsLogger { |
|
20 |
@Autowired |
|
21 |
private MailLibrary mailLibrary; |
|
22 |
|
|
23 |
private @Value("#{cascadingPropertyLoader.properties['goldoa.debugemails']}") boolean sendEmails = false; |
|
24 |
|
|
25 |
@Around("execution(public void eu.dnetlib.goldoa.service.utils.EmailUtils.send* (..))") |
|
26 |
public Object logErrors(ProceedingJoinPoint joinPoint) throws Throwable { |
|
27 |
if (sendEmails) { |
|
28 |
try { |
|
29 |
mailLibrary.sendEmail("antleb@di.uoa.gr", "sending email: " + joinPoint.getSignature().getName(), ""); |
|
30 |
|
|
31 |
return joinPoint.proceed(); |
|
32 |
} catch (Throwable throwable) { |
|
33 |
StringWriter sw = new StringWriter(); |
|
34 |
PrintWriter pw = new PrintWriter(sw); |
|
35 |
|
|
36 |
throwable.printStackTrace(pw); |
|
37 |
pw.close(); |
|
38 |
|
|
39 |
try { |
|
40 |
mailLibrary.sendEmail("antleb@di.uoa.gr", "Exception in mails", sw.toString()); |
|
41 |
} catch (MessagingException e) { |
|
42 |
e.printStackTrace(); |
|
43 |
} |
|
44 |
|
|
45 |
throw throwable; |
|
46 |
} |
|
47 |
} else { |
|
48 |
return joinPoint.proceed(); |
|
49 |
} |
|
50 |
} |
|
51 |
} |
modules/uoa-goldoa-service/trunk/src/main/java/eu/dnetlib/goldoa/service/utils/EmailUtilsImpl.java | ||
---|---|---|
1 |
package eu.dnetlib.goldoa.service.utils; |
|
2 |
|
|
3 |
import eu.dnetlib.goldoa.domain.*; |
|
4 |
import eu.dnetlib.goldoa.service.dao.PersonDAO; |
|
5 |
import org.apache.log4j.Logger; |
|
6 |
import org.springframework.beans.factory.annotation.Autowired; |
|
7 |
|
|
8 |
import javax.mail.MessagingException; |
|
9 |
import java.text.SimpleDateFormat; |
|
10 |
import java.util.List; |
|
11 |
|
|
12 |
/** |
|
13 |
* Created by antleb on 3/9/15. |
|
14 |
*/ |
|
15 |
public class EmailUtilsImpl implements EmailUtils { |
|
16 |
private static Logger logger = Logger.getLogger(EmailUtilsImpl.class); |
|
17 |
|
|
18 |
@Autowired |
|
19 |
PersonDAO personDAO; |
|
20 |
|
|
21 |
private MailLibrary mailLibrary; |
|
22 |
private String baseAddress; |
|
23 |
private String termsOfAgreementUrl; |
|
24 |
|
|
25 |
@Override |
|
26 |
public void sendActivationEmail(Person user, String token) throws MessagingException { |
|
27 |
String link = baseAddress + "/GoldOAPortal.html?token=" + token + "&email=" + user.getEmail() +"#activate"; |
|
28 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Account activation"; |
|
29 |
|
|
30 |
String message = "Dear " + user.getName() + " " + user.getLastname() + ",\n" + |
|
31 |
"Welcome to the OpenAIRE FP7 post-grant Gold OA Pilot service, \n" + |
|
32 |
"\n" + |
|
33 |
"Thank you for signing up. To verify your account, please click on the link below:\n" + |
|
34 |
link + "\n" + |
|
35 |
"\n" + |
|
36 |
"Best,\n" + |
|
37 |
"The OpenAIRE team"; |
|
38 |
|
|
39 |
mailLibrary.sendEmail(user.getEmail(), subject, message); |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void sendResetPasswordEmail(Person user, String password) throws MessagingException { |
|
44 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] New password"; |
|
45 |
String message = "Dear " + user.getName() + " " + user.getLastname() + ",\n" + |
|
46 |
"Your new password is " + password + |
|
47 |
"\n" + |
|
48 |
"Best,\n" + |
|
49 |
"The OpenAIRE team"; |
|
50 |
|
|
51 |
mailLibrary.sendEmail(user.getEmail(), subject, message); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public void sendRequesterOKEmail(RequestInfo requestInfo) throws MessagingException { |
|
56 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request at " + new SimpleDateFormat("yyyy-MM-dd").format(requestInfo.getDate()); |
|
57 |
String link = baseAddress + "/#existingFundingRequests"; |
|
58 |
|
|
59 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
60 |
"\n" + |
|
61 |
"We have received a request to fund for the following:\n" + |
|
62 |
"\n" + |
|
63 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
64 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
65 |
|
|
66 |
if (requestInfo.getPublication().getJournal() != null) |
|
67 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
68 |
else |
|
69 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
70 |
|
|
71 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
72 |
"\n" + |
|
73 |
"At a first glance it seems that this is an eligible request and it will be processed asap. We will notify you if you need to take further actions and we will you keep you posted on its status.\n" + |
|
74 |
"\n" + |
|
75 |
"You may click on the link below at any time to follow the status of your request:\n" + |
|
76 |
link + "\n" + |
|
77 |
" \n" + |
|
78 |
"Best,\n" + |
|
79 |
"The OpenAIRE team"; |
|
80 |
|
|
81 |
mailLibrary.sendEmail(requestInfo.getUser().getEmail(), subject, text); |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public void sendModeratorOKEmail(RequestInfo requestInfo, Person moderator) throws MessagingException { |
|
86 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] New funding request (" + requestInfo.getId() + ")"; |
|
87 |
String link = baseAddress + "/#monitorFundingRequests"; |
|
88 |
|
|
89 |
|
|
90 |
String text = "Dear moderator,\n" + |
|
91 |
"\n" + |
|
92 |
"We have received a request to fund for the following:\n" + |
|
93 |
"\n" + |
|
94 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
95 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
96 |
|
|
97 |
if (requestInfo.getPublication().getJournal() != null) |
|
98 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
99 |
else |
|
100 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
101 |
|
|
102 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
103 |
"\n" + |
|
104 |
"At a first glance it seems that this is an eligible request. Please visit the link below to validate and process the request:\n" + |
|
105 |
link + "\n" + |
|
106 |
" \n" + |
|
107 |
"Best,\n" + |
|
108 |
"The OpenAIRE team"; |
|
109 |
|
|
110 |
mailLibrary.sendEmail(moderator.getEmail(), subject, text); |
|
111 |
} |
|
112 |
|
|
113 |
@Override |
|
114 |
public void sendRequesterIFFYEmail(RequestInfo requestInfo) throws MessagingException { |
|
115 |
String subject = "Your funding request at " + new SimpleDateFormat("yyyy-MM-dd").format(requestInfo.getDate()); |
|
116 |
|
|
117 |
String text = "Hello " + requestInfo.getUser().getName() + ",\n" + |
|
118 |
" your request will be processed soon.The terms of agreement can be found here: " + termsOfAgreementUrl + "\n" + |
|
119 |
" The OpenAIRE Gold Open Access team."; |
|
120 |
|
|
121 |
mailLibrary.sendEmail(requestInfo.getUser().getEmail(), subject, text); |
|
122 |
} |
|
123 |
|
|
124 |
@Override |
|
125 |
public void sendModeratorIFFYEmail(RequestInfo requestInfo, Person moderator) throws MessagingException { |
|
126 |
String subject = "New funding request (" + requestInfo.getId() + ")"; |
|
127 |
|
|
128 |
String text = "Hello " + moderator.getName() + ",\n" + |
|
129 |
" A new smelly, stinky and iffy request has been submitted. You may inspect it and approve or reject it here...\n" + |
|
130 |
" Thank you !\n The OpenAIRE Gold Open Access team."; |
|
131 |
|
|
132 |
mailLibrary.sendEmail(moderator.getEmail(), subject, text); |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public void sendRequesterApprovedEmail(RequestInfo requestInfo) throws MessagingException { |
|
137 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request at " + new SimpleDateFormat("yyyy-MM-dd").format(requestInfo.getDate()) + "has been approved"; |
|
138 |
String link = baseAddress + "/#existingFundingRequests"; |
|
139 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
140 |
"\n" + |
|
141 |
"The following request is eligible and has been approved for funding:\n" + |
|
142 |
"\n" + |
|
143 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
144 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
145 |
|
|
146 |
if (requestInfo.getPublication().getJournal() != null) |
|
147 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
148 |
else |
|
149 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
150 |
|
|
151 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
152 |
"\n" + |
|
153 |
"If no invoice has been uploaded, or the publisher bank information is missing, our accounting office may put the request on hold until all information is in the system.\n" + |
|
154 |
"\n"; |
|
155 |
|
|
156 |
if (requestInfo.getComment() != null) |
|
157 |
text += requestInfo.getComment() + "\n\n"; |
|
158 |
|
|
159 |
text += "You may click on the link below at any time to follow the status of your request:\n" + |
|
160 |
link + "\n" + |
|
161 |
" \n" + |
|
162 |
"Best,\n" + |
|
163 |
"The OpenAIRE team"; |
|
164 |
|
|
165 |
mailLibrary.sendEmail(requestInfo.getUser().getEmail(), subject, text); |
|
166 |
} |
|
167 |
|
|
168 |
@Override |
|
169 |
public void sendRequesterRejectedEmail(RequestInfo requestInfo) throws MessagingException { |
|
170 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request at " + new SimpleDateFormat("yyyy-MM-dd").format(requestInfo.getDate()) + "has been rejected"; |
|
171 |
String link = baseAddress + "/#existingFundingRequests"; |
|
172 |
|
|
173 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
174 |
"\n" + |
|
175 |
"The following request has been rejected:\n" + |
|
176 |
"\n" + |
|
177 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
178 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
179 |
|
|
180 |
if (requestInfo.getPublication().getJournal() != null) |
|
181 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
182 |
else |
|
183 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
184 |
|
|
185 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
186 |
"\n" + |
|
187 |
"Reason: "; |
|
188 |
|
|
189 |
if (requestInfo.getComment() != null) |
|
190 |
text += requestInfo.getComment() + "\n\n"; |
|
191 |
else |
|
192 |
text += "-\n\n"; |
|
193 |
|
|
194 |
text += "You may click on the link below at any time to find more information:\n" + |
|
195 |
link + "\n" + |
|
196 |
" \n" + |
|
197 |
"Best,\n" + |
|
198 |
"The OpenAIRE team"; |
|
199 |
|
|
200 |
mailLibrary.sendEmail(requestInfo.getUser().getEmail(), subject, text); |
|
201 |
} |
|
202 |
|
|
203 |
@Override |
|
204 |
public void sendModeratorNewBudgetEmail(Person moderator, BudgetInfo budgetInfo) throws MessagingException { |
|
205 |
String subject = "New budget request"; |
|
206 |
|
|
207 |
String text = "Hello " + moderator.getName() + ",\n" + |
|
208 |
" A new budget request by " + budgetInfo.getUser().getName() + " " + budgetInfo.getUser().getLastname() + " has been submitted!\n" + |
|
209 |
" The OpenAIRE Gold Open Access team."; |
|
210 |
|
|
211 |
mailLibrary.sendEmail(new String[] {moderator.getEmail()}, subject, text); |
|
212 |
} |
|
213 |
|
|
214 |
@Override |
|
215 |
public void sendUserNewBudgetEmail(BudgetInfo budgetInfo) throws MessagingException { |
|
216 |
String subject = "New budget request"; |
|
217 |
|
|
218 |
String text = "Hello " + budgetInfo.getUser().getName() + ",\n" + |
|
219 |
" Your budget request has been submitted. We'll process it as soon as possible!\n" + |
|
220 |
" The OpenAIRE Gold Open Access team."; |
|
221 |
|
|
222 |
mailLibrary.sendEmail(new String[] {budgetInfo.getUser().getEmail()}, subject, text); |
|
223 |
} |
|
224 |
|
|
225 |
@Override |
|
226 |
public void sendUserAcceptedBudgetEmail(BudgetInfo budgetInfo) throws MessagingException { |
|
227 |
String subject = "Your budget request"; |
|
228 |
|
|
229 |
String text = "Hello " + budgetInfo.getUser().getName() + ",\n" + |
|
230 |
" Your budget request has been accepted! Spend them wisely!\n" + |
|
231 |
" The OpenAIRE Gold Open Access team."; |
|
232 |
|
|
233 |
mailLibrary.sendEmail(new String[] {budgetInfo.getUser().getEmail()}, subject, text); |
|
234 |
} |
|
235 |
|
|
236 |
@Override |
|
237 |
public void sendModeratorAcceptedBudgetEmail(Person moderator, BudgetInfo budgetInfo) throws MessagingException { |
|
238 |
String subject = "Budget request accepted"; |
|
239 |
|
|
240 |
String text = "Hello " + moderator.getName() + ",\n" + |
|
241 |
" A budget request by " + budgetInfo.getUser().getName() + " " + budgetInfo.getUser().getLastname() + " has been accepted!\n" + |
|
242 |
" The OpenAIRE Gold Open Access team."; |
|
243 |
|
|
244 |
mailLibrary.sendEmail(new String[] {moderator.getEmail()}, subject, text); |
|
245 |
} |
|
246 |
|
|
247 |
@Override |
|
248 |
public void sendUserRejectedBudgetEmail(BudgetInfo budgetInfo) throws MessagingException { |
|
249 |
String subject = "Your budget request"; |
|
250 |
|
|
251 |
String text = "Hello " + budgetInfo.getUser().getName() + ",\n" + |
|
252 |
" Your budget request has been rejected :(\n" + |
|
253 |
" The OpenAIRE Gold Open Access team."; |
|
254 |
|
|
255 |
mailLibrary.sendEmail(new String[] {budgetInfo.getUser().getEmail()}, subject, text); |
|
256 |
} |
|
257 |
|
|
258 |
@Override |
|
259 |
public void sendModeratorRejectedBudgetEmail(Person moderator, BudgetInfo budgetInfo) throws MessagingException { |
|
260 |
String subject = "Budget request rejected"; |
|
261 |
|
|
262 |
String text = "Hello " + moderator.getName() + ",\n" + |
|
263 |
" A budget request by " + budgetInfo.getUser().getName() + " " + budgetInfo.getUser().getLastname() + " has been rejected.\n" + |
|
264 |
" The OpenAIRE Gold Open Access team."; |
|
265 |
|
|
266 |
mailLibrary.sendEmail(new String[] {moderator.getEmail()}, subject, text); |
|
267 |
} |
|
268 |
|
|
269 |
@Override |
|
270 |
public void sendUserRoleAcceptedEmail(Person person, Role role) throws MessagingException { |
|
271 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] " + role.getName() + " status granted"; |
|
272 |
|
|
273 |
String text = "Dear " + person.getName() + " " + person.getLastname() + ",\n" + |
|
274 |
"\n" + |
|
275 |
"You have been upgraded/granted to the " + role.getName() + " status.\n" + |
|
276 |
"\n" + |
|
277 |
"Best,\n" + |
|
278 |
"The OpenAIRE team"; |
|
279 |
|
|
280 |
mailLibrary.sendEmail(new String[] {person.getEmail()}, subject, text); |
|
281 |
} |
|
282 |
|
|
283 |
@Override |
|
284 |
public void sendModeratorRoleAcceptedEmail(Person moderator, Person user, Role role) throws MessagingException { |
|
285 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] " + role.getName() + " status granted to user " + user.getName() + " " + user.getLastname(); |
|
286 |
|
|
287 |
String text = "Dear moderator,\n" + |
|
288 |
"\n" + |
|
289 |
"User " + user.getName() + " " + user.getLastname(); |
|
290 |
if (user.getAffiliations().size() > 0 && user.getAffiliations().get(0).getOrganization() != null && user.getAffiliations().get(0).getOrganization().getName() != null) |
|
291 |
text += " from organization " + user.getAffiliations().get(0).getOrganization().getName(); |
|
292 |
text += "has been upgraded/granted the {XXXX} status.\n" + |
|
293 |
" \n" + |
|
294 |
"Best,\n" + |
|
295 |
"The OpenAIRE team"; |
|
296 |
|
|
297 |
mailLibrary.sendEmail(new String[] {moderator.getEmail()}, subject, text); |
|
298 |
} |
|
299 |
|
|
300 |
@Override |
|
301 |
public void sendUserRoleRejectedEmail(Person person, Role role) throws MessagingException { |
|
302 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] " + role.getName() + " status not granted"; |
|
303 |
// TODO use contact us link when ready |
|
304 |
String link = baseAddress + "/#home"; |
|
305 |
|
|
306 |
String text = "Dear " + person.getName() + " " + person.getLastname() + ",\n" + |
|
307 |
"\n" + |
|
308 |
"You have not been upgraded/granted the " + role.getName() + " status.\n" + |
|
309 |
"\n" + |
|
310 |
"Contact us at " + link + " if you need further information.\n" + |
|
311 |
" \n" + |
|
312 |
"Best,\n" + |
|
313 |
"The OpenAIRE team"; |
|
314 |
|
|
315 |
mailLibrary.sendEmail(new String[] {person.getEmail()}, subject, text); |
|
316 |
} |
|
317 |
|
|
318 |
@Override |
|
319 |
public void sendModeratorRoleRejectedEmail(Person moderator, Person user, Role role) throws MessagingException { |
|
320 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] " + role.getName() + " status NOT granted to user " + user.getName() + " " + user.getLastname(); |
|
321 |
|
|
322 |
String text = "Dear moderator,\n" + |
|
323 |
"\n" + |
|
324 |
"User " + user.getName() + " " + user.getLastname(); |
|
325 |
if (user.getAffiliations().size() > 0 && user.getAffiliations().get(0).getOrganization() != null && user.getAffiliations().get(0).getOrganization().getName() != null) |
|
326 |
text += " from organization " + user.getAffiliations().get(0).getOrganization().getName(); |
|
327 |
text += "has not been upgraded/granted the {XXXX} status.\n" + |
|
328 |
" \n" + |
|
329 |
"Best,\n" + |
|
330 |
"The OpenAIRE team"; |
|
331 |
|
|
332 |
mailLibrary.sendEmail(new String[]{moderator.getEmail()}, subject, text); |
|
333 |
} |
|
334 |
|
|
335 |
@Override |
|
336 |
public void sendUserRoleRequestedEmail(Person person, List<Role> roles) throws MessagingException { |
|
337 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] "; |
|
338 |
for (Role role:roles) { |
|
339 |
subject += role.getName() + ", "; |
|
340 |
} |
|
341 |
subject = subject.substring(0, subject.length() - 2); |
|
342 |
subject += " status upgrade requested"; |
|
343 |
// TODO use contact us link when ready |
|
344 |
String link = baseAddress + "/#home"; |
|
345 |
|
|
346 |
String text = "Dear " + person.getName() + " " + person.getLastname() + ",\n" + |
|
347 |
"\n" + |
|
348 |
"You have requested to upgrade your status to "; |
|
349 |
for (Role role:roles) { |
|
350 |
text += role.getName() + ", "; |
|
351 |
} |
|
352 |
text = text.substring(0, text.length() - 2); |
|
353 |
text += "\n" + |
|
354 |
"We will process your request asap.\n" + |
|
355 |
"\n" + |
|
356 |
"If you don't hear us from us within the next few days, or need further information do not hesitate to contact us at " + link + ".\n" + |
|
357 |
" \n" + |
|
358 |
"Best,\n" + |
|
359 |
"The OpenAIRE team"; |
|
360 |
|
|
361 |
mailLibrary.sendEmail(new String[] {person.getEmail()}, subject, text); |
|
362 |
} |
|
363 |
|
|
364 |
@Override |
|
365 |
public void sendModeratorRoleRequestedEmail(Person moderator, Person user, List<Role> roles) throws MessagingException { |
|
366 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] "; |
|
367 |
for (Role role:roles) { |
|
368 |
subject += role.getName() + ", "; |
|
369 |
} |
|
370 |
subject = subject.substring(0, subject.length() - 2); |
|
371 |
subject += " status upgrade requested by user " + user.getName() + " " + user.getLastname(); |
|
372 |
|
|
373 |
String text = "Dear moderator,\n" + |
|
374 |
"\n" + |
|
375 |
"User " + user.getName() + " " + user.getLastname(); |
|
376 |
if (user.getAffiliations().size() > 0 && user.getAffiliations().get(0).getOrganization() != null && user.getAffiliations().get(0).getOrganization().getName() != null) |
|
377 |
text += " from organization " + user.getAffiliations().get(0).getOrganization().getName(); |
|
378 |
text += "has requested to upgraded/be granted the "; |
|
379 |
for (Role role : roles) { |
|
380 |
text += role.getName() + ", "; |
|
381 |
} |
|
382 |
text = text.substring(0, text.length() - 2); |
|
383 |
text += " status.\n\n" + |
|
384 |
"Best,\n" + |
|
385 |
"The OpenAIRE team"; |
|
386 |
|
|
387 |
mailLibrary.sendEmail(new String[]{moderator.getEmail()}, subject, text); |
|
388 |
} |
|
389 |
|
|
390 |
@Override |
|
391 |
public void sendRequesterInvoiceNotification(RequestInfo requestInfo) throws MessagingException { |
|
392 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request " + requestInfo.getId() + " - missing invoice"; |
|
393 |
// TODO use contact us link when ready |
|
394 |
String contactLink = baseAddress + "/#home"; |
|
395 |
String requestLink = baseAddress + "/#existingFundingRequests"; |
|
396 |
|
|
397 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
398 |
"\n" + |
|
399 |
"The following request has been approved for funding but we are missing the invoice:\n" + |
|
400 |
"\n" + |
|
401 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
402 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
403 |
|
|
404 |
if (requestInfo.getPublication().getJournal() != null) |
|
405 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
406 |
else |
|
407 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
408 |
|
|
409 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
410 |
"\n" + |
|
411 |
"Please make sure that either you or the publisher uploads the invoice in our system. Unless you do so, the request will be left in a pending state.\n" + |
|
412 |
"\n" + |
|
413 |
"All invoices must be addressed to: \n" + |
|
414 |
"\"\"Athena\"\" Research Centre\n" + |
|
415 |
"Artemidos 6 & Epidavrou\n" + |
|
416 |
"GR-151 25, Athens - GREECE\n" + |
|
417 |
"Phone: +30 210 6875 300 Fax +30 210 6875 485\n" + |
|
418 |
"VAT NUMBER: EL999723442\n" + |
|
419 |
"\n"; |
|
420 |
|
|
421 |
if (requestInfo.getComment() != null) |
|
422 |
text += requestInfo.getComment() + "\n\n"; |
|
423 |
|
|
424 |
text += "Click on the link below at any time to follow the status of your request:\n" + |
|
425 |
requestLink + "\n" + |
|
426 |
"\n" + |
|
427 |
"Feel free to contact us at " + contactLink + " if you need further information.\n" + |
|
428 |
" \n" + |
|
429 |
"Best,\n" + |
|
430 |
"The OpenAIRE team"; |
|
431 |
|
|
432 |
mailLibrary.sendEmail(new String[]{requestInfo.getUser().getEmail()}, subject, text); |
|
433 |
} |
|
434 |
|
|
435 |
@Override |
|
436 |
public void sendPublisherInvoiceNotification(RequestInfo requestInfo) throws MessagingException { |
|
437 |
Publisher publisher = requestInfo.getPublication().getPublisher() != null?requestInfo.getPublication().getPublisher():requestInfo.getPublication().getJournal().getPublisher(); |
|
438 |
|
|
439 |
if (publisher != null && publisher.getEmail() != null) { |
|
440 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Funding request " + requestInfo.getId() + " - missing invoice"; |
|
441 |
// TODO use contact us link when ready |
|
442 |
String contactLink = baseAddress + "/#home"; |
|
443 |
String requestLink = baseAddress + "/#existingFundingRequests"; |
|
444 |
Person contact; |
|
445 |
String text; |
|
446 |
|
|
447 |
if (publisher.getContact() != null && publisher.getContact().getId() != null) { |
|
448 |
contact = personDAO.getPersonById(publisher.getContact().getId()); |
|
449 |
text = "Dear " + contact.getName() + " " + contact.getLastname() + ",\n"; |
|
450 |
} else { |
|
451 |
text = "Dear Madame/Sir,\n"; |
|
452 |
} |
|
453 |
|
|
454 |
text += "The following request by " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + " has been approved for funding but we are missing the invoice:\n" + |
|
455 |
"\n" + |
|
456 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
457 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
458 |
|
|
459 |
if (requestInfo.getPublication().getJournal() != null) |
|
460 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
461 |
else |
|
462 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
463 |
|
|
464 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
465 |
"\n" + |
|
466 |
"If you haven't done so already, sign in our system and see how to upload the invoice. Unless you or do so, the request will be left in a pending state.\n" + |
|
467 |
"\n" + |
|
468 |
"All invoices must be addressed to: \n" + |
|
469 |
"\"\"Athena\"\" Research Centre\n" + |
|
470 |
"Artemidos 6 & Epidavrou\n" + |
|
471 |
"GR-151 25, Athens - GREECE\n" + |
|
472 |
"Phone: +30 210 6875 300 Fax +30 210 6875 485\n" + |
|
473 |
"VAT NUMBER: EL999723442\n" + |
|
474 |
"\n"; |
|
475 |
|
|
476 |
if (requestInfo.getComment() != null) |
|
477 |
text += requestInfo.getComment() + "\n\n"; |
|
478 |
|
|
479 |
text += "Click on the link below at any time to follow the status of this request:\n" + |
|
480 |
requestLink + "\n" + |
|
481 |
"\n" + |
|
482 |
"Feel free to contact us at " + contactLink + " if you need further information.\n" + |
|
483 |
" \n" + |
|
484 |
"Best,\n" + |
|
485 |
"The OpenAIRE team"; |
|
486 |
|
|
487 |
mailLibrary.sendEmail(new String[]{publisher.getEmail()}, subject, text); |
|
488 |
} |
|
489 |
} |
|
490 |
|
|
491 |
@Override |
|
492 |
public void sendAccountingRequestApprovedEmail(Person person, RequestInfo requestInfo) throws MessagingException { |
|
493 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Funding request \" + requestInfo.getId() + \" completed"; |
|
494 |
// TODO use contact us link when ready |
|
495 |
String requestLink = baseAddress + "/#accountingMonitorFundingRequests"; |
|
496 |
|
|
497 |
String text = "Dear Accounting Officer,\n" + |
|
498 |
"\n" + |
|
499 |
"The following request has been approved for funding:\n" + |
|
500 |
"\n" + |
|
501 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
502 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
503 |
|
|
504 |
if (requestInfo.getPublication().getJournal() != null) |
|
505 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
506 |
else |
|
507 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
508 |
|
|
509 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
510 |
"\n"; |
|
511 |
text += "Click on the link below to visit the publication data and related accounting info:\n" + |
|
512 |
requestLink + "\n" + |
|
513 |
"\n" + |
|
514 |
"Best,\n" + |
|
515 |
"The OpenAIRE team"; |
|
516 |
|
|
517 |
mailLibrary.sendEmail(new String[]{person.getEmail()}, subject, text); |
|
518 |
} |
|
519 |
|
|
520 |
@Override |
|
521 |
public void sendRequesterPaidEmail(RequestInfo requestInfo) throws MessagingException { |
|
522 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request " + requestInfo.getId() + " has been paid"; |
|
523 |
String contactLink = baseAddress + "/#home"; |
|
524 |
|
|
525 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
526 |
"\n" + |
|
527 |
"The following request has been completed and APCs have been paid:\n" + |
|
528 |
"\n" + |
|
529 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
530 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
531 |
|
|
532 |
if (requestInfo.getPublication().getJournal() != null) |
|
533 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
534 |
else |
|
535 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
536 |
|
|
537 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
538 |
"\n"; |
|
539 |
text += "Please make sure that you or the researcher\n" + |
|
540 |
"1. update the DOI in our system, and \n" + |
|
541 |
"2. deposit the final manuscript in an OpenAIRE compliant repository (see list here)\n" + |
|
542 |
"\n"; |
|
543 |
if (requestInfo.getComment() != null) |
|
544 |
text += requestInfo.getComment() + "\n\n"; |
|
545 |
|
|
546 |
text += "Feel free to contact us at " + contactLink + " if you need further information.\n\n" + |
|
547 |
"Best,\n" + |
|
548 |
"The OpenAIRE team"; |
|
549 |
|
|
550 |
mailLibrary.sendEmail(new String[]{requestInfo.getUser().getEmail()}, subject, text); |
|
551 |
} |
|
552 |
|
|
553 |
@Override |
|
554 |
public void sendPublisherPaidEmail(RequestInfo requestInfo) throws MessagingException { |
|
555 |
Publisher publisher = requestInfo.getPublication().getPublisher() != null?requestInfo.getPublication().getPublisher():requestInfo.getPublication().getJournal().getPublisher(); |
|
556 |
|
|
557 |
if (publisher != null && publisher.getEmail() != null) { |
|
558 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Funding request " + requestInfo.getId() + " for invoice " + requestInfo.getInvoice().getNumber() + " has been paid"; |
|
559 |
String contactLink = baseAddress + "/#home"; |
|
560 |
String text; |
|
561 |
Person contact; |
|
562 |
|
|
563 |
if (publisher.getContact() != null && publisher.getContact().getId() != null) { |
|
564 |
contact = personDAO.getPersonById(publisher.getContact().getId()); |
|
565 |
text = "Dear " + contact.getName() + " " + contact.getLastname() + ",\n"; |
|
566 |
} else { |
|
567 |
text = "Dear Madame/Sir,\n"; |
|
568 |
} |
|
569 |
|
|
570 |
text += "\n" + |
|
571 |
"The following request has been completed and APCs have been paid:\n" + |
|
572 |
"\n" + |
|
573 |
"Invoice #: " + requestInfo.getInvoice().getNumber() + "\n" + |
|
574 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
575 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
576 |
|
|
577 |
if (requestInfo.getPublication().getJournal() != null) |
|
578 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
579 |
else |
|
580 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
581 |
|
|
582 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
583 |
"\n"; |
|
584 |
text += "Please make sure that you or the researcher\n" + |
|
585 |
"1. update the DOI in our system, and \n" + |
|
586 |
"2. deposit the final manuscript in an OpenAIRE compliant repository (see list here)\n" + |
|
587 |
"\n"; |
|
588 |
if (requestInfo.getComment() != null) |
|
589 |
text += requestInfo.getComment() + "\n\n"; |
|
590 |
|
|
591 |
text += "Feel free to contact us at " + contactLink + " if you need further information.\n\n" + |
|
592 |
"Best,\n" + |
|
593 |
"The OpenAIRE team"; |
|
594 |
|
|
595 |
mailLibrary.sendEmail(new String[]{publisher.getEmail()}, subject, text); |
|
596 |
} |
|
597 |
} |
|
598 |
|
|
599 |
@Override |
|
600 |
public void sendRequesterOnHoldEmail(RequestInfo requestInfo) throws MessagingException { |
|
601 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Your funding request " + requestInfo.getId() + " has been put on hold"; |
|
602 |
String contactLink = baseAddress + "/#home"; |
|
603 |
String requestLink = baseAddress + "/#existingFundingRequests"; |
|
604 |
|
|
605 |
String text = "Dear " + requestInfo.getUser().getName() + " " + requestInfo.getUser().getLastname() + ",\n" + |
|
606 |
"\n" + |
|
607 |
"The following request has been put on hold by our accounting office:\n" + |
|
608 |
"\n" + |
|
609 |
"Project: " + requestInfo.getProject().getAcronym() + " - " + requestInfo.getProject().getGrant() + "\n" + |
|
610 |
"Publication: " + requestInfo.getPublication().getTitle() + "\n"; // TODO add authors |
|
611 |
|
|
612 |
if (requestInfo.getPublication().getJournal() != null) |
|
613 |
text += "Journal: " + requestInfo.getPublication().getJournal().getTitle() + " , " + requestInfo.getPublication().getJournal().getPublisher().getName() + "\n"; |
|
614 |
else |
|
615 |
text += "Publisher: " + requestInfo.getPublication().getPublisher().getName() + "\n"; |
|
616 |
|
|
617 |
text += "Requested funding: " + requestInfo.getFundingRequested() + " " + requestInfo.getCurrency().getName() + "\n" + |
|
618 |
"\n"; |
|
619 |
if (requestInfo.getComment() != null) |
|
620 |
text += requestInfo.getComment() + "\n\n"; |
|
621 |
|
|
622 |
text += "Click on the link below at any time to follow the status of your request:\n" + |
|
623 |
requestLink + "\n" + |
|
624 |
"\n" + |
|
625 |
"Feel free to contact us at " + contactLink + " if you need further information.\n\n" + |
|
626 |
"Best,\n" + |
|
627 |
"The OpenAIRE team"; |
|
628 |
|
|
629 |
mailLibrary.sendEmail(new String[]{requestInfo.getUser().getEmail()}, subject, text); |
|
630 |
} |
|
631 |
|
|
632 |
@Override |
|
633 |
public void sendPublisherOnHoldEmail(RequestInfo requestInfo) throws MessagingException { |
|
634 |
Publisher publisher = requestInfo.getPublication().getPublisher() != null?requestInfo.getPublication().getPublisher():requestInfo.getPublication().getJournal().getPublisher(); |
|
635 |
|
|
636 |
if (publisher != null && publisher.getEmail() != null) { |
|
637 |
String subject = "[OpenAIRE-FP7-Gold-OA-Pilot] Funding request " + requestInfo.getId() + " for invoice " + requestInfo.getInvoice().getNumber() + " has been put on hold"; |
|
638 |
String contactLink = baseAddress + "/#home"; |
|
639 |
String requestLink = baseAddress + "/#existingFundingRequests"; |
|
640 |
String text; |
|
641 |
Person contact; |
|
642 |
|
|
643 |
if (publisher.getContact() != null && publisher.getContact().getId() != null) { |
|
644 |
contact = personDAO.getPersonById(publisher.getContact().getId()); |
|
645 |
text = "Dear " + contact.getName() + " " + contact.getLastname() + ",\n"; |
|
646 |
} else { |
|
647 |
text = "Dear Madame/Sir,\n"; |
|
648 |
} |
Also available in: Unified diff
added a crude logger for emails