/**
   * Returns the user group with the name.
   *
   * @param name the user group's name
   * @return Returns the user group with the name
   * @throws PortalException if a user group with the name could not be found or if the user did not
   *     have permission to view the user group
   * @throws SystemException if a system exception occurred
   */
  public static com.liferay.portal.model.UserGroupSoap getUserGroup(java.lang.String name)
      throws RemoteException {
    try {
      com.liferay.portal.model.UserGroup returnValue = UserGroupServiceUtil.getUserGroup(name);

      return com.liferay.portal.model.UserGroupSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
  /**
   * Returns all the user groups to which the user belongs.
   *
   * @param userId the primary key of the user
   * @return the user groups to which the user belongs
   * @throws PortalException if the current user did not have permission to view the user or any one
   *     of the user group members
   * @throws SystemException if a system exception occurred
   */
  public static com.liferay.portal.model.UserGroupSoap[] getUserUserGroups(long userId)
      throws RemoteException {
    try {
      java.util.List<com.liferay.portal.model.UserGroup> returnValue =
          UserGroupServiceUtil.getUserUserGroups(userId);

      return com.liferay.portal.model.UserGroupSoap.toSoapModels(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
  /**
   * Updates the user group.
   *
   * @param userGroupId the primary key of the user group
   * @param name the user group's name
   * @param description the the user group's description
   * @return the user group
   * @throws PortalException if a user group with the primary key was not found, if the new
   *     information was invalid, or if the user did not have permission to update the user group
   *     information
   * @throws SystemException if a system exception occurred
   * @deprecated As of 6.2.0, replaced by {@link #updateUserGroup(long, String, String,
   *     serviceContext)}
   */
  public static com.liferay.portal.model.UserGroupSoap updateUserGroup(
      long userGroupId, java.lang.String name, java.lang.String description)
      throws RemoteException {
    try {
      com.liferay.portal.model.UserGroup returnValue =
          UserGroupServiceUtil.updateUserGroup(userGroupId, name, description);

      return com.liferay.portal.model.UserGroupSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
  /**
   * Adds a user group.
   *
   * <p>This method handles the creation and bookkeeping of the user group, including its resources,
   * metadata, and internal data structures.
   *
   * @param name the user group's name
   * @param description the user group's description
   * @param serviceContext the service context to be applied (optionally <code>null</code>). Can set
   *     expando bridge attributes for the user group.
   * @return the user group
   * @throws PortalException if the user group's information was invalid or if the user did not have
   *     permission to add the user group
   * @throws SystemException if a system exception occurred
   */
  public static com.liferay.portal.model.UserGroupSoap addUserGroup(
      java.lang.String name,
      java.lang.String description,
      com.liferay.portal.service.ServiceContext serviceContext)
      throws RemoteException {
    try {
      com.liferay.portal.model.UserGroup returnValue =
          UserGroupServiceUtil.addUserGroup(name, description, serviceContext);

      return com.liferay.portal.model.UserGroupSoap.toSoapModel(returnValue);
    } catch (Exception e) {
      _log.error(e, e);

      throw new RemoteException(e.getMessage());
    }
  }
  /**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static UserGroup toModel(UserGroupSoap soapModel) {
    UserGroup model = new UserGroupImpl();

    model.setUserGroupId(soapModel.getUserGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setParentUserGroupId(soapModel.getParentUserGroupId());
    model.setName(soapModel.getName());
    model.setDescription(soapModel.getDescription());
    model.setAddedByLDAPImport(soapModel.getAddedByLDAPImport());

    return model;
  }
  /**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static UserGroup toModel(UserGroupSoap soapModel) {
    if (soapModel == null) {
      return null;
    }

    UserGroup model = new UserGroupImpl();

    model.setUuid(soapModel.getUuid());
    model.setUserGroupId(soapModel.getUserGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setParentUserGroupId(soapModel.getParentUserGroupId());
    model.setName(soapModel.getName());
    model.setDescription(soapModel.getDescription());
    model.setAddedByLDAPImport(soapModel.getAddedByLDAPImport());

    return model;
  }