private void unregister(IQ request, JID actorJID, boolean isRemote) throws Exception {
    LOGGER.debug("Processing unregister request from " + request.getFrom());

    if (!validateSingleChildElement(request)) {
      failBadRequest(request);
      return;
    }
    if (!isRemote && !userRegistered(actorJID)) {
      failRegistrationRequired(request);
      return;
    }

    Transaction t = null;
    try {
      t = channelManager.beginTransaction();

      List<Packet> notifications = new LinkedList<Packet>();
      Set<String> remoteDomains = getRemoteDomains();

      ResultSet<NodeMembership> userMemberships = channelManager.getUserMemberships(actorJID);
      for (NodeMembership userMembership : userMemberships) {
        String nodeId = userMembership.getNodeId();
        if (isPersonal(nodeId) || isSingleOwner(nodeId, actorJID)) {
          channelManager.deleteNode(nodeId);
          if (Configuration.getInstance().isLocalNode(nodeId)) {
            addDeleteNodeNotifications(nodeId, notifications);
          }
        }
        if (!isRemote) {
          addUnsubscribeFromNodeNotifications(actorJID, userMembership.getNodeId(), notifications);
        }
      }

      ResultSet<NodeItem> userItems = channelManager.getUserPublishedItems(actorJID);
      for (NodeItem userItem : userItems) {
        if (Configuration.getInstance().isLocalNode(userItem.getNodeId())) {
          addDeleteItemNotifications(userItem.getNodeId(), userItem.getId(), notifications);
        }
      }

      channelManager.deleteUserItems(actorJID);
      channelManager.deleteUserSubscriptions(actorJID);
      channelManager.deleteUserAffiliations(actorJID);

      outQueue.put(IQ.createResultIQ(request));
      if (!isRemote) {
        makeRemoteRequests(request, remoteDomains);
      }
      sendNotifications(notifications);

      t.commit();
    } finally {
      if (t != null) {
        t.close();
      }
    }
  }
 private boolean isSingleOwner(String nodeId, JID userJid) throws NodeStoreException {
   ResultSet<NodeMembership> nodeMemberships = channelManager.getNodeMemberships(nodeId);
   int ownerCount = 0;
   boolean isOwner = false;
   for (NodeMembership nodeMembership : nodeMemberships) {
     if (nodeMembership.getAffiliation().equals(Affiliations.owner)) {
       ownerCount++;
       if (nodeMembership.getUser().equals(userJid)) {
         isOwner = true;
       }
     }
   }
   return isOwner && ownerCount == 1;
 }