Paging for Dropbox
The administrator must write the Before Rule and After Rule for Dropbox account and group aggregation as follows:
Before Rule
See the sample Before Rule for account aggregation request in Web Services Connector for Dropbox using V2 in examplerules.xml file by name Example WSBeforeRl DropboxPaging as follows:
import sailpoint.tools.Util;
Map obj = (Map) application.getAttributeValue("transientValues");
System.out.println("BEFORE RULE: Transient Values ==> " + obj);
if(null != obj) {
String offset = obj.get("offset");
System.out.println("BEFORE RULE: offset value ==> " + offset);
String urlString = (String) requestEndPoint.getFullUrl();
if(Util.isNotNullOrEmpty(offset)) {
System.out.println("BEFORE RULE: requestEndpoint ==> " + requestEndPoint);
System.out.println("BEFORE RULE: URL ==> " + urlString);
URL tempUrl = new URL(urlString);
String queryString = tempUrl.getQuery();
System.out.println("BEFORE RULE: Query String ==> " + queryString);
if(Util.isNotNullOrEmpty(queryString)) {
StringBuffer queryParams = new StringBuffer();
String[] params = tempUrl.getQuery().split("&");
for (String param : params) {
if(queryParams.length() > 0)
queryParams.append("&");
if(param.startsWith("sysparm_offset=")) {
queryParams.append("sysparm_offset=");
queryParams.append(offset);
} else {
queryParams.append(param);
}
}
urlString = urlString.replace(tempUrl.getQuery(), queryParams.toString());
}
}
System.out.println("BEFORE RULE: Updated Query String ==> " + urlString);
requestEndPoint.setFullUrl(urlString);
}
System.out.println("BEFORE RULE: requestEndpoint Updated ==> " + requestEndPoint);
return requestEndPoint;
For of Dropbox V2, the cursor returned from the previous team membership listing API is stored in the transientValues
map in the application by the Web Service After Rule. The URL is modified to redirect to the paging API and the cursor is sent as a part of the form data. Ensure that the hasMore
flag is set by the earlier requests of the After Rule.
After Rule
Configuring paging for Dropbox has specific instructions. Refer to the sample After Rule for account aggregation request in Web Services Connector for Dropbox using V2 in examplerules.xml by name Example WSAfterRl DropboxPaging as follows:
Integer fetchedRecordsCount = 0;if(null != processedResponseObject) {
fetchedRecordsCount = ((List) processedResponseObject).size();
}
Integer expectedCount = null;
Integer offset = null;
URL url = new URL(requestEndPoint.getFullUrl());
System.out.println("AFTER RULE: Original Url ==> " + url);
String[] params = url.getQuery().split("&");
for (String param : params) {
String name = param.split("=")[0];
String value = param.split("=")[1];
switch(name) {
case "sysparm_limit":
expectedCount = Integer.parseInt(value);
break;
case "sysparm_offset":
offset = Integer.parseInt(value);
break;
default:
}
}
System.out.println("AFTER RULE: Fetch Count ==> " + fetchedRecordsCount);
System.out.println("AFTER RULE: Limit Count ==> " + expectedCount);
System.out.println("AFTER RULE: Fetch Offset ==> " + offset);
Boolean hasMore = (fetchedRecordsCount != 0 && null != expectedCount &&
fetchedRecordsCount.equals(expectedCount) && null != offset);
System.out.println("AFTER RULE: Has More? ==> " + hasMore);
Map transientValues = application.getAttributeValue("transientValues");
if(transientValues == null) {
transientValues = new HashMap();
application.setAttribute("transientValues", transientValues);
}
transientValues.put("hasMore", hasMore);
if (hasMore) {
if(null != offset) {
System.out.println("AFTER RULE: New Offset ==> " + (offset + expectedCount));
transientValues.put("offset", String.valueOf(offset + expectedCount));
}
}
Team membership response in Dropbox and Dropbox V2 contains the following elements:
-
cursor – An encrypted token which represents the next page to be aggregated, if any, and would form part of the subsequent API calls.
-
has_more – A Boolean value which explicitly indicates whether more records are available for fetching.
The After Rule stores the cursor and has_more
values from the response in the transientValues
map in the Application object. This map stores the necessary information which will be used by the Before Rule to manipulate the next API call.
Important
Ensure that the parameter indicating whether the managed system contains more records is stored by the key is named "has_more". This field is mandatory as it is the deciding factor for aborting the pagination requests.