Following was the first approach I used.
public List getLinks(DbxClientV2 client) throws DbxException {
List result = new ArrayList();
ListSharedLinksResult sharedLinksResult = client.sharing().listSharedLinks();
for (SharedLinkMetadata slm : sharedLinksResult.getLinks()) {
result.add(slm.getUrl());
}
return result;
}
ListSharedLinksResult sharedLinksResult = client.sharing().listSharedLinks();
sharedLinksResult.getHasMore();
So if there are more items left, then we need to extract them as well.
sharedLinksResult has a cursor, which can be used to extract additional items. This can be done using:
client.sharing().listSharedLinks(new ListSharedLinksArg((String)null, sharedLinksResult.getCursor(), true));
Hack!!!
I managed to use this, by placing my class into the same package where the class DbxUserSharingRequests lie i.e. com.dropbox.core.v2. Obviously, this is not a clean approach.Solution
As it turns out, the solution is to use
DbxUserSharingRequests.listSharedLinksBuilder()
public List getLinks(DbxClientV2 client) throws DbxException {
List result = new ArrayList();
ListSharedLinksResult sharedLinksResult = client.sharing().listSharedLinks();
while(true) {
for (SharedLinkMetadata slm : sharedLinksResult.getLinks()) {
result.add(slm.getUrl());
}
if (sharedLinksResult.getHasMore()) {
sharedLinksResult = client.sharing().listSharedLinksBuilder().withCursor(sharedLinksResult.getCursor()).withDirectOnly(true).start();
} else {
break;
}
}
return result;
}
No comments:
Post a Comment