Class PortalItem
- java.lang.Object
-
- com.esri.arcgisruntime.mapping.Item
-
- com.esri.arcgisruntime.portal.PortalItem
-
- All Implemented Interfaces:
JsonSerializable
,Loadable
public final class PortalItem extends Item implements JsonSerializable
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 owningPortal
, 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 typePortalItem.Type.WEBMAP
viaArcGISMap(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.- Since:
- 100.0.0
- See Also:
Basemap.getItem()
,GeoModel.getItem()
,Layer.getItem()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PortalItem.Access
Signifies the level of access to a portal item.static class
PortalItem.Type
Represents the type of an item stored in an ArcGIS portal.
-
Constructor Summary
Constructors Constructor Description PortalItem(Portal portal, PortalItem.Type type, java.lang.String title, java.lang.String description, java.lang.String snippet, java.lang.Iterable<java.lang.String> tags)
Constructor for use if you wish to add a new item to a portal.PortalItem(Portal portal, java.lang.String itemId)
Creates a portal item object for a specified portal and a specified item ID.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addDoneLoadingListener(java.lang.Runnable listener)
Adds a listener to the loadable resource that is invoked when loading has completed.void
addLoadStatusChangedListener(LoadStatusChangedListener listener)
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.void
cancelLoad()
Cancels loading metadata for the object.ListenableFuture<java.util.List<PortalItemComment>>
fetchCommentsAsync()
Executes an asynchronous operation to fetch the comments for this portal item.ListenableFuture<java.io.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<java.util.List<PortalItem>>
fetchRelatedItemsAsync(PortalItemRelationship relationship, PortalItemRelationshipDirection direction)
Executes an asynchronous operation to fetch all related portal items with the specified relationship to this portal item.ListenableFuture<java.util.List<PortalItem>>
fetchRelatedItemsAsync(java.lang.Iterable<PortalItemRelationship> relationships, PortalItemRelationshipDirection direction)
Executes an asynchronous operation to fetch all related portal items with any of the specified relationships to this portal item.ListenableFuture<byte[]>
fetchThumbnailAsync()
Executes an asynchronous operation to fetch the thumbnail for this portal item.static PortalItem
fromJson(java.lang.String json, Portal portal)
Creates a PortalItem from a JSON string.PortalItem.Access
getAccess()
Gets the access level of this item.java.lang.String
getAccessAndUseConstraintsHtml()
Deprecated.As of 100.4.0, replaced byItem.getTermsOfUse()
.float
getAverageRating()
Gets the average rating of this item.int
getCommentCount()
Gets the number of comments on this item.java.lang.String
getCulture()
Gets the item locale (language and country) information.java.lang.String
getFolderId()
Gets the ID of the folder in which the owner has stored this item.java.lang.String
getGuid()
Deprecated.As of 100.5.0, useItem.getItemId()
as a unique ID for items on a portal.ArcGISRuntimeException
getLoadError()
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.LoadStatus
getLoadStatus()
Returns theLoadStatus
of the loadable resource.java.lang.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.java.lang.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 usingsetThumbnailData(byte[])
.java.lang.String
getThumbnailFileName()
Gets the filename of the thumbnail for this item.PortalItem.Type
getType()
Gets the type of this item.java.lang.String
getTypeName()
Gets the type name for this item.java.util.Map<java.lang.String,java.lang.Object>
getUnknownJson()
If this object was created from JSON, this method gets unknown data from the source JSON.java.util.Map<java.lang.String,java.lang.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()
Loads the metadata of the loadable resource asynchronously.boolean
removeDoneLoadingListener(java.lang.Runnable listener)
Removes a done loading listener from the loadable resource.boolean
removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Removes aLoadStatusChangedListener
from the loadable resource.void
retryLoadAsync()
Loads or retries loading metadata for the object asynchronously.void
setAccessAndUseConstraintsHtml(java.lang.String accessAndUseConstraintsHtml)
Deprecated.As of 100.4.0, replaced byItem.setTermsOfUse(String)
.void
setThumbnailData(byte[] thumbnailData)
Sets the thumbnail data for this portal item.ListenableFuture<java.lang.Void>
shareWithAsync(boolean everyone, boolean organization)
Executes an asynchronous operation to modify the sharing of this portal item.ListenableFuture<java.util.List<PortalGroup>>
shareWithGroupsAsync(java.lang.Iterable<PortalGroup> groups)
Executes an asynchronous operation to share this portal item with a number of groups.java.lang.String
toJson()
Serializes this object to a JSON string.ListenableFuture<java.lang.Void>
unshareAsync()
Executes an asynchronous operation to stop all sharing of this portal item.ListenableFuture<java.util.List<PortalGroup>>
unshareGroupsAsync(java.lang.Iterable<PortalGroup> groups)
Executes an asynchronous operation to stop sharing this portal item with a number of groups.ListenableFuture<java.lang.Void>
updateDataAsync(java.lang.String jsonContent)
Executes an asynchronous operation to update the portal item content data.ListenableFuture<java.lang.Void>
updateItemPropertiesAsync()
Executes an asynchronous operation to update any portal item properties that have been changed (using the setter methods).-
Methods inherited from class com.esri.arcgisruntime.mapping.Item
getAccessInformation, getCreated, getDescription, getExtent, getItemId, getModified, getName, getSnippet, getSpatialReferenceName, getTags, getTermsOfUse, getTitle, getTypeKeywords, setAccessInformation, setDescription, setExtent, setExtent, setSnippet, setTermsOfUse, setTitle
-
-
-
-
Constructor Detail
-
PortalItem
public PortalItem(Portal portal, java.lang.String itemId)
Creates a portal item object for a specified portal and a specified item ID.Use this constructor to instantiate a
PortalItem
from an existing item using its unique ID.The portal item 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:
https://www.arcgis.com/home/item.html?id=[item_id]
. The webmap viewer has the following format:https://www.arcgis.com/home/webmap/viewer.html?webmap=[item_id]
. The webscene viewer has the following format:https://www.arcgis.com/home/webscene/viewer.html?webscene=[item_id]
. In all cases, the [item_id] can be used as the ID to instantiate a portal item.- Parameters:
portal
- the portal the item belongs toitemId
- the ID for the item- Throws:
java.lang.IllegalArgumentException
- if portal is null or if itemId is null or empty- Since:
- 100.0.0
-
PortalItem
public PortalItem(Portal portal, PortalItem.Type type, java.lang.String title, java.lang.String description, java.lang.String snippet, java.lang.Iterable<java.lang.String> tags)
Constructor for use if you wish to add a new item to a portal. Pass the resultant object toPortalUser.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 addedtype
- the type of the itemtitle
- the title of the itemdescription
- the description of the item, or null if nonesnippet
- the summary description snippet of the item, or null if nonetags
- the tags associated with the item, or null if none- Throws:
java.lang.IllegalArgumentException
- if portal, type or title is nulljava.lang.IllegalArgumentException
- if title is an empty string- Since:
- 100.0.0
-
-
Method Detail
-
fromJson
public static PortalItem fromJson(java.lang.String json, Portal portal)
Creates a PortalItem from a JSON string.- Parameters:
json
- the JSON stringportal
- the Portal object for use by the PortalItem- Returns:
- the PortalItem
- Throws:
java.lang.IllegalArgumentException
- if portal is null or json is null or empty- Since:
- 100.0.0
-
toJson
public java.lang.String toJson()
Description copied from interface:JsonSerializable
Serializes this object to a JSON string. Note that unknown JSON is omitted from the serialized string.- Specified by:
toJson
in interfaceJsonSerializable
- Returns:
- a JSON string
-
getUnknownJson
public java.util.Map<java.lang.String,java.lang.Object> getUnknownJson()
Description copied from interface:JsonSerializable
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.- Specified by:
getUnknownJson
in interfaceJsonSerializable
- 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
- a
-
getUnsupportedJson
public java.util.Map<java.lang.String,java.lang.Object> getUnsupportedJson()
Description copied from interface:JsonSerializable
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.- Specified by:
getUnsupportedJson
in interfaceJsonSerializable
- 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
- a
-
getAccess
public PortalItem.Access getAccess()
Gets the access level of this item.- Returns:
- the access level of this item
- Since:
- 100.0.0
-
getAverageRating
public float getAverageRating()
Gets the average rating of this item.- Returns:
- the average rating of this item
- Since:
- 100.0.0
-
getAccessAndUseConstraintsHtml
@Deprecated public java.lang.String getAccessAndUseConstraintsHtml()
Deprecated.As of 100.4.0, replaced byItem.getTermsOfUse()
.Gets a description of any access and use constraints for this item. This may include HTML markup.- Returns:
- the access and use constraints
- Since:
- 100.0.0
-
getCommentCount
public int getCommentCount()
Gets the number of comments on this item.- Returns:
- the number of comments on this item
- Since:
- 100.0.0
-
getCulture
public java.lang.String getCulture()
Gets the item locale (language and country) information.- Returns:
- the item locale
- Since:
- 100.4.0
-
getRatingCount
public int getRatingCount()
Gets the number of ratings on this item.- Returns:
- the number of ratings on this item
- Since:
- 100.0.0
-
getViewCount
public int getViewCount()
Gets the number of times this item has been viewed.- Returns:
- the number of times this item has been viewed
- Since:
- 100.0.0
-
getOwner
public java.lang.String getOwner()
Gets the username of the owner of this item.- Returns:
- the username of the owner of this item
- Since:
- 100.0.0
-
getFolderId
public java.lang.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
- Since:
- 100.0.0
-
getGuid
@Deprecated public java.lang.String getGuid()
Deprecated.As of 100.5.0, useItem.getItemId()
as a unique ID for items on a portal.Gets the GUID of this item.- Returns:
- the GUID of this item
- Since:
- 100.3.0
-
getPortal
public Portal getPortal()
Gets the portal this item belongs to.- Returns:
- the portal this item belongs to
- Since:
- 100.0.0
-
getServiceUrl
public java.lang.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
- Since:
- 100.3.0
-
getSize
public long getSize()
Gets the size of this item.- Returns:
- the size of this item in kilobytes
- Since:
- 100.0.0
-
getThumbnailData
public byte[] getThumbnailData()
Gets the thumbnail data for this portal item, if this has been set usingsetThumbnailData(byte[])
. Note, to retrieve the thumbnail data that's stored on the portal, usefetchThumbnailAsync()
instead of this method.- Specified by:
getThumbnailData
in classItem
- Returns:
- the thumbnail data, or null if this has not been set using
setThumbnailData(byte[])
- Since:
- 100.0.0
-
getThumbnailFileName
public java.lang.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
- Since:
- 100.0.0
-
getType
public PortalItem.Type getType()
Gets the type of this item.- Returns:
- the type of this item
- Since:
- 100.0.0
-
getTypeName
public java.lang.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
- Since:
- 100.0.0
-
isCommentsEnabled
public boolean isCommentsEnabled()
Indicates if comments are allowed on this item.- Returns:
- true if comments are allowed on this item
- Since:
- 100.3.0
-
setAccessAndUseConstraintsHtml
@Deprecated public void setAccessAndUseConstraintsHtml(java.lang.String accessAndUseConstraintsHtml)
Deprecated.As of 100.4.0, replaced byItem.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- Since:
- 100.0.0
-
setThumbnailData
public void setThumbnailData(byte[] thumbnailData)
Sets the thumbnail data for this portal item.- Specified by:
setThumbnailData
in classItem
- 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.- Since:
- 100.0.0
-
fetchDataAsync
public ListenableFuture<java.io.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.
- Specified by:
fetchDataAsync
in classItem
- 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:
java.lang.IllegalStateException
- if this PortalItem does not have a portal item ID- Since:
- 100.0.0
-
fetchThumbnailAsync
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.- Specified by:
fetchThumbnailAsync
in classItem
- 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:
java.lang.IllegalStateException
- if this PortalItem does not have a portal item ID- Since:
- 100.0.0
-
fetchCommentsAsync
public ListenableFuture<java.util.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:
java.lang.IllegalStateException
- if this PortalItem does not have a portal item ID- Since:
- 100.0.0
-
fetchGroupsAsync
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 containing PortalGroup objects that are fully populated and have a load status ofLoadStatus.LOADED
.- 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:
java.lang.IllegalStateException
- if this PortalItem does not have a portal item ID- Since:
- 100.0.0
-
updateItemPropertiesAsync
public ListenableFuture<java.lang.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.- Specified by:
updateItemPropertiesAsync
in classItem
- 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:
java.lang.IllegalStateException
- if this PortalItem does not have a portal item IDArcGISRuntimeException
- if the currentLicenseLevel
is too low for this operation (LicenseLevel.BASIC
or higher is required to edit portal content)- Since:
- 100.0.0
-
updateDataAsync
public ListenableFuture<java.lang.Void> updateDataAsync(java.lang.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:
java.lang.IllegalStateException
- if this PortalItem does not have a portal item IDArcGISRuntimeException
- if the currentLicenseLevel
is too low for this operation (LicenseLevel.BASIC
or higher is required to edit portal content)- Since:
- 100.0.0
-
shareWithAsync
public ListenableFuture<java.lang.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
PortalItem.Access.PUBLIC
- if 'everyone' is false and 'organization' is true, the item is shared with all users in the organization and
the access property is
PortalItem.Access.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
PortalItem.Access.PRIVATE
- If 'everyone' and 'organization' are both false and the item has been shared with some groups, the access
property is
PortalItem.Access.SHARED
The groups an item has been shared with are not affected by this method.
- Parameters:
everyone
- true to share this item with everyoneorganization
- 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:
java.lang.IllegalStateException
- if this PortalItem does not have a portal item IDArcGISRuntimeException
- if the currentLicenseLevel
is too low for this operation (LicenseLevel.BASIC
or higher is required to edit portal content)- Since:
- 100.0.0
- See Also:
shareWithGroupsAsync(Iterable)
- if 'everyone' is true, the item is shared with everyone and the access property is
-
shareWithGroupsAsync
public ListenableFuture<java.util.List<PortalGroup>> shareWithGroupsAsync(java.lang.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. UsefetchGroupsAsync()
to find out which groups the item is shared with. UseunshareGroupsAsync(Iterable)
to stop sharing with particular groups.Note that sharing with groups has an effect even when the item is shared more widely (
PortalItem.Access.PUBLIC
orPortalItem.Access.ORGANIZATION
). Sharing the item also with a group causes the item to be found when searching for items within that group.It's not necessary to load the PortalGroup objects that are passed to this method.
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:
java.lang.IllegalArgumentException
- if groups is null or emptyjava.lang.IllegalStateException
- if this PortalItem does not have a portal item IDArcGISRuntimeException
- if the currentLicenseLevel
is too low for this operation (LicenseLevel.BASIC
or higher is required to edit portal content)- Since:
- 100.0.0
- See Also:
shareWithAsync(boolean, boolean)
-
unshareGroupsAsync
public ListenableFuture<java.util.List<PortalGroup>> unshareGroupsAsync(java.lang.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. UsefetchGroupsAsync()
to find out which groups the item is shared with.It's not necessary to load the PortalGroup objects that are passed to this method.
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:
java.lang.IllegalArgumentException
- if groups is null or emptyjava.lang.IllegalStateException
- if this PortalItem does not have a portal item IDArcGISRuntimeException
- if the currentLicenseLevel
is too low for this operation (LicenseLevel.BASIC
or higher is required to edit portal content)- Since:
- 100.0.0
- See Also:
shareWithAsync(boolean, boolean)
-
unshareAsync
public ListenableFuture<java.lang.Void> unshareAsync()
Executes an asynchronous operation to stop all sharing of this portal item. This sets the access property of the item toPortalItem.Access.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:
java.lang.IllegalStateException
- if this PortalItem does not have a portal item IDArcGISRuntimeException
- if the currentLicenseLevel
is too low for this operation (LicenseLevel.BASIC
or higher is required to edit portal content)- Since:
- 100.0.0
-
fetchRelatedItemsAsync
public ListenableFuture<java.util.List<PortalItem>> fetchRelatedItemsAsync(java.lang.Iterable<PortalItemRelationship> relationships, PortalItemRelationshipDirection direction)
Executes an asynchronous operation to fetch all related portal items with any of the specified relationships to this portal item.- Parameters:
relationships
- a collection of relationshipsdirection
- the direction of the relationships- Returns:
- a
ListenableFuture
that returns a collection of portal items that match the specified relationships - Throws:
java.lang.IllegalArgumentException
- if relationships is empty or nulljava.lang.IllegalArgumentException
- if direction is nulljava.lang.IllegalStateException
- if this PortalItem does not have a portal item ID- Since:
- 100.11.0
-
fetchRelatedItemsAsync
public ListenableFuture<java.util.List<PortalItem>> fetchRelatedItemsAsync(PortalItemRelationship relationship, PortalItemRelationshipDirection direction)
Executes an asynchronous operation to fetch all related portal items with the specified relationship to this portal item.- Parameters:
relationship
- the relationshipdirection
- the direction of the relationship- Returns:
- a
ListenableFuture
that returns a collection of portal items that match the specified relationship - Throws:
java.lang.IllegalArgumentException
- if relationship is nulljava.lang.IllegalArgumentException
- if direction is nulljava.lang.IllegalStateException
- if this PortalItem does not have a portal item ID- Since:
- 100.11.0
-
getLoadStatus
public LoadStatus getLoadStatus()
Description copied from interface:Loadable
Returns theLoadStatus
of the loadable resource.- Specified by:
getLoadStatus
in interfaceLoadable
- Returns:
- the LoadStatus of the loadable resource
-
getLoadError
public ArcGISRuntimeException getLoadError()
Description copied from interface:Loadable
Returns the most recent error that was encountered when the loadable resource transitioned to theLoadStatus.FAILED_TO_LOAD
state, either due to calling theLoadable.loadAsync()
orLoadable.retryLoadAsync()
method.If the resource subsequently transitions to
LoadStatus.LOADED
(for example, if a call toretryLoadAsync
completes successfully) the error is cleared out.- Specified by:
getLoadError
in interfaceLoadable
- Returns:
- the most recent error that was encountered when the loadable resource transitioned to the
LoadStatus.FAILED_TO_LOAD
state.
-
cancelLoad
public void cancelLoad()
Description copied from interface:Loadable
Cancels loading metadata for the object.Cancels loading the metadata if the object is loading, and always invokes the done loading listener.
A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by calling this method and the resource will transition fromLoadStatus.LOADING
toLoadStatus.FAILED_TO_LOAD
state. If the load operation was successfully cancelled, a CancellationException will be returned fromLoadable.getLoadError()
.Cancellation should be used carefully because all enqueued done loading listeners for that resource instance will get invoked with an error stating that the operation was cancelled. Thus, one component in the application can cancel the load operation initiated by other components.
This method does nothing if the resource is not in
LoadStatus.LOADING
state.- Specified by:
cancelLoad
in interfaceLoadable
-
loadAsync
public void loadAsync()
Description copied from interface:Loadable
Loads the metadata of the loadable resource asynchronously.The load status changes from
LoadStatus.NOT_LOADED
toLoadStatus.LOADING
. A listener can be added viaLoadable.addDoneLoadingListener(java.lang.Runnable)
that is invoked upon completion of the asynchronous load operation.If the load operation completes successfully, the load status will be
LoadStatus.LOADED
, which means the resource has loaded its metadata.If the load operation failed, the load status will be
LoadStatus.FAILED_TO_LOAD
and the error can be retrieved by callingLoadable.getLoadError()
.This method can be called concurrently and repeatedly, but only one attempt is ever made to perform the load operation. If a load operation is already in progress (
LoadStatus.LOADING
state) whenloadAsync
is called, it simply piggy-backs on the outstanding operation and the done loading listener added to the loadable resource is enqueued to be invoked when that operation completes. If the operation has already completed (LoadStatus.LOADED
orLoadStatus.FAILED_TO_LOAD
state) whenloadAsync
is called, the done loading listener is immediately invoked when added to the loadable resource.If a loadable resource has failed to load, calling
loadAsync
on it subsequently will not change its state. The done loading listener will be invoked immediately when added to the loadable resource. In order to retry loading the resource,Loadable.retryLoadAsync()
needs to be used.A load operation that is in progress (
LoadStatus.LOADING
state) can be cancelled by callingLoadable.cancelLoad()
.
-
retryLoadAsync
public void retryLoadAsync()
Description copied from interface:Loadable
Loads or retries loading metadata for the object asynchronously.Will retry loading the metadata if the object's load status is
LoadStatus.FAILED_TO_LOAD
. Will load the object if it is not loaded. Will not retry to load the object if the object is loaded.For more details on the load process see
Loadable.loadAsync()
.- Specified by:
retryLoadAsync
in interfaceLoadable
-
addDoneLoadingListener
public void addDoneLoadingListener(java.lang.Runnable listener)
Description copied from interface:Loadable
Adds a listener to the loadable resource that is invoked when loading has completed.The listener may be added at any point, whether the loadable resource has already completed loading or not.
- For resources that are not loaded when the listener is added (LoadStatus is NOT_LOADED or LOADING): When the resource completes loading, the listener will be invoked on the UI thread if it is added from the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
- For resources that are already loaded when the listener is added (LoadStatus is LOADED or FAILED_TO_LOAD): The listener will be called immediately, on the current thread.
Alternatively, to be notified when there is any change in the load status, use the
Loadable.addLoadStatusChangedListener(LoadStatusChangedListener)
method instead.- Specified by:
addDoneLoadingListener
in interfaceLoadable
- Parameters:
listener
- a Runnable that is invoked upon completion of the load operation
-
removeDoneLoadingListener
public boolean removeDoneLoadingListener(java.lang.Runnable listener)
Description copied from interface:Loadable
Removes a done loading listener from the loadable resource.- Specified by:
removeDoneLoadingListener
in interfaceLoadable
- Parameters:
listener
- the listener to be removed- Returns:
- true if the listener was removed, otherwise false
-
addLoadStatusChangedListener
public void addLoadStatusChangedListener(LoadStatusChangedListener listener)
Description copied from interface:Loadable
Adds aLoadStatusChangedListener
to the loadable resource that is invoked whenever the load status changes.Adding this listener on the UI thread will cause it to be invoked on the UI thread, otherwise it is not guaranteed on which thread the listener is invoked.
The listener will not be called if added to a loadable resource that has already completed loading. To be notified when a loadable resource has completed loading, including if the resource is already loaded when the listener is added, use the
Loadable.addDoneLoadingListener(Runnable)
method.- Specified by:
addLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be added
-
removeLoadStatusChangedListener
public boolean removeLoadStatusChangedListener(LoadStatusChangedListener listener)
Description copied from interface:Loadable
Removes aLoadStatusChangedListener
from the loadable resource.- Specified by:
removeLoadStatusChangedListener
in interfaceLoadable
- Parameters:
listener
- theLoadStatusChangedListener
to be removed- Returns:
- true if the listener was removed, otherwise false
-
-