Skip To Content ArcGIS for Developers Sign In Dashboard

Portal Class

(Esri::ArcGISRuntime::Portal)

Represents a view into a portal by a user, either anonymous or with a Credential. More...

Header: #include <Portal>
Since: Esri::ArcGISRuntime 100.0
Inherits: Object, Loadable, and RemoteResource

Public Functions

Portal(QObject *parent = nullptr)
Portal(bool loginRequired, QObject *parent = nullptr)
Portal(const QUrl &url, QObject *parent = nullptr)
Portal(const QUrl &url, bool loginRequired, QObject *parent = nullptr)
Portal(Credential *credential, QObject *parent = nullptr)
Portal(const QUrl &url, Credential *credential, QObject *parent = nullptr)
~Portal()
BasemapListModel *basemaps() const
PortalGroupListModel *featuredGroups() const
PortalItemListModel *featuredItems() const
void fetchBasemaps()
void fetchFeaturedGroups()
void fetchFeaturedItems()
void fetchHomepageFeaturedContent()
void findGroups(const PortalQueryParametersForGroups &queryParameters)
void findItems(const PortalQueryParametersForItems &queryParameters)
PortalItemListModel *homepageFeaturedContent() const
bool isLoginRequired() const
PortalInfo *portalInfo() const
PortalUser *portalUser() const
void setCredential(Credential *credential)

Reimplemented Public Functions

virtual void cancelLoad()
virtual Credential *credential() const
virtual void load()
virtual Error loadError() const
virtual LoadStatus loadStatus() const
virtual RequestConfiguration requestConfiguration() const
virtual void retryLoad()
virtual void setRequestConfiguration(const RequestConfiguration &requestConfiguration)
virtual QUrl url() const

Signals

void basemapsChanged()
void doneLoading(Esri::ArcGISRuntime::Error error)
void featuredGroupsChanged()
void featuredItemsChanged()
void findGroupsCompleted(Esri::ArcGISRuntime::PortalQueryResultSetForGroups *result)
void findItemsCompleted(Esri::ArcGISRuntime::PortalQueryResultSetForItems *result)
void homepageFeaturedContentChanged()
void loadStatusChanged(Esri::ArcGISRuntime::LoadStatus loadStatus)

Additional Inherited Members

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

Detailed Description

Represents a view into a portal by a user, either anonymous or with a Credential.

The Portal class is the main entry point into the API used to work with portals and organization subscriptions. It implements all the operations to interface with the backend ArcGIS REST API. Use Portal to search for items and groups and see the contents of the portal, such as services, layers, and so on.

Portals allow users and organizations to publish and share content over the web. A portal can support subscriptions which provides organizations a sandboxed area on the portal. The website www.arcgis.com (ArcGIS Online) is an example of a portal.

Load the portal by calling load before using it.

This class is not a singleton and returns a new Portal object whenever the constructor is called.

Organizations

A Portal may contain multiple organizations. An organization has users in different roles including administrators, publishers, and other users.

  • Administrators can add users to their organization subscriptions and have access to all content within the organization.
  • Publishers within an organization can in addition create hosted services based on data files that they upload.
  • All users can create web maps based on mashing up services that they have access to and can register services running on external servers.

Content

Users create and share content that organized into Items. A Portal can contain different types of content items including:

  • Web maps
  • Map services (that can be used as layers in web maps)
  • Applications (that are built around web maps)
  • Data files (that can be uploaded and downloaded)

Users can choose to keep the content they create private, or share it with other members of the same group, or make content public and accessible to everyone.

Users and Groups

A user of the Portal sees the view of the Portal that corresponds to their organization's subscription. This view includes users, groups, and items that belong to the organization or have been shared with them. This view may also include users, groups, and items that are external to the user's organization and have been shared with the user. A Portal can have users who are affiliated with an organization or users who are not.

Users can create and join groups.

Portal Constructors

Constructors are available that take some combination of these parameters.

  • url - The URL of the portal to access. If not present, this defaults to {https://www.arcgis.com/}{www.arcgis.com} (ArcGIS Online).
  • loginRequired - Determines whether the user is asked to log in (optional).
    • Set to false if you intend to access the portal anonymously or true if you want to use a credential.
    • If set to true, an authentication challenge will be issued.
    • If set to false, the portal will be accessed anonymously. If the portal does not permit anonymous access, an authentication challenge will be issued.

    When the credential property is set, the credential will be used regardless of the value of the loginRequired parameter.

  • credential - The credential to use when accessing the portal (optional).
  • parent - The parent QObject (optional).

Example: Create a portal anonymously:

Portal* portalAnon = new Portal(QUrl("http://www.arcgis.com"), parent);

Example: Create and load a portal with a credential:

Credential* ucPortal = new Credential(myUserName, myPassword, parent);
Portal* myPortal = new Portal(QUrl(myPortalUrl), ucPortal, parent);
connect(myPortal, &Portal::doneLoading, this, [](Esri::ArcGISRuntime::Error loadError)
{
  if (!loadError.isEmpty())
    qDebug() << loadError.message();
});
myPortal->load();

See also PortalUser and PortalGroup.

Member Function Documentation

Portal::Portal(QObject *parent = nullptr)

Default constructor with optional parent object.

Portal::Portal(bool loginRequired, QObject *parent = nullptr)

Constructor that accepts the parameters loginRequired and parent.

Portal::Portal(const QUrl &url, QObject *parent = nullptr)

Constructor that accepts the parameters url and parent.

Portal::Portal(const QUrl &url, bool loginRequired, QObject *parent = nullptr)

Constructor that accepts the parameters url, loginRequired, and parent.

Portal::Portal(Credential *credential, QObject *parent = nullptr)

Constructor that accepts the parameters credential and parent.

Portal::Portal(const QUrl &url, Credential *credential, QObject *parent = nullptr)

Constructor that accepts the parameters url, credential and parent.

Portal::~Portal()

Destructor.

BasemapListModel *Portal::basemaps() const

Returns the list of portal basemaps.

See also Basemap.

[signal] void Portal::basemapsChanged()

Signal emitted when the fetchBasemaps task is completed.

See also Basemap.

[virtual] void Portal::cancelLoad()

Reimplemented from Loadable::cancelLoad().

See Loadable.

[virtual] Credential *Portal::credential() const

Reimplemented from RemoteResource::credential().

Returns the Credential for this portal.

This is the security credential to access the remote resource. Only applies if the resource is secured.

Returns nullptr if no credential has been set.

See also setCredential().

[signal] void Portal::doneLoading(Esri::ArcGISRuntime::Error error)

Signal emitted when this object is done loading.

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

See also Loadable and Object.

PortalGroupListModel *Portal::featuredGroups() const

Returns the list of groups featured for the portal.

See also PortalGroup.

[signal] void Portal::featuredGroupsChanged()

Signal emitted when the fetchFeaturedGroups task is completed.

See also PortalGroup.

PortalItemListModel *Portal::featuredItems() const

Returns the list of items featured for the portal.

See also PortalItem.

[signal] void Portal::featuredItemsChanged()

Signal emitted when the fetchFeaturedItems task is completed.

See also PortalItem.

void Portal::fetchBasemaps()

Retrieves the set of basemaps available from the portal.

After the basemaps have been retrieved, the results are available via the basemaps method.

Example:

Fetch the basemaps for a portal:

int basemapsCount = 0;
connect(portal, &Portal::basemapsChanged, this, [portal, &basemapsCount]()
{
  if (portal && portal->basemaps())
    basemapsCount = portal->basemaps()->rowCount();
});

portal->fetchBasemaps();

See also Basemap.

void Portal::fetchFeaturedGroups()

Retrieves the set of featured groups available from the portal.

After the groups have been retrieved, the results are available via the featuredGroups method.

See also PortalGroup.

void Portal::fetchFeaturedItems()

Retrieves the set of featured items available from the portal.

After the items have been retrieved, the results are available via the featuredItems method.

See also PortalItem.

void Portal::fetchHomepageFeaturedContent()

Retrieves the set of items featured on the homepage of the portal.

After the content has been retrieved, the results are available via the homepageFeaturedContent method.

See also PortalItem.

void Portal::findGroups(const PortalQueryParametersForGroups &queryParameters)

Performs a query to fetch groups matching specified criteria.

  • queryParameters - Definition of the query to be executed.

After the query has completed, the results are returned via the findGroupsCompleted signal. If the task is unsuccesful, an error is emitted.

Example:

Use findGroups to retrieve all of the groups for a portal:

// example query to return all groups
QString groupsQuery = "1==1";
PortalQueryParametersForGroups findGroupsQueryParameters(groupsQuery);
portal->findGroups(findGroupsQueryParameters);

int numberOfGroups = 0;
connect(portal, &Portal::findGroupsCompleted, this, [&numberOfGroups](PortalQueryResultSetForGroups* results)
{
  if (results)
    numberOfGroups = results->totalResults();
});

See also PortalQueryParametersForGroups.

[signal] void Portal::findGroupsCompleted(Esri::ArcGISRuntime::PortalQueryResultSetForGroups *result)

Signal emitted when the findGroups task is completed. The signal includes the result.

The returned PortalQueryResultSetForGroups object has the Portal as its parent.

See also Returned QObjects Parenting and PortalQueryResultSetForGroups.

void Portal::findItems(const PortalQueryParametersForItems &queryParameters)

Performs a query to fetch items matching specified criteria.

  • queryParameters - Definition of the query to be executed.

After the query is complete, the results are returned via the findItemsCompleted signal. If the query task was unsuccessful, an error is emitted.

Example:

Use findItems to retrieve web maps with specific tags from a portal:

// webmaps authored prior to July 2nd, 2014 are not supported
// so search only from that date to the current time (in milliseconds)
QString fromDate = QString("000000%1").arg(QDateTime(QDate(2014, 7, 2)).toMSecsSinceEpoch());
QString toDate = QString("000000%1").arg(QDateTime::currentDateTime().toMSecsSinceEpoch());

PortalQueryParametersForItems query;
query.setSearchString(QString("tags:\"%1\" AND +uploaded:[%2 TO %3]")
                      .arg(keyword, fromDate, toDate));
query.setTypes(QList<PortalItemType>() << PortalItemType::WebMap);

m_portal->findItems(query);
connect(m_portal, &Portal::findItemsCompleted, this, [this](PortalQueryResultSetForItems *webmapResults)
{
  m_webmapResults = webmapResults;
  m_webmaps = m_webmapResults->itemResults();
  emit webmapsChanged();
  emit hasMoreResultsChanged();
});

See also PortalQueryParametersForItems.

[signal] void Portal::findItemsCompleted(Esri::ArcGISRuntime::PortalQueryResultSetForItems *result)

Signal emitted when the findItems task is completed. The signal include the result.

The returned PortalQueryResultSetForItems object has the Portal as its parent.

See also Returned QObjects Parenting and PortalQueryResultSetForGroups.

PortalItemListModel *Portal::homepageFeaturedContent() const

Returns the list of items featured on the homepage of the portal.

See also PortalItem.

[signal] void Portal::homepageFeaturedContentChanged()

Signal emitted when the fetchHomepageFeaturedContent task is completed.

See also PortalItem.

bool Portal::isLoginRequired() const

Returns whether you may access the portal anonymously or use a Credential.

[virtual] void Portal::load()

Reimplemented from Loadable::load().

See Loadable.

[virtual] Error Portal::loadError() const

Reimplemented from Loadable::loadError().

See Loadable.

[virtual] LoadStatus Portal::loadStatus() const

Reimplemented from Loadable::loadStatus().

See Loadable.

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

Signal emitted when the loadStatus changes for this object.

See also Loadable.

PortalInfo *Portal::portalInfo() const

Returns information about the portal, upon successful initialization of the portal.

A PortalInfo object represents details of the portal/organization as seen by the current user, anonymous or logged in. If the current user is a member of an organization on this portal, information about the user and organization is included.

This property will be a nullptr until the portal is loaded.

PortalUser *Portal::portalUser() const

Returns the registered user of the portal.

This information is available after successful initialization of the portal with a credential and load completes.

[virtual] RequestConfiguration Portal::requestConfiguration() const

Reimplemented from RemoteResource::requestConfiguration().

Returns the RequestConfiguration in use by this Portal object.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also setRequestConfiguration().

[virtual] void Portal::retryLoad()

Reimplemented from Loadable::retryLoad().

See Loadable.

void Portal::setCredential(Credential *credential)

Sets the portal's Credential to credential.

The Credential is used when calling Portal::load().

See also credential().

[virtual] void Portal::setRequestConfiguration(const RequestConfiguration &requestConfiguration)

Reimplemented from RemoteResource::setRequestConfiguration().

Sets configuration parameters used for network requests sent by this Portal object to requestConfiguration.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also requestConfiguration().

[virtual] QUrl Portal::url() const

Reimplemented from RemoteResource::url().

Returns the URL of the portal. If no URL has been set, it defaults to https://www.arcgis.com (ArcGIS Online).


Feedback on this topic?