Skip to content

Portal metadata and search

The Portal class is the entry point to the portal services hosted by ArcGIS Online and ArcGIS Enterprise. A Portal instance provides access to the portal's information, including its name, URL, and other metadata. You can also use it to search for the PortalItems and PortalGroups that the portal contains.

The most common workflow for a ArcGIS Maps SDK for Kotlin app focuses on portal items, including searching for items, retrieving item details, managing items, and displaying items as web maps, web scenes, and galleries. The use of the PortalUser and PortalGroup classes is typically secondary, as these classes are primarily used to find items associated with the a user or a group. The tasks of creating and managing users and groups is performed through the ArcGIS Online or ArcGIS Enterprise web interface or an automation script that uses the ArcGIS Python API.

Create a portal instance

Start by creating an instance of the Portal class, passing the URL of the portal and whether the user needs to log in to the portal (authenticated access) or not (anonymous access).

You can create a portal instance with anonymous access like this:

Use dark colors for code blocksCopy
1
val portal = Portal("https://your-portal-url.com", Portal.Connection.Anonymous)

And you can create a portal instance with authenticated access like this:

Use dark colors for code blocksCopy
1
val portal = Portal("https://your-portal-url.com", Portal.Connection.Authenticated)

Portal properties

Portal provides components applicable to the portal as a whole via such functions as:

The Portal.user property returns the current user in the case of authenticated access. In the case of anonymous access, it returns null. The property is of type PortalUser.

Portal info

While Portal contains many properties to describe basic information about the portal, it also exposes the PortalInfo class to provide additional metadata for the portal. You can access this metadata from the Portal.portalInfo property. The PortalInfo class exposes information about the organization, including: default basemaps and extent to use when creating new maps, the thumbnail and banner images displayed on the organization page, a variety of query strings you can use to query groups, and more.

Search for portal items and groups

The Portal class enables you to search for portal items and portal groups. You can use Portal.findItems() to find items based on various criteria, such as keywords, tags, and owner. Similarly, Portal.findGroups() allows you to find groups within the portal. Both methods take a PortalQueryParameters as a parameter.

The key to using PortalQueryParameters effectively is to understand how to create an object of the class.

Call the appropriate factory method to create query parameters suited to your search:

  • groups(): groups that have a specific owner and title.
  • item(): an item that has a specific item ID.
  • items(): items with the specified PortalItemTypes. (You can also restrict the search to a specific item owner, a group ID, and/or query string.)

Search for items in a group

You can search for portal items that belong to a specific group using the PortalGroup class. The PortalGroup.findItems() method takes a PortalGroupContentSearchParameters instance.

You can use the appropriate factory method to create query parameters suited to your search:

  • item(): a portal item in the group that has a specific ID.
  • items(): items within the group with the specified types.
  • query(): items within the group using a specific query string.

There are several ways to obtain a PortalGroup instance. If you know the group ID, you can instantiate PortalGroup using its ID. To find a specific group that the current user belongs to, use the groups property to get a list of all the user's groups. You can then iterate through the list to find the group you want.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
    coroutineScope.launch {
        portal.load().onFailure { error ->
            return@launch showError(error.message.toString())
        }

        val portalUser = portal.user ?: return@launch
        portalUser.load().onFailure { error ->
            return@launch showError(error.message.toString())
        }

        val portalGroups = portalUser.groups

        portalGroups.forEach { portalGroup ->

            val searchParameters = PortalGroupContentSearchParameters.items(
                listOf(
                    PortalItemType.WebMap,
                    PortalItemType.VectorTileService
                )
            )
            val resultSet = portalGroup.findItems(searchParameters).getOrThrow()
            val portalItems = resultSet.results
            portalItems.forEach { portalItem ->
                showTitleFound(portalItem.title)
            }
        }

    }

Search for items by user

You can search for portal items by PortalUser. To find items owned by a user, callPortaulUser.fetchContent(). This returns a PortalUserContent object representing the content (folders and items) owned by the user. Its properties include:

You can then iterate over the collection of subfolders. For each subfolder, call PortalUser.fetchContentInFolder() and pass in the subfolder name to retrieve the portal items in the folder.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
    coroutineScope.launch {
        portal.load().onFailure { error ->
            return@launch showError(error.message.toString())
        }

        val portalUser = portal.user ?: return@launch
        portalUser.load().onFailure { error ->
            return@launch showError(error.message.toString())
        }

        val portalUserContent = portalUser.fetchContent().getOrThrow()

        val subfolders = portalUserContent.folders
        subfolders.forEach { subfolder ->
            showTitleFound("subfolder: " + subfolder.title )
            val portalItems = portalUser.fetchContentInFolder(subfolder.folderId).getOrThrow()
            portalItems.forEach { portalItem ->
                // use portal item, such as display its name
                showTitleFound("item: " + portalItem.title)
            }
        }

    }

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.