public final class

PortalItem

extends Item
implements JsonSerializable
java.lang.Object
   ↳ com.esri.arcgisruntime.mapping.Item
     ↳ com.esri.arcgisruntime.portal.PortalItem

Class Overview

Represents an item (a unit of content) stored in an ArcGIS portal. Contains information about the item such as the item's unique ID, the owning Portal, and the type of item it is (PortalItem.Type), for example a web map, a map service, or a tile package.

The portal item ID can be used along with a portal URL to quickly instantiate a new portal item object. The ID can be determined from the URL of the item details web page or the map viewer URL (for maps only) in your portal. The item details page has the following format: http://www.arcgis.com/home/item.html?id=[item_id]. The webmap viewer has the following format: http://www.arcgis.com/home/webmap/viewer.html?webmap=[item_id]. In both cases the [item_id] can be used as the ID to instantiate a portal item.

A PortalItem can be used to create an instance of the item for item types supported by this API. For example an ArcGISMap can be created from a PortalItem of type WEBMAP via ArcGISMap(PortalItem) and displayed in an application.

This class contains metadata about the portal item rather than the content of the item itself. The content for a particular item (such as an ArcGISMap) will be retrieved when the item instance is loaded.

Summary

Nested Classes
enum PortalItem.Access Signifies the level of access to a portal item. 
enum PortalItem.Type Represents the type of an item stored in an ArcGIS portal. 
Public Constructors
PortalItem(Portal portal, String itemId)
Constructor for use if you wish to fetch a particular item from a portal.
PortalItem(Portal portal, PortalItem.Type type, String title, String description, String snippet, Iterable<String> tags)
Constructor for use if you wish to add a new item to a portal.
Public Methods
void addDoneLoadingListener(Runnable listener)
void addLoadStatusChangedListener(LoadStatusChangedListener listener)
void cancelLoad()
ListenableFuture<List<PortalItemComment>> fetchCommentsAsync()
Executes an asynchronous operation to fetch the comments for this portal item.
ListenableFuture<InputStream> fetchDataAsync()
Executes an asynchronous operation to fetch the portal item data.
ListenableFuture<PortalItemGroups> fetchGroupsAsync()
Executes an asynchronous operation to fetch the groups this portal item belongs to.
ListenableFuture<byte[]> fetchThumbnailAsync()
Executes an asynchronous operation to fetch the thumbnail for this portal item.
static PortalItem fromJson(String json, Portal portal)
Creates a PortalItem from a JSON string.
PortalItem.Access getAccess()
Gets the access level of this item.
String getAccessAndUseConstraintsHtml()
This method is deprecated. As of 100.4.0, replaced by getTermsOfUse()
float getAverageRating()
Gets the average rating of this item.
int getCommentCount()
Gets the number of comments on this item.
String getCulture()
Gets the item locale (language and country) information.
String getFolderId()
Gets the ID of the folder in which the owner has stored this item.
String getGuid()
Gets the GUID of this item.
ArcGISRuntimeException getLoadError()
LoadStatus getLoadStatus()
String getName()
Gets the file name of this item (for file types only).
String getOwner()
Gets the username of the owner of this item.
Portal getPortal()
Gets the portal this item belongs to.
int getRatingCount()
Gets the number of ratings on this item.
String getServiceUrl()
Gets the URL of the service this item represents.
long getSize()
Gets the size of this item.
byte[] getThumbnailData()
Gets the thumbnail data for this portal item, if this has been set using setThumbnailData(byte[]).
String getThumbnailFileName()
Gets the filename of the thumbnail for this item.
PortalItem.Type getType()
Gets the type of this item.
List<String> getTypeKeywords()
Gets a list of keywords that further describe the type of this item.
String getTypeName()
Gets the type name for this item.
Map<String, Object> getUnknownJson()
If this object was created from JSON, this method gets unknown data from the source JSON.
Map<String, Object> getUnsupportedJson()
If this object was created from JSON, this method gets unsupported data from the source JSON.
int getViewCount()
Gets the number of times this item has been viewed.
boolean isCommentsEnabled()
Indicates if comments are allowed on this item.
void loadAsync()
boolean removeDoneLoadingListener(Runnable listener)
boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener)
void retryLoadAsync()
void setAccessAndUseConstraintsHtml(String accessAndUseConstraintsHtml)
This method is deprecated. As of 100.4.0, replaced by setTermsOfUse(String)
void setThumbnailData(byte[] thumbnailData)
Sets the thumbnail data for this portal item.
ListenableFuture<Void> shareWithAsync(boolean everyone, boolean organization)
Executes an asynchronous operation to modify the sharing of this portal item.
ListenableFuture<List<PortalGroup>> shareWithGroupsAsync(Iterable<PortalGroup> groups)
Executes an asynchronous operation to share this portal item with a number of groups.
String toJson()
Serializes this object to a JSON string.
ListenableFuture<Void> unshareAsync()
Executes an asynchronous operation to stop all sharing of this portal item.
ListenableFuture<List<PortalGroup>> unshareGroupsAsync(Iterable<PortalGroup> groups)
Executes an asynchronous operation to stop sharing this portal item with a number of groups.
ListenableFuture<Void> updateDataAsync(String jsonContent)
Executes an asynchronous operation to update the portal item content data.
ListenableFuture<Void> updateItemPropertiesAsync()
Executes an asynchronous operation to update any portal item properties that have been changed (using the setter methods).
[Expand]
Inherited Methods
From class com.esri.arcgisruntime.mapping.Item
From class java.lang.Object
From interface com.esri.arcgisruntime.io.JsonSerializable
From interface com.esri.arcgisruntime.loadable.Loadable

Public Constructors

public PortalItem (Portal portal, String itemId)

Constructor for use if you wish to fetch a particular item from a portal. Call loadAsync() on the resultant object to fetch the metadata for this item. Note that most of the getter methods will return null, zero or an empty String until the load operation is complete.

A portal items ID can be obtained using the getItemId() method. The ID can also be determined from the URL of the item details web page or the map viewer URL (for maps only) in your portal. The item details page has the following format: http://www.arcgis.com/home/item.html?id=[item_id]. The webmap viewer has the following format: http://www.arcgis.com/home/webmap/viewer.html?webmap=[item_id]. In both cases the [item_id] can be used as the ID to instantiate a portal item.

Parameters
portal the portal the item belongs to
itemId the ID for the item
Throws
IllegalArgumentException if portal is null or if itemId is null or empty

public PortalItem (Portal portal, PortalItem.Type type, String title, String description, String snippet, Iterable<String> tags)

Constructor for use if you wish to add a new item to a portal. Pass the resultant object to addPortalItemAsync(PortalItem, PortalItemContentParameters, PortalFolder) to add the item. You must do this to populate the PortalItem with a portal item ID, which is necessary before calling many of the methods on this object.

Parameters
portal the portal to which the item will be added
type the type of the item
title the title of the item
description the description of the item, or null if none
snippet the summary description snippet of the item, or null if none
tags the tags associated with the item, or null if none
Throws
IllegalArgumentException if portal, type or title is null
IllegalArgumentException if title is an empty string

Public Methods

public void addDoneLoadingListener (Runnable listener)

public void addLoadStatusChangedListener (LoadStatusChangedListener listener)

public void cancelLoad ()

public ListenableFuture<List<PortalItemComment>> fetchCommentsAsync ()

Executes an asynchronous operation to fetch the comments for this portal item. The result is an unmodifiable list of PortalItemComments for this portal item.

Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to an exception as follows:
    • IOException if the network request fails
Throws
IllegalStateException if this PortalItem does not have a portal item ID

public ListenableFuture<InputStream> fetchDataAsync ()

Executes an asynchronous operation to fetch the portal item data. The result is an InputStream object. You are responsible for closing the InputStream after using it.

Note that reading the InputStream causes network activity and must not be done on the Android UI thread.

Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to an exception as follows:
    • IOException if the network request fails
Throws
IllegalStateException if this PortalItem does not have a portal item ID

public ListenableFuture<PortalItemGroups> fetchGroupsAsync ()

Executes an asynchronous operation to fetch the groups this portal item belongs to. Includes only the groups that the calling user can access. The result is a PortalItemGroups object containing the groups.

Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to an exception as follows:
    • IOException if the network request fails
Throws
IllegalStateException if this PortalItem does not have a portal item ID

public ListenableFuture<byte[]> fetchThumbnailAsync ()

Executes an asynchronous operation to fetch the thumbnail for this portal item. The result is a byte[] containing the thumbnail data, or null if there is no thumbnail for this portal item.

Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to an exception as follows:
    • IOException if the network request fails
Throws
IllegalStateException if this PortalItem does not have a portal item ID

public static PortalItem fromJson (String json, Portal portal)

Creates a PortalItem from a JSON string.

Parameters
json the JSON string
portal the Portal object for use by the PortalItem
Returns
  • the PortalItem
Throws
IllegalArgumentException if portal is null or json is null or empty

public PortalItem.Access getAccess ()

Gets the access level of this item.

Returns
  • the access level of this item

public String getAccessAndUseConstraintsHtml ()

This method is deprecated.
As of 100.4.0, replaced by getTermsOfUse()

Gets a description of any access and use constraints for this item. This may include HTML markup.

Returns
  • the access and use constraints

public float getAverageRating ()

Gets the average rating of this item.

Returns
  • the average rating of this item

public int getCommentCount ()

Gets the number of comments on this item.

Returns
  • the number of comments on this item

public String getCulture ()

Gets the item locale (language and country) information.

Returns
  • the item locale

public String getFolderId ()

Gets the ID of the folder in which the owner has stored this item.

Returns
  • the ID of the folder in which the owner has stored this item; an empty string indicates the owner's root folder; null indicates the folder is unknown

public String getGuid ()

Gets the GUID of this item.

Returns
  • the GUID of this item

public ArcGISRuntimeException getLoadError ()

public LoadStatus getLoadStatus ()

public String getName ()

Gets the file name of this item (for file types only).

Returns
  • the file name of this item, or null if none

public String getOwner ()

Gets the username of the owner of this item.

Returns
  • the username of the owner of this item

public Portal getPortal ()

Gets the portal this item belongs to.

Returns
  • the portal this item belongs to

public int getRatingCount ()

Gets the number of ratings on this item.

Returns
  • the number of ratings on this item

public String getServiceUrl ()

Gets the URL of the service this item represents. Applies only to items that represent web-accessible resources such as map services.

Returns
  • the URL of the service this item represents; an empty string if the item doesn't represent a web-accessible resource

public long getSize ()

Gets the size of this item.

Returns
  • the size of this item in kilobytes

public byte[] getThumbnailData ()

Gets the thumbnail data for this portal item, if this has been set using setThumbnailData(byte[]). Note, to retrieve the thumbnail data that's stored on the portal, use fetchThumbnailAsync() instead of this method.

Returns

public String getThumbnailFileName ()

Gets the filename of the thumbnail for this item. This is actually a relative path that may contain a folder name as well as a filename, for example "thumbnail/thumbnail.jpg".

Returns
  • the filename of the thumbnail for this item, or null if there's no thumbnail

public PortalItem.Type getType ()

Gets the type of this item.

Returns
  • the type of this item

public List<String> getTypeKeywords ()

Gets a list of keywords that further describe the type of this item. Each item is tagged with a set of type keywords that are derived based on its primary type.

The returned list is modifiable and changes made to it will affect the type keywords used by this item. Update this list only if you wish to add additional type keywords.

Returns
  • the list of type keywords for this item

public String getTypeName ()

Gets the type name for this item.

Most generally the type name is the string representation of the Type returned by getType(). However if the type is unknown, the type name is set with the type found in the portal item JSON. This allows the API to deal with new portal item types added since the latest API release.

Returns
  • the type name for this item

public Map<String, Object> getUnknownJson ()

If this object was created from JSON, this method gets unknown data from the source JSON. Unknown JSON is a Map of values that were in the source JSON but are not known by the Runtime and therefore not exposed in the API.

Returns
  • an unmodifiable Map containing unknown JSON data. The keys are Strings containing names. The types of the values depend on the types of tokens within the JSON as follows:
    • a Map<String, Object> represents an object in the JSON
    • a List<Object> represents an array in the JSON
    • a String represents a string in the JSON
    • a Double represents a number in the JSON
    • a Boolean represents true or false in the JSON
    • null represents null in the JSON

public Map<String, Object> getUnsupportedJson ()

If this object was created from JSON, this method gets unsupported data from the source JSON. Unsupported JSON is a Map of values that are supported by webmaps and known to the version of the webmap specification the API supports (see system requirements), but are not explicitly exposed through the Runtime API.

Returns
  • an unmodifiable Map containing unsupported JSON data. The keys are Strings containing names. The types of the values depend on the types of tokens within the JSON as follows:
    • a Map<String, Object> represents an object in the JSON
    • a List<Object> represents an array in the JSON
    • a String represents a string in the JSON
    • a Double represents a number in the JSON
    • a Boolean represents true or false in the JSON
    • null represents null in the JSON

public int getViewCount ()

Gets the number of times this item has been viewed.

Returns
  • the number of times this item has been viewed

public boolean isCommentsEnabled ()

Indicates if comments are allowed on this item.

Returns
  • true if comments are allowed on this item

public void loadAsync ()

public boolean removeDoneLoadingListener (Runnable listener)

public boolean removeLoadStatusChangedListener (LoadStatusChangedListener listener)

public void retryLoadAsync ()

public void setAccessAndUseConstraintsHtml (String accessAndUseConstraintsHtml)

This method is deprecated.
As of 100.4.0, replaced by setTermsOfUse(String)

Sets a description of any access and use constraints for this item. This may include HTML markup.

Parameters
accessAndUseConstraintsHtml the access and use constraints

public void setThumbnailData (byte[] thumbnailData)

Sets the thumbnail data for this portal item.

Parameters
thumbnailData a byte array representing the thumbnail. The recommended image size is 200 pixels wide by 133 pixels high. Acceptable image formats are PNG, GIF, and JPEG. The maximum file size for an image is 1 MB.

public ListenableFuture<Void> shareWithAsync (boolean everyone, boolean organization)

Executes an asynchronous operation to modify the sharing of this portal item. The access property of the item is changed depending on the parameters passed and also whether the item has been shared with groups, as follows:

  • if 'everyone' is true, the item is shared with everyone and the access property is PUBLIC
  • if 'everyone' is false and 'organization' is true, the item is shared with all users in the organization and the access property is ORGANIZATION
  • If 'everyone' and 'organization' are both false and the item has not been shared with any groups, the item is not shared with anyone and the access property is PRIVATE
  • If 'everyone' and 'organization' are both false and the item has been shared with some groups, the access property is SHARED

The groups an item has been shared with are not affected by this method.

Parameters
everyone true to share this item with everyone
organization true to share this item with all users in the organization
Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to one of the following exceptions:
    • IOException if the network request fails
Throws
IllegalStateException if this PortalItem does not have a portal item ID
ArcGISRuntimeException if the current LicenseLevel is too low for this operation (BASIC or higher is required to edit portal content)

public ListenableFuture<List<PortalGroup>> shareWithGroupsAsync (Iterable<PortalGroup> groups)

Executes an asynchronous operation to share this portal item with a number of groups. These groups are added to the existing set of groups the item is shared with. Use fetchGroupsAsync() to find out which groups the item is shared with. Use unshareGroupsAsync(Iterable) to stop sharing with particular groups.

Note that sharing with groups has an effect even when the item is shared more widely (PUBLIC or ORGANIZATION). Sharing the item also with a group causes the item to be found when searching for items within that group.

The result of the operation is an unmodifiable list of PortalGroups, one for each group with which the item could not be shared, empty if all groups were shared with successfully.

Parameters
groups the groups to be shared with; must not be null or empty
Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to an exception as follows:
    • IOException if the network request fails
Throws
IllegalArgumentException if groups is null or empty
IllegalStateException if this PortalItem does not have a portal item ID
ArcGISRuntimeException if the current LicenseLevel is too low for this operation (BASIC or higher is required to edit portal content)

public String toJson ()

Serializes this object to a JSON string. Note that unknown JSON is omitted from the serialized string.

Returns
  • a JSON string

public ListenableFuture<Void> unshareAsync ()

Executes an asynchronous operation to stop all sharing of this portal item. This sets the access property of the item to PRIVATE and makes the item accessible to only the item owner. Removes all groups from the set of groups the item is shared with.

Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to an exception as follows:
    • IOException if the network request fails
Throws
IllegalStateException if this PortalItem does not have a portal item ID
ArcGISRuntimeException if the current LicenseLevel is too low for this operation (BASIC or higher is required to edit portal content)

public ListenableFuture<List<PortalGroup>> unshareGroupsAsync (Iterable<PortalGroup> groups)

Executes an asynchronous operation to stop sharing this portal item with a number of groups. These groups are removed from the set of groups the item is shared with. Use fetchGroupsAsync() to find out which groups the item is shared with.

The result of the operation is an unmodifiable list of PortalGroups, one for each group for which the item could not be unshared, empty if all groups were unshared with successfully.

Parameters
groups the groups to stop sharing with; must not be null or empty
Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to an exception as follows:
    • IOException if the network request fails
Throws
IllegalArgumentException if groups is null or empty
IllegalStateException if this PortalItem does not have a portal item ID
ArcGISRuntimeException if the current LicenseLevel is too low for this operation (BASIC or higher is required to edit portal content)

public ListenableFuture<Void> updateDataAsync (String jsonContent)

Executes an asynchronous operation to update the portal item content data. Also updates the portal item properties stored on the portal to match those stored within this PortalItem object.

Parameters
jsonContent content data, in JSON format, to replace the item's existing content data
Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to an exception as follows:
    • IOException if the network request fails
Throws
IllegalStateException if this PortalItem does not have a portal item ID
ArcGISRuntimeException if the current LicenseLevel is too low for this operation (BASIC or higher is required to edit portal content)

public ListenableFuture<Void> updateItemPropertiesAsync ()

Executes an asynchronous operation to update any portal item properties that have been changed (using the setter methods). This causes the values that have been changed to be updated on the portal.

Returns
  • a ListenableFuture for tracking when the operation is done and getting the result; also allows cancellation. Calling get() on the returned future may throw an ExecutionException with its cause set to an exception as follows:
    • IOException if the network request fails
Throws
IllegalStateException if this PortalItem does not have a portal item ID
ArcGISRuntimeException if the current LicenseLevel is too low for this operation (BASIC or higher is required to edit portal content)