/**
   * Creates a group if it does not exists already.
   *
   * @param proxy The user management webservice.
   */
  private static void createGroups(final UserManagementPortTypeProxy proxy) {
    final AuthenticationToken token = Settings.getAuthToken();
    try {
      final Group group = proxy.getGroup(GROUP_NAME, token);
      if (group == null) {
        final Group newGroup = proxy.createGroup(GROUP_NAME, ROLES, token);
        LOG.info(
            "Group [name="
                + newGroup.getName()
                + ", roles="
                + Arrays.toString(newGroup.getRoles())
                + "] created.");
      } else {
        LOG.info(
            "Group [name="
                + group.getName()
                + ", roles="
                + Arrays.toString(group.getRoles())
                + "]"
                + " already exists.");
      }

    } catch (final RemoteException e) {
      LOG.error(null, e);
    }
  }
 /**
  * Creates a user if it does not exists already.
  *
  * @param proxy The user management webservice.
  */
 private static void createUser(final UserManagementPortTypeProxy proxy) {
   final AuthenticationToken token = Settings.getAuthToken();
   final User user;
   try {
     user = proxy.getUser(USER_NAME, token);
     if (user == null) {
       final User newUser =
           proxy.createUser(USER_NAME, PASSWORD, GROUP_NAMES, CHANNELS, ROLES, token);
       LOG.info(
           "User [name="
               + newUser.getName()
               + ", groups="
               + Arrays.toString(populateGroupsNames(newUser.getGroups()))
               + ", channels="
               + Arrays.toString(newUser.getChannels())
               + ", roles="
               + Arrays.toString(newUser.getRoles())
               + "] created.");
     } else {
       LOG.info(
           "User [name="
               + user.getName()
               + ", groups="
               + Arrays.toString(populateGroupsNames(user.getGroups()))
               + ", channels="
               + Arrays.toString(user.getChannels())
               + ", roles="
               + Arrays.toString(user.getRoles())
               + "] already exists.");
     }
   } catch (final RemoteException e) {
     LOG.error(null, e);
   }
 }
  /**
   * Deletes a group if possible.
   *
   * @param proxy The user management webservice.
   */
  private static void deleteGroup(final UserManagementPortTypeProxy proxy) {
    final AuthenticationToken token = Settings.getAuthToken();
    try {
      final Group group = proxy.getGroup(GROUP_NAME, token);
      if (group == null) {
        LOG.info("Group [name=" + GROUP_NAME + "] not deleted because it does not exist");
      } else {
        proxy.deleteGroup(GROUP_NAME, token);
        LOG.info(
            "Group [name="
                + group.getName()
                + ", roles="
                + Arrays.toString(group.getRoles())
                + ']'
                + " deleted.");
      }

    } catch (final RemoteException e) {
      LOG.error(null, e);
    }
  }
  /**
   * Deletes a user if possible.
   *
   * @param proxy The user management webservice.
   */
  private static void deleteUser(final UserManagementPortTypeProxy proxy) {
    final AuthenticationToken token = Settings.getAuthToken();
    try {
      final User user = proxy.getUser(USER_NAME, token);
      if (user == null) {
        LOG.info("User [name=" + USER_NAME + "] not deleted because it does not exist");
      } else {
        proxy.deleteUser(USER_NAME, token);
        LOG.info(
            "User [name="
                + user.getName()
                + ", groups="
                + Arrays.toString(populateGroupsNames(user.getGroups()))
                + ", channels="
                + Arrays.toString(user.getChannels())
                + ", roles="
                + Arrays.toString(user.getRoles())
                + "] deleted.");
      }

    } catch (final RemoteException e) {
      LOG.error(null, e);
    }
  }