File tree Expand file tree Collapse file tree 6 files changed +29
-4
lines changed
src/aces/webctrl/postgresql Expand file tree Collapse file tree 6 files changed +29
-4
lines changed Original file line number Diff line number Diff line change 11<extension version =" 1" >
22 <name >PostgreSQL_Connect</name >
33 <description >Periodically synchronizes data to an external PostgreSQL database.</description >
4- <version >0.4.1 </version >
4+ <version >0.4.3 </version >
55 <vendor >Automatic Controls Equipment Systems, Inc.</vendor >
66 <system-menu-provider >aces.webctrl.postgresql.web.SystemMenuEditor</system-menu-provider >
77</extension >
Original file line number Diff line number Diff line change 33import java .io .*;
44import java .nio .file .*;
55import com .controlj .green .webserver .*;
6+ import com .controlj .green .core .ui .UserSession ;
67import com .controlj .green .datatable .util .CoreHelper ;
78public class HelperAPI {
89 private final static long timeout = 300L ;
910 private HelperAPI (){}
11+ /**
12+ * Terminates sessions corresponding to the given set of usernames.
13+ * @return whether all relevant sessions were closed.
14+ */
15+ public static boolean logout (Set <String > usernames ){
16+ try {
17+ String n ;
18+ for (final UserSession session :UserSession .getAllUserSessions ()){
19+ n = session .getOperator ().getLoginName ();
20+ if (n !=null && usernames .contains (n .toLowerCase ())){
21+ session .close ();
22+ }
23+ }
24+ return true ;
25+ }catch (Throwable t ){
26+ Initializer .log (t );
27+ }
28+ return false ;
29+ }
1030 /**
1131 * @return a collection of all local WebCTRL operators where usernames are mapped to display names, or {@code null} if an error occurs.
1232 */
Original file line number Diff line number Diff line change @@ -339,6 +339,7 @@ public void execute(SystemAccess sys){
339339 con .commit ();
340340 if (Initializer .stop ){ return ; }
341341 operatorWhitelist = new HashSet <String >(whitelist .keySet ());
342+ final HashSet <String > deletedOps = new HashSet <String >(16 );
342343 try (
343344 OperatorLink link = new OperatorLink (false );
344345 ){
@@ -348,6 +349,7 @@ public void execute(SystemAccess sys){
348349 if (blacklist .contains (opname )){
349350 refusernameCache .remove (op .getReferenceName ());
350351 op .delete ();
352+ deletedOps .add (opname );
351353 Initializer .log ("Deleted blacklisted operator: " +opname );
352354 }else if ((data = whitelist .get (opname ))!=null ){
353355 data .write (link , op );
@@ -363,6 +365,8 @@ public void execute(SystemAccess sys){
363365 Initializer .log ("Created whitelisted operator: " +d .username );
364366 }
365367 link .commit ();
368+ }finally {
369+ HelperAPI .logout (deletedOps );
366370 }
367371 }
368372 if (Initializer .stop ){ return ; }
@@ -492,6 +496,7 @@ public void execute(SystemAccess sys){
492496 ){
493497 s .executeUpdate ("INSERT INTO webctrl.events VALUES(" +ID +",'SYNCED',CURRENT_TIMESTAMP);" );
494498 }
499+ con .commit ();
495500 syncLog (con ,ID );
496501 }finally {
497502 con .rollback ();
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ CREATE TABLE webctrl.settings (
222222-- Populate default values for webctrl.settings
223223INSERT INTO webctrl .settings VALUES
224224 -- Version of PostgreSQL connector addon
225- (' version' ,' 0.4.1 ' ),
225+ (' version' ,' 0.4.3 ' ),
226226 -- Whether debug mode is enabled (e.g, verbose log messages when true)
227227 (' debug' ,' false' ),
228228 -- Whether to auto-update the PostgreSQL connector addon
Original file line number Diff line number Diff line change @@ -368,7 +368,7 @@ <h1 id="mainTitle"></h1>
368368 < br >
369369 < button class ="e " id ="saveButton " onclick ="save() "> Save Changes</ button >
370370 < button class ="e " id ="discardButton " onclick ="discard() "> Discard Changes</ button >
371- < button class ="e " id ="refreshButton " onclick ="window.location. refresh() "> Refresh</ button >
371+ < button class ="e " id ="refreshButton " onclick ="refresh() "> Refresh</ button >
372372 < br > < br >
373373 < a class ="e nav " href ="__PREFIX__/TableEditor?table=operator_whitelist "> Operator Whitelist</ a >
374374 < a class ="e nav " href ="__PREFIX__/TableEditor?table=operator_blacklist "> Operator Blacklist</ a >
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public class LogViewerPage extends ServletBase {
2020 final ArrayList <LogMessage > list = new ArrayList <LogMessage >(Initializer .logCache );
2121 final int len = list .size ();
2222 LogMessage l ;
23- boolean first = false ;
23+ boolean first = true ;
2424 sb .append ("[\n " );
2525 for (int i =len -1 ;i >=0 ;--i ){
2626 l = list .get (i );
You can’t perform that action at this time.
0 commit comments