Project

General

Profile

1 46884 konstantin
package eu.dnetlib.data.emailSender;
2
3 57029 argiro.kok
import eu.dnetlib.data.claims.entity.Claim;
4
import eu.dnetlib.data.claims.entity.Context;
5
import eu.dnetlib.data.claims.entity.Notification;
6
import eu.dnetlib.data.claims.entity.Project;
7
import eu.dnetlib.data.claims.handler.*;
8
import eu.dnetlib.data.claims.utils.ClaimUtils;
9 60560 konstantin
//import eu.dnetlib.data.claims.utils.CommunityUtils;
10 57029 argiro.kok
import eu.dnetlib.data.claims.sql.SQLStoreException;
11 60560 konstantin
import eu.dnetlib.data.claims.utils.ManagerUtils;
12 47211 katerina.i
import org.apache.log4j.Logger;
13 47265 katerina.i
import org.springframework.beans.factory.annotation.Autowired;
14 46884 konstantin
15
import javax.mail.*;
16
import javax.mail.internet.AddressException;
17
import javax.mail.internet.InternetAddress;
18
import javax.mail.internet.MimeMessage;
19 47444 konstantin
import java.text.SimpleDateFormat;
20 46884 konstantin
import java.util.*;
21
22
public class EmailSender implements Runnable {
23
24 47211 katerina.i
    private static final Logger logger = Logger.getLogger(EmailSender.class);
25 46884 konstantin
26 47265 katerina.i
    @Autowired
27 47211 katerina.i
    private FetchClaimHandler fetchClaimHandler = null;
28 53202 konstantin
    @Autowired
29
    private FetchProjectHandler fetchProjectHandler = null;
30
    @Autowired
31
    private FetchNotificationHandler fetchNotificationHandler = null;
32
    @Autowired
33
    private NotificationHandler notificationHandler = null;
34
    @Autowired
35
    private FetchContextHandler fetchContextHandler = null;
36 47265 katerina.i
37
    @Autowired
38 53202 konstantin
    private String defaultFrequencyInHours;
39 46884 konstantin
40 60560 konstantin
//    @Autowired
41
//    private CommunityUtils communityUtils;
42
43 58704 argiro.kok
    @Autowired
44 60560 konstantin
    private ManagerUtils managerUtils;
45 58704 argiro.kok
46 53916 konstantin
    private static String manageCommunityUserNotificationsPage;
47
    private static String openaireProjectClaimsPage;
48
    private static String openaireCommunityClaimsPage;
49 47211 katerina.i
    private static String username;
50
    private static String password;
51
    private static String host;
52
    private static String port;
53
    private static String from;
54 54959 argiro.kok
    private static String auth;
55 53916 konstantin
    private static String contactMail;
56 47265 katerina.i
    private static String specialRecipients;
57 56879 konstantin
    private static String enabledCommunities;
58 58702 argiro.kok
    private static boolean notifyCommunityManagers;
59
    private static boolean notifyProjectManagers;
60 46884 konstantin
61
    @Override
62
    public void run() {
63 47265 katerina.i
        logger.info("EmailSender thread is running. " + host);
64
        logger.info("Special Recipients  " + specialRecipients);
65 56879 konstantin
        logger.info("Enabled Communities " + enabledCommunities);
66 46884 konstantin
67 53202 konstantin
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
68
        Date date = new Date();
69
        String dateTo = (format.format(date));
70 58702 argiro.kok
        if(notifyCommunityManagers){
71
            defaultEmails_For_CommunityClaims(dateTo, format);  // daily for managers not in notification table
72
            notificationEmails_For_CommunityClaims(dateTo, format);
73
        }
74
        if(notifyProjectManagers) {
75 54959 argiro.kok
//        defaultEmails_For_ProjectClaims(dateTo, format);    // daily for managers not in notification table
76
//        notificationEmails_For_ProjectClaims(dateTo, format);
77 58702 argiro.kok
        }
78 53202 konstantin
    }
79
80
    public void defaultEmails_For_ProjectClaims(String dateTo, SimpleDateFormat format) {
81
        Map<String, List<String>> managersOfProject = new HashMap<String, List<String>>();
82
        Project project;
83 47444 konstantin
        List<Claim> claims = null;
84
        List<String> types = new ArrayList<String>();
85 46884 konstantin
86 47444 konstantin
        types.add(ClaimUtils.PROJECT);
87 46884 konstantin
88 47444 konstantin
        Calendar calendar = Calendar.getInstance();
89 53202 konstantin
        calendar.add(Calendar.HOUR_OF_DAY, -(Integer.parseInt(defaultFrequencyInHours)-1));
90 47444 konstantin
        calendar.add(Calendar.MINUTE, -59);
91
        calendar.add(Calendar.SECOND, -59);
92 53202 konstantin
        Date date = calendar.getTime();
93
        String dateFrom=(format.format(date));
94 47211 katerina.i
95 53202 konstantin
        logger.debug("Sending emails for project claims between " + dateFrom + " and "+dateTo);
96 46884 konstantin
97 47444 konstantin
        try {
98
            // Get all claims between dateFrom and dateTo which satisfy source_type == "project" or target_type == "project"
99
            claims = fetchClaimHandler.fetchClaimsByDate(dateFrom, dateTo, null, null, "", "source", true, types, false);
100
        } catch (SQLStoreException|Exception e) {
101
            logger.error("Could not fetch claims by date from "+dateFrom+" to "+dateTo, e);
102
        }
103 46884 konstantin
104 47444 konstantin
        for (Claim claim: claims) {
105
            if (claim.getSourceType().equals("project")) {
106
                project = (Project)claim.getSource();
107
            } else {
108 47504 konstantin
                project = (Project)claim.getTarget();
109 47444 konstantin
            }
110 46884 konstantin
111 47444 konstantin
            if (!managersOfProject.containsKey(project.getOpenaireId())) {
112 46884 konstantin
113 47444 konstantin
                // specialRecipients are used currently for testing purposes
114
                List<String> tmpManagers = null;
115
                if (specialRecipients != null && !specialRecipients.isEmpty()) {
116 53916 konstantin
                    tmpManagers = new ArrayList<>(Arrays.asList(specialRecipients.split("\\s*,\\s*")));
117 47444 konstantin
                    logger.debug("Special recipients: " + specialRecipients);
118 53916 konstantin
119
                    if(tmpManagers != null) {
120
                        Iterator itr = tmpManagers.iterator();
121
                        while (itr.hasNext()) {
122
                            String manager = (String) itr.next();
123
                            Notification notification = null;
124
                            try {
125
                                notification = fetchNotificationHandler.fetchNotification(project.getOpenaireId(), manager);
126
                            } catch (Exception e) {
127
                                e.printStackTrace();
128
                            } catch (SQLStoreException e) {
129
                                e.printStackTrace();
130
                            }
131
                            if (notification != null) {
132
                                itr.remove();
133
                            }
134
                        }
135
                    }
136
137 47444 konstantin
                    managersOfProject.put(project.getOpenaireId(), tmpManagers);
138
                }
139 47265 katerina.i
140 47444 konstantin
                // Send emails to actual project managers instead of special recipients
141 53202 konstantin
                List<String> managers = null;
142
                try {
143
                    managers = fetchProjectHandler.fetchContactEmailsByProjectId(project.getOpenaireId());
144 53916 konstantin
                    logger.debug("All actual Managers of project " + project.getOpenaireId() + ": "+managers);
145
146 53202 konstantin
                    if(managers != null) {
147
                        Iterator itr = managers.iterator();
148
                        while (itr.hasNext()) {
149
                            String manager = (String) itr.next();
150
                            Notification notification = fetchNotificationHandler.fetchNotification(project.getOpenaireId(), manager);
151
                            //if (notification != null && (!notification.isNotify() || notification.getFrequency() != 24)) {
152
                            if (notification != null) {
153
                                itr.remove();
154
                            }
155
                        }
156
                    }
157
                } catch (Exception e) {
158
                    e.printStackTrace();
159
                } catch (SQLStoreException e) {
160
                    e.printStackTrace();
161
                }
162 46884 konstantin
163 53916 konstantin
                logger.debug("Managers of project (not in notification table) " + project.getOpenaireId() + ": "+managers);
164
                /*
165 53202 konstantin
                managersOfProject.put(project.getOpenaireId(), managers);
166
                */
167
168
                if (managersOfProject.get(project.getOpenaireId()) != null &&
169
                        !managersOfProject.get(project.getOpenaireId()).isEmpty()) {
170 53916 konstantin
                    send(project.getOpenaireId(), project.getName(), "project", managersOfProject.get(project.getOpenaireId()));
171 53202 konstantin
                }
172
            }
173
        }
174
    }
175
176
    public void defaultEmails_For_CommunityClaims(String dateTo, SimpleDateFormat format) {
177
        Map<String, List<String>> managersOfCommunity = new HashMap<String, List<String>>();
178
        Context context;
179
        List<Claim> claims = null;
180
        List<String> types = new ArrayList<String>();
181
182
        types.add(ClaimUtils.CONTEXT);
183
184
        Calendar calendar = Calendar.getInstance();
185
        calendar.add(Calendar.HOUR_OF_DAY, -(Integer.parseInt(defaultFrequencyInHours)-1));
186
        calendar.add(Calendar.MINUTE, -59);
187
        calendar.add(Calendar.SECOND, -59);
188
        Date date = calendar.getTime();
189
        String dateFrom=(format.format(date));
190
191 56879 konstantin
        List<String> enabledCommunitiesList = null;
192
        if (enabledCommunities != null && !enabledCommunities.isEmpty()) {
193
            enabledCommunitiesList = Arrays.asList(enabledCommunities.split("\\s*,\\s*"));
194
        }
195
196 53202 konstantin
        logger.debug("Sending emails for community claims between " + dateFrom + " and "+dateTo);
197
198
        try {
199
            // Get all claims between dateFrom and dateTo which satisfy source_type == "context" or target_type == "context"
200
            claims = fetchClaimHandler.fetchClaimsByDate(dateFrom, dateTo, null, null, "", "source", true, types, false);
201
        } catch (SQLStoreException|Exception e) {
202
            logger.error("Could not fetch claims by date from "+dateFrom+" to "+dateTo, e);
203
        }
204
205
        for (Claim claim: claims) {
206
            if (claim.getSourceType().equals("context")) {
207
                context = (Context)claim.getSource();
208
            } else {
209
                context = (Context)claim.getTarget();
210
            }
211
212
            String openaireId = context.getOpenaireId().split("::")[0];
213 56879 konstantin
            if (!managersOfCommunity.containsKey(openaireId) && enabledCommunitiesList != null && enabledCommunitiesList.contains(openaireId)) {
214 53202 konstantin
215
                /*
216
                // specialRecipients are used currently for testing purposes
217
                List<String> tmpManagers = null;
218
                if (specialRecipients != null && !specialRecipients.isEmpty()) {
219
                    tmpManagers = Arrays.asList(specialRecipients.split("\\s*,\\s*"));
220
                    logger.debug("Special recipients: " + specialRecipients);
221
                    managersOfCommunity.put(openaireId, tmpManagers);
222
                }
223
                */
224
225
226
                // Send emails to actual project managers instead of special recipients
227
                List<String> managers = null;
228 47444 konstantin
                try {
229 60560 konstantin
                    //CommunityUtils communityInfo = this.communityUtils.getCommunityInfo(openaireId);
230
                    List<ManagerUtils> managerUtils = this.managerUtils.getManagersByEmail(openaireId);
231
                    //managers = communityInfo.getManagers();
232
                    if(managerUtils != null) {
233
                        Iterator<ManagerUtils> itr = managerUtils.iterator();
234 53202 konstantin
                        while (itr.hasNext()) {
235 60560 konstantin
                            String manager = (String) itr.next().getEmail();
236 53202 konstantin
                            Notification notification = fetchNotificationHandler.fetchNotification(openaireId, manager);
237
                            if (notification != null) {
238
                                itr.remove();
239
                            } else {
240 60560 konstantin
                                if(managers == null) {
241
                                    managers = new ArrayList<>();
242
                                }
243
                                managers.add(manager);
244 53202 konstantin
                                logger.debug("Sending email to community manager: "+ manager);
245
                            }
246
                        }
247
                    }
248
                    else {
249
                        logger.debug("Community Managers: null");
250
                    }
251
                } catch (Exception e) {
252
                    e.printStackTrace();
253
                } catch (SQLStoreException e) {
254
                    e.printStackTrace();
255
                }
256 46884 konstantin
257 53202 konstantin
                logger.debug("Managers of community " + openaireId + ": "+managers);
258
                managersOfCommunity.put(openaireId, managers);
259
260
261
                if (managersOfCommunity.get(openaireId) != null &&
262
                        !managersOfCommunity.get(openaireId).isEmpty()) {
263 53916 konstantin
                    send(openaireId, context.getTitle().split(">")[0], "community", managersOfCommunity.get(openaireId));
264 53202 konstantin
                }
265 56879 konstantin
            } else if(enabledCommunitiesList == null || !enabledCommunitiesList.contains(openaireId)) {
266
                logger.debug("Community "+openaireId+" is not enabled");
267 53202 konstantin
            }
268
        }
269
    }
270
271
    public void notificationEmails_For_ProjectClaims(String dateTo, SimpleDateFormat format) {
272
        Project project = null;
273
        List<String> types = new ArrayList<String>();
274
275
        types.add(ClaimUtils.PROJECT);
276
277
        logger.debug("Sending email for project claims from notification table");
278
279
        try {
280
            List<Notification> trueNotifications = fetchNotificationHandler.fetchTrueNotifications();
281
            logger.debug(trueNotifications);
282
            if(trueNotifications != null) {
283
                for(Notification notification : trueNotifications) {
284
                    List<String> managers = fetchProjectHandler.fetchContactEmailsByProjectId(notification.getOpenaireId());
285
                    if(managers != null && managers.contains(notification.getUserMail())) {
286
287
                        Date _dateTo = format.parse(dateTo);
288
289 53618 konstantin
                        Date _last_interaction_date = notification.getDate();
290
                        Calendar cal = Calendar.getInstance();
291
                        cal.setTime(_last_interaction_date);
292
                        cal.add(Calendar.SECOND, 1);
293
                        _last_interaction_date = cal.getTime();
294 53202 konstantin
295 53618 konstantin
                        String last_interaction_date = (format.format(_last_interaction_date));
296
297 53202 konstantin
                        long diff = _dateTo.getTime() - notification.getDate().getTime();
298
                        diff = diff / 1000;
299
300
                        if (diff >= (notification.getFrequency() * 3600)) {
301
                            if (fetchClaimHandler.fetchNumberOfClaimsByDateAndOpenaireId(last_interaction_date, dateTo, notification.getOpenaireId(), null, null, "", null, true, types, false) > 0) {
302
                                List<String> managersByNotification = new ArrayList<>();
303
                                managersByNotification.add(notification.getUserMail());
304
305
                                project = fetchProjectHandler.fetchProjectById(notification.getOpenaireId());
306
307
                                logger.debug("Sending email for project claims between " + last_interaction_date + " and " + dateTo + " to " + notification.getUserMail());
308
309 53916 konstantin
                                send(project.getOpenaireId(), project.getName(), "project", managersByNotification);
310 53202 konstantin
                            }
311 53916 konstantin
312 53202 konstantin
                            notificationHandler.updateNotificationLastInteractionDate(notification.getOpenaireId(), notification.getUserMail(), _dateTo);
313
                        }
314
                    } else {
315
                        logger.debug("managers do not contain "+notification.getUserMail());
316 46884 konstantin
                    }
317
                }
318 53202 konstantin
            } else {
319
                logger.debug("true notifications: null");
320 46884 konstantin
            }
321 53202 konstantin
        } catch (Exception e) {
322
            e.printStackTrace();
323
        } catch (SQLStoreException e) {
324
            e.printStackTrace();
325 46884 konstantin
        }
326
    }
327
328 53202 konstantin
    public void notificationEmails_For_CommunityClaims(String dateTo, SimpleDateFormat format) {
329
        Context context = null;
330
        List<String> types = new ArrayList<String>();
331 46884 konstantin
332 53202 konstantin
        types.add(ClaimUtils.CONTEXT);
333
334 56879 konstantin
        List<String> enabledCommunitiesList = null;
335
        if (enabledCommunities != null && !enabledCommunities.isEmpty()) {
336
            enabledCommunitiesList = Arrays.asList(enabledCommunities.split("\\s*,\\s*"));
337
        }
338
339 53202 konstantin
        logger.debug("Sending email for community claims from notification table");
340
341
        try {
342
            List<Notification> trueNotifications = fetchNotificationHandler.fetchTrueNotifications();
343
344 60560 konstantin
            Map<String, List<String>> allManagers = new HashMap<>();
345
346 53202 konstantin
            if(trueNotifications != null) {
347
                for(Notification notification : trueNotifications) {
348 56879 konstantin
                    if (enabledCommunitiesList != null && enabledCommunitiesList.contains(notification.getOpenaireId())) {
349 53202 konstantin
350 60560 konstantin
                        if(!allManagers.containsKey(notification.getOpenaireId())) {
351
                            allManagers.put(notification.getOpenaireId(), new ArrayList());
352
353
//                        CommunityUtils communityInfo = this.communityUtils.getCommunityInfo(notification.getOpenaireId());
354
                            List<ManagerUtils> managerUtils = this.managerUtils.getManagersByEmail(notification.getOpenaireId());
355
356
//                        List<String> managers = null;
357
                            if (managerUtils != null) {
358
                                for (ManagerUtils manager : managerUtils) {
359
                                    allManagers.get(notification.getOpenaireId()).add(manager.getEmail());
360
                                }
361
                            }
362 56879 konstantin
                        }
363 53202 konstantin
364 60560 konstantin
365
//                        if (managers != null && managers.contains(notification.getUserMail())) {
366
                        if(allManagers.get(notification.getOpenaireId()).contains(notification.getUserMail())) {
367 56879 konstantin
                            Date _dateTo = format.parse(dateTo);
368 53618 konstantin
369 56879 konstantin
                            Date _last_interaction_date = notification.getDate();
370
                            Calendar cal = Calendar.getInstance();
371
                            cal.setTime(_last_interaction_date);
372
                            cal.add(Calendar.SECOND, 1);
373
                            _last_interaction_date = cal.getTime();
374 53202 konstantin
375 56879 konstantin
                            String last_interaction_date = (format.format(_last_interaction_date));
376
                            long diff = _dateTo.getTime() - notification.getDate().getTime();
377
                            diff = diff / 1000;
378 53202 konstantin
379 56879 konstantin
                            if (diff >= (notification.getFrequency() * 3600)) {
380
                                if (fetchClaimHandler.fetchNumberOfClaimsByDateAndOpenaireId(last_interaction_date, dateTo, notification.getOpenaireId(), null, null, "", null, true, types, false) > 0) {
381
                                    List<String> managersByNotification = new ArrayList<>();
382
                                    managersByNotification.add(notification.getUserMail());
383 53202 konstantin
384 56879 konstantin
                                    // We need that to get name of community
385
                                    context = fetchContextHandler.fetchFirstContextByCommunityId(notification.getOpenaireId());
386 53202 konstantin
387 56879 konstantin
                                    logger.debug("Sending email for community claims between " + last_interaction_date + " and " + dateTo + " to " + notification.getUserMail());
388
389
                                    send(context.getOpenaireId().split("::")[0], context.getTitle().split(">")[0], "community", managersByNotification);
390
                                }
391
392
                                notificationHandler.updateNotificationLastInteractionDate(notification.getOpenaireId(), notification.getUserMail(), _dateTo);
393 60560 konstantin
                            } else {
394
                                logger.debug("[no notification] User "+notification.getUserMail()+" got latest notification at "+last_interaction_date+" and has set frequency to: "+notification.getFrequency());
395 53202 konstantin
                            }
396 60560 konstantin
                        } else {
397
                            logger.debug("User "+notification.getUserMail()+" is not manager of community "+notification.getOpenaireId());
398 53202 konstantin
                        }
399 56879 konstantin
                    } else {
400
                        logger.debug("Community "+notification.getOpenaireId()+" is not enabled");
401 53202 konstantin
                    }
402
                }
403
            }
404
        } catch (Exception e) {
405
            e.printStackTrace();
406
        } catch (SQLStoreException e) {
407
            e.printStackTrace();
408
        }
409
    }
410
411 53916 konstantin
    public void send(String openaire_id, String openaire_name, String type, List<String> managers) {
412
        logger.debug("Sending email");
413
        String openaireClaimsPageUrl = "";
414
        String manageUserNotificationsPage = "";
415
        String messageContent = "";
416
        String subject = "";
417 53202 konstantin
418 53916 konstantin
        if(type.equals("project")) {
419
            openaireClaimsPageUrl = openaireProjectClaimsPage + openaire_id;
420
421
            subject = "[OpenAIRE] Links notification";
422
            messageContent = "There are new Claims for: '" + openaire_name +"' project for which you seem to be a contact person." +
423
                    "<br>Click <a href=\""+openaireClaimsPageUrl+"\">here</a> to curate these Claims.";
424
        } else if(type.equals("community")) {
425
            openaireClaimsPageUrl = openaireCommunityClaimsPage + openaire_id;
426
            manageUserNotificationsPage = manageCommunityUserNotificationsPage + openaire_id;
427
428
            subject = "[OpenAIRE-Connect] "+openaire_name+": Links notification";
429
            messageContent =
430
                    " <div style=\"font-size:14px;\">" +
431
                    "    <p>" +
432
                    "       There are new links for '"+openaire_name+"' community. Click  <a href=\""+openaireClaimsPageUrl+"\">here</a> to view the links.\n" +
433
                    "    </p>" +
434
                    "    <p>OpenAIRE team<br/>" +
435
                    "       <a href=\"https://www.openaire.eu\">www.openaire.eu</a>" +
436
                    "    </p>" +
437 60031 konstantin
                    "    <p style=\"font-size:11px;\">You are receiving this e-mail as manager of the community  <a href=\"https://"+openaire_id+".openaire.eu\">"+openaire_name+"</a>." +
438 53916 konstantin
                    "    If you are not responsible for this community, please <a href=\"mailto:"+contactMail+"\">contact us</a>." +
439
                    "    <br/>" +
440
                    "    Click  <a href=\""+manageUserNotificationsPage+"\">here</a> to manage your notification settings. </p>" +
441
                    "    </div>"
442
                    ;
443
        }
444
445
        //logger.debug(messageContent);
446
447 46884 konstantin
        // Get system properties
448
        Properties properties = System.getProperties();
449
        properties.setProperty("mail.smtp.host", host);
450
        properties.put("mail.smtp.port", port);
451 54959 argiro.kok
        properties.put("mail.smtp.auth", auth); //enable authentication
452 46884 konstantin
        properties.put("mail.smtp.starttls.enable", "true");
453
454
        Session session = Session.getInstance(properties,
455
            new javax.mail.Authenticator() {
456
                protected PasswordAuthentication getPasswordAuthentication() {
457
                    return new PasswordAuthentication(username, password);
458
                }
459
            });
460
461
        try {
462
            // Create a default MimeMessage object.
463
            MimeMessage message = new MimeMessage(session);
464
465
            // Set From: header field of the header.
466
            message.setFrom(new InternetAddress(from));
467
468
            // Set To: header field of the header.
469
            for(String to : managers) {
470 53202 konstantin
                logger.debug(to);
471 46884 konstantin
                message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
472
            }
473 53916 konstantin
            message.addRecipient(Message.RecipientType.BCC, new InternetAddress("openaire.test@gmail.com"));
474 46884 konstantin
475
            // Set Subject: header field
476 53916 konstantin
            message.setSubject(subject);
477 46884 konstantin
478 47444 konstantin
            // For simple text setText() can be used instead of setContent()
479 46884 konstantin
480
            // Send the actual HTML message, as big as you like
481 53916 konstantin
            message.setContent(messageContent, "text/html");
482 46884 konstantin
483
            // Send message
484
            Transport.send(message);
485 47444 konstantin
            logger.debug("Sent message successfully....\n");
486 47211 katerina.i
487
        } catch (AddressException ae) {
488
            logger.error("Email could not be send.", ae);
489
490
        } catch (MessagingException me) {
491
            logger.error("Email could not be send.", me);
492 46884 konstantin
        }
493
    }
494
495 47211 katerina.i
    public void setFetchClaimHandler(FetchClaimHandler fetchClaimHandler) {
496
        this.fetchClaimHandler = fetchClaimHandler;
497
    }
498
499 53202 konstantin
    public void setFetchProjectHandler(FetchProjectHandler fetchProjectHandler) {
500
        this.fetchProjectHandler = fetchProjectHandler;
501 47211 katerina.i
    }
502
503 53202 konstantin
    public void setFetchNotificationHandler(FetchNotificationHandler fetchNotificationHandler) {
504
        this.fetchNotificationHandler = fetchNotificationHandler;
505
    }
506
507 53916 konstantin
    public void setNotificationHandler(NotificationHandler notificationHandler) {
508
        this.notificationHandler = notificationHandler;
509
    }
510
511 53202 konstantin
    public void setFetchContextHandler(FetchContextHandler fetchContextHandler) {
512
        this.fetchContextHandler = fetchContextHandler;
513
    }
514
515 56879 konstantin
    public void setOpenaireProjectClaimsPage(String openaireProjectClaimsPage) {
516 53916 konstantin
        EmailSender.openaireProjectClaimsPage = openaireProjectClaimsPage;
517 47211 katerina.i
    }
518
519 56879 konstantin
    public void setOpenaireCommunityClaimsPage(String openaireCommunityClaimsPage) {
520 53916 konstantin
        EmailSender.openaireCommunityClaimsPage = openaireCommunityClaimsPage;
521
    }
522
523 56879 konstantin
    public void setManageCommunityUserNotificationsPage(String manageCommunityUserNotificationsPage) {
524 53916 konstantin
        EmailSender.manageCommunityUserNotificationsPage = manageCommunityUserNotificationsPage;
525
    }
526
527 56879 konstantin
    public void setUsername(String username) {
528 47211 katerina.i
        EmailSender.username = username;
529
    }
530
531 56879 konstantin
    public void setPassword(String password) {
532 47211 katerina.i
        EmailSender.password = password;
533
    }
534
535 56879 konstantin
    public void setHost(String host) {
536 47211 katerina.i
        EmailSender.host = host;
537
    }
538
539 56879 konstantin
    public void setPort(String port) {
540 47211 katerina.i
        EmailSender.port = port;
541
    }
542
543 56879 konstantin
    public void setFrom(String from) {
544 47211 katerina.i
        EmailSender.from = from;
545
    }
546 47265 katerina.i
547 56879 konstantin
    public void setAuth(String auth) {
548 54959 argiro.kok
        EmailSender.auth = auth;
549
    }
550
551 56879 konstantin
    public void setContactMail(String contactMail) { EmailSender.contactMail = contactMail; }
552 53916 konstantin
553 56879 konstantin
    public void setSpecialRecipients(String specialRecipients) {
554 47265 katerina.i
        EmailSender.specialRecipients = specialRecipients;
555
    }
556 53916 konstantin
557
    public void setDefaultFrequencyInHours(String defaultFrequencyInHours) {
558
        this.defaultFrequencyInHours = defaultFrequencyInHours;
559
    }
560 56879 konstantin
561
    public void setEnabledCommunities(String enabledCommunities) {
562
        EmailSender.enabledCommunities = enabledCommunities;
563
    }
564 58702 argiro.kok
565
    public static boolean isNotifyCommunityManagers() {
566
        return notifyCommunityManagers;
567
    }
568
569
    public static void setNotifyCommunityManagers(boolean notifyCommunityManagers) {
570
        EmailSender.notifyCommunityManagers = notifyCommunityManagers;
571
    }
572
573
    public static boolean isNotifyProjectManagers() {
574
        return notifyProjectManagers;
575
    }
576
577
    public static void setNotifyProjectManagers(boolean notifyProjectManagers) {
578
        EmailSender.notifyProjectManagers = notifyProjectManagers;
579
    }
580 58704 argiro.kok
581 60560 konstantin
//    public void setCommunityUtils(CommunityUtils communityUtils) {
582
//        this.communityUtils = communityUtils;
583
//    }
584
//
585
//    public CommunityUtils getCommunityUtils() {
586
//        return communityUtils;
587
//    }
588
589
590
    public ManagerUtils getManagerUtils() {
591
        return managerUtils;
592 58704 argiro.kok
    }
593
594 60560 konstantin
    public void setManagerUtils(ManagerUtils managerUtils) {
595
        this.managerUtils = managerUtils;
596 58704 argiro.kok
    }
597 46884 konstantin
}