From 008ef2c034336503d9a8ca747f77f78e3cfd468e Mon Sep 17 00:00:00 2001 From: Samraj Date: Mon, 1 Oct 2018 16:53:27 +0530 Subject: [PATCH 1/2] Added token providing option for pagination. From the documentation, the paginating the file using callback won't work in the standalone program. We need to pass the skip token based on the new request. So added the skip token functionality. --- .../BaseDriveItemCollectionRequest.java | 53 ++++++++++++++----- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/microsoft/graph/requests/generated/BaseDriveItemCollectionRequest.java b/src/main/java/com/microsoft/graph/requests/generated/BaseDriveItemCollectionRequest.java index 2a0af2416df..b9c2ff997fa 100644 --- a/src/main/java/com/microsoft/graph/requests/generated/BaseDriveItemCollectionRequest.java +++ b/src/main/java/com/microsoft/graph/requests/generated/BaseDriveItemCollectionRequest.java @@ -5,18 +5,21 @@ // **NOTE** This file was generated by a tool and any changes will be overwritten. package com.microsoft.graph.requests.generated; -import com.microsoft.graph.concurrency.*; -import com.microsoft.graph.core.*; -import com.microsoft.graph.models.extensions.*; -import com.microsoft.graph.models.generated.*; -import com.microsoft.graph.http.*; -import com.microsoft.graph.requests.extensions.*; -import com.microsoft.graph.requests.generated.*; -import com.microsoft.graph.options.*; -import com.microsoft.graph.serializer.*; - -import java.util.Arrays; -import java.util.EnumSet; +import com.microsoft.graph.concurrency.ICallback; +import com.microsoft.graph.concurrency.IExecutors; +import com.microsoft.graph.core.ClientException; +import com.microsoft.graph.core.IBaseClient; +import com.microsoft.graph.http.BaseCollectionRequest; +import com.microsoft.graph.models.extensions.DriveItem; +import com.microsoft.graph.options.Option; +import com.microsoft.graph.options.QueryOption; +import com.microsoft.graph.requests.extensions.DriveItemCollectionPage; +import com.microsoft.graph.requests.extensions.DriveItemCollectionRequest; +import com.microsoft.graph.requests.extensions.DriveItemCollectionRequestBuilder; +import com.microsoft.graph.requests.extensions.DriveItemRequestBuilder; +import com.microsoft.graph.requests.extensions.IDriveItemCollectionPage; +import com.microsoft.graph.requests.extensions.IDriveItemCollectionRequest; +import com.microsoft.graph.requests.extensions.IDriveItemCollectionRequestBuilder; // **NOTE** This file was generated by a tool and any changes will be overwritten. @@ -101,6 +104,19 @@ public IDriveItemCollectionRequest top(final int value) { addQueryOption(new QueryOption("$top", value + "")); return (DriveItemCollectionRequest)this; } + /** + * Add Skip token for pagination + * @param skipToken - Token for pagination + * @return the updated request + * @author K.Samraj + * @since 1.0 + */ + public IDriveItemCollectionRequest skipToken(final String skipToken) { + if(!isBlank(skipToken)) { + addQueryOption(new QueryOption("$skiptoken", skipToken)); + } + return (DriveItemCollectionRequest)this; + } public IDriveItemCollectionPage buildFromResponse(final BaseDriveItemCollectionResponse response) { final IDriveItemCollectionRequestBuilder builder; @@ -113,4 +129,17 @@ public IDriveItemCollectionPage buildFromResponse(final BaseDriveItemCollectionR page.setRawObject(response.getSerializer(), response.getRawObject()); return page; } + + public static boolean isBlank(final CharSequence cs) { + int strLen; + if (cs == null || (strLen = cs.length()) == 0) { + return true; + } + for (int i = 0; i < strLen; i++) { + if (!Character.isWhitespace(cs.charAt(i))) { + return false; + } + } + return true; + } } From 1db00fc3651dc5180d4a1d2335b7dc693d1491a2 Mon Sep 17 00:00:00 2001 From: Samraj Date: Mon, 1 Oct 2018 16:56:46 +0530 Subject: [PATCH 2/2] Adding skip token option for pagination Adding skip token option for pagination --- .../IBaseDriveItemCollectionRequest.java | 83 ++++++++++--------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/microsoft/graph/requests/generated/IBaseDriveItemCollectionRequest.java b/src/main/java/com/microsoft/graph/requests/generated/IBaseDriveItemCollectionRequest.java index f63200a573f..85b87b58c63 100644 --- a/src/main/java/com/microsoft/graph/requests/generated/IBaseDriveItemCollectionRequest.java +++ b/src/main/java/com/microsoft/graph/requests/generated/IBaseDriveItemCollectionRequest.java @@ -4,56 +4,63 @@ package com.microsoft.graph.requests.generated; -import com.microsoft.graph.concurrency.*; -import com.microsoft.graph.core.*; -import com.microsoft.graph.models.extensions.*; -import com.microsoft.graph.models.generated.*; -import com.microsoft.graph.http.*; -import com.microsoft.graph.requests.extensions.*; -import com.microsoft.graph.requests.generated.*; -import com.microsoft.graph.options.*; -import com.microsoft.graph.serializer.*; - -import java.util.Arrays; -import java.util.EnumSet; +import com.microsoft.graph.concurrency.ICallback; +import com.microsoft.graph.core.ClientException; +import com.microsoft.graph.models.extensions.DriveItem; +import com.microsoft.graph.requests.extensions.IDriveItemCollectionPage; +import com.microsoft.graph.requests.extensions.IDriveItemCollectionRequest; // **NOTE** This file was generated by a tool and any changes will be overwritten. /** * The interface for the Base Drive Item Collection Request. */ -public interface IBaseDriveItemCollectionRequest { +public interface IBaseDriveItemCollectionRequest +{ - void get(final ICallback callback); + void get(final ICallback callback); - IDriveItemCollectionPage get() throws ClientException; + IDriveItemCollectionPage get() throws ClientException; - void post(final DriveItem newDriveItem, final ICallback callback); + void post(final DriveItem newDriveItem, final ICallback callback); - DriveItem post(final DriveItem newDriveItem) throws ClientException; + DriveItem post(final DriveItem newDriveItem) throws ClientException; - /** - * Sets the expand clause for the request - * - * @param value the expand clause - * @return the updated request - */ - IDriveItemCollectionRequest expand(final String value); + /** + * Sets the expand clause for the request + * + * @param value + * the expand clause + * @return the updated request + */ + IDriveItemCollectionRequest expand(final String value); - /** - * Sets the select clause for the request - * - * @param value the select clause - * @return the updated request - */ - IDriveItemCollectionRequest select(final String value); + /** + * Sets the select clause for the request + * + * @param value + * the select clause + * @return the updated request + */ + IDriveItemCollectionRequest select(final String value); - /** - * Sets the top value for the request - * - * @param value the max number of items to return - * @return the updated request - */ - IDriveItemCollectionRequest top(final int value); + /** + * Sets the top value for the request + * + * @param value + * the max number of items to return + * @return the updated request + */ + IDriveItemCollectionRequest top(final int value); + /** + * Sets the skip token value for the request + * + * @param skipToken + * value for pagination + * @return the updated request + * @author K.Samraj + * @since 1.0 + */ + IDriveItemCollectionRequest skipToken(String skipToken); }