private boolean equalsAccessPoints(HashMap<String, AccessPoint> accessPoints) { if (this.accessPoints == null && accessPoints == null) { return true; } else if (this.accessPoints == null || accessPoints == null || this.accessPoints.size() != accessPoints.size()) { return false; } Set<String> localAccessPointsIds = this.accessPoints.keySet(); Set<String> otherAccessPointsIds = accessPoints.keySet(); return localAccessPointsIds.containsAll(otherAccessPointsIds); }
private void sendEmail(Task.Status exitStatus, File logFile) throws IOException, MessagingException, TemplateException { String smtpServer = RepoxContextUtil.getRepoxManager().getConfiguration().getSmtpServer(); if (smtpServer == null || smtpServer.isEmpty()) { return; } String fromEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getDefaultEmail(); String recipientsEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getAdministratorEmail(); String adminMailPass = RepoxContextUtil.getRepoxManager().getConfiguration().getMailPassword(); String subject = "REPOX Data Source ingesting finished. Exit status: " + exitStatus.toString(); EmailSender emailSender = new EmailSender(); String pathIngestFile = URLDecoder.decode( Thread.currentThread().getContextClassLoader().getResource("ingest.html.ftl").getFile(), "ISO-8859-1"); emailSender.setTemplate( pathIngestFile.substring(0, pathIngestFile.lastIndexOf("/")) + "/ingest"); HashMap map = new HashMap<String, String>(); map.put("exitStatus", exitStatus.toString()); map.put("id", id); JavaMailSenderImpl mail = new JavaMailSenderImpl(); // mail.setUsername(fromEmail); mail.setUsername(recipientsEmail); mail.setPassword(adminMailPass); mail.setPort(25); Properties props = System.getProperties(); props.put("mail.smtp.host", smtpServer); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "true"); mail.setJavaMailProperties(props); emailSender.setMailSender(mail); emailSender.sendEmail(recipientsEmail, fromEmail, subject, map, logFile.getAbsolutePath()); }
public static void main(String[] args) throws Exception { String smtpServer = RepoxContextUtil.getRepoxManager().getConfiguration().getSmtpServer(); if (smtpServer == null || smtpServer.isEmpty()) { return; } String fromEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getDefaultEmail(); String recipientsEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getAdministratorEmail(); String adminMailPass = RepoxContextUtil.getRepoxManager().getConfiguration().getMailPassword(); String subject = "REPOX Data Source ingesting finished. Exit status: "; EmailSender emailSender = new EmailSender(); String pathIngestFile = URLDecoder.decode( Thread.currentThread().getContextClassLoader().getResource("ingest.html.ftl").getFile(), "ISO-8859-1"); emailSender.setTemplate( pathIngestFile.substring(0, pathIngestFile.lastIndexOf("/")) + "/ingest"); HashMap map = new HashMap<String, String>(); map.put("exitStatus", "OK"); map.put("id", "1111"); JavaMailSenderImpl mail = new JavaMailSenderImpl(); mail.setUsername(recipientsEmail); mail.setPassword(adminMailPass); mail.setPort(25); Properties props = System.getProperties(); props.put("mail.smtp.host", smtpServer); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "false"); mail.setJavaMailProperties(props); emailSender.setMailSender(mail); emailSender.sendEmail( recipientsEmail, fromEmail, subject, map, "C:\\Users\\GPedrosa\\Desktop\\indexSec.txt"); }