BrightSide Workbench Full Report + Source Code
org.turro.mail.provider.MailProviderMigration Class Reference

Static Public Member Functions

static MailProviderSet migrate ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 37 of file MailProviderMigration.java.

Member Function Documentation

◆ migrate()

static MailProviderSet org.turro.mail.provider.MailProviderMigration.migrate ( )
static

Definition at line 39 of file MailProviderMigration.java.

39  {
40  Set<String> ids = new HashSet<>();
41  MailProviderSet set = new MailProviderSet();
42  List<String> names = new ArrayList<>();
43  names.add("IMailMessagePool");
44  names.addAll(ContextFactory.getImplementationNamesByType("IMailMessagePool"));
45  names.forEach((s) -> {
46  MailMessagePool pool = (MailMessagePool) HeadlessApplication.getInstance().getImplementation((String) s);
47  MailProvider provider = new MailProvider();
48  KeyValueMap attrs = pool.getAttributes();
49  String id = ((String) s).substring(((String) s).indexOf("_") + 1);
50  if("IMailMessagePool".equals(id)) id = MailProviders.GENERIC;
51  if(!ids.contains(id)) {
52  provider.setId(id);
53  provider.setHostname(attrs.get("mailhost"));
54  provider.setPort(attrs.get(Integer.class, "port", null));
55  provider.setTls(attrs.get(Boolean.class, "tls", false));
56  provider.setSsl(attrs.get(Boolean.class, "ssl", false));
57  provider.setUser(attrs.get(String.class, "user", null));
58  provider.setPassword(attrs.get(String.class, "cryptpass", null));
59  if(Strings.isBlank(provider.getPassword())) {
60  provider.setPassword(ElephantContext.encrypt(attrs.get(String.class, "password", null)));
61  }
62  provider.setFrom(MailRecipient.of(attrs.get(String.class, "from", null)));
63  provider.clearEmpties();
64  set.addProvider(provider);
65  ids.add(id);
66  }
67  });
68  ContextFactory.getImplementationNamesByType("IMailPool").forEach((s) -> {
69  MailPool pool = (MailPool) HeadlessApplication.getInstance().getImplementation((String) s);
70  MailProvider provider = new MailProvider();
71  KeyValueMap attrs = pool.getAttributes();
72  String id = ((String) s).substring(((String) s).indexOf("_") + 1);
73  if(!ids.contains(id)) {
74  provider.setId(id);
75  provider.setHostname(attrs.get("mailhost"));
76  provider.setPort(attrs.get(Integer.class, "port", null));
77  provider.setTls(attrs.get(Boolean.class, "tls", false));
78  provider.setSsl(attrs.get(Boolean.class, "ssl", false));
79  provider.setUser(attrs.get(String.class, "user", null));
80  provider.setPassword(attrs.get(String.class, "cryptpass", null));
81  if(Strings.isBlank(provider.getPassword())) {
82  provider.setPassword(ElephantContext.encrypt(attrs.get(String.class, "password", null)));
83  }
84  provider.setFrom(MailRecipient.of(attrs.get(String.class, "from", null)));
85  provider.clearEmpties();
86  set.addProvider(provider);
87  ids.add(id);
88  }
89  });
90  return set;
91  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: