Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class MSBatchRequestContent {

/*
* Creates Batch request content using list provided
*
*
* @param batchRequestStepsArray List of batch steps for batching
*/
public MSBatchRequestContent(final List<MSBatchRequestStep> batchRequestStepsArray) {
Expand All @@ -50,7 +50,7 @@ public MSBatchRequestContent() {

/*
* @param batchRequestStep Batch request step adding to batch content
*
*
* @return true or false based on addition or no addition of batch request step
* given
*/
Expand Down Expand Up @@ -81,7 +81,7 @@ public String addBatchRequestStep(final Request request, final String... arrayOf

/*
* @param requestId Id of Batch request step to be removed
*
*
* @return true or false based on removal or no removal of batch request step
* with given id
*/
Expand Down Expand Up @@ -116,18 +116,13 @@ public String getBatchRequestContent() {
}

private static final Pattern protocolAndHostReplacementPattern = Pattern.compile("(?i)^http[s]?:\\/\\/graph\\.microsoft\\.com\\/(?>v1\\.0|beta)\\/?"); // (?i) case insensitive
private Matcher protocolAndHostReplacementMatcher; // not static to avoid multithreading issues as the object is mutable
private JsonObject getBatchRequestObjectFromRequestStep(final MSBatchRequestStep batchRequestStep) {
final JsonObject contentmap = new JsonObject();
contentmap.add("id", new JsonPrimitive(batchRequestStep.getRequestId()));

if(protocolAndHostReplacementMatcher == null) {
protocolAndHostReplacementMatcher = protocolAndHostReplacementPattern.matcher(batchRequestStep.getRequest().url().toString());
} else {
protocolAndHostReplacementMatcher = protocolAndHostReplacementMatcher.reset(batchRequestStep.getRequest().url().toString());
}
final Matcher protocolAndHostReplacementMatcher = protocolAndHostReplacementPattern.matcher(batchRequestStep.getRequest().url().toString());

final String url = protocolAndHostReplacementMatcher.replaceAll("");
final String url = protocolAndHostReplacementMatcher.replaceAll("");
contentmap.add("url", new JsonPrimitive(url));

contentmap.add("method", new JsonPrimitive(batchRequestStep.getRequest().method().toString()));
Expand Down Expand Up @@ -186,5 +181,5 @@ private JsonObject requestBodyToJSONObject(final Request request) throws IOExcep
else
return requestBodyElement.getAsJsonObject();
}

}