3838import org .labkey .api .admin .FolderWriterImpl ;
3939import org .labkey .api .admin .StaticLoggerGetter ;
4040import org .labkey .api .attachments .AttachmentParent ;
41+ import org .labkey .api .attachments .AttachmentService ;
4142import org .labkey .api .audit .AuditLogService ;
4243import org .labkey .api .audit .AuditTypeEvent ;
4344import org .labkey .api .audit .provider .ContainerAuditProvider ;
@@ -422,6 +423,7 @@ public static Container createContainerFromTemplate(Container parent, String nam
422423
423424 // import objects into the target folder
424425 XmlObject folderXml = vf .getXmlBean ("folder.xml" );
426+
425427 if (folderXml instanceof FolderDocument folderDoc )
426428 {
427429 FolderImportContext importCtx = new FolderImportContext (user , c , folderDoc , null , new StaticLoggerGetter (LogManager .getLogger (FolderImporterImpl .class )), vf );
@@ -1539,7 +1541,7 @@ else if (hasAncestryRead)
15391541 }
15401542
15411543 if (!addFolder )
1542- LOG .debug ("isNavAccessOpen restriction: \" " + f .getPath () + " \" " );
1544+ LOG .debug ("isNavAccessOpen restriction: \" {} \" " , f .getPath ());
15431545 }
15441546
15451547 if (addFolder )
@@ -1915,7 +1917,7 @@ private static boolean delete(final Container c, User user, @Nullable String com
19151917 throw new IllegalStateException ("Container not flagged as being deleted: " + c .getPath ());
19161918 }
19171919
1918- LOG .debug ("Starting container delete for " + c .getContainerNoun (true ) + " " + c .getPath ());
1920+ LOG .debug ("Starting container delete for {} {}" , c .getContainerNoun (true ), c .getPath ());
19191921
19201922 // Tell the search indexer to drop work for the container that's about to be deleted
19211923 SearchService .get ().purgeForContainer (c );
@@ -1942,6 +1944,8 @@ private static boolean delete(final Container c, User user, @Nullable String com
19421944 setContainerTabDeleted (c .getParent (), c .getName (), c .getParent ().getFolderType ().getName ());
19431945 }
19441946
1947+ AttachmentService .get ().detectOrphans (c );
1948+
19451949 fireDeleteContainer (c , user );
19461950
19471951 SqlExecutor sqlExecutor = new SqlExecutor (CORE .getSchema ());
@@ -1981,11 +1985,11 @@ private static boolean delete(final Container c, User user, @Nullable String com
19811985 boolean success = CORE .getSchema ().getScope ().executeWithRetry (tryDeleteContainer );
19821986 if (success )
19831987 {
1984- LOG .debug ("Completed container delete for " + c .getContainerNoun (true ) + " " + c .getPath ());
1988+ LOG .debug ("Completed container delete for {} {}" , c .getContainerNoun (true ), c .getPath ());
19851989 }
19861990 else
19871991 {
1988- LOG .warn ("Failed to delete container: " + c .getPath ());
1992+ LOG .warn ("Failed to delete container: {}" , c .getPath ());
19891993 }
19901994 return success ;
19911995 }
@@ -2025,13 +2029,13 @@ public static void deleteAll(Container root, User user, @Nullable String comment
20252029 if (!hasTreePermission (root , user , DeletePermission .class ))
20262030 throw new UnauthorizedException ("You don't have delete permissions to all folders" );
20272031
2028- LOG .debug ("Starting container (and children) delete for " + root .getContainerNoun (true ) + " " + root .getPath ());
2032+ LOG .debug ("Starting container (and children) delete for {} {}" , root .getContainerNoun (true ), root .getPath ());
20292033 Set <Container > depthFirst = getAllChildrenDepthFirst (root );
20302034 depthFirst .add (root );
20312035
20322036 delete (depthFirst , user , comment );
20332037
2034- LOG .debug ("Completed container (and children) delete for " + root .getContainerNoun (true ) + " " + root .getPath ());
2038+ LOG .debug ("Completed container (and children) delete for {} {}" , root .getContainerNoun (true ), root .getPath ());
20352039 }
20362040
20372041 public static void deleteAll (Container root , User user ) throws UnauthorizedException
@@ -2426,7 +2430,7 @@ protected static void fireCreateContainer(Container c, User user, @Nullable Stri
24262430 }
24272431 catch (Throwable t )
24282432 {
2429- LOG .error ("fireCreateContainer for " + cl .getClass ().getName (), t );
2433+ LOG .error ("fireCreateContainer for {}" , cl .getClass ().getName (), t );
24302434 }
24312435 }
24322436 }
@@ -2490,7 +2494,7 @@ public static void firePropertyChangeEvent(ContainerPropertyChangeEvent evt)
24902494 }
24912495 catch (Throwable t )
24922496 {
2493- LOG .error ("firePropertyChangeEvent for " + l .getClass ().getName (), t );
2497+ LOG .error ("firePropertyChangeEvent for {}" , l .getClass ().getName (), t );
24942498 }
24952499 }
24962500 }
@@ -2523,8 +2527,8 @@ public static Container createDefaultSupportContainer()
25232527 // create a "support" container. Admins can do anything,
25242528 // Users can read/write, Guests can read.
25252529 return bootstrapContainer (DEFAULT_SUPPORT_PROJECT_PATH ,
2526- RoleManager .getRole (AuthorRole .class ),
2527- RoleManager .getRole (ReaderRole .class )
2530+ RoleManager .getRole (AuthorRole .class ),
2531+ RoleManager .getRole (ReaderRole .class )
25282532 );
25292533 }
25302534
@@ -2693,7 +2697,7 @@ public static Container bootstrapContainer(String path, @NotNull Role userRole,
26932697
26942698 if (c == null )
26952699 {
2696- LOG .debug ("Creating new container for path '" + path + "'" );
2700+ LOG .debug ("Creating new container for path '{}'" , path );
26972701 newContainer = true ;
26982702 c = ensureContainer (path , user );
26992703 }
@@ -2710,7 +2714,7 @@ public static Container bootstrapContainer(String path, @NotNull Role userRole,
27102714
27112715 if (newContainer || 0 == policyCount .intValue ())
27122716 {
2713- LOG .debug ("Setting permissions for '" + path + "'" );
2717+ LOG .debug ("Setting permissions for '{}'" , path );
27142718 MutableSecurityPolicy policy = new MutableSecurityPolicy (c );
27152719 policy .addRoleAssignment (SecurityManager .getGroup (Group .groupUsers ), userRole );
27162720 if (guestRole != null )
@@ -2881,25 +2885,25 @@ public void testFolderType()
28812885
28822886 private void testOneFolderType (FolderType folderType )
28832887 {
2884- LOG .info ("testOneFolderType(" + folderType . getName () + ") : creating container" );
2888+ LOG .info ("testOneFolderType({}) : creating container" , folderType . getName () );
28852889 Container newFolder = createContainer (_testRoot , "folderTypeTest" , TestContext .get ().getUser ());
28862890 FolderType ft = newFolder .getFolderType ();
28872891 assertEquals (FolderType .NONE , ft );
28882892
28892893 Container newFolderFromCache = getForId (newFolder .getId ());
28902894 assertNotNull (newFolderFromCache );
28912895 assertEquals (FolderType .NONE , newFolderFromCache .getFolderType ());
2892- LOG .info ("testOneFolderType(" + folderType . getName () + ") : setting folder type" );
2896+ LOG .info ("testOneFolderType({}) : setting folder type" , folderType . getName () );
28932897 newFolder .setFolderType (folderType , TestContext .get ().getUser ());
28942898
28952899 newFolderFromCache = getForId (newFolder .getId ());
28962900 assertNotNull (newFolderFromCache );
28972901 assertEquals (newFolderFromCache .getFolderType ().getName (), folderType .getName ());
28982902 assertEquals (newFolderFromCache .getFolderType ().getDescription (), folderType .getDescription ());
28992903
2900- LOG .info ("testOneFolderType(" + folderType .getName () + "): deleteAll" );
2904+ LOG .info ("testOneFolderType({}): deleteAll" , folderType .getName ());
29012905 deleteAll (newFolder , TestContext .get ().getUser ()); // There might be subfolders because of container tabs
2902- LOG .info ("testOneFolderType(" + folderType . getName () + ") : deleteAll complete" );
2906+ LOG .info ("testOneFolderType({}) : deleteAll complete" , folderType . getName () );
29032907 Container deletedContainer = getForId (newFolder .getId ());
29042908
29052909 if (deletedContainer != null )
@@ -2946,7 +2950,7 @@ private static void logNode(MultiValuedMap<String, String> mm, String name, int
29462950
29472951 for (String childName : nodes )
29482952 {
2949- LOG .debug (StringUtils .repeat (" " , offset ) + childName );
2953+ LOG .debug ("{}{}" , StringUtils .repeat (" " , offset ), childName );
29502954 logNode (mm , childName , offset + 1 );
29512955 }
29522956 }
0 commit comments