{"action":"created","comment":{"url":"https://api.github.com/repos/linagora/james-project/pulls/comments/68035442","id":68035442,"diff_hunk":"@@ -96,11 +97,31 @@ public boolean testMailboxExists(String username, String mailboxName) throws Mai\n             mailboxSession);\n     }\n \n-    public void deleteMailbox(String username, String mailboxName) throws MailboxException, UsersRepositoryException {\n+    public void deleteMailbox(String username, String mailboxName) throws MailboxException, UsersRepositoryException, MailboxHaveChildrenException {\n         usernamePreconditions(username);\n         Preconditions.checkArgument(!Strings.isNullOrEmpty(mailboxName));\n         MailboxSession mailboxSession = mailboxManager.createSystemSession(USER_NAME, LOGGER);\n-        deleteMailbox(mailboxSession, convertToMailboxPath(username, mailboxName, mailboxSession));\n+        MailboxPath mailboxPath = convertToMailboxPath(username, mailboxName, mailboxSession);\n+        try {\n+            if (!haveChildren(mailboxPath, mailboxSession)) {\n+                deleteMailbox(mailboxSession, mailboxPath);\n+            } else {\n+                throw new MailboxHaveChildrenException(mailboxName);\n+            }\n+        } catch (MailboxNotFoundException e) {\n+            LOGGER.info(\"Attempt to delete mailbox {} for user {} that does not exists\", mailboxPath.getName(), mailboxPath.getUser());\n+        }\n+    }\n+\n+    private boolean haveChildren(MailboxPath mailboxPath, MailboxSession mailboxSession) throws MailboxException {\n+        return mailboxManager.search(\n+            MailboxQuery.builder()\n+                .base(mailboxPath)\n+                .build(), mailboxSession)\n+            .stream()\n+            .findAny()","path":"server/protocols/webadmin/src/main/java/org/apache/james/webadmin/service/UserMailboxesService.java","position":122,"original_position":36,"commit_id":"f357d87f48142e1e0366d19812f7817caaa74a71","original_commit_id":"f357d87f48142e1e0366d19812f7817caaa74a71","user":{"login":"aduprat","id":2900528,"avatar_url":"https://avatars.githubusercontent.com/u/2900528?v=3","gravatar_id":"","url":"https://api.github.com/users/aduprat","html_url":"https://github.com/aduprat","followers_url":"https://api.github.com/users/aduprat/followers","following_url":"https://api.github.com/users/aduprat/following{/other_user}","gists_url":"https://api.github.com/users/aduprat/gists{/gist_id}","starred_url":"https://api.github.com/users/aduprat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aduprat/subscriptions","organizations_url":"https://api.github.com/users/aduprat/orgs","repos_url":"https://api.github.com/users/aduprat/repos","events_url":"https://api.github.com/users/aduprat/events{/privacy}","received_events_url":"https://api.github.com/users/aduprat/received_events","type":"User","site_admin":false},"body":"Why not filter?","created_at":"2016-06-22T11:17:43Z","updated_at":"2016-06-22T11:17:43Z","html_url":"https://github.com/linagora/james-project/pull/289#discussion_r68035442","pull_request_url":"https://api.github.com/repos/linagora/james-project/pulls/289","_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments/68035442"},"html":{"href":"https://github.com/linagora/james-project/pull/289#discussion_r68035442"},"pull_request":{"href":"https://api.github.com/repos/linagora/james-project/pulls/289"}}},"pull_request":{"url":"https://api.github.com/repos/linagora/james-project/pulls/289","id":74746733,"html_url":"https://github.com/linagora/james-project/pull/289","diff_url":"https://github.com/linagora/james-project/pull/289.diff","patch_url":"https://github.com/linagora/james-project/pull/289.patch","issue_url":"https://api.github.com/repos/linagora/james-project/issues/289","number":289,"state":"open","locked":false,"title":"James 1759 : Add support for CRUD operations on mailboxes","user":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"body":"In the Gatling test, I need to provision mailboxes for the users.","created_at":"2016-06-22T08:58:08Z","updated_at":"2016-06-22T11:17:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"90b71d9d3cfffe80f17470c5f159f6a63a0abdcf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linagora/james-project/pulls/289/commits","review_comments_url":"https://api.github.com/repos/linagora/james-project/pulls/289/comments","review_comment_url":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linagora/james-project/issues/289/comments","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/f357d87f48142e1e0366d19812f7817caaa74a71","head":{"label":"chibenwa:JAMES-1759-1","ref":"JAMES-1759-1","sha":"f357d87f48142e1e0366d19812f7817caaa74a71","user":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"repo":{"id":42459504,"name":"james-project","full_name":"chibenwa/james-project","owner":{"login":"chibenwa","id":6928740,"avatar_url":"https://avatars.githubusercontent.com/u/6928740?v=3","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chibenwa/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/chibenwa/james-project","forks_url":"https://api.github.com/repos/chibenwa/james-project/forks","keys_url":"https://api.github.com/repos/chibenwa/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chibenwa/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chibenwa/james-project/teams","hooks_url":"https://api.github.com/repos/chibenwa/james-project/hooks","issue_events_url":"https://api.github.com/repos/chibenwa/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/chibenwa/james-project/events","assignees_url":"https://api.github.com/repos/chibenwa/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/chibenwa/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/chibenwa/james-project/tags","blobs_url":"https://api.github.com/repos/chibenwa/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chibenwa/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chibenwa/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/chibenwa/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chibenwa/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/chibenwa/james-project/languages","stargazers_url":"https://api.github.com/repos/chibenwa/james-project/stargazers","contributors_url":"https://api.github.com/repos/chibenwa/james-project/contributors","subscribers_url":"https://api.github.com/repos/chibenwa/james-project/subscribers","subscription_url":"https://api.github.com/repos/chibenwa/james-project/subscription","commits_url":"https://api.github.com/repos/chibenwa/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/chibenwa/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/chibenwa/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/chibenwa/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/chibenwa/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/chibenwa/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chibenwa/james-project/merges","archive_url":"https://api.github.com/repos/chibenwa/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chibenwa/james-project/downloads","issues_url":"https://api.github.com/repos/chibenwa/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/chibenwa/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/chibenwa/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/chibenwa/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chibenwa/james-project/labels{/name}","releases_url":"https://api.github.com/repos/chibenwa/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/chibenwa/james-project/deployments","created_at":"2015-09-14T15:57:25Z","updated_at":"2016-01-24T14:16:15Z","pushed_at":"2016-06-22T11:14:31Z","git_url":"git://github.com/chibenwa/james-project.git","ssh_url":"git@github.com:chibenwa/james-project.git","clone_url":"https://github.com/chibenwa/james-project.git","svn_url":"https://github.com/chibenwa/james-project","homepage":null,"size":12523,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"linagora:master","ref":"master","sha":"4097e0933123e238263e2db2fb9f6c9fd96d4ae4","user":{"login":"linagora","id":1230365,"avatar_url":"https://avatars.githubusercontent.com/u/1230365?v=3","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"repo":{"id":39182136,"name":"james-project","full_name":"linagora/james-project","owner":{"login":"linagora","id":1230365,"avatar_url":"https://avatars.githubusercontent.com/u/1230365?v=3","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linagora/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/linagora/james-project","forks_url":"https://api.github.com/repos/linagora/james-project/forks","keys_url":"https://api.github.com/repos/linagora/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linagora/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linagora/james-project/teams","hooks_url":"https://api.github.com/repos/linagora/james-project/hooks","issue_events_url":"https://api.github.com/repos/linagora/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/linagora/james-project/events","assignees_url":"https://api.github.com/repos/linagora/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/linagora/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/linagora/james-project/tags","blobs_url":"https://api.github.com/repos/linagora/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linagora/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linagora/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/linagora/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/linagora/james-project/languages","stargazers_url":"https://api.github.com/repos/linagora/james-project/stargazers","contributors_url":"https://api.github.com/repos/linagora/james-project/contributors","subscribers_url":"https://api.github.com/repos/linagora/james-project/subscribers","subscription_url":"https://api.github.com/repos/linagora/james-project/subscription","commits_url":"https://api.github.com/repos/linagora/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/linagora/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/linagora/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/linagora/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/linagora/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/linagora/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linagora/james-project/merges","archive_url":"https://api.github.com/repos/linagora/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linagora/james-project/downloads","issues_url":"https://api.github.com/repos/linagora/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/linagora/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/linagora/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/linagora/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linagora/james-project/labels{/name}","releases_url":"https://api.github.com/repos/linagora/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/linagora/james-project/deployments","created_at":"2015-07-16T07:04:59Z","updated_at":"2016-05-24T08:51:49Z","pushed_at":"2016-06-22T11:14:32Z","git_url":"git://github.com/linagora/james-project.git","ssh_url":"git@github.com:linagora/james-project.git","clone_url":"https://github.com/linagora/james-project.git","svn_url":"https://github.com/linagora/james-project","homepage":null,"size":14446,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":9,"forks":8,"open_issues":9,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/289"},"html":{"href":"https://github.com/linagora/james-project/pull/289"},"issue":{"href":"https://api.github.com/repos/linagora/james-project/issues/289"},"comments":{"href":"https://api.github.com/repos/linagora/james-project/issues/289/comments"},"review_comments":{"href":"https://api.github.com/repos/linagora/james-project/pulls/289/comments"},"review_comment":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linagora/james-project/pulls/289/commits"},"statuses":{"href":"https://api.github.com/repos/linagora/james-project/statuses/f357d87f48142e1e0366d19812f7817caaa74a71"}}}}
{"actor":{"display_login":"aduprat"}}