@@ -52,9 +52,9 @@ private void updatePassword(EntityStore entityStore) {
5252 Set <String > keys = envValues .keySet ();
5353 Iterator <String > keysIterator = keys .iterator ();
5454
55- Map <String , String > ldap = groupEnvVariables (envValues ,"ldap_" );
56- Map <String , String > jms = groupEnvVariables (envValues ,"jms_" );
57- Map <String , String > smtp = groupEnvVariables (envValues ,"smtp_" );
55+ Map <String , String > ldap = groupEnvVariables (envValues , "ldap_" );
56+ Map <String , String > jms = groupEnvVariables (envValues , "jms_" );
57+ Map <String , String > smtp = groupEnvVariables (envValues , "smtp_" );
5858 Map <String , String > cassandraConsistency = groupEnvVariables (envValues , "cassandraconsistency_" );
5959
6060 while (keysIterator .hasNext ()) {
@@ -198,7 +198,7 @@ private void updatePassword(EntityStore entityStore) {
198198 }
199199 }
200200
201- private Map <String , String > groupEnvVariables ( Map <String , String > envValues , String namePrefix ){
201+ private Map <String , String > groupEnvVariables (Map <String , String > envValues , String namePrefix ) {
202202 return envValues .entrySet ()
203203 .stream ()
204204 .filter (map -> map .getKey ().startsWith (namePrefix ))
@@ -314,7 +314,7 @@ private void updateSMTP(EntityStore entityStore, Credential credential) {
314314 if (host != null ) {
315315 entity .setStringField ("smtpServer" , host );
316316 }
317- updateMailConnectionType (entity , credential .getFilterName ());
317+ updateMailConnectionTypeAndPort (entity , credential .getFilterName ());
318318 entityStore .updateEntity (entity );
319319 }
320320
@@ -329,11 +329,12 @@ private void updateAlertSMTP(EntityStore entityStore, Credential credential) {
329329 if (host != null ) {
330330 entity .setStringField ("smtp" , host );
331331 }
332- updateMailConnectionType (entity , credential .getFilterName ());
332+ updateMailConnectionTypeAndPort (entity , credential .getFilterName ());
333333 entityStore .updateEntity (entity );
334334 }
335335 }
336- private void updateMailConnectionType (Entity entity , String filterName ) {
336+
337+ private void updateMailConnectionTypeAndPort (Entity entity , String filterName ) {
337338 String connectionType = System .getenv ("smtp_" + filterName + "_connectionType" );
338339 if (connectionType != null ) {
339340 // Possible Values NONE, SSL TLS
@@ -343,6 +344,15 @@ private void updateMailConnectionType(Entity entity, String filterName) {
343344 Trace .error ("Invalid connection type : " + connectionType );
344345 }
345346 }
347+
348+ String port = System .getenv ("smtp_" + filterName + "_port" );
349+ if (port != null ) {
350+ try {
351+ entity .setIntegerField ("port" , Integer .parseInt (port ));
352+ }catch (NumberFormatException e ){
353+ Trace .error ("Invalid SMTP port number :" +port );
354+ }
355+ }
346356 }
347357
348358 private void updateCassandraCert (EntityStore entityStore , String alias , boolean append ) {
@@ -600,7 +610,7 @@ private void updateCassandraConsistencyLevel(EntityStore entityStore, String rea
600610 private void updateCassandraConsistencyLevel (ShorthandKeyFinder shorthandKeyFinder , String shorthandKey , String readConsistencyLevelFieldName , String readConsistencyLevel , String writeConsistencyLevelFieldName , String writeConsistencyLevel ) {
601611 List <Entity > kpsEntities = shorthandKeyFinder .getEntities (shorthandKey );
602612 if (kpsEntities != null ) {
603- Trace .info ("Total number of KPS Store: " + kpsEntities .size () + " in entity : " + shorthandKey );
613+ Trace .info ("Total number of KPS Store: " + kpsEntities .size () + " in entity : " + shorthandKey );
604614 EntityStore entityStore = shorthandKeyFinder .getEntityStore ();
605615 for (Entity entity : kpsEntities ) {
606616// Trace.info(entity.toString());
0 commit comments