Skip to content

Commit ddf76cc

Browse files
committed
Merge branch 'dev' into feature/v2
2 parents 2e27d2e + cbb9444 commit ddf76cc

12 files changed

Lines changed: 186 additions & 162 deletions

File tree

‎.azure-pipelines/buildAndPackage.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ steps:
8686
settings.gradle
8787
gradle.properties
8888
**/gradle/**
89-
Scripts/getLatestVersion.ps1
89+
Scripts/**
9090
TargetFolder: '$(Build.ArtifactStagingDirectory)/'
9191

9292
- task: PublishBuildArtifacts@1

‎.azure-pipelines/prValidate.yml‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ steps:
4343
inputs:
4444
debugMode: false
4545

46-
- task: PowerShell@2
47-
condition: and(failed(), eq(variables['Build.SourceBranchName'], 'dev'))
48-
inputs:
49-
filePath: '$(System.DefaultWorkingDirectory)\Scripts\validateMavenVersion.ps1'
50-
pwsh: true
51-
arguments: '-packageName "$(PACKAGE_NAME)" -propertiesPath "$(PROPERTIES_PATH)"'
52-
5346
- task: Gradle@2
5447
inputs:
5548
gradleWrapperFile: 'gradlew'

‎.editorconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[*.java]
2+
indent_style = space
3+
indent_size = 4
4+
insert_final_newline = true
5+
trim_trailing_whitespace = true

‎.github/CODEOWNERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @baywet @ddyett @MichaelMainer @nikithauc @zengin

‎Scripts/incrementMinorVersion.ps1‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
<#
5+
.Synopsis
6+
Increment the minor version string in the gradle.properties if the major,
7+
minor, or patch version hasn't been manually updated.
8+
.Description
9+
Assumptions:
10+
Targets Gradle.properties
11+
This script assumes it is run from the repo root.
12+
Minor version is typically auto-incremented.
13+
14+
#>
15+
16+
function Update-ReadmeVersion([string]$readmeFilePath, [version]$version) {
17+
$readmeFileContent = Get-Content -Path $readmeFilePath -Raw
18+
$readmeFileContent = $readmeFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version.ToString()
19+
Set-Content -Path $readmeFilePath $readmeFileContent
20+
}
21+
22+
function Update-TelemetryVersion([string]$telemetryFilePath, [version]$version) {
23+
$telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw
24+
$telemetryFileContent = $telemetryFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version.ToString()
25+
Set-Content -Path $telemetryFilePath $telemetryFileContent
26+
}
27+
28+
function Update-PackageVersion([string]$propertiesFilePath, [version]$version) {
29+
$propertiesFileContent = Get-Content -Path $propertiesFilePath -Raw
30+
$propertiesFileContent = $propertiesFileContent -replace "mavenMajorVersion\s+=\s+\d{1,}", "mavenMajorVersion = $($version.Major)"
31+
$propertiesFileContent = $propertiesFileContent -replace "mavenMinorVersion\s+=\s+\d{1,}", "mavenMinorVersion = $($version.Minor)"
32+
$propertiesFileContent = $propertiesFileContent -replace "mavenPatchVersion\s+=\s+\d{1,}", "mavenPatchVersion = $($version.Build)"
33+
Set-Content -Path $propertiesFilePath $propertiesFileContent
34+
}
35+
function Get-CurrentTelemetryVersion([string]$telemetryFilePath) {
36+
$telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw
37+
if($telemetryFileContent -match "(\d{1,}\.\d{1,}\.\d{1,})") {
38+
return [version]::Parse($Matches[1])
39+
} else {
40+
Write-Error "Invalid version number format"
41+
return $null;
42+
}
43+
}
44+
45+
function Update-MinorVersionNumber([version]$currentVersion) {
46+
return [version]::new($currentVersion.Major, $currentVersion.Minor + 1, 0);
47+
}
48+
49+
function Update-MinorVersion() {
50+
$readmeFilePath = Join-Path -Path $PWD.ToString() -ChildPath "../readme.md"
51+
$propertiesFilePath = Join-Path -Path $PWD.ToString() -ChildPath "../gradle.properties"
52+
$telemetryFilePath = Join-Path -Path $PWD.ToString() -ChildPath "../src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java"
53+
$currentVersion = Get-CurrentTelemetryVersion -telemetryFilePath $telemetryFilePath
54+
$nextVersion = Update-MinorVersionNumber -currentVersion $currentVersion
55+
Update-ReadmeVersion -version $nextVersion -readmeFilePath $readmeFilePath
56+
Update-TelemetryVersion -version $nextVersion -telemetryFilePath $telemetryFilePath
57+
Update-PackageVersion -version $nextVersion -propertiesFilePath $propertiesFilePath
58+
}
59+
Update-MinorVersion

‎Scripts/validateMavenVersion.ps1‎

Lines changed: 0 additions & 67 deletions
This file was deleted.

‎gradle.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mavenGroupId = com.microsoft.graph
2525
mavenArtifactId = microsoft-graph-core
2626
mavenMajorVersion = 1
2727
mavenMinorVersion = 0
28-
mavenPatchVersion = 5
28+
mavenPatchVersion = 6
2929
mavenArtifactSuffix =
3030
nightliesUrl = http://dl.bintray.com/MicrosoftGraph/Maven
3131

‎pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>com.microsoft.graph</groupId>
1010
<artifactId>microsoft-graph-core</artifactId>
11-
<version>1.0.5</version>
11+
<version>1.0.6</version>
1212
<packaging>pom</packaging>
1313

1414
<dependencies>

‎readme.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Microsoft Graph Core SDK for Java
22

3-
Get started with the Microsoft Graph Core SDK for Java by integrating the [Microsoft Graph API](https://graph.microsoft.io/en-us/getting-started) into your Java and Android application!
3+
Get started with the Microsoft Graph Core SDK for Java by integrating the [Microsoft Graph API](https://developer.microsoft.com/en-us/graph/get-started/java) into your Java and Android application! You can also have a look at the [Javadoc](https://docs.microsoft.com/en-us/java/api/com.microsoft.graph.httpcore?view=graph-core-java)
44

55
## Samples and usage guide
66

@@ -20,7 +20,7 @@ repositories {
2020
2121
dependencies {
2222
// Include the sdk as a dependency
23-
implementation 'com.microsoft.graph:microsoft-graph-core:1.0.5'
23+
implementation 'com.microsoft.graph:microsoft-graph-core:1.0.6'
2424
}
2525
```
2626

@@ -32,7 +32,7 @@ Add the dependency in `dependencies` in pom.xml
3232
<dependency>
3333
<groupId>com.microsoft.graph</groupId>
3434
<artifactId>microsoft-graph-core</artifactId>
35-
<version>1.0.5</version>
35+
<version>1.0.6</version>
3636
</dependency>
3737
```
3838

‎src/main/java/com/microsoft/graph/content/MSBatchRequestContent.java‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.util.List;
77
import java.util.Map;
88
import java.util.concurrent.ThreadLocalRandom;
9+
import java.util.regex.Matcher;
10+
import java.util.regex.Pattern;
911

1012
import javax.annotation.Nullable;
1113
import javax.annotation.Nonnull;
@@ -30,7 +32,7 @@ public class MSBatchRequestContent {
3032

3133
/*
3234
* Creates Batch request content using list provided
33-
*
35+
*
3436
* @param batchRequestStepsArray List of batch steps for batching
3537
*/
3638
public MSBatchRequestContent(@Nonnull final List<MSBatchRequestStep> batchRequestStepsArray) {
@@ -51,7 +53,7 @@ public MSBatchRequestContent() {
5153

5254
/*
5355
* @param batchRequestStep Batch request step adding to batch content
54-
*
56+
*
5557
* @return true or false based on addition or no addition of batch request step
5658
* given
5759
*/
@@ -83,7 +85,7 @@ public String addBatchRequestStep(@Nonnull final Request request, @Nullable fina
8385

8486
/*
8587
* @param requestId Id of Batch request step to be removed
86-
*
88+
*
8789
* @return true or false based on removal or no removal of batch request step
8890
* with given id
8991
*/
@@ -118,13 +120,14 @@ public String getBatchRequestContent() {
118120
return content;
119121
}
120122

123+
private static final Pattern protocolAndHostReplacementPattern = Pattern.compile("(?i)^http[s]?:\\/\\/graph\\.microsoft\\.com\\/(?>v1\\.0|beta)\\/?"); // (?i) case insensitive
121124
private JsonObject getBatchRequestObjectFromRequestStep(final MSBatchRequestStep batchRequestStep) {
122125
final JsonObject contentmap = new JsonObject();
123126
contentmap.add("id", new JsonPrimitive(batchRequestStep.getRequestId()));
124127

125-
final String url = batchRequestStep.getRequest().url().toString()
126-
.replaceAll("https://graph.microsoft.com/v1.0/", "").replaceAll("http://graph.microsoft.com/v1.0/", "")
127-
.replaceAll("https://graph.microsoft.com/beta/", "").replaceAll("http://graph.microsoft.com/beta/", "");
128+
final Matcher protocolAndHostReplacementMatcher = protocolAndHostReplacementPattern.matcher(batchRequestStep.getRequest().url().toString());
129+
130+
final String url = protocolAndHostReplacementMatcher.replaceAll("");
128131
contentmap.add("url", new JsonPrimitive(url));
129132

130133
contentmap.add("method", new JsonPrimitive(batchRequestStep.getRequest().method().toString()));
@@ -183,5 +186,5 @@ private JsonObject requestBodyToJSONObject(final Request request) throws IOExcep
183186
else
184187
return requestBodyElement.getAsJsonObject();
185188
}
186-
189+
187190
}

0 commit comments

Comments
 (0)