Skip To Content ArcGIS for Developers Sign In Dashboard

PortalUser Class

(Esri::ArcGISRuntime::PortalUser)

A registered user of a portal or organization. More...

Header: #include <PortalUser>
Since: Esri::ArcGISRuntime 100.0
Inherits: Object, Loadable, and JsonSerializable

Public Functions

PortalUser(Portal *portal, const QString &username, QObject *parent = nullptr)
~PortalUser()
PortalAccess access() const
void addPortalItemWithJson(PortalItem *portalItem, const QString &json, const PortalFolder &toFolder = PortalFolder())
void addPortalItemWithUrl(PortalItem *portalItem, const QUrl &fromUrl, const QString &fileName = QString(), const PortalFolder &toFolder = PortalFolder())
void addToFavorites(PortalItem *portalItem)
void createFolder(const QString &title)
QDateTime created() const
void deleteFolder(const PortalFolder &folder)
void deletePortalItem(PortalItem *portalItem)
QString email() const
QString favoritesGroupId() const
void fetchContent()
void fetchContentInFolder(const QString &folderId)
void fetchFavoritesStatus(PortalItem *portalItem)
PortalFolderListModel *folders() const
QString fullName() const
PortalGroupListModel *groups() const
PortalItemListModel *items() const
QDateTime modified() const
void movePortalItem(PortalItem *portalItem, const PortalFolder &toFolder = PortalFolder())
void movePortalItems(const QList<PortalItem *> &portalItems, const PortalFolder &toFolder = PortalFolder())
QString organizationId() const
QString phone() const
Portal *portal() const
PortalPrivilegeListModel *privileges() const
void removeFromFavorites(PortalItem *portalItem)
PortalUserRole role() const
QStringList tags() const
QUrl thumbnailUrl() const
UnitSystem units() const
QString userDescription() const
QString username() const

Reimplemented Public Functions

virtual void cancelLoad()
virtual void load()
virtual Error loadError() const
virtual LoadStatus loadStatus() const
virtual void retryLoad()
virtual QString toJson() const
virtual QJsonObject unknownJson() const
virtual QJsonObject unsupportedJson() const

Signals

void addPortalItemCompleted(bool success)
void addToFavoritesCompleted(bool success)
void createFolderCompleted(bool success, Esri::ArcGISRuntime::PortalFolder folder)
void deleteFolderCompleted(bool success)
void deletePortalItemCompleted(bool success)
void doneLoading(Esri::ArcGISRuntime::Error loadError)
void fetchContentCompleted(bool success)
void fetchFavoritesStatusCompleted(bool status)
void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)
void movePortalItemCompleted(bool success)
void movePortalItemsCompleted(QList<Esri::ArcGISRuntime::PortalResult> results)
void removeFromFavoritesCompleted(bool success)

Static Public Members

PortalUser *fromJson(const QString &json, Portal *portal = nullptr, QObject *parent = nullptr)
  • 10 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 9 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

A registered user of a portal or organization.

A Portal may have users who are unaffiliated with an organization or users who are part of an organization. Users sign in to the portal and create and share content which is organized into items (PortalItem). Users can create and join groups (PortalGroup) and share items with groups. This makes the items visible and accessible to other members of the group. Users could be in different roles including administrators, publishers and information workers. Administrators can add users to their organizations and have access to all content within the organization. All users can create web maps based on mashing up services that they have access to and can register services running on external servers. Publishers within an organization can in addition create hosted services based on data files that they upload.

Member Function Documentation

PortalUser::PortalUser(Portal *portal, const QString &username, QObject *parent = nullptr)

Constructs a user for the given portal.

portal: The Portal for the user to access. username: The registered name of the user. parent (optional).

PortalUser::~PortalUser()

Destructor.

PortalAccess PortalUser::access() const

Returns the visibility of a user's information.

If set to PortalAccess.Private, the user's descriptive information will not be available to others nor will the username be searchable. The organization's administrator can always see all users.

[signal] void PortalUser::addPortalItemCompleted(bool success)

Signal emitted when an add operation is completed. success is true when the operation succeeded.

This function was introduced in Esri::ArcGISRuntime 100.1.

void PortalUser::addPortalItemWithJson(PortalItem *portalItem, const QString &json, const PortalFolder &toFolder = PortalFolder())

Adds a PortalItem from a JSON object.

The portalItem will be created using the following arguments:

  • portalItem. The local PortalItem which will be added to the portal.
  • json. The JSON representation of the portal item. This format is particularly suitable for adding items such as web maps and is the format used by the Map::saveAs method.
  • toFolder (optional). The folder in which the item will be located. If empty, the item will be placed in the user's root folder.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also Items and item types.

void PortalUser::addPortalItemWithUrl(PortalItem *portalItem, const QUrl &fromUrl, const QString &fileName = QString(), const PortalFolder &toFolder = PortalFolder())

Adds a PortalItem from a local or online URL.

The PortalItem will be created using the following arguments:

  • portalItem. The local PortalItem which will be added to the portal.
  • fromUrl. The local or online URL from which the portalItem will be populated. For local files, this should be of the form "qrc:/example.csv" or "file://"; for online resources this should be of the form "https://...".
  • fileName (optional). The name of the file which will be associated with the PortalItem (including extension). If a file name is not supplied, the portal item will have no file associated with it for future downloads.

    Note: A file name is only relevant for certain item types such as PortalItemType.Image.

  • toFolder (optional). The folder in whih the item will be located. If empty, the item will be placed in the user's root folder.

Example:

Add an item with a local URL:

QUrl localCSV("qrc:/Samples/CloudAndPortal/AddItemsToPortal/add_item_sample.csv");
m_user->addPortalItemWithUrl(m_item, localCSV, "add_item_sample.csv" );

Load the item once it has been successfully loaded

connect(m_user, &PortalUser::addPortalItemCompleted, this, [this](bool success)
{
  m_busy = false;

  if (!success)
    return;

  setStatusText("Successfully added item.");
  m_item->load();
});

This function was introduced in Esri::ArcGISRuntime 100.1.

See also Items and item types.

void PortalUser::addToFavorites(PortalItem *portalItem)

Adds the PortalItem portalItem to the user's favorites group.

[signal] void PortalUser::addToFavoritesCompleted(bool success)

Signal emitted when a addToFavorites operation is completed.

The parameter success is true when the operation succeeded, otherwise false.

[virtual] void PortalUser::cancelLoad()

Reimplemented from Loadable::cancelLoad().

See Loadable.

void PortalUser::createFolder(const QString &title)

Creates a new PortalFolder with the given title in the user's root folder.

Multilevel folders are not supported in a portal.

[signal] void PortalUser::createFolderCompleted(bool success, Esri::ArcGISRuntime::PortalFolder folder)

Signal emitted when a createFolder operation is completed.

  • success - Whether fetching content completed successfully.
  • folder - The newly created PortalFolder.

This function was introduced in Esri::ArcGISRuntime 100.1.

QDateTime PortalUser::created() const

Returns the date and time the user was created.

void PortalUser::deleteFolder(const PortalFolder &folder)

Removes the specified folder from the portal.

[signal] void PortalUser::deleteFolderCompleted(bool success)

Signal emitted when a deleteFolder operation is completed. success is true when the operation succeeded.

void PortalUser::deletePortalItem(PortalItem *portalItem)

Removes the PortalItem portalItem from the portal.

[signal] void PortalUser::deletePortalItemCompleted(bool success)

Signal emitted when a delete item operation is completed. success is true when the operation succeeded.

[signal] void PortalUser::doneLoading(Esri::ArcGISRuntime::Error loadError)

Signal emitted when this object is done loading.

  • loadError - Details about any error that may have occurred.

See also Loadable and Object.

QString PortalUser::email() const

Returns the user's email address.

QString PortalUser::favoritesGroupId() const

The ID of the group that contains the user's favorites.

void PortalUser::fetchContent()

Starts an operation that fetches the user's content at the root level (not in a folder).

The content is made up of lists of PortalItem and PortalFolder objects.

Example:

Retrieve the model representing a user's folders:

// fetch the portal user's folders
QMap<QString, QString> folderTitles; // folderId and folderTitle

connect(&portalUser, &PortalUser::fetchContentCompleted, this, [&portalUser, &folderTitles](bool success)
{
  if(!success)
    return;

  PortalFolderListModel* folders = portalUser.folders();
  Q_CHECK_PTR(folders);

  for (int i = 0; i < folders->size(); ++i)
  {
    PortalFolder folder = folders->at(i);
    folderTitles[folder.folderId()] = folder.title();
    qDebug() << folder.title();
  }
});

portalUser.fetchContent();

[signal] void PortalUser::fetchContentCompleted(bool success)

Signal emitted when the fetchContent or fetchContentInFolder operations are completed.

  • success - Whether fetching content completed successfully.

This function was introduced in Esri::ArcGISRuntime 100.1.

void PortalUser::fetchContentInFolder(const QString &folderId)

Starts an operation that fetches the user's content within a specific folder (folderId).

The content is made up of lists of PortalItem objects.

void PortalUser::fetchFavoritesStatus(PortalItem *portalItem)

Starts an operation to determine whether PortalItem portalItem is in the user's favorites group.

The fetchFavoritesStatusCompleted is emitted when the operation is complete.

[signal] void PortalUser::fetchFavoritesStatusCompleted(bool status)

Signal emitted when a removeFromFavorites operation is completed. status is true when the operation succeeded.

PortalFolderListModel *PortalUser::folders() const

Returns a list of PortalFolder objects for the user's content.

The folders are retrieved by calling fetchContent and the signal fetchContentCompleted is emitted when complete.

[static] PortalUser *PortalUser::fromJson(const QString &json, Portal *portal = nullptr, QObject *parent = nullptr)

Creates a new PortalUser from JSON with an optional Portal and parent.

The PortalUser will be created using the following arguments:

  • json. The JSON representation of the portal user.
  • portal (optional). A Portal object for use by the PortalUser.
  • parent (optional). A QObject object used as parent.

To fetch data from an online portal, the JSON must contains the "username" parameter, and portal must be valid.

const QString json = QStringLiteral(" { \"username\": \"my_username\" }");
PortalUser* portalUser = PortalUser::fromJson(json, portal, parent);

This function was introduced in Esri::ArcGISRuntime 100.1.

See also JsonSerializable.

QString PortalUser::fullName() const

Returns the user's full name.

PortalGroupListModel *PortalUser::groups() const

Returns the list of groups for the portal user.

See also PortalGroup.

PortalItemListModel *PortalUser::items() const

Returns a list of PortalItem objects for which the user has access.

The items are retrieved by calling fetchContent or fetchContentInFolder and the signal fetchContentCompleted is emitted when complete.

[virtual] void PortalUser::load()

Reimplemented from Loadable::load().

See Loadable.

[virtual] Error PortalUser::loadError() const

Reimplemented from Loadable::loadError().

See Loadable.

[virtual] LoadStatus PortalUser::loadStatus() const

Reimplemented from Loadable::loadStatus().

See Loadable.

[signal] void PortalUser::loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

Signal emitted when the loadStatus changes for this object.

See also Loadable.

QDateTime PortalUser::modified() const

Returns the date and time the user was last modified.

void PortalUser::movePortalItem(PortalItem *portalItem, const PortalFolder &toFolder = PortalFolder())

Moves a PortalItem.

Move item portalItem to the folder specified by toFolder. Leaving toFolder empty will move the item to the user's root folder.

[signal] void PortalUser::movePortalItemCompleted(bool success)

Signal emitted when a move item operation is completed. success is true when the operation succeeded.

void PortalUser::movePortalItems(const QList<PortalItem *> &portalItems, const PortalFolder &toFolder = PortalFolder())

Moves multiple PortalItems.

Move the items listed in portalItems to the folder specified by toFolder. Leaving toFolder empty will move the items to the user's root folder.

This function was introduced in Esri::ArcGISRuntime 100.1.

[signal] void PortalUser::movePortalItemsCompleted(QList<Esri::ArcGISRuntime::PortalResult> results)

Signal emitted when a movePortalItems operation is completed. The list of results indicates the status for individual items.

QString PortalUser::organizationId() const

Returns the ID of the organization the user belongs to (if any).

QString PortalUser::phone() const

Returns the user's phone number.

Portal *PortalUser::portal() const

Returns the portal that the user belongs to.

PortalPrivilegeListModel *PortalUser::privileges() const

A list of the privileges possessed by this user.

See also PortalPrivilege.

void PortalUser::removeFromFavorites(PortalItem *portalItem)

Removes the PortalItem portalItem from the user's favorites group.

[signal] void PortalUser::removeFromFavoritesCompleted(bool success)

Signal emitted when a removeFromFavorites operation is completed.

The parameter success is true when the operation succeeded, otherwise false.

[virtual] void PortalUser::retryLoad()

Reimplemented from Loadable::retryLoad().

See Loadable.

PortalUserRole PortalUser::role() const

Returns the user's role in the organization.

QStringList PortalUser::tags() const

Returns a list of user-defined tags that describe the user.

QUrl PortalUser::thumbnailUrl() const

Returns a URL to the user's thumbnail.

[virtual] QString PortalUser::toJson() const

Reimplemented from JsonSerializable::toJson().

Returns the JSON representation of this object.

See also JsonSerializable.

UnitSystem PortalUser::units() const

Returns the user's preferred units.

[virtual] QJsonObject PortalUser::unknownJson() const

Reimplemented from JsonSerializable::unknownJson().

Returns the unknown JSON of this object.

See also JsonSerializable.

[virtual] QJsonObject PortalUser::unsupportedJson() const

Reimplemented from JsonSerializable::unsupportedJson().

Returns the unsupported JSON of this object.

See also JsonSerializable.

QString PortalUser::userDescription() const

Returns the user's description.

QString PortalUser::username() const

Returns the user's username.


Feedback on this topic?