Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-59110

SOAP API removeUser needs to be able to delete users with content as can be done through the UI

    • We collect Confluence feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      The REST API does not offer a way to delete users, however the SOAP API does = "removeUser". Currently, if a user has content associated to them, removeUser will fail. This functionality to delete a user if they have content is supported through the UI.

      The feature request is to fix the SOAP API removeUser so that it will allow users with content associated to them be deleted via API call.

      The problem exists in the implementation of SOAP API removeUser. 

      public boolean removeUser(String username) throws RemoteException {
          ConfluenceUser user = retrieveUser(username);
      
          ConfluenceUser currentUser = AuthenticatedUserThreadLocal.get();
          if (!permissionManager.hasPermission(currentUser, Permission.REMOVE, user))
              throw new NotPermittedException("You do not have permissions to remove the user " + username);
      
          if (userContentManager.hasAuthoredContent(user))
              throw new RemoteException("Cannot remove user because they have authored content");
      
          Space personalSpace = spaceManager.getPersonalSpace(user);
          if (personalSpace != null) {
              spaceManager.removeSpace(personalSpace);
              user = retrieveUser(username);
          }
      
          try {
              userAccessor.removeUser(user);
          } catch (InfrastructureException e) {
              return false;
          }
      
          return true;
      }
      

      UsersSoapService#removeUser invoke UserContentManager#hasAuthoredContent. Below is the code for DefaultUserContentManager. 

      @Override
      public boolean hasAuthoredContent(User user) {
          if (user == null)
              return false;
      
          return !(
                  getUserEditedSpaces(user).isEmpty() &&
                  getUserOwnedSpaces(user).isEmpty() &&
                  getUserCommentedSpaces(user).isEmpty());
      }
      

      Because of this the delete user operation fails due to authored content existing.

      This is further complicated by the fact that when creating a fresh new user, by default a draft entry (title null) will be created in Demo Space in Content table. 

      Verify here: 

      select * from SPACES where spaceid in (select SPACEID from content where creator = 'ff8080816dec764a016dec79d2180002');
      --------------------------------------------
      98305 Demonstration Space ds ds 65586 65557 2018-09-25 11:05:32.331000000 2019-10-21 14:57:43.695000000 global CURRENT98305 Demonstration Space ds ds 65586 65557 2018-09-25 11:05:32.331000000 2019-10-21 14:57:43.695000000 global CURRENT 
      

       ff8080816dec764a016dec79d2180002 is the newly created user that hasn't edited any content. This is a performance optimization, when dummy draft is created for new users just to warm up browser cache with editor resources but results in creating a condition where you can never delete a user via API because they will always have content associated with them.

            [CONFSERVER-59110] SOAP API removeUser needs to be able to delete users with content as can be done through the UI

            Hi All,

            Quick update on this one.

            The SOAP API has been deprecated in Confluence since Confluence 6. As a result, there will be no additional work on this functionality.

            We're currently implementing the expected functions in our REST API, so this should act as a replacement in this case.

            Thanks,
            James Ponting
            Engineering Manager - Confluence Data Center

            James Ponting added a comment - Hi All, Quick update on this one. The SOAP API has been deprecated in Confluence since Confluence 6. As a result, there will be no additional work on this functionality. We're currently implementing the expected functions in our REST API, so this should act as a replacement in this case. Thanks, James Ponting Engineering Manager - Confluence Data Center

              Unassigned Unassigned
              asmith4@atlassian.com Andrew S
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: