public class

Portal

extends Object
java.lang.Object
   ↳ com.esri.core.portal.Portal

Class Overview

This class is used for connecting to an ArcGIS portal and searching for items, users, and groups. arcgis.com is an example of a portal. Using an instance of this class, a user (anonymous or with credentials) can see the contents of the portal, such as web map items, services, layers, and so on.

Using arcgis.com or another portal via a browser, a user can create content using maps that are public or services published by the user on a server instance. The user can share content with other users that are also members of the portal. That content can then be accessed using this API. For example content items of type WEBMAP, i.e. web maps, can be displayed in a Java or Android application.

Note: The API supports connecting to portals running ArcGIS Portal API Version 1.6.2 or higher.

Summary

Nested Classes
interface Portal.GetAuthCodeCallback This is a callback interface used by the Portal.doOAuthUserAuthenticate() methods to get the calling app to display a web page that asks the user to login. 
Fields
public static final String DEFAULT_CULTURE The default locale of the Portal, for example en-us.
Public Constructors
Portal(String url, UserCredentials credential)
Instantiates a Portal using the portal URL and user credentials (or null for anonymous access to a portal).
Public Methods
void doOAuthAppAuthenticate(String clientSecret, String clientId, CallbackListener<Portal> authorizedCallback)
Uses OAuth 2.0 to authenticate this Portal instance as an application with the given client secret and client ID.
void doOAuthDeviceAuthenticate(String clientId, CallbackListener<Portal> authorizedCallback)
Uses OAuth 2.0 to authenticate this Portal instance as an application with the given client ID.
void doOAuthUserAuthenticate(String clientSecret, String clientId, Portal.GetAuthCodeCallback authcodeCallback, CallbackListener<Portal> authorizedCallback)
Uses OAuth 2.0 to authenticate this Portal instance as a user with the given client ID and optionally the client secret.
void doOAuthUserAuthenticate(String clientSecret, String clientId, String redirectUri, Portal.GetAuthCodeCallback authcodeCallback, CallbackListener<Portal> authorizedCallback)
Uses OAuth 2.0 to authenticate this Portal instance as a user with the given client ID, redirect URI, and optionally the client secret.
PortalInfo fetchPortalInfo()
Fetches the portal information from the server.
InputStream fetchTxtFileContents()
Returns properties from arcgismobile.txt config file.
PortalUser fetchUser()
Fetches the PortalUser set on this portal object from the server.
String fetchVersion()
Fetches the version of the portal.
PortalQueryResultSet<PortalGroup> findGroups(PortalQueryParams queryParams)
Finds groups in this portal with a query using the specified portal query parameters.
PortalQueryResultSet<PortalItem> findItems(PortalQueryParams queryParams)
Finds items in this portal with a query using the specified portal query parameters.
String findSharingUrl()
Returns the portal's sharing URL, that is, the URL of the root REST resource for the portal; for example http://www.arcgis.com/sharing/rest for ArcGIS Online, or http://<host>:<port>/arcgis/sharing/rest for your own portal.
UserCredentials getCredentials()
Returns a copy of the user credentials set on this portal instance.
String getUrl()
Returns the portal's URL.
boolean isPreVersion162()
Returns true if the portal version is earlier than 1.6.2.
JsonParser postRequest(String requestURL)
Sends the customized request and lets the caller handle the response.
JsonParser sendRequest(String requestURL)
Sends the customized request and lets users handle the response.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final String DEFAULT_CULTURE

The default locale of the Portal, for example en-us.

Public Constructors

public Portal (String url, UserCredentials credential)

Instantiates a Portal using the portal URL and user credentials (or null for anonymous access to a portal).

Parameters
url String: the portal URL.
credential UserCredentials

Public Methods

public void doOAuthAppAuthenticate (String clientSecret, String clientId, CallbackListener<Portal> authorizedCallback)

Uses OAuth 2.0 to authenticate this Portal instance as an application with the given client secret and client ID. The authorizedCallback will be called when authentication is complete. This Portal instance will then be able to access secured content on the portal.

Parameters
clientSecret String: client secret for the application
clientId String: client ID for the application
authorizedCallback CallbackListener: called when authentication is complete
Throws
Exception if unable to submit the request

public void doOAuthDeviceAuthenticate (String clientId, CallbackListener<Portal> authorizedCallback)

Uses OAuth 2.0 to authenticate this Portal instance as an application with the given client ID. The authorizedCallback will be called when authentication is complete. This Portal instance will then be able to access secured content on the portal.

Parameters
clientId String: client ID
authorizedCallback CallbackListener: called when authentication is complete
Throws
Exception if unable to submit the request

public void doOAuthUserAuthenticate (String clientSecret, String clientId, Portal.GetAuthCodeCallback authcodeCallback, CallbackListener<Portal> authorizedCallback)

Uses OAuth 2.0 to authenticate this Portal instance as a user with the given client ID and optionally the client secret. The default redirect URI is used. The authcodeCallback parameter is a callback that will be passed the URL of a login page. It is up to the calling code to display this web page and return the resulting authorization code. The authorizedCallback will be called when authentication is complete. This Portal instance will then be able to access secured content on the portal.

Parameters
clientSecret String: the client secret obtained when registering an application; null if using only the clientId
clientId String: the client ID obtained when registering an application
authcodeCallback Portal.GetAuthCodeCallback: passes a URL to the calling code and expects an authorization code back
authorizedCallback CallbackListener: called when authentication is complete

public void doOAuthUserAuthenticate (String clientSecret, String clientId, String redirectUri, Portal.GetAuthCodeCallback authcodeCallback, CallbackListener<Portal> authorizedCallback)

Uses OAuth 2.0 to authenticate this Portal instance as a user with the given client ID, redirect URI, and optionally the client secret. The authcodeCallback parameter is a callback that will be passed the URL of a login page. It is up to the calling code to display this web page and return the resulting authorization code. The authorizedCallback will be called when authentication is complete. This Portal instance will then be able to access secured content on the portal.

Parameters
clientSecret String: client secret obtained when registering an application; null if using only the clientId
clientId String: client ID obtained when registering an application
redirectUri String: a custom redirect URI
authcodeCallback Portal.GetAuthCodeCallback: passes a URL to the calling code and expects an authorization code back
authorizedCallback CallbackListener: called when authentication is complete

public PortalInfo fetchPortalInfo ()

Fetches the portal information from the server. If the portal information is not yet known, this method will perform a network request on the current thread, so do not call it from the UI thread.

Returns
PortalInfo the portal information
Throws
Exception if unable to complete the request

public InputStream fetchTxtFileContents ()

Returns properties from arcgismobile.txt config file. Performs a network request on the current thread, so do not call this from the UI thread.

Returns
InputStream properties from arcgismobile.txt config file, or null if unavailable for any reason

public PortalUser fetchUser ()

Fetches the PortalUser set on this portal object from the server. If the PortalUser is not yet known, this method will perform a network request on the current thread, so do not call it from the UI thread.

Returns
PortalUser the PortalUser
Throws
Exception if unable to complete the request

public String fetchVersion ()

Fetches the version of the portal. If the version is not yet known, this method will perform a network request on the current thread, so do not call it from the UI thread.

Returns
String the version of the portal
Throws
Exception if unable to complete the request

public PortalQueryResultSet<PortalGroup> findGroups (PortalQueryParams queryParams)

Finds groups in this portal with a query using the specified portal query parameters. Performs a network request on the current thread, so do not call this from the UI thread.

Parameters
queryParams PortalQueryParams: parameters used to search the portal
Returns
PortalQueryResultSet<PortalGroup> the query results (portal groups)
Throws
Exception if unable to complete the request

public PortalQueryResultSet<PortalItem> findItems (PortalQueryParams queryParams)

Finds items in this portal with a query using the specified portal query parameters. Performs a network request on the current thread, so do not call this from the UI thread.

Parameters
queryParams PortalQueryParams: the parameters used to search the portal
Returns
PortalQueryResultSet<PortalItem> the query results (portal items)
Throws
Exception if unable to complete the request

public String findSharingUrl ()

Returns the portal's sharing URL, that is, the URL of the root REST resource for the portal; for example http://www.arcgis.com/sharing/rest for ArcGIS Online, or http://<host>:<port>/arcgis/sharing/rest for your own portal. If the sharing URL is not yet known, this method may perform a network request on the current thread, so do not call it from the UI thread.

Returns
String the portal's sharing URL
Throws
EsriSecurityException if failed to pass the security checking
Exception any other exception

public UserCredentials getCredentials ()

Returns a copy of the user credentials set on this portal instance.

Returns
UserCredentials the user credentials

public String getUrl ()

Returns the portal's URL.

Returns
String the portal's URL

public boolean isPreVersion162 ()

Returns true if the portal version is earlier than 1.6.2. If the portal version is not yet known, this method may perform a network request on the current thread, so do not call it from the UI thread.

Returns
boolean true if the portal version is earlier than 1.6.2, false otherwise or if an exception occurred during network activity and was caught by this method

public JsonParser postRequest (String requestURL)

Sends the customized request and lets the caller handle the response. The request will be sent using the "POST" method. Performs a network request on the current thread, so do not call this from the UI thread.

Parameters
requestURL String: the URL of the request
Returns
JsonParser the response as a JsonParser
Throws
EsriSecurityException if failed to pass the security checking
Exception if the request is invalid

public JsonParser sendRequest (String requestURL)

Sends the customized request and lets users handle the response. The request will be sent using the "POST" or "GET" method based on the length of the URL. Performs a network request on the current thread, so do not call this from the UI thread.

Parameters
requestURL String: the URL of the request
Returns
JsonParser the response as a JsonParser
Throws
EsriSecurityException if failed to pass the security checking
Exception if the request is invalid

public String toString ()

Returns
String