@@ -441,41 +441,36 @@ public ApiResponse execute(SimpleApiJsonForm form, BindException errors)
441441
442442 final Map <Container , List <Map <String , Object >>> rows = new HashMap <>();
443443 TableSelector ts = new TableSelector (JBrowseSchema .getInstance ().getTable (JBrowseSchema .TABLE_JSONFILES ), PageFlowUtil .set ("objectid" , "container" , "trackJson" ), new SimpleFilter (FieldKey .fromString ("objectid" ), objectIds , CompareType .IN ), null );
444- ts .forEachResults (new Selector .ForEachBlock <Results >()
445- {
446- @ Override
447- public void exec (Results rs ) throws SQLException , StopIteratingException
444+ ts .forEachResults (rs -> {
445+ Container c = ContainerManager .getForId (rs .getString (FieldKey .fromString ("container" )));
446+ if (!c .hasPermission (getUser (), UpdatePermission .class ))
448447 {
449- Container c = ContainerManager .getForId (rs .getString (FieldKey .fromString ("container" )));
450- if (!c .hasPermission (getUser (), UpdatePermission .class ))
451- {
452- throw new UnauthorizedException ("User does not have permission to update records in the folder: " + c .getPath ());
453- }
448+ throw new UnauthorizedException ("User does not have permission to update records in the folder: " + c .getPath ());
449+ }
454450
455- JSONObject json = rs .getString ("trackJson" ) == null ? new JSONObject () : new JSONObject (rs .getString ("trackJson" ));
456- for (String key : attributes .keySet ())
451+ JSONObject json = rs .getString ("trackJson" ) == null ? new JSONObject () : new JSONObject (rs .getString ("trackJson" ));
452+ for (String key : attributes .keySet ())
453+ {
454+ if (StringUtils .trimToNull (attributes .getString (key )) == null )
457455 {
458- if (StringUtils .trimToNull (attributes .getString (key )) == null )
459- {
460- json .remove (key );
461- }
462- else
463- {
464- json .put (key , attributes .get (key ));
465- }
456+ json .remove (key );
466457 }
467-
468- if (!rows .containsKey (c ))
458+ else
469459 {
470- rows .put (c , new ArrayList <>( ));
460+ json .put (key , attributes . get ( key ));
471461 }
462+ }
472463
473- Map <String , Object > row = new CaseInsensitiveHashMap <>();
474- row .put ("objectid" , rs .getString ("objectid" ));
475- row .put ("trackJson" , json .isEmpty () ? null : json .toString ());
476-
477- rows .get (c ).add (row );
464+ if (!rows .containsKey (c ))
465+ {
466+ rows .put (c , new ArrayList <>());
478467 }
468+
469+ Map <String , Object > row = new CaseInsensitiveHashMap <>();
470+ row .put ("objectid" , rs .getString ("objectid" ));
471+ row .put ("trackJson" , json .isEmpty () ? null : json .toString ());
472+
473+ rows .get (c ).add (row );
479474 });
480475
481476 try (DbScope .Transaction transaction = DbScope .getLabKeyScope ().ensureTransaction ())
0 commit comments