33import java .util .ArrayList ;
44import java .util .List ;
55
6+ import com .google .gwt .user .client .rpc .AsyncCallback ;
67import com .logicaldoc .gui .common .client .beans .GUIAccessControlEntry ;
78import com .logicaldoc .gui .common .client .beans .GUIWorkflow ;
89import com .logicaldoc .gui .common .client .data .WorkflowAclDS ;
910import com .logicaldoc .gui .common .client .i18n .I18N ;
11+ import com .logicaldoc .gui .common .client .log .GuiLog ;
1012import com .logicaldoc .gui .common .client .util .GridUtil ;
1113import com .logicaldoc .gui .common .client .util .ItemFactory ;
1214import com .logicaldoc .gui .common .client .util .LD ;
1315import com .logicaldoc .gui .common .client .widgets .grid .UserListGridField ;
14- import com .smartgwt . client .data . Record ;
16+ import com .logicaldoc . gui . frontend . client .services . WorkflowService ;
1517import com .smartgwt .client .types .HeaderControls ;
1618import com .smartgwt .client .types .ListGridFieldType ;
1719import com .smartgwt .client .types .SelectionStyle ;
@@ -107,6 +109,7 @@ void refresh(GUIWorkflow workflow) {
107109 list .setHeight100 ();
108110 list .setMinHeight (200 );
109111 list .setMinWidth (300 );
112+
110113 dataSource = new WorkflowAclDS (Long .parseLong (workflow .getId ()));
111114 list .setDataSource (dataSource );
112115
@@ -231,22 +234,17 @@ private void addGroupSelector(HLayout buttons) {
231234 * @return the list of ACEs
232235 */
233236 public List <GUIAccessControlEntry > getACL () {
234- int totalRecords = list .getRecordList ().getLength ();
235237 List <GUIAccessControlEntry > acl = new ArrayList <>();
236238
237- for (int i = 0 ; i < totalRecords ; i ++) {
238- Record rec = list .getRecordList ().get (i );
239- if (Boolean .FALSE .equals (rec .getAttributeAsBoolean ("read" )))
240- continue ;
241-
242- GUIAccessControlEntry right = new GUIAccessControlEntry ();
243-
244- right .setName (rec .getAttributeAsString (ENTITY ));
245- right .setEntityId (Long .parseLong (rec .getAttribute (ENTITY_ID )));
246- right .setWrite ("true" .equals (rec .getAttributeAsString (WRITE )));
247-
248- acl .add (right );
249- }
239+ if (list .getRecords () != null )
240+ for (ListGridRecord rec : list .getRecords ()) {
241+ GUIAccessControlEntry right = new GUIAccessControlEntry ();
242+ right .setName (rec .getAttributeAsString (ENTITY ));
243+ right .setEntityId (Long .parseLong (rec .getAttribute (ENTITY_ID )));
244+ right .setWrite ("true" .equals (rec .getAttributeAsString (WRITE )));
245+ right .setRead ("true" .equals (rec .getAttributeAsString ("read" )));
246+ acl .add (right );
247+ }
250248
251249 return acl ;
252250 }
@@ -268,8 +266,7 @@ private Menu setupContextMenu() {
268266
269267 MenuItem deleteItem = new MenuItem ();
270268 deleteItem .setTitle (I18N .message ("ddelete" ));
271- deleteItem .addClickHandler (event ->
272- onDelete ());
269+ deleteItem .addClickHandler (event -> onDelete ());
273270
274271 contextMenu .setItems (deleteItem );
275272 return contextMenu ;
@@ -288,6 +285,16 @@ private void onDelete() {
288285
289286 public void onSave () {
290287 workflow .setAccessControlList (getACL ());
291- destroy ();
288+ WorkflowService .Instance .get ().saveACL (workflow , new AsyncCallback <Void >() {
289+ @ Override
290+ public void onFailure (Throwable caught ) {
291+ GuiLog .serverError (caught );
292+ }
293+
294+ @ Override
295+ public void onSuccess (Void arg0 ) {
296+ destroy ();
297+ }
298+ });
292299 }
293300}
0 commit comments