Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 428559

Summary: [server] Error 500 when admin tries to delete a user
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: ServerAssignee: Anthony Hunter <ahunter.eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ahunter.eclipse, john.arthorne
Version: 5.0   
Target Milestone: 6.0 M1   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Mark Macdonald CLA 2014-02-19 11:12:11 EST
I am using the simple metastore backend on a local server with user creation enabled.

1. Create a new user "zzz"
2. Log in as zzz, create a project and some files, then log out.
3. Log in as the admin user
4. Go to http://localhost:8080/profile/user-list.html
5. Select zzz and click Delete

Nothing happens in the UI, but internally a server error is thrown:
> javax.servlet.ServletException: Error handling user: zzz
> 	at org.eclipse.orion.server.useradmin.servlets.UserHandlerV1.handleRequest(UserHandlerV1.java:119) ~[na:na]
> 	at org.eclipse.orion.server.useradmin.servlets.UserHandlerV1.handleRequest(UserHandlerV1.java:1) ~[na:na]
> 	at org.eclipse.orion.server.useradmin.servlets.ServletUserHandler.handleRequest(ServletUserHandler.java:49) ~[na:na]
> 	at org.eclipse.orion.server.useradmin.servlets.ServletUserHandler.handleRequest(ServletUserHandler.java:1) ~[na:na]
> 	at org.eclipse.orion.server.useradmin.servlets.UserServlet.doGet(UserServlet.java:63) ~[na:na]
> 	at org.eclipse.orion.server.useradmin.servlets.UserServlet.doDelete(UserServlet.java:71) ~[na:na]
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:761) ~[javax.servlet_3.0.0.v201112011016.jar:na]
> 	...
> Caused by: java.lang.RuntimeException: Meta File Error, cannot delete, not empty.
> 	at org.eclipse.orion.internal.server.core.metastore.SimpleMetaStoreUtil.deleteMetaFolder(SimpleMetaStoreUtil.java:204) ~[na:na]
> 	at org.eclipse.orion.internal.server.core.metastore.SimpleMetaStore.deleteProject(SimpleMetaStore.java:258) ~[na:na]
> 	at org.eclipse.orion.internal.server.core.metastore.SimpleMetaStore.deleteWorkspace(SimpleMetaStore.java:300) ~[na:na]
> 	at org.eclipse.orion.internal.server.core.metastore.SimpleMetaStore.deleteUser(SimpleMetaStore.java:277) ~[na:na]
> 	at org.eclipse.orion.server.useradmin.servlets.UserHandlerV1.handleUserDelete(UserHandlerV1.java:422) ~[na:na]
> 	at org.eclipse.orion.server.useradmin.servlets.UserHandlerV1.handleRequest(UserHandlerV1.java:112) ~[na:na]
> 	...

The delete will continue to fail until the admin first deletes the contents of zzz's user directory on disk. 

I expected it to just delete all zzz's files automatically.
Comment 1 Anthony Hunter CLA 2014-02-19 16:21:05 EST
Confirmed with the latest bits, this regression was introduced sometime after build I20140128-2230. Build I20140128-2230 does not have this issue.
Comment 2 Anthony Hunter CLA 2014-02-20 17:53:59 EST
(In reply to Anthony Hunter from comment #1)
> Confirmed with the latest bits, this regression was introduced sometime
> after build I20140128-2230. Build I20140128-2230 does not have this issue.

Actually, the user failed to be deleted in I20140128-2230, you just did not get an exception.

The problem I introduced with the new simple metadata storage is that I throw an exception when you are told to asked to delete a project and it is not empty.

I was trying to figure out what was going on here, and the issue does back to Orion 3.0 M2 and Bug 408590.

The metadata implementation has never deleted the project contents. The WorkspaceResourceHandler and GitCloneHandler remove project contents and then remove the projects from the metadata. We added this in Bug 408590.

The UserHandler has never deleted project contents. When you delete a user, it only deletes the user metadata. I have tested with the legacy metadata storage and when you delete a user, the projects are not deleted. The legacy metadata storage only deletes existing project contents when you create a new project so you do not get your old project contents.

The proper way to handle this is to make UserHandler behave the same as WorkspaceResourceHandler and GitCloneHandler and remove all project contents before deleting the user.
Comment 3 Anthony Hunter CLA 2014-03-03 11:37:27 EST
Fixed with commit:
http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=fbc04deaa50c6b9076913e837ff5f1db00b16d4b

I also updated the JUnit tests to ensure the a user with projects deletes correctly.