11package com .acuity .iot .dsa .dslink .sys .cert ;
22
33import org .iot .dsa .node .DSBool ;
4- import org .iot .dsa .node .DSElement ;
54import org .iot .dsa .node .DSIValue ;
65import org .iot .dsa .node .DSInfo ;
76import org .iot .dsa .node .DSJavaEnum ;
@@ -18,6 +17,10 @@ public static enum WhitelistValue {
1817 ALLOWED , FORBIDDEN ;
1918 }
2019
20+ public static enum WhitelistOption {
21+ ALLOWED , FORBIDDEN , REMOVE ;
22+ }
23+
2124 private static final String ENABLED = "Enabled" ;
2225 private static final String ADD_HOSTNAME = "Add Hostname" ;
2326
@@ -54,8 +57,9 @@ public ActionResult invoke(DSInfo info, ActionInvocation invocation) {
5457
5558 private void addHostname (DSMap parameters ) {
5659 String hostname = parameters .getString ("Hostname" );
57- DSElement status = parameters .get ("Status" );
58- put (hostname , status ).setRemovable (true );
60+ String statusStr = parameters .getString ("Status" );
61+ WhitelistOption option = WhitelistOption .valueOf (statusStr );
62+ put (hostname , DSJavaEnum .valueOf (option ));
5963 }
6064
6165 public WhitelistValue checkHostname (String hostname ) {
@@ -70,5 +74,15 @@ public WhitelistValue checkHostname(String hostname) {
7074 return null ;
7175 }
7276 }
77+
78+ protected void onChildChanged (DSInfo info ) {
79+ if (info .isValue ()) {
80+ String val = info .getValue ().toElement ().toString ();
81+ if (WhitelistOption .REMOVE .name ().equals (val )) {
82+ remove (info );
83+ }
84+ }
85+ }
86+
7387
7488}
0 commit comments