6060import org .labkey .api .util .URLHelper ;
6161import org .labkey .api .view .ActionURL ;
6262import org .labkey .api .view .HtmlView ;
63- import org .labkey .api .view .HttpView ;
6463import org .labkey .api .view .JspView ;
6564import org .labkey .api .view .NavTree ;
6665import org .labkey .api .view .NotFoundException ;
@@ -85,6 +84,7 @@ public class OConnorExperimentsController extends SpringActionController
8584{
8685 public static final String EXPERIMENTS = "Experiments" ;
8786 private static final DefaultActionResolver _actionResolver = new DefaultActionResolver (OConnorExperimentsController .class );
87+ public static final org .apache .logging .log4j .Logger LOG = LogManager .getLogger (OConnorExperimentsController .class );
8888
8989 public OConnorExperimentsController ()
9090 {
@@ -110,7 +110,7 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
110110 {
111111 if (form .isFinalMigration ())
112112 {
113- LogManager . getLogger ( OConnorExperimentsController . class ) .info ("Final migration to be performed - file move events will be performed (irreversible)." );
113+ LOG .info ("Final migration to be performed - file move events will be performed (irreversible)." );
114114 }
115115
116116 // global containers
@@ -160,7 +160,7 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
160160 newType .put ("Name" , currentType );
161161 newType .put ("Enabled" , true );
162162 List <Map <String , Object >> newTypes = typeUpdateService .insertRows (getUser (), getContainer (), Collections .singletonList (newType ), new BatchValidationException (), null , null );
163- targetType = (Integer ) newTypes .get ( 0 ).get ("RowId" );
163+ targetType = (Integer ) newTypes .getFirst ( ).get ("RowId" );
164164 }
165165 }
166166
@@ -178,7 +178,7 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
178178 User user = UserManager .getUserByDisplayName ((String ) databaseMap .get ("initials" ));
179179 if (user == null )
180180 {
181- LogManager . getLogger ( OConnorExperimentsController . class ). warn ("User '" + databaseMap . get ( "initials" ) + " ' not found for experiment " + databaseMap .get ("expnumber" ));
181+ LOG . warn ("User '{} ' not found for experiment {}" , databaseMap . get ( "initials" ), databaseMap .get ("expnumber" ));
182182 effectiveUser = getUser ();
183183 }
184184 else
@@ -188,7 +188,7 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
188188 }
189189
190190 databaseMap .put ("EffectiveUser" , effectiveUser );
191- LogManager . getLogger ( OConnorExperimentsController . class ). info ("Insert on experiment " + databaseMap .get ("expnumber" ));
191+ LOG . info ("Insert on experiment {}" , databaseMap .get ("expnumber" ));
192192 List <Map <String , Object >> updateResult ;
193193 try
194194 {
@@ -197,18 +197,18 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
197197 catch (Exception e )
198198 {
199199 // log the error to the logfile and continue
200- LogManager . getLogger ( OConnorExperimentsController . class ). warn ("Error inserting expNumber " + expNumber + " with exception " + e .getMessage ());
200+ LOG . warn ("Error inserting expNumber {} with exception {}" , expNumber , e .getMessage ());
201201 continue ;
202202 }
203203 if (batchErrors .hasErrors ())
204204 {
205205 // throw batchErrors.getLastRowError();
206- LogManager . getLogger ( OConnorExperimentsController . class ). warn ("Error inserting expNumber " + expNumber );
206+ LOG . warn ("Error inserting expNumber {}" , expNumber );
207207 }
208208
209- Container workbookContainer = ContainerManager .getForId ((String )updateResult .get ( 0 ).get ("EntityId" ));
209+ Container workbookContainer = ContainerManager .getForId ((String )updateResult .getFirst ( ).get ("EntityId" ));
210210 databaseMap .put ("ContainerObj" , workbookContainer );
211- databaseMap .put ("ContainerStr" , updateResult .get ( 0 ).get ("EntityId" ));
211+ databaseMap .put ("ContainerStr" , updateResult .getFirst ( ).get ("EntityId" ));
212212
213213 // We don't want these fields to be spoofable through the QueryUpdateService (and hence the Client API),
214214 // so preserve the value from the source data manually
@@ -218,7 +218,7 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
218218 // Move files
219219 File sourceFile = new File (fileContentService .getFileRoot (sourceContainer ).getPath () + File .separator + "@files" , databaseMap .get ("expnumber" ).toString ());
220220 File targetDir = new File (fileContentService .getFileRoot (targetContainer ).getPath () + File .separator + databaseMap .get ("expnumber" ).toString () + File .separator + "@files" );
221- LogManager . getLogger ( OConnorExperimentsController . class ). info ("Copy from file '" + sourceFile + " ' to directory '" + targetDir + "'" );
221+ LOG . info ("Copy from file '{} ' to directory '{}'" , sourceFile , targetDir );
222222 if (sourceFile .exists ())
223223 {
224224 FileUtils .copyDirectory (sourceFile , targetDir );
@@ -260,7 +260,7 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
260260 }
261261 else
262262 {
263- LogManager . getLogger ( OConnorExperimentsController . class ). warn ("child container not found: " + parents [ i ] + " for experiment " + databaseMap .get ("expnumber" ) + " with username " + databaseMap .get ("initials" ));
263+ LOG . warn ("child container not found: {} for experiment {} with username {}" , parents [ i ], databaseMap .get ("expnumber" ), databaseMap .get ("initials" ));
264264 }
265265 }
266266 }
@@ -269,16 +269,15 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
269269 map .put ("ParentExperiments" , parentsEntityId .toArray (new String [0 ]));
270270
271271 // workaround, pass user, container - databaseMap.get("Container"), singleton list
272- LogManager . getLogger ( OConnorExperimentsController . class ). info ("Update rows on experiment " + databaseMap .get ("expnumber" ));
272+ LOG . info ("Update rows on experiment {}" , databaseMap .get ("expnumber" ));
273273 try
274274 {
275275 queryUpdateService .updateRows (getUser (), targetContainer , Collections .singletonList (map ), null , null , null );
276276 }
277277 catch (Exception e )
278278 {
279279 // log the error to the logfile and continue
280- LogManager .getLogger (OConnorExperimentsController .class ).warn ("Error updating parent experiments for experiment number " + expNumber + " with exception " + e .getMessage ());
281- continue ;
280+ LOG .warn ("Error updating parent experiments for experiment number {} with exception {}" , expNumber , e .getMessage ());
282281 }
283282
284283 }
@@ -304,7 +303,7 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
304303 Container workbookContainer = targetContainer .getChild (databaseMap .get ("expnumber" ).toString ());
305304 if (workbookContainer == null )
306305 {
307- LogManager . getLogger ( OConnorExperimentsController . class ). warn ("Updating wiki, container not found: " + databaseMap .get ("expnumber" ));
306+ LOG . warn ("Updating wiki, container not found: {}" , databaseMap .get ("expnumber" ));
308307 }
309308 else
310309 {
@@ -320,14 +319,14 @@ public boolean handlePost(UserForm form, BindException errors) throws Exception
320319 catch (Exception e )
321320 {
322321 // log the error to the logfile and continue
323- LogManager . getLogger ( OConnorExperimentsController . class ). warn ("Error wiki for experiment number " + expNumber + " with exception " + e .getMessage ());
322+ LOG . warn ("Error wiki for experiment number {} with exception {}" , expNumber , e .getMessage ());
324323 continue ;
325324 }
326325 finally
327326 {
328327 in .closeInputStream ();
329328 }
330- LogManager . getLogger ( OConnorExperimentsController . class ). info ("Inserting wiki for experiment " + databaseMap .get ("expnumber" ));
329+ LOG . info ("Inserting wiki for experiment {}" , databaseMap .get ("expnumber" ));
331330 }
332331 }
333332 }
@@ -439,7 +438,7 @@ public boolean handlePost(Object o, BindException errors) throws Exception
439438
440439 if (result != null && !result .isEmpty ())
441440 {
442- String entityId = (String )result .get ( 0 ).get ("Container" );
441+ String entityId = (String )result .getFirst ( ).get ("Container" );
443442 newExperiment = ContainerManager .getForId (entityId );
444443 return true ;
445444 }
@@ -464,7 +463,7 @@ public ApiResponse execute(Object o, BindException errors) throws Exception
464463 ApiSimpleResponse resp = new ApiSimpleResponse ();
465464 if (result != null && !result .isEmpty ())
466465 {
467- Map <String , Object > exp = result .get ( 0 );
466+ Map <String , Object > exp = result .getFirst ( );
468467
469468 resp .put ("success" , true );
470469 resp .put ("experiment" , exp );
0 commit comments