public void delete(User userToDelete, User user, boolean respectFrontEndRoles) throws DotDataException, DotSecurityException {
if (userToDelete.getUserId() == null) {
throw new DotDataException("Can't delete a user without a userId");
}
if(!perAPI.doesUserHavePermission(upAPI.getUserProxy(userToDelete,APILocator.getUserAPI().getSystemUser(), false), PermissionAPI.PERMISSION_EDIT, user, respectFrontEndRoles)){
throw new DotSecurityException("User doesn't have permission to userToDelete the user which is trying to be saved");
}
RoleAPI roleAPI = APILocator.getRoleAPI();
roleAPI.removeAllRolesFromUser(userToDelete);
uf.delete(userToDelete);
}