diff --git a/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java
index a150fa6f8..9274bb97a 100644
--- a/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java
+++ b/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/BotFrameworkAdapter.java
@@ -41,7 +41,7 @@
import com.microsoft.bot.schema.TokenExchangeState;
import com.microsoft.bot.schema.TokenResponse;
import com.microsoft.bot.schema.TokenStatus;
-import com.microsoft.bot.rest.retry.RetryStrategy;
+import com.microsoft.bot.restclient.retry.RetryStrategy;
import java.util.Collections;
import org.apache.commons.lang3.StringUtils;
diff --git a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MemoryConnectorClient.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MemoryConnectorClient.java
index 6e0320648..d18d99dc4 100644
--- a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MemoryConnectorClient.java
+++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MemoryConnectorClient.java
@@ -3,8 +3,8 @@
import com.microsoft.bot.connector.Attachments;
import com.microsoft.bot.connector.ConnectorClient;
import com.microsoft.bot.connector.Conversations;
-import com.microsoft.bot.rest.RestClient;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.RestClient;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
public class MemoryConnectorClient implements ConnectorClient {
private MemoryConversations conversations = new MemoryConversations();
diff --git a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MockConnectorClient.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MockConnectorClient.java
index cda3dd92f..757c51894 100644
--- a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MockConnectorClient.java
+++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/MockConnectorClient.java
@@ -4,8 +4,8 @@
import com.microsoft.bot.connector.ConnectorClient;
import com.microsoft.bot.connector.Conversations;
import com.microsoft.bot.connector.authentication.AppCredentials;
-import com.microsoft.bot.rest.RestClient;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.RestClient;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
public class MockConnectorClient implements ConnectorClient {
diff --git a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java
index e60272940..c46567d31 100644
--- a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java
+++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/TurnContextTests.java
@@ -8,13 +8,13 @@
import com.microsoft.bot.connector.Attachments;
import com.microsoft.bot.connector.ConnectorClient;
import com.microsoft.bot.connector.Conversations;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ActivityTypes;
import com.microsoft.bot.schema.ConversationAccount;
import com.microsoft.bot.schema.ConversationReference;
import com.microsoft.bot.schema.ResourceResponse;
-import com.microsoft.bot.rest.RestClient;
+import com.microsoft.bot.restclient.RestClient;
import org.junit.Assert;
import org.junit.Test;
diff --git a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/TestBase.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/TestBase.java
index 18d5c90ed..7e0f5b4eb 100644
--- a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/TestBase.java
+++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/base/TestBase.java
@@ -4,13 +4,13 @@
package com.microsoft.bot.builder.base;
import com.microsoft.bot.connector.authentication.MicrosoftAppCredentials;
-import com.microsoft.bot.rest.LogLevel;
-import com.microsoft.bot.rest.RestClient;
-import com.microsoft.bot.rest.ServiceResponseBuilder;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
-import com.microsoft.bot.rest.credentials.TokenCredentials;
-import com.microsoft.bot.rest.interceptors.LoggingInterceptor;
-import com.microsoft.bot.rest.serializer.JacksonAdapter;
+import com.microsoft.bot.restclient.LogLevel;
+import com.microsoft.bot.restclient.RestClient;
+import com.microsoft.bot.restclient.ServiceResponseBuilder;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.credentials.TokenCredentials;
+import com.microsoft.bot.restclient.interceptors.LoggingInterceptor;
+import com.microsoft.bot.restclient.serializer.JacksonAdapter;
import org.junit.*;
import org.junit.rules.TestName;
diff --git a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/teams/TeamsActivityHandlerTests.java b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/teams/TeamsActivityHandlerTests.java
index c656c1627..0dddcac0f 100644
--- a/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/teams/TeamsActivityHandlerTests.java
+++ b/libraries/bot-builder/src/test/java/com/microsoft/bot/builder/teams/TeamsActivityHandlerTests.java
@@ -15,7 +15,7 @@
import com.microsoft.bot.connector.Conversations;
import com.microsoft.bot.connector.authentication.AppCredentials;
import com.microsoft.bot.connector.authentication.MicrosoftAppCredentials;
-import com.microsoft.bot.rest.serializer.JacksonAdapter;
+import com.microsoft.bot.restclient.serializer.JacksonAdapter;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ActivityTypes;
import com.microsoft.bot.schema.ChannelAccount;
diff --git a/libraries/bot-connector/pom.xml b/libraries/bot-connector/pom.xml
index d764843bf..17af92eb6 100644
--- a/libraries/bot-connector/pom.xml
+++ b/libraries/bot-connector/pom.xml
@@ -54,7 +54,7 @@
com.google.guava
guava
- 20.0
+ 30.1-jre
com.squareup.retrofit2
@@ -174,7 +174,7 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- com/microsoft/bot/rest/**,com/microsoft/bot/azure/**
+ com/microsoft/bot/restclient/**
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureAsyncOperation.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureAsyncOperation.java
deleted file mode 100644
index c1f450a1e..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureAsyncOperation.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.microsoft.bot.rest.protocol.SerializerAdapter;
-import okhttp3.ResponseBody;
-import retrofit2.Response;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * The response body contains the status of the specified
- * asynchronous operation, indicating whether it has succeeded, is in
- * progress, or has failed. Note that this status is distinct from the
- * HTTP status code returned for the Get Operation Status operation
- * itself. If the asynchronous operation succeeded, the response body
- * includes the HTTP status code for the successful request. If the
- * asynchronous operation failed, the response body includes the HTTP
- * status code for the failed request, and also includes error
- * information regarding the failure.
- */
-final class AzureAsyncOperation {
- /**
- * Default delay in seconds for long running operations.
- */
- static final int DEFAULT_DELAY = 30;
-
- /**
- * Successful status for long running operations.
- */
- static final String SUCCESS_STATUS = "Succeeded";
-
- /**
- * In progress status for long running operations.
- */
- static final String IN_PROGRESS_STATUS = "InProgress";
-
- /**
- * Failed status for long running operations.
- */
- static final String FAILED_STATUS = "Failed";
-
- /**
- * Canceled status for long running operations.
- */
- static final String CANCELED_STATUS = "Canceled";
-
- /**
- * @return a list of statuses indicating a failed operation
- */
- static List failedStatuses() {
- return Arrays.asList(FAILED_STATUS, CANCELED_STATUS);
- }
-
- /**
- * @return a list of terminal statuses for long running operations
- */
- static List terminalStatuses() {
- return Arrays.asList(FAILED_STATUS, CANCELED_STATUS, SUCCESS_STATUS);
- }
-
- /**
- * The status of the asynchronous request.
- */
- private String status;
-
- /**
- * @return the status of the asynchronous request
- */
- String status() {
- return this.status;
- }
-
- /**
- * Sets the status of the asynchronous request.
- *
- * @param status the status of the asynchronous request.
- */
- void setStatus(String status) {
- this.status = status;
- }
-
- /**
- * If the asynchronous operation failed, the response body includes
- * the HTTP status code for the failed request, and also includes
- * error information regarding the failure.
- */
- private CloudError error;
-
- /**
- * Gets the cloud error.
- *
- * @return the cloud error.
- */
- CloudError getError() {
- return this.error;
- }
-
- /**
- * Sets the cloud error.
- *
- * @param error the cloud error.
- */
- void setError(CloudError error) {
- this.error = error;
- }
-
- /**
- * Async operation in string format.
- */
- private String rawString;
-
- /**
- * @return the raw string
- */
- String rawString() {
- return this.rawString;
- }
-
- /**
- * Creates AzureAsyncOperation from the given HTTP response.
- *
- * @param serializerAdapter the adapter to use for deserialization
- * @param response the response
- * @return the async operation object
- * @throws CloudException if the deserialization fails or response contains invalid body
- */
- static AzureAsyncOperation fromResponse(SerializerAdapter> serializerAdapter, Response response) throws CloudException {
- AzureAsyncOperation asyncOperation = null;
- String rawString = null;
- if (response.body() != null) {
- try {
- rawString = response.body().string();
- asyncOperation = serializerAdapter.deserialize(rawString, AzureAsyncOperation.class);
- } catch (IOException ignore) {
- // Exception will be handled below
- } finally {
- response.body().close();
- }
- }
- if (asyncOperation == null || asyncOperation.status() == null) {
- throw new CloudException("polling response does not contain a valid body: " + rawString, response);
- } else {
- asyncOperation.rawString = rawString;
- }
- return asyncOperation;
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureEnvironment.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureEnvironment.java
deleted file mode 100644
index 9f9f5ed61..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureEnvironment.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.microsoft.bot.rest.protocol.Environment;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * An instance of this class describes an environment in Azure.
- */
-public final class AzureEnvironment implements Environment {
- /** the map of all endpoints. */
- private final Map endpoints;
-
- /**
- * Initializes an instance of AzureEnvironment class.
- *
- * @param endpoints a map storing all the endpoint info
- */
- public AzureEnvironment(Map endpoints) {
- this.endpoints = endpoints;
- }
-
- /**
- * Provides the settings for authentication with Azure.
- */
- public static final AzureEnvironment AZURE = new AzureEnvironment(new HashMap() {{
- put("portalUrl", "http://go.microsoft.com/fwlink/?LinkId=254433");
- put("publishingProfileUrl", "http://go.microsoft.com/fwlink/?LinkId=254432");
- put("managementEndpointUrl", "https://management.core.windows.net/");
- put("resourceManagerEndpointUrl", "https://management.azure.com/");
- put("sqlManagementEndpointUrl", "https://management.core.windows.net:8443/");
- put("sqlServerHostnameSuffix", ".database.windows.net");
- put("galleryEndpointUrl", "https://gallery.azure.com/");
- put("activeDirectoryEndpointUrl", "https://login.microsoftonline.com/");
- put("activeDirectoryResourceId", "https://management.core.windows.net/");
- put("activeDirectoryGraphResourceId", "https://graph.windows.net/");
- put("dataLakeEndpointResourceId", "https://datalake.azure.net/");
- put("activeDirectoryGraphApiVersion", "2013-04-05");
- put("storageEndpointSuffix", ".core.windows.net");
- put("keyVaultDnsSuffix", ".vault.azure.net");
- put("azureDataLakeStoreFileSystemEndpointSuffix", "azuredatalakestore.net");
- put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "azuredatalakeanalytics.net");
- put("azureLogAnalyticsResourceId", "https://api.loganalytics.io/");
- put("azureApplicationInsightsResourceId", "https://api.applicationinsights.io/");
- }});
-
- /**
- * Provides the settings for authentication with Azure China.
- */
- public static final AzureEnvironment AZURE_CHINA = new AzureEnvironment(new HashMap() {{
- put("portalUrl", "http://go.microsoft.com/fwlink/?LinkId=301902");
- put("publishingProfileUrl", "http://go.microsoft.com/fwlink/?LinkID=301774");
- put("managementEndpointUrl", "https://management.core.chinacloudapi.cn/");
- put("resourceManagerEndpointUrl", "https://management.chinacloudapi.cn/");
- put("sqlManagementEndpointUrl", "https://management.core.chinacloudapi.cn:8443/");
- put("sqlServerHostnameSuffix", ".database.chinacloudapi.cn");
- put("galleryEndpointUrl", "https://gallery.chinacloudapi.cn/");
- put("activeDirectoryEndpointUrl", "https://login.chinacloudapi.cn/");
- put("activeDirectoryResourceId", "https://management.core.chinacloudapi.cn/");
- put("activeDirectoryGraphResourceId", "https://graph.chinacloudapi.cn/");
- // TODO: add resource id for the china cloud for datalake once it is defined.
- put("dataLakeEndpointResourceId", "N/A");
- put("activeDirectoryGraphApiVersion", "2013-04-05");
- put("storageEndpointSuffix", ".core.chinacloudapi.cn");
- put("keyVaultDnsSuffix", ".vault.azure.cn");
- // TODO: add dns suffixes for the china cloud for datalake store and datalake analytics once they are defined.
- put("azureDataLakeStoreFileSystemEndpointSuffix", "N/A");
- put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "N/A");
- put("azureLogAnalyticsResourceId", "N/A");
- put("azureApplicationInsightsResourceId", "N/A");
- }});
-
- /**
- * Provides the settings for authentication with Azure US Government.
- */
- public static final AzureEnvironment AZURE_US_GOVERNMENT = new AzureEnvironment(new HashMap() {{
- put("portalUrl", "https://manage.windowsazure.us");
- put("publishingProfileUrl", "https://manage.windowsazure.us/publishsettings/index");
- put("managementEndpointUrl", "https://management.core.usgovcloudapi.net/");
- put("resourceManagerEndpointUrl", "https://management.usgovcloudapi.net/");
- put("sqlManagementEndpointUrl", "https://management.core.usgovcloudapi.net:8443/");
- put("sqlServerHostnameSuffix", ".database.usgovcloudapi.net");
- put("galleryEndpointUrl", "https://gallery.usgovcloudapi.net/");
- put("activeDirectoryEndpointUrl", "https://login.microsoftonline.us/");
- put("activeDirectoryResourceId", "https://management.core.usgovcloudapi.net/");
- put("activeDirectoryGraphResourceId", "https://graph.windows.net/");
- // TODO: add resource id for the US government for datalake once it is defined.
- put("dataLakeEndpointResourceId", "N/A");
- put("activeDirectoryGraphApiVersion", "2013-04-05");
- put("storageEndpointSuffix", ".core.usgovcloudapi.net");
- put("keyVaultDnsSuffix", ".vault.usgovcloudapi.net");
- // TODO: add dns suffixes for the US government for datalake store and datalake analytics once they are defined.
- put("azureDataLakeStoreFileSystemEndpointSuffix", "N/A");
- put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "N/A");
- put("azureLogAnalyticsResourceId", "https://api.loganalytics.us/");
- put("azureApplicationInsightsResourceId", "N/A");
- }});
-
- /**
- * Provides the settings for authentication with Azure Germany.
- */
- public static final AzureEnvironment AZURE_GERMANY = new AzureEnvironment(new HashMap() {{
- put("portalUrl", "http://portal.microsoftazure.de/");
- put("publishingProfileUrl", "https://manage.microsoftazure.de/publishsettings/index");
- put("managementEndpointUrl", "https://management.core.cloudapi.de/");
- put("resourceManagerEndpointUrl", "https://management.microsoftazure.de/");
- put("sqlManagementEndpointUrl", "https://management.core.cloudapi.de:8443/");
- put("sqlServerHostnameSuffix", ".database.cloudapi.de");
- put("galleryEndpointUrl", "https://gallery.cloudapi.de/");
- put("activeDirectoryEndpointUrl", "https://login.microsoftonline.de/");
- put("activeDirectoryResourceId", "https://management.core.cloudapi.de/");
- put("activeDirectoryGraphResourceId", "https://graph.cloudapi.de/");
- // TODO: add resource id for the germany cloud for datalake once it is defined.
- put("dataLakeEndpointResourceId", "N/A");
- put("activeDirectoryGraphApiVersion", "2013-04-05");
- put("storageEndpointSuffix", ".core.cloudapi.de");
- put("keyVaultDnsSuffix", ".vault.microsoftazure.de");
- // TODO: add dns suffixes for the germany cloud for datalake store and datalake analytics once they are defined.
- put("azureDataLakeStoreFileSystemEndpointSuffix", "N/A");
- put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "N/A");
- put("azureLogAnalyticsResourceId", "N/A");
- put("azureApplicationInsightsResourceId", "N/A");
- }});
-
- /**
- * @return the entirety of the endpoints associated with the current environment.
- */
- public Map endpoints() {
- return endpoints;
- }
-
- /**
- * @return the array of known environments to Azure SDK.
- */
- public static AzureEnvironment[] knownEnvironments() {
- List environments = Arrays.asList(AZURE, AZURE_CHINA, AZURE_GERMANY, AZURE_US_GOVERNMENT);
- return environments.toArray(new AzureEnvironment[environments.size()]);
- }
-
- /**
- * @return the management portal URL.
- */
- public String portal() {
- return endpoints.get("portalUrl");
- }
-
- /**
- * @return the publish settings file URL.
- */
- public String publishingProfile() {
- return endpoints.get("publishingProfileUrl");
- }
-
- /**
- * @return the management service endpoint.
- */
- public String managementEndpoint() {
- return endpoints.get("managementEndpointUrl");
- }
-
- /**
- * @return the resource management endpoint.
- */
- public String resourceManagerEndpoint() {
- return endpoints.get("resourceManagerEndpointUrl");
- }
-
- /**
- * @return the sql server management endpoint for mobile commands.
- */
- public String sqlManagementEndpoint() {
- return endpoints.get("sqlManagementEndpointUrl");
- }
-
- /**
- * @return the dns suffix for sql servers.
- */
- public String sqlServerHostnameSuffix() {
- return endpoints.get("sqlServerHostnameSuffix");
- }
-
- /**
- * @return the Active Directory login endpoint.
- */
- public String activeDirectoryEndpoint() {
- return endpoints.get("activeDirectoryEndpointUrl").replaceAll("/$", "") + "/";
- }
-
- /**
- * @return The resource ID to obtain AD tokens for.
- */
- public String activeDirectoryResourceId() {
- return endpoints.get("activeDirectoryResourceId");
- }
-
- /**
- * @return the template gallery endpoint.
- */
- public String galleryEndpoint() {
- return endpoints.get("galleryEndpointUrl");
- }
-
- /**
- * @return the Active Directory resource ID.
- */
- public String graphEndpoint() {
- return endpoints.get("activeDirectoryGraphResourceId");
- }
-
- /**
- * @return the Data Lake resource ID.
- */
- public String dataLakeEndpointResourceId() {
- return endpoints.get("dataLakeEndpointResourceId");
- }
-
- /**
- * @return the Active Directory api version.
- */
- public String activeDirectoryGraphApiVersion() {
- return endpoints.get("activeDirectoryGraphApiVersion");
- }
-
- /**
- * @return the endpoint suffix for storage accounts.
- */
- public String storageEndpointSuffix() {
- return endpoints.get("storageEndpointSuffix");
- }
-
- /**
- * @return the keyvault service dns suffix.
- */
- public String keyVaultDnsSuffix() {
- return endpoints.get("keyVaultDnsSuffix");
- }
-
- /**
- * @return the data lake store filesystem service dns suffix.
- */
- public String azureDataLakeStoreFileSystemEndpointSuffix() {
- return endpoints.get("azureDataLakeStoreFileSystemEndpointSuffix");
- }
-
- /**
- * @return the data lake analytics job and catalog service dns suffix.
- */
- public String azureDataLakeAnalyticsCatalogAndJobEndpointSuffix() {
- return endpoints.get("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix");
- }
-
- /**
- * @return the log analytics endpoint.
- */
- public String logAnalyticsEndpoint() {
- return endpoints.get("azureLogAnalyticsResourceId");
- }
-
- /**
- * @return the log analytics endpoint.
- */
- public String applicationInsightsEndpoint() {
- return endpoints.get("azureApplicationInsightsResourceId");
- }
-
-
- /**
- * The enum representing available endpoints in an environment.
- */
- public enum Endpoint implements Environment.Endpoint {
- /** Azure management endpoint. */
- MANAGEMENT("managementEndpointUrl"),
- /** Azure Resource Manager endpoint. */
- RESOURCE_MANAGER("resourceManagerEndpointUrl"),
- /** Azure SQL endpoint. */
- SQL("sqlManagementEndpointUrl"),
- /** Azure Gallery endpoint. */
- GALLERY("galleryEndpointUrl"),
- /** Active Directory authentication endpoint. */
- ACTIVE_DIRECTORY("activeDirectoryEndpointUrl"),
- /** Azure Active Directory Graph APIs endpoint. */
- GRAPH("activeDirectoryGraphResourceId"),
- /** Key Vault DNS suffix. */
- KEYVAULT("keyVaultDnsSuffix"),
- /** Azure Data Lake Store DNS suffix. */
- DATA_LAKE_STORE("azureDataLakeStoreFileSystemEndpointSuffix"),
- /** Azure Data Lake Analytics DNS suffix. */
- DATA_LAKE_ANALYTICS("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix"),
- /** Azure Log Analytics endpoint. */
- LOG_ANALYTICS("azureLogAnalyticsResourceId"),
- /** Azure Application Insights. */
- APPLICATION_INSIGHTS("azureApplicationInsightsResourceId");
-
- private String field;
-
- Endpoint(String value) {
- this.field = value;
- }
-
- @Override
- public String identifier() {
- return field;
- }
-
- @Override
- public String toString() {
- return field;
- }
- }
-
- /**
- * Get the endpoint URL for the current environment.
- *
- * @param endpoint the endpoint
- * @return the URL
- */
- public String url(Environment.Endpoint endpoint) {
- return endpoints.get(endpoint.identifier());
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureResponseBuilder.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureResponseBuilder.java
deleted file mode 100644
index 0fd1d3399..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureResponseBuilder.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.google.common.reflect.TypeToken;
-import com.microsoft.bot.rest.RestException;
-import com.microsoft.bot.rest.ServiceResponse;
-import com.microsoft.bot.rest.ServiceResponseBuilder;
-import com.microsoft.bot.rest.ServiceResponseWithHeaders;
-import com.microsoft.bot.rest.protocol.ResponseBuilder;
-import com.microsoft.bot.rest.protocol.SerializerAdapter;
-import okhttp3.ResponseBody;
-import retrofit2.Response;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Type;
-
-/**
- * The builder for building a {@link ServiceResponse} customized for Azure.
- *
- * @param the return type from caller.
- * @param the exception to throw in case of error.
- */
-public final class AzureResponseBuilder implements ResponseBuilder {
- /** The base response builder for handling most scenarios. */
- private ServiceResponseBuilder baseBuilder;
-
- /**
- * Create a ServiceResponseBuilder instance.
- *
- * @param serializer the serialization utils to use for deserialization operations
- */
- private AzureResponseBuilder(SerializerAdapter> serializer) {
- baseBuilder = new ServiceResponseBuilder.Factory().newInstance(serializer);
- }
-
- @Override
- public ResponseBuilder register(int statusCode, Type type) {
- baseBuilder.register(statusCode, type);
- return this;
- }
-
- @Override
- public ResponseBuilder registerError(Class extends RestException> type) {
- baseBuilder.registerError(type);
- return this;
- }
-
- @Override
- public ServiceResponse build(Response response) throws IOException {
- return baseBuilder.build(response);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public ServiceResponse buildEmpty(Response response) throws E, IOException {
- int statusCode = response.code();
- if (baseBuilder.isSuccessful(statusCode)) {
- if (new TypeToken(getClass()) { }.getRawType().isAssignableFrom(Boolean.class)) {
- return new ServiceResponse(response).withBody((T) (Object) (statusCode / 100 == 2));
- } else {
- return new ServiceResponse<>(response);
- }
- } else {
- try {
- throw baseBuilder.exceptionType().getConstructor(String.class, Response.class)
- .newInstance("Status code " + statusCode, response);
- } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- throw new IOException("Invalid status code " + statusCode + ", but an instance of " + baseBuilder.exceptionType().getCanonicalName()
- + " cannot be created.", e);
- }
- }
- }
-
- @Override
- public ServiceResponseWithHeaders buildWithHeaders(Response response, Class headerType) throws IOException {
- return baseBuilder.buildWithHeaders(response, headerType);
- }
-
- @Override
- public ServiceResponseWithHeaders buildEmptyWithHeaders(Response response, Class headerType) throws IOException {
- ServiceResponse bodyResponse = buildEmpty(response);
- ServiceResponseWithHeaders baseResponse = baseBuilder.buildEmptyWithHeaders(response, headerType);
- ServiceResponseWithHeaders serviceResponse = new ServiceResponseWithHeaders<>(baseResponse.headers(), bodyResponse.headResponse());
- serviceResponse.withBody(bodyResponse.body());
- return serviceResponse;
- }
-
- /**
- * Specifies whether to throw on 404 responses from a GET call.
- * @param throwOnGet404 true if to throw; false to simply return null. Default is false.
- * @return the response builder itself
- */
- public AzureResponseBuilder withThrowOnGet404(boolean throwOnGet404) {
- baseBuilder.withThrowOnGet404(throwOnGet404);
- return this;
- }
-
- /**
- * A factory to create an Azure response builder.
- */
- public static final class Factory implements ResponseBuilder.Factory {
- @Override
- public AzureResponseBuilder newInstance(final SerializerAdapter> serializerAdapter) {
- return new AzureResponseBuilder(serializerAdapter);
- }
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureServiceClient.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureServiceClient.java
deleted file mode 100644
index d188000ac..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureServiceClient.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.google.common.hash.Hashing;
-import com.microsoft.bot.azure.serializer.AzureJacksonAdapter;
-import com.microsoft.bot.rest.RestClient;
-import com.microsoft.bot.rest.ServiceClient;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
-import okhttp3.OkHttpClient;
-import retrofit2.Retrofit;
-
-import java.net.NetworkInterface;
-import java.util.Enumeration;
-
-/**
- * ServiceClient is the abstraction for accessing REST operations and their payload data types.
- */
-public abstract class AzureServiceClient extends ServiceClient {
- protected AzureServiceClient(String baseUrl, ServiceClientCredentials credentials) {
- this(baseUrl, credentials, new OkHttpClient.Builder(), new Retrofit.Builder());
- }
-
- /**
- * Initializes a new instance of the ServiceClient class.
- *
- * @param baseUrl the service base uri
- * @param credentials the credentials
- * @param clientBuilder the http client builder
- * @param restBuilder the retrofit rest client builder
- */
- protected AzureServiceClient(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) {
- this(new RestClient.Builder(clientBuilder, restBuilder)
- .withBaseUrl(baseUrl)
- .withCredentials(credentials)
- .withSerializerAdapter(new AzureJacksonAdapter())
- .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
- .build());
- }
-
- /**
- * Initializes a new instance of the ServiceClient class.
- *
- * @param restClient the REST client
- */
- protected AzureServiceClient(RestClient restClient) {
- super(restClient);
- }
-
- /**
- * The default User-Agent header. Override this method to override the user agent.
- *
- * @return the user agent string.
- */
- public String userAgent() {
- return String.format("Azure-SDK-For-Java/%s OS:%s MacAddressHash:%s Java:%s",
- getClass().getPackage().getImplementationVersion(),
- OS,
- MAC_ADDRESS_HASH,
- JAVA_VERSION);
- }
-
- private static final String MAC_ADDRESS_HASH;
- private static final String OS;
- private static final String JAVA_VERSION;
-
- static {
- OS = System.getProperty("os.name") + "/" + System.getProperty("os.version");
- String macAddress = "Unknown";
- try {
- Enumeration networks = NetworkInterface.getNetworkInterfaces();
- while (networks.hasMoreElements()) {
- NetworkInterface network = networks.nextElement();
- byte[] mac = network.getHardwareAddress();
-
- if (mac != null) {
- macAddress = Hashing.sha256().hashBytes(mac).toString();
- break;
- }
- }
- } catch (Throwable ignore) {
- // It's okay ignore mac address hash telemetry
- }
- MAC_ADDRESS_HASH = macAddress;
- String version = System.getProperty("java.version");
- JAVA_VERSION = version != null ? version : "Unknown";
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureServiceFuture.java.dep b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureServiceFuture.java.dep
deleted file mode 100644
index 9cd9f80e8..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/AzureServiceFuture.java.dep
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.azure;
-
-import com.microsoft.rest.ServiceFuture;
-import com.microsoft.rest.ServiceResponse;
-import com.microsoft.rest.ServiceResponseWithHeaders;
-import rx.Observable;
-import rx.Subscriber;
-import rx.functions.Func1;
-
-import java.util.List;
-
-/**
- * An instance of this class provides access to the underlying REST call invocation.
- * This class wraps around the Retrofit Call object and allows updates to it in the
- * progress of a long running operation or a paging operation.
- *
- * @param the type of the returning object
- */
-public final class AzureServiceFuture extends ServiceFuture {
- private AzureServiceFuture() {
- }
-
- /**
- * Creates a ServiceCall from a paging operation.
- *
- * @param first the observable to the first page
- * @param next the observable to poll subsequent pages
- * @param callback the client-side callback
- * @param the element type
- * @return the future based ServiceCall
- */
- public static ServiceFuture> fromPageResponse(Observable>> first, final Func1>>> next, final ListOperationCallback callback) {
- final AzureServiceFuture> serviceCall = new AzureServiceFuture<>();
- final PagingSubscriber subscriber = new PagingSubscriber<>(serviceCall, next, callback);
- serviceCall.setSubscription(first
- .single()
- .subscribe(subscriber));
- return serviceCall;
- }
-
- /**
- * Creates a ServiceCall from a paging operation that returns a header response.
- *
- * @param first the observable to the first page
- * @param next the observable to poll subsequent pages
- * @param callback the client-side callback
- * @param the element type
- * @param the header object type
- * @return the future based ServiceCall
- */
- public static ServiceFuture> fromHeaderPageResponse(Observable, V>> first, final Func1, V>>> next, final ListOperationCallback callback) {
- final AzureServiceFuture> serviceCall = new AzureServiceFuture<>();
- final PagingSubscriber subscriber = new PagingSubscriber<>(serviceCall, new Func1>>>() {
- @Override
- public Observable>> call(String s) {
- return next.call(s)
- .map(new Func1, V>, ServiceResponse>>() {
- @Override
- public ServiceResponse> call(ServiceResponseWithHeaders, V> pageVServiceResponseWithHeaders) {
- return pageVServiceResponseWithHeaders;
- }
- });
- }
- }, callback);
- serviceCall.setSubscription(first
- .single()
- .subscribe(subscriber));
- return serviceCall;
- }
-
- /**
- * The subscriber that handles user callback and automatically subscribes to the next page.
- *
- * @param the element type
- */
- private static final class PagingSubscriber extends Subscriber>> {
- private AzureServiceFuture> serviceCall;
- private Func1>>> next;
- private ListOperationCallback callback;
- private ServiceResponse> lastResponse;
-
- PagingSubscriber(final AzureServiceFuture> serviceCall, final Func1>>> next, final ListOperationCallback callback) {
- this.serviceCall = serviceCall;
- this.next = next;
- this.callback = callback;
- }
-
- @Override
- public void onCompleted() {
- // do nothing
- }
-
- @Override
- public void onError(Throwable e) {
- serviceCall.setException(e);
- if (callback != null) {
- callback.failure(e);
- }
- }
-
- @Override
- public void onNext(ServiceResponse> serviceResponse) {
- lastResponse = serviceResponse;
- ListOperationCallback.PagingBehavior behavior = ListOperationCallback.PagingBehavior.CONTINUE;
- if (callback != null) {
- behavior = callback.progress(serviceResponse.body().items());
- if (behavior == ListOperationCallback.PagingBehavior.STOP || serviceResponse.body().nextPageLink() == null) {
- callback.success();
- }
- }
- if (behavior == ListOperationCallback.PagingBehavior.STOP || serviceResponse.body().nextPageLink() == null) {
- serviceCall.set(lastResponse.body().items());
- } else {
- serviceCall.setSubscription(next.call(serviceResponse.body().nextPageLink()).single().subscribe(this));
- }
- }
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/CloudError.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/CloudError.java
deleted file mode 100644
index 627be615d..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/CloudError.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.microsoft.bot.azure.serializer.TypedErrorInfoDeserializer;
-
-/**
- * An instance of this class provides additional information about an http error response.
- */
-public final class CloudError {
- /**
- * The error code parsed from the body of the http error response.
- */
- private String code;
-
- /**
- * The error message parsed from the body of the http error response.
- */
- private String message;
-
- /**
- * The target of the error.
- */
- private String target;
-
- /**
- * Details for the error.
- */
- private List details;
-
- /**
- * Additional error information.
- */
- @JsonDeserialize(contentUsing = TypedErrorInfoDeserializer.class)
- private List additionalInfo;
-
- /**
- * Initializes a new instance of CloudError.
- */
- public CloudError() {
- this.details = new ArrayList();
- }
-
- /**
- * @return the error code parsed from the body of the http error response
- */
- public String code() {
- return code;
- }
-
- /**
- * Sets the error code parsed from the body of the http error response.
- *
- * @param code the error code
- * @return the CloudError object itself
- */
- public CloudError withCode(String code) {
- this.code = code;
- return this;
- }
-
- /**
- * @return the error message
- */
- public String message() {
- return message;
- }
-
- /**
- * Sets the error message parsed from the body of the http error response.
- *
- * @param message the error message
- * @return the CloudError object itself
- */
- public CloudError withMessage(String message) {
- this.message = message;
- return this;
- }
-
- /**
- * @return the target of the error
- */
- public String target() {
- return target;
- }
-
- /**
- * Sets the target of the error.
- *
- * @param target the target of the error
- * @return the CloudError object itself
- */
- public CloudError withTarget(String target) {
- this.target = target;
- return this;
- }
-
- /**
- * @return the details for the error
- */
- public List details() {
- return details;
- }
-
- /**
- * @return the additional error information
- */
- public List additionalInfo() {
- return additionalInfo;
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/CloudException.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/CloudException.java
deleted file mode 100644
index 8f869161b..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/CloudException.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.microsoft.bot.rest.RestException;
-import okhttp3.ResponseBody;
-import retrofit2.Response;
-
-/**
- * Exception thrown for an invalid response with custom error information.
- */
-public final class CloudException extends RestException {
- /**
- * Initializes a new instance of the CloudException class.
- *
- * @param message the exception message or the response content if a message is not available
- * @param response the HTTP response
- */
- public CloudException(final String message, final Response response) {
- super(message, response);
- }
-
- /**
- * Initializes a new instance of the CloudException class.
- *
- * @param message the exception message or the response content if a message is not available
- * @param response the HTTP response
- * @param body the deserialized response body
- */
- public CloudException(final String message, Response response, CloudError body) {
- super(message, response, body);
- }
-
- @Override
- public CloudError body() {
- return (CloudError) super.body();
- }
-
- @Override
- public String toString() {
- String message = super.toString();
- if (body() != null && body().message() != null) {
- message = message + ": " + body().message();
- }
- return message;
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/ListOperationCallback.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/ListOperationCallback.java
deleted file mode 100644
index 79a81855c..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/ListOperationCallback.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.microsoft.bot.rest.ServiceCallback;
-
-import java.util.List;
-
-/**
- * The callback used for client side asynchronous list operations.
- *
- * @param the item type
- */
-public abstract class ListOperationCallback implements ServiceCallback> {
- /**
- * A list result that stores the accumulated resources loaded from server.
- */
- private List result;
-
- /**
- * Number of loaded pages.
- */
- private int pageCount;
-
- /**
- * Creates an instance of ListOperationCallback.
- */
- public ListOperationCallback() {
- this.pageCount = 0;
- }
-
- /**
- * Override this method to handle progressive results.
- * The user is responsible for returning a {@link PagingBehavior} Enum to indicate
- * whether the client should continue loading or stop.
- *
- * @param partial the list of resources from the current request.
- * @return CONTINUE if you want to go on loading, STOP otherwise.
- *
- */
- public abstract PagingBehavior progress(List partial);
-
- /**
- * Get the list result that stores the accumulated resources loaded from server.
- *
- * @return the list of resources.
- */
- public List get() {
- return result;
- }
-
- /**
- * This method is called by the client to load the most recent list of resources.
- * This method should only be called by the service client.
- *
- * @param result the most recent list of resources.
- */
- public void load(List result) {
- ++pageCount;
- if (this.result == null || this.result.isEmpty()) {
- this.result = result;
- } else {
- this.result.addAll(result);
- }
- }
-
- @Override
- public void success(List result) {
- success();
- }
-
- /**
- * Override this method to handle successful REST call results.
- */
- public abstract void success();
-
- /**
- * Get the number of loaded pages.
- *
- * @return the number of pages.
- */
- public int pageCount() {
- return pageCount;
- }
-
- /**
- * An enum to indicate whether the client should continue loading or stop.
- */
- public enum PagingBehavior {
- /**
- * Indicates that the client should continue loading.
- */
- CONTINUE,
- /**
- * Indicates that the client should stop loading.
- */
- STOP
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/LongRunningFinalState.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/LongRunningFinalState.java
deleted file mode 100644
index fc1453d5a..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/LongRunningFinalState.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-/**
- * Describes how to retrieve the final state of a long running operation.
- */
-public enum LongRunningFinalState {
- /**
- * Indicate that no specific action required to retrieve the final state.
- */
- DEFAULT,
- /**
- * Indicate that use azure async operation uri to retrieve the final state.
- */
- AZURE_ASYNC_OPERATION,
- /**
- * Indicate that use location uri to retrieve the final state.
- */
- LOCATION,
- /**
- * Indicate that use original uri to retrieve the final state.
- */
- ORIGINAL_URI
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/LongRunningOperationOptions.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/LongRunningOperationOptions.java
deleted file mode 100644
index 4e18ebdf9..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/LongRunningOperationOptions.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-/**
- * Type representing LRO meta-data present in the x-ms-long-running-operation-options autorest extension.
- */
-public final class LongRunningOperationOptions {
- /**
- * Default instance of this type.
- */
- public static final LongRunningOperationOptions DEFAULT = new LongRunningOperationOptions().withFinalStateVia(LongRunningFinalState.DEFAULT);
-
- /**
- * Describes how to retrieve the final state of the LRO.
- */
- private LongRunningFinalState finalStateVia;
-
- /**
- * @return indicates how to retrieve the final state of LRO.
- */
- public LongRunningFinalState finalStateVia() {
- return this.finalStateVia;
- }
-
- /**
- * Sets LongRunningFinalState value.
- *
- * @param finalStateVia indicates how to retrieve the final state of LRO.
- * @return LongRunningOperationOptions
- */
- public LongRunningOperationOptions withFinalStateVia(LongRunningFinalState finalStateVia) {
- this.finalStateVia = finalStateVia;
- return this;
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/Page.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/Page.java
deleted file mode 100644
index 8849825c9..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/Page.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import java.util.List;
-
-/**
- * Defines a page interface in Azure responses.
- *
- * @param the element type.
- */
-public interface Page {
- /**
- * Gets the link to the next page.
- *
- * @return the link.
- */
- String nextPageLink();
-
- /**
- * Gets the list of items.
- *
- * @return the list of items.
- */
- List items();
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PagedList.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PagedList.java
deleted file mode 100644
index b2eef2e2a..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PagedList.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.microsoft.bot.rest.RestException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-/**
- * Defines a list response from a paging operation. The pages are
- * lazy initialized when an instance of this class is iterated.
- *
- * @param the element type.
- */
-public abstract class PagedList implements List {
- /** The actual items in the list. */
- private List items;
- /** Stores the latest page fetched. */
- private Page currentPage;
- /** Cached page right after the current one. */
- private Page cachedPage;
-
- /**
- * Creates an instance of Pagedlist.
- */
- public PagedList() {
- items = new ArrayList<>();
- }
-
- /**
- * Creates an instance of PagedList from a {@link Page} response.
- *
- * @param page the {@link Page} object.
- */
- public PagedList(Page page) {
- this();
- if (page == null) {
- return;
- }
- List retrievedItems = page.items();
- if (retrievedItems != null) {
- items.addAll(retrievedItems);
- }
- currentPage = page;
- cachePage(page.nextPageLink());
- }
-
- private void cachePage(String nextPageLink) {
- try {
- while (nextPageLink != null && nextPageLink != "") {
- cachedPage = nextPage(nextPageLink);
- if (cachedPage == null) {
- break;
- }
- nextPageLink = cachedPage.nextPageLink();
- if (hasNextPage()) {
- // a legit, non-empty page has been fetched, otherwise keep fetching
- break;
- }
- }
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Override this method to load the next page of items from a next page link.
- *
- * @param nextPageLink the link to get the next page of items.
- * @return the {@link Page} object storing a page of items and a link to the next page.
- * @throws RestException thrown if an error is raised from Azure.
- * @throws IOException thrown if there's any failure in deserialization.
- */
- public abstract Page nextPage(String nextPageLink) throws RestException, IOException;
-
- /**
- * If there are more pages available.
- *
- * @return true if there are more pages to load. False otherwise.
- */
- public boolean hasNextPage() {
- return this.cachedPage != null && this.cachedPage.items() != null && !this.cachedPage.items().isEmpty();
- }
-
- /**
- * Loads a page from next page link.
- * The exceptions are wrapped into Java Runtime exceptions.
- */
- public void loadNextPage() {
- this.currentPage = cachedPage;
- cachedPage = null;
- this.items.addAll(currentPage.items());
- cachePage(currentPage.nextPageLink());
- }
-
- /**
- * Keep loading the next page from the next page link until all items are loaded.
- */
- public void loadAll() {
- while (hasNextPage()) {
- loadNextPage();
- }
- }
-
- /**
- * Gets the latest page fetched.
- *
- * @return the latest page.
- */
- public Page currentPage() {
- return currentPage;
- }
-
- /**
- * Sets the current page.
- *
- * @param currentPage the current page.
- */
- protected void setCurrentPage(Page currentPage) {
- this.currentPage = currentPage;
- List retrievedItems = currentPage.items();
- if (retrievedItems != null) {
- items.addAll(retrievedItems);
- }
- cachePage(currentPage.nextPageLink());
- }
-
- /**
- * The implementation of {@link ListIterator} for PagedList.
- */
- private class ListItr implements ListIterator {
- /**
- * index of next element to return.
- */
- private int nextIndex;
- /**
- * index of last element returned; -1 if no such action happened.
- */
- private int lastRetIndex = -1;
-
- /**
- * Creates an instance of the ListIterator.
- *
- * @param index the position in the list to start.
- */
- ListItr(int index) {
- this.nextIndex = index;
- }
-
- @Override
- public boolean hasNext() {
- return this.nextIndex != items.size() || hasNextPage();
- }
-
- @Override
- public E next() {
- if (this.nextIndex >= items.size()) {
- if (!hasNextPage()) {
- throw new NoSuchElementException();
- } else {
- loadNextPage();
- }
- // Recurse until we load a page with non-zero items.
- return next();
- } else {
- try {
- E nextItem = items.get(this.nextIndex);
- this.lastRetIndex = this.nextIndex;
- this.nextIndex = this.nextIndex + 1;
- return nextItem;
- } catch (IndexOutOfBoundsException ex) {
- // The nextIndex got invalid means a different instance of iterator
- // removed item from this index.
- throw new ConcurrentModificationException();
- }
- }
- }
-
- @Override
- public void remove() {
- if (this.lastRetIndex < 0) {
- throw new IllegalStateException();
- } else {
- try {
- items.remove(this.lastRetIndex);
- this.nextIndex = this.lastRetIndex;
- this.lastRetIndex = -1;
- } catch (IndexOutOfBoundsException ex) {
- throw new ConcurrentModificationException();
- }
- }
- }
-
- @Override
- public boolean hasPrevious() {
- return this.nextIndex != 0;
- }
-
- @Override
- public E previous() {
- int i = this.nextIndex - 1;
- if (i < 0) {
- throw new NoSuchElementException();
- } else if (i >= items.size()) {
- throw new ConcurrentModificationException();
- } else {
- try {
- this.nextIndex = i;
- this.lastRetIndex = i;
- return items.get(this.lastRetIndex);
- } catch (IndexOutOfBoundsException ex) {
- throw new ConcurrentModificationException();
- }
- }
- }
-
- @Override
- public int nextIndex() {
- return this.nextIndex;
- }
-
- @Override
- public int previousIndex() {
- return this.nextIndex - 1;
- }
-
- @Override
- public void set(E e) {
- if (this.lastRetIndex < 0) {
- throw new IllegalStateException();
- } else {
- try {
- items.set(this.lastRetIndex, e);
- } catch (IndexOutOfBoundsException ex) {
- throw new ConcurrentModificationException();
- }
- }
- }
-
- @Override
- public void add(E e) {
- try {
- items.add(this.nextIndex, e);
- this.nextIndex = this.nextIndex + 1;
- this.lastRetIndex = -1;
- } catch (IndexOutOfBoundsException ex) {
- throw new ConcurrentModificationException();
- }
- }
- }
-
- @Override
- public int size() {
- loadAll();
- return items.size();
- }
-
- @Override
- public boolean isEmpty() {
- return items.isEmpty() && !hasNextPage();
- }
-
- @Override
- public boolean contains(Object o) {
- return indexOf(o) >= 0;
- }
-
- @Override
- public Iterator iterator() {
- return new ListItr(0);
- }
-
- @Override
- public Object[] toArray() {
- loadAll();
- return items.toArray();
- }
-
- @Override
- public T[] toArray(T[] a) {
- loadAll();
- return items.toArray(a);
- }
-
- @Override
- public boolean add(E e) {
- return items.add(e);
- }
-
- @Override
- public boolean remove(Object o) {
- return items.remove(o);
- }
-
- @Override
- public boolean containsAll(Collection> c) {
- for (Object e : c) {
- if (!contains(e)) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean addAll(Collection extends E> c) {
- return items.addAll(c);
- }
-
- @Override
- public boolean addAll(int index, Collection extends E> c) {
- return items.addAll(index, c);
- }
-
- @Override
- public boolean removeAll(Collection> c) {
- return items.removeAll(c);
- }
-
- @Override
- public boolean retainAll(Collection> c) {
- return items.retainAll(c);
- }
-
- @Override
- public void clear() {
- items.clear();
- }
-
- @Override
- public E get(int index) {
- while (index >= items.size() && hasNextPage()) {
- loadNextPage();
- }
- return items.get(index);
- }
-
- @Override
- public E set(int index, E element) {
- return items.set(index, element);
- }
-
- @Override
- public void add(int index, E element) {
- items.add(index, element);
- }
-
- @Override
- public E remove(int index) {
- return items.remove(index);
- }
-
- @Override
- public int indexOf(Object o) {
- int index = 0;
- if (o == null) {
- for (E item : this) {
- if (item == null) {
- return index;
- }
- ++index;
- }
- } else {
- for (E item : this) {
- if (item == o) {
- return index;
- }
- ++index;
- }
- }
- return -1;
- }
-
- @Override
- public int lastIndexOf(Object o) {
- loadAll();
- return items.lastIndexOf(o);
- }
-
- @Override
- public ListIterator listIterator() {
- return new ListItr(0);
- }
-
- @Override
- public ListIterator listIterator(int index) {
- while (index >= items.size() && hasNextPage()) {
- loadNextPage();
- }
- return new ListItr(index);
- }
-
- @Override
- public List subList(int fromIndex, int toIndex) {
- while ((fromIndex >= items.size()
- || toIndex >= items.size())
- && hasNextPage()) {
- loadNextPage();
- }
- return items.subList(fromIndex, toIndex);
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PolicyViolation.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PolicyViolation.java
deleted file mode 100644
index 97cd10a04..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PolicyViolation.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import java.io.IOException;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.MapperFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * An instance of this class provides Azure policy violation information.
- */
-public class PolicyViolation extends TypedErrorInfo {
- /**
- * Policy violation error details.
- */
- private PolicyViolationErrorInfo policyErrorInfo;
-
- /**
- * Initializes a new instance of PolicyViolation.
- * @param type the error type
- * @param policyErrorInfo the error details
- * @throws JsonParseException if the policyErrorInfo has invalid content.
- * @throws JsonMappingException if the policyErrorInfo's JSON does not match the expected schema.
- * @throws IOException if an IO error occurs.
- */
- public PolicyViolation(String type, ObjectNode policyErrorInfo) throws JsonParseException, JsonMappingException, IOException {
- super(type, policyErrorInfo);
- ObjectMapper objectMapper = new ObjectMapper();
- objectMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
- this.policyErrorInfo = objectMapper.readValue(policyErrorInfo.toString(), PolicyViolationErrorInfo.class);
- }
-
- /**
- * @return the policy violation error details.
- */
- public PolicyViolationErrorInfo policyErrorInfo() {
- return policyErrorInfo;
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PolicyViolationErrorInfo.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PolicyViolationErrorInfo.java
deleted file mode 100644
index 3b102c780..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PolicyViolationErrorInfo.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import java.util.HashMap;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * An instance of this class provides Azure policy violation information.
- */
-public class PolicyViolationErrorInfo {
- /**
- * The policy definition id.
- */
- private String policyDefinitionId;
-
- /**
- * The policy set definition id.
- */
- private String policySetDefinitionId;
-
- /**
- * The policy definition instance id inside a policy set.
- */
- private String policyDefinitionReferenceId;
-
- /**
- * The policy set definition name.
- */
- private String policySetDefinitionName;
-
- /**
- * The policy definition name.
- */
- private String policyDefinitionName;
-
- /**
- * The policy definition action.
- */
- private String policyDefinitionEffect;
-
- /**
- * The policy assignment id.
- */
- private String policyAssignmentId;
-
- /**
- * The policy assignment name.
- */
- private String policyAssignmentName;
-
- /**
- * The policy assignment display name.
- */
- private String policyAssignmentDisplayName;
-
- /**
- * The policy assignment scope.
- */
- private String policyAssignmentScope;
-
- /**
- * The policy assignment parameters.
- */
- private HashMap policyAssignmentParameters;
-
- /**
- * The policy definition display name.
- */
- private String policyDefinitionDisplayName;
-
- /**
- * The policy set definition display name.
- */
- private String policySetDefinitionDisplayName;
-
- /**
- * @return the policy definition id.
- */
- public String getPolicyDefinitionId() {
- return policyDefinitionId;
- }
-
- /**
- * @return the policy set definition id.
- */
- public String getPolicySetDefinitionId() {
- return policySetDefinitionId;
- }
-
- /**
- * @return the policy definition instance id inside a policy set.
- */
- public String getPolicyDefinitionReferenceId() {
- return policyDefinitionReferenceId;
- }
-
- /**
- * @return the policy set definition name.
- */
- public String getPolicySetDefinitionName() {
- return policySetDefinitionName;
- }
-
- /**
- * @return the policy definition name.
- */
- public String getPolicyDefinitionName() {
- return policyDefinitionName;
- }
-
- /**
- * @return the policy definition action.
- */
- public String getPolicyDefinitionEffect() {
- return policyDefinitionEffect;
- }
-
- /**
- * @return the policy assignment id.
- */
- public String getPolicyAssignmentId() {
- return policyAssignmentId;
- }
-
- /**
- * @return the policy assignment name.
- */
- public String getPolicyAssignmentName() {
- return policyAssignmentName;
- }
-
- /**
- * @return the policy assignment display name.
- */
- public String getPolicyAssignmentDisplayName() {
- return policyAssignmentDisplayName;
- }
-
- /**
- * @return the policy assignment scope.
- */
- public String getPolicyAssignmentScope() {
- return policyAssignmentScope;
- }
-
- /**
- * @return the policy assignment parameters.
- */
- public HashMap getPolicyAssignmentParameters() {
- return policyAssignmentParameters;
- }
-
- /**
- * @return the policy definition display name.
- */
- public String getPolicyDefinitionDisplayName() {
- return policyDefinitionDisplayName;
- }
-
- /**
- * @return the policy set definition display name.
- */
- public String getPolicySetDefinitionDisplayName() {
- return policySetDefinitionDisplayName;
- }
-
- /**
- * An instance of this class provides policy parameter value.
- */
- public static class PolicyParameter {
- private JsonNode value;
-
- /**
- * @return the parameter value.
- */
- public JsonNode getValue() {
- return value;
- }
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PollingState.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PollingState.java
deleted file mode 100644
index 0c5a1d5fd..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/PollingState.java
+++ /dev/null
@@ -1,590 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
-import com.microsoft.bot.rest.protocol.SerializerAdapter;
-import com.microsoft.bot.rest.serializer.Base64UrlSerializer;
-import com.microsoft.bot.rest.serializer.ByteArraySerializer;
-import com.microsoft.bot.rest.serializer.HeadersSerializer;
-import okhttp3.ResponseBody;
-import retrofit2.Response;
-
-import java.io.IOException;
-import java.lang.reflect.Type;
-
-/**
- * An instance of this class defines polling status of a long running operation.
- *
- * @param the type of the resource the operation returns.
- */
-public class PollingState {
- /** The HTTP method used to initiate the long running operation. **/
- private String initialHttpMethod;
- /** The polling status. */
- private String status;
- /** The HTTP status code. */
- private int statusCode = DEFAULT_STATUS_CODE;
- /** The link in 'Azure-AsyncOperation' header. */
- private String azureAsyncOperationHeaderLink;
- /** The link in 'Location' Header. */
- private String locationHeaderLink;
- /** The default timeout interval between two polling operations. */
- private int defaultRetryTimeout;
- /** The timeout interval between two polling operation. **/
- private int retryTimeout;
- /** The resource uri on which PUT or PATCH operation is applied. **/
- private String putOrPatchResourceUri;
- /** The logging context. **/
- private String loggingContext;
- /** indicate how to retrieve the final state of LRO. **/
- private LongRunningFinalState finalStateVia;
-
- // Non-serializable properties
- //
- /** The logging context header name. **/
- @JsonIgnore
- private static final String LOGGING_HEADER = "x-ms-logging-context";
- /** The statusCode that is used when no statusCode has been set. */
- @JsonIgnore
- private static final int DEFAULT_STATUS_CODE = 0;
- /** The Retrofit response object. */
- @JsonIgnore
- private Response response;
- /** The response resource object. */
- @JsonIgnore
- private T resource;
- /** The type of the response resource object. */
- @JsonIgnore
- private Type resourceType;
- /** The error during the polling operations. */
- @JsonIgnore
- private CloudError error;
- /** The adapter for a custom serializer. */
- @JsonIgnore
- private SerializerAdapter> serializerAdapter;
-
- /**
- * Default constructor.
- */
- PollingState() {
- }
-
- /**
- * Creates a polling state.
- *
- * @param response the response from Retrofit REST call that initiate the long running operation.
- * @param lroOptions long running operation options.
- * @param defaultRetryTimeout the long running operation retry timeout.
- * @param resourceType the type of the resource the long running operation returns
- * @param serializerAdapter the adapter for the Jackson object mapper
- * @param the result type
- * @return the polling state
- * @throws IOException thrown by deserialization
- */
- public static PollingState create(Response response, LongRunningOperationOptions lroOptions, int defaultRetryTimeout, Type resourceType, SerializerAdapter> serializerAdapter) throws IOException {
- PollingState pollingState = new PollingState<>();
- pollingState.initialHttpMethod = response.raw().request().method();
- pollingState.defaultRetryTimeout = defaultRetryTimeout;
- pollingState.withResponse(response);
- pollingState.resourceType = resourceType;
- pollingState.serializerAdapter = serializerAdapter;
- pollingState.loggingContext = response.raw().request().header(LOGGING_HEADER);
- pollingState.finalStateVia = lroOptions.finalStateVia();
-
- String responseContent = null;
- PollingResource resource = null;
- if (response.body() != null) {
- responseContent = response.body().string();
- response.body().close();
- }
- if (responseContent != null && !responseContent.isEmpty()) {
- pollingState.resource = serializerAdapter.deserialize(responseContent, resourceType);
- resource = serializerAdapter.deserialize(responseContent, PollingResource.class);
- }
- final int statusCode = pollingState.response.code();
- if (resource != null && resource.properties != null
- && resource.properties.provisioningState != null) {
- pollingState.withStatus(resource.properties.provisioningState, statusCode);
- } else {
- switch (statusCode) {
- case 202:
- pollingState.withStatus(AzureAsyncOperation.IN_PROGRESS_STATUS, statusCode);
- break;
- case 204:
- case 201:
- case 200:
- pollingState.withStatus(AzureAsyncOperation.SUCCESS_STATUS, statusCode);
- break;
- default:
- pollingState.withStatus(AzureAsyncOperation.FAILED_STATUS, statusCode);
- }
- }
- return pollingState;
- }
-
- /**
- * Creates PollingState from the json string.
- *
- * @param serializedPollingState polling state as json string
- * @param the result that the poll operation produces
- * @return the polling state
- */
- public static PollingState createFromJSONString(String serializedPollingState) {
- ObjectMapper mapper = initMapper(new ObjectMapper());
- PollingState pollingState;
- try {
- pollingState = mapper.readValue(serializedPollingState, PollingState.class);
- } catch (IOException exception) {
- throw new RuntimeException(exception);
- }
- return pollingState;
- }
-
- /**
- * Creates PollingState from another polling state.
- *
- * @param other other polling state
- * @param result the final result of the LRO
- * @param the result that the poll operation produces
- * @return the polling state
- */
- public static PollingState createFromPollingState(PollingState> other, ResultT result) {
- PollingState pollingState = new PollingState<>();
- pollingState.resource = result;
- pollingState.initialHttpMethod = other.initialHttpMethod();
- pollingState.status = other.status();
- pollingState.statusCode = other.statusCode();
- pollingState.azureAsyncOperationHeaderLink = other.azureAsyncOperationHeaderLink();
- pollingState.locationHeaderLink = other.locationHeaderLink();
- pollingState.putOrPatchResourceUri = other.putOrPatchResourceUri();
- pollingState.defaultRetryTimeout = other.defaultRetryTimeout;
- pollingState.retryTimeout = other.retryTimeout;
- pollingState.loggingContext = other.loggingContext;
- pollingState.finalStateVia = other.finalStateVia;
- return pollingState;
- }
-
- /**
- * @return the polling state in json string format
- */
- public String serialize() {
- ObjectMapper mapper = initMapper(new ObjectMapper());
- try {
- return mapper.writeValueAsString(this);
- } catch (JsonProcessingException exception) {
- throw new RuntimeException(exception);
- }
- }
-
- /**
- * Gets the resource.
- *
- * @return the resource.
- */
- public T resource() {
- return resource;
- }
-
- /**
- * Gets the operation response.
- *
- * @return the operation response.
- */
- public Response response() {
- return this.response;
- }
-
- /**
- * Gets the polling status.
- *
- * @return the polling status.
- */
- public String status() {
- return status;
- }
-
- /**
- * Gets the polling HTTP status code.
- *
- * @return the polling HTTP status code.
- */
- public int statusCode() {
- return statusCode;
- }
-
- /**
- * Gets the value captured from Azure-AsyncOperation header.
- *
- * @return the link in the header.
- */
- public String azureAsyncOperationHeaderLink() {
- if (azureAsyncOperationHeaderLink != null && !azureAsyncOperationHeaderLink.isEmpty()) {
- return azureAsyncOperationHeaderLink;
- }
- return null;
- }
-
- /**
- * Gets the value captured from Location header.
- *
- * @return the link in the header.
- */
- public String locationHeaderLink() {
- if (locationHeaderLink != null && !locationHeaderLink.isEmpty()) {
- return locationHeaderLink;
- }
- return null;
- }
-
- /**
- * Updates the polling state from a PUT or PATCH operation.
- *
- * @param response the response from Retrofit REST call
- * @throws CloudException thrown if the response is invalid
- * @throws IOException thrown by deserialization
- */
- void updateFromResponseOnPutPatch(Response response) throws CloudException, IOException {
- String responseContent = null;
- if (response.body() != null) {
- responseContent = response.body().string();
- response.body().close();
- }
-
- if (responseContent == null || responseContent.isEmpty()) {
- throw new CloudException("polling response does not contain a valid body", response);
- }
-
- PollingResource resource = serializerAdapter.deserialize(responseContent, PollingResource.class);
- final int statusCode = response.code();
- if (resource != null && resource.properties != null && resource.properties.provisioningState != null) {
- this.withStatus(resource.properties.provisioningState, statusCode);
- } else {
- this.withStatus(AzureAsyncOperation.SUCCESS_STATUS, statusCode);
- }
-
- CloudError error = new CloudError();
- this.withErrorBody(error);
- error.withCode(this.status());
- error.withMessage("Long running operation failed");
- this.withResponse(response);
- this.withResource(serializerAdapter.deserialize(responseContent, resourceType));
- }
-
- /**
- * Updates the polling state from a DELETE or POST operation.
- *
- * @param response the response from Retrofit REST call
- * @throws IOException thrown by deserialization
- */
-
- void updateFromResponseOnDeletePost(Response response) throws IOException {
- this.withResponse(response);
- String responseContent = null;
- if (response.body() != null) {
- responseContent = response.body().string();
- response.body().close();
- }
- this.withResource(serializerAdapter.deserialize(responseContent, resourceType));
- withStatus(AzureAsyncOperation.SUCCESS_STATUS, response.code());
- }
-
- /**
- * Gets long running operation delay in milliseconds.
- *
- * @return the delay in milliseconds.
- */
- int delayInMilliseconds() {
- if (this.retryTimeout >= 0) {
- return this.retryTimeout;
- }
- if (this.defaultRetryTimeout >= 0) {
- return this.defaultRetryTimeout * 1000;
- }
- return AzureAsyncOperation.DEFAULT_DELAY * 1000;
- }
-
- /**
- * @return the uri of the resource on which the LRO PUT or PATCH applied.
- */
- String putOrPatchResourceUri() {
- return this.putOrPatchResourceUri;
- }
-
- /**
- * @return true if the status this state hold represents terminal status.
- */
- boolean isStatusTerminal() {
- for (String terminalStatus : AzureAsyncOperation.terminalStatuses()) {
- if (terminalStatus.equalsIgnoreCase(this.status())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @return true if the status this state hold is represents failed status.
- */
- boolean isStatusFailed() {
- for (String failedStatus : AzureAsyncOperation.failedStatuses()) {
- if (failedStatus.equalsIgnoreCase(this.status())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @return true if the status this state represents is succeeded status.
- */
- boolean isStatusSucceeded() {
- return AzureAsyncOperation.SUCCESS_STATUS.equalsIgnoreCase(this.status());
- }
-
- boolean resourcePending() {
- boolean resourcePending = statusCode() != 204
- && isStatusSucceeded()
- && resource() == null
- && resourceType() != Void.class
- && locationHeaderLink() != null;
- if (resourcePending) {
- // Keep current behaviour for backward-compact
- return true;
- } else {
- return this.finalStateVia() == LongRunningFinalState.LOCATION;
- }
- }
-
- /**
- * Gets the logging context.
- *
- * @return the logging context
- */
- String loggingContext() {
- return loggingContext;
- }
-
- /**
- * Sets the polling status.
- *
- * @param status the polling status.
- * @throws IllegalArgumentException thrown if status is null.
- */
- PollingState withStatus(String status) throws IllegalArgumentException {
- return withStatus(status, DEFAULT_STATUS_CODE);
- }
-
- /**
- * Sets the polling status.
- *
- * @param status the polling status.
- * @param statusCode the HTTP status code
- * @throws IllegalArgumentException thrown if status is null.
- */
- PollingState withStatus(String status, int statusCode) throws IllegalArgumentException {
- if (status == null) {
- throw new IllegalArgumentException("Status is null.");
- }
- this.status = status;
- this.statusCode = statusCode;
- return this;
- }
-
- /**
- * Sets the last operation response.
- *
- * @param response the last operation response.
- */
- PollingState withResponse(Response response) {
- this.response = response;
- withPollingUrlFromResponse(response);
- withPollingRetryTimeoutFromResponse(response);
- return this;
- }
-
- PollingState withPollingUrlFromResponse(Response response) {
- if (response != null) {
- String asyncHeader = response.headers().get("Azure-AsyncOperation");
- String locationHeader = response.headers().get("Location");
- if (asyncHeader != null) {
- this.azureAsyncOperationHeaderLink = asyncHeader;
- }
- if (locationHeader != null) {
- this.locationHeaderLink = locationHeader;
- }
- }
- return this;
- }
-
- PollingState withPollingRetryTimeoutFromResponse(Response response) {
- if (this.response != null && response.headers().get("Retry-After") != null) {
- retryTimeout = Integer.parseInt(response.headers().get("Retry-After")) * 1000;
- return this;
- }
- this.retryTimeout = -1;
- return this;
- }
-
- PollingState withPutOrPatchResourceUri(final String uri) {
- this.putOrPatchResourceUri = uri;
- return this;
- }
-
- /**
- * Sets the resource.
- *
- * @param resource the resource.
- */
- PollingState withResource(T resource) {
- this.resource = resource;
- return this;
- }
-
- /**
- * @return the resource type
- */
- Type resourceType() {
- return resourceType;
- }
-
- /**
- * @return describes how to retrieve the final result of long running operation.
- */
- LongRunningFinalState finalStateVia() {
- // FinalStateVia is supported only for POST LRO at the moment.
- if (this.initialHttpMethod().equalsIgnoreCase("POST") && resourceType() != Void.class
- && this.locationHeaderLink() != null
- && this.azureAsyncOperationHeaderLink() != null
- && this.finalStateVia == LongRunningFinalState.LOCATION) {
-
- // Consider final-state-via option only if both headers are provided on the wire otherwise
- // there is nothing to disambiguate.
- // A POST LRO can be tracked only using Location or AsyncOperation Header.
- // If AsyncOperationHeader is present then anyway polling will be performed using
- // it and there is no point in making one additional call to retrieve state using
- // async operation uri anyway. Hence we consider only LongRunningFinalState.LOCATION.
- return LongRunningFinalState.LOCATION;
- }
- return LongRunningFinalState.DEFAULT;
- }
-
- /**
- * Sets resource type.
- *
- * param resourceType the resource type
- */
- PollingState withResourceType(Type resourceType) {
- this.resourceType = resourceType;
- return this;
- }
-
- /**
- * Gets {@link CloudError} from current instance.
- *
- * @return the cloud error.
- */
- CloudError errorBody() {
- return error;
- }
-
- /**
- * Sets {@link CloudError} from current instance.
- *
- * @param error the cloud error.
- */
- PollingState withErrorBody(CloudError error) {
- this.error = error;
- return this;
- }
-
- /**
- * Sets the serializer adapter.
- *
- * @param serializerAdapter the serializer adapter.
- */
- PollingState withSerializerAdapter(SerializerAdapter> serializerAdapter) {
- this.serializerAdapter = serializerAdapter;
- return this;
- }
-
- /**
- * @return the http method used to initiate the long running operation.
- */
- String initialHttpMethod() {
- return this.initialHttpMethod;
- }
-
- /**
- * If status is in failed state then throw CloudException.
- */
- void throwCloudExceptionIfInFailedState() {
- if (this.isStatusFailed()) {
- if (this.errorBody() != null) {
- throw new CloudException("Async operation failed with provisioning state: " + this.status(), this.response(), this.errorBody());
- } else {
- throw new CloudException("Async operation failed with provisioning state: " + this.status(), this.response());
- }
- }
- }
-
- /**
- * Initializes an object mapper.
- *
- * @param mapper the mapper to initialize
- * @return the initialized mapper
- */
- private static ObjectMapper initMapper(ObjectMapper mapper) {
- mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
- .configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, true)
- .configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
- .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
- .configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true)
- .setSerializationInclusion(JsonInclude.Include.NON_NULL)
- .registerModule(new ParameterNamesModule())
- .registerModule(new Jdk8Module())
- .registerModule(new JavaTimeModule())
- .registerModule(ByteArraySerializer.getModule())
- .registerModule(Base64UrlSerializer.getModule())
- .registerModule(HeadersSerializer.getModule());
- mapper.setVisibility(mapper.getSerializationConfig().getDefaultVisibilityChecker()
- .withFieldVisibility(JsonAutoDetect.Visibility.ANY)
- .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
- .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
- .withIsGetterVisibility(JsonAutoDetect.Visibility.NONE));
- return mapper;
- }
-
- /**
- * An instance of this class describes the status of a long running operation
- * and is returned from server each time.
- */
- private static class PollingResource {
- /** Inner properties object. */
- @JsonProperty(value = "properties")
- private Properties properties;
-
- /**
- * Inner properties class.
- */
- private static class Properties {
- /** The provisioning state of the resource. */
- @JsonProperty(value = "provisioningState")
- private String provisioningState;
- }
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/ProxyResource.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/ProxyResource.java
deleted file mode 100644
index bbdd0e6d6..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/ProxyResource.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * The Proxy Resource model.
- */
-public class ProxyResource {
- /**
- * Resource Id.
- */
- @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
- private String id;
-
- /**
- * Resource name.
- */
- @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
- private String name;
-
- /**
- * Resource type.
- */
- @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
- private String type;
-
- /**
- * Get the id value.
- *
- * @return the id value
- */
- public String id() {
- return this.id;
- }
-
- /**
- * Get the name value.
- *
- * @return the name value
- */
- public String name() {
- return this.name;
- }
-
- /**
- * Get the type value.
- *
- * @return the type value
- */
- public String type() {
- return this.type;
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/Resource.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/Resource.java
deleted file mode 100644
index cad012f2a..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/Resource.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.Map;
-
-/**
- * The Resource model.
- */
-public class Resource extends ProxyResource {
- /**
- * Resource location.
- */
- @JsonProperty(required = true)
- private String location;
-
- /**
- * Resource tags.
- */
- private Map tags;
-
- /**
- * Get the location value.
- *
- * @return the location value
- */
- public String location() {
- return this.location;
- }
-
- /**
- * Set the location value.
- *
- * @param location the location value to set
- * @return the resource itself
- */
- public Resource withLocation(String location) {
- this.location = location;
- return this;
- }
-
- /**
- * Get the tags value.
- *
- * @return the tags value
- */
- public Map getTags() {
- return this.tags;
- }
-
- /**
- * Set the tags value.
- *
- * @param tags the tags value to set
- * @return the resource itself
- */
- public Resource withTags(Map tags) {
- this.tags = tags;
- return this;
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/SubResource.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/SubResource.java
deleted file mode 100644
index 9b9f03339..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/SubResource.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-/**
- * The SubResource model.
- */
-public class SubResource {
- /**
- * Resource Id.
- */
- private String id;
-
- /**
- * Get the id value.
- *
- * @return the id value
- */
- public String id() {
- return this.id;
- }
-
- /**
- * Set the id value.
- *
- * @param id the id value to set
- * @return the sub resource itself
- */
- public SubResource withId(String id) {
- this.id = id;
- return this;
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/TypedErrorInfo.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/TypedErrorInfo.java
deleted file mode 100644
index 2351f3aef..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/TypedErrorInfo.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * An instance of this class provides Azure error type and information.
- */
-public class TypedErrorInfo {
- /**
- * The error type.
- */
- private String type;
-
- /**
- * The error information.
- */
- private ObjectNode info;
-
- /**
- * Initializes a new instance of TypedErrorInfo.
- * @param type the error type.
- * @param info the error information.
- */
- public TypedErrorInfo(String type, ObjectNode info) {
- this.type = type;
- this.info = info;
- }
-
- /**
- * @return the error type.
- */
- public String type() {
- return type;
- }
-
- /**
- * @return the error information.
- */
- public ObjectNode info() {
- return info;
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/credentials/AzureTokenCredentials.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/credentials/AzureTokenCredentials.java
deleted file mode 100644
index e0a32eb1f..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/credentials/AzureTokenCredentials.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure.credentials;
-
-import com.microsoft.bot.azure.AzureEnvironment;
-import com.microsoft.bot.azure.AzureEnvironment.Endpoint;
-import com.microsoft.bot.rest.credentials.TokenCredentials;
-import okhttp3.Authenticator;
-import okhttp3.OkHttpClient;
-import okhttp3.Request;
-import okhttp3.Response;
-import okhttp3.Route;
-
-import javax.net.ssl.SSLSocketFactory;
-import java.io.IOException;
-import java.net.Proxy;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * AzureTokenCredentials represents a credentials object with access to Azure
- * Resource management.
- */
-public abstract class AzureTokenCredentials extends TokenCredentials {
- private final AzureEnvironment environment;
- private final String domain;
- private String defaultSubscription;
-
- private Proxy proxy;
- private SSLSocketFactory sslSocketFactory;
-
- /**
- * Initializes a new instance of the AzureTokenCredentials.
- *
- * @param environment the Azure environment to use
- * @param domain the tenant or domain the credential is authorized to
- */
- public AzureTokenCredentials(AzureEnvironment environment, String domain) {
- super("Bearer", null);
- this.environment = (environment == null) ? AzureEnvironment.AZURE : environment;
- this.domain = domain;
- }
-
- @Override
- protected final String getToken(Request request) throws IOException {
- String host = request.url().toString().toLowerCase();
- String resource = environment().managementEndpoint();
- for (Map.Entry endpoint : environment().endpoints().entrySet()) {
- if (host.contains(endpoint.getValue())) {
- if (endpoint.getKey().equals(Endpoint.KEYVAULT.identifier())) {
- resource = String.format("https://%s/", endpoint.getValue().replaceAll("^\\.*", ""));
- break;
- } else if (endpoint.getKey().equals(Endpoint.GRAPH.identifier())) {
- resource = environment().graphEndpoint();
- break;
- } else if (endpoint.getKey().equals(Endpoint.LOG_ANALYTICS.identifier())) {
- resource = environment().logAnalyticsEndpoint();
- break;
- } else if (endpoint.getKey().equals(Endpoint.APPLICATION_INSIGHTS.identifier())) {
- resource = environment().applicationInsightsEndpoint();
- break;
- } else if (endpoint.getKey().equals(Endpoint.DATA_LAKE_STORE.identifier())
- || endpoint.getKey().equals(Endpoint.DATA_LAKE_ANALYTICS.identifier())) {
- resource = environment().dataLakeEndpointResourceId();
- break;
- }
- }
- }
- return getToken(resource);
- }
-
- /**
- * Override this method to provide the mechanism to get a token.
- *
- * @param resource the resource the access token is for
- * @return the token to access the resource
- * @throws IOException exceptions from IO
- */
- public abstract String getToken(String resource) throws IOException;
-
- /**
- * Override this method to provide the domain or tenant ID the token is valid in.
- *
- * @return the domain or tenant ID string
- */
- public String domain() {
- return domain;
- }
-
- /**
- * @return the environment details the credential has access to.
- */
- public AzureEnvironment environment() {
- return environment;
- }
-
- /**
- * @return The default subscription ID, if any
- */
- public String defaultSubscriptionId() {
- return defaultSubscription;
- }
-
- /**
- * Set default subscription ID.
- *
- * @param subscriptionId the default subscription ID.
- * @return the credentials object itself.
- */
- public AzureTokenCredentials withDefaultSubscriptionId(String subscriptionId) {
- this.defaultSubscription = subscriptionId;
- return this;
- }
-
- /**
- * @return the proxy being used for accessing Active Directory.
- */
- public Proxy proxy() {
- return proxy;
- }
-
- /**
- * @return the ssl socket factory.
- */
- public SSLSocketFactory sslSocketFactory() {
- return sslSocketFactory;
- }
-
- /**
- * @param proxy the proxy being used for accessing Active Directory
- * @return the credential itself
- */
- public AzureTokenCredentials withProxy(Proxy proxy) {
- this.proxy = proxy;
- return this;
- }
-
- /**
- * @param sslSocketFactory the ssl socket factory
- * @return the credential itself
- */
- public AzureTokenCredentials withSslSocketFactory(SSLSocketFactory sslSocketFactory) {
- this.sslSocketFactory = sslSocketFactory;
- return this;
- }
-
- @Override
- public void applyCredentialsFilter(OkHttpClient.Builder clientBuilder) {
- clientBuilder.interceptors().add(new AzureTokenCredentialsInterceptor(this));
- clientBuilder.authenticator(new Authenticator() {
- @Override
- public Request authenticate(Route route, Response response) throws IOException {
- String authenticateHeader = response.header("WWW-Authenticate");
- if (authenticateHeader != null && !authenticateHeader.isEmpty()) {
- Pattern pattern = Pattern.compile("resource=\"([a-zA-Z0-9.:/-_]+)\"");
- Matcher matcher = pattern.matcher(authenticateHeader);
- if (matcher.find()) {
- String resource = matcher.group(1);
- return response.request().newBuilder()
- .header("Authorization", "Bearer " + getToken(resource))
- .build();
- }
- }
- // Otherwise cannot satisfy the challenge
- return null;
- }
- });
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/credentials/AzureTokenCredentialsInterceptor.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/credentials/AzureTokenCredentialsInterceptor.java
deleted file mode 100644
index 8e11fa31c..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/credentials/AzureTokenCredentialsInterceptor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure.credentials;
-
-import okhttp3.Interceptor;
-import okhttp3.Request;
-import okhttp3.Response;
-
-import java.io.IOException;
-
-/**
- * Token credentials filter for placing a token credential into request headers.
- */
-public final class AzureTokenCredentialsInterceptor implements Interceptor {
- /**
- * The credentials instance to apply to the HTTP client pipeline.
- */
- private AzureTokenCredentials credentials;
-
- /**
- * Initialize a TokenCredentialsFilter class with a
- * TokenCredentials credential.
- *
- * @param credentials a TokenCredentials instance
- */
- AzureTokenCredentialsInterceptor(AzureTokenCredentials credentials) {
- this.credentials = credentials;
- }
-
- @Override
- public Response intercept(Chain chain) throws IOException {
- String token = credentials.getToken(chain.request());
- Request newRequest = chain.request().newBuilder()
- .header("Authorization", "Bearer " + token)
- .build();
- return chain.proceed(newRequest);
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/credentials/package-info.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/credentials/package-info.java
deleted file mode 100644
index aa6d63128..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/credentials/package-info.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * The package contains the credentials classes required for AutoRest generated
- * Azure clients to compile and function. To learn more about AutoRest generator,
- * see https://github.com/azure/autorest.
- */
-package com.microsoft.bot.azure.credentials;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/package-info.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/package-info.java
deleted file mode 100644
index 7e6fe3a95..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/package-info.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * The package contains the runtime classes required for AutoRest generated
- * Azure clients to compile and function. To learn more about AutoRest generator,
- * see https://github.com/azure/autorest.
- */
-package com.microsoft.bot.azure;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/AzureJacksonAdapter.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/AzureJacksonAdapter.java
deleted file mode 100644
index 5c9d9adc8..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/AzureJacksonAdapter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure.serializer;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.microsoft.bot.rest.protocol.SerializerAdapter;
-import com.microsoft.bot.rest.serializer.JacksonAdapter;
-
-/**
- * A serialization helper class overriding {@link JacksonAdapter} with extra
- * functionality useful for Azure operations.
- */
-public final class AzureJacksonAdapter extends JacksonAdapter implements SerializerAdapter {
- /**
- * Creates an instance of the Azure flavored Jackson adapter.
- */
- public AzureJacksonAdapter() {
- super();
- serializer().registerModule(CloudErrorDeserializer.getModule(simpleMapper()));
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/CloudErrorDeserializer.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/CloudErrorDeserializer.java
deleted file mode 100644
index 386beb43d..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/CloudErrorDeserializer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure.serializer;
-
-import com.fasterxml.jackson.core.JsonFactory;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.MapperFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.module.SimpleModule;
-import com.microsoft.bot.azure.CloudError;
-
-import java.io.IOException;
-
-/**
- * Custom serializer for serializing {@link CloudError} objects.
- */
-final class CloudErrorDeserializer extends JsonDeserializer {
- /** Object mapper for default deserializations. */
- private ObjectMapper mapper;
-
- /**
- * Creates an instance of CloudErrorDeserializer.
- *
- * @param mapper the object mapper for default deserializations.
- */
- private CloudErrorDeserializer(ObjectMapper mapper) {
- mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
- this.mapper = mapper;
- }
-
- /**
- * Gets a module wrapping this serializer as an adapter for the Jackson
- * ObjectMapper.
- *
- * @param mapper the object mapper for default deserializations.
- * @return a simple module to be plugged onto Jackson ObjectMapper.
- */
- static SimpleModule getModule(ObjectMapper mapper) {
- SimpleModule module = new SimpleModule();
- module.addDeserializer(CloudError.class, new CloudErrorDeserializer(mapper));
- return module;
- }
-
- @Override
- public CloudError deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
- p.setCodec(mapper);
- JsonNode errorNode = p.readValueAsTree();
-
- if (errorNode == null) {
- return null;
- }
- if (errorNode.get("error") != null) {
- errorNode = errorNode.get("error");
- }
-
- JsonParser parser = new JsonFactory().createParser(errorNode.toString());
- parser.setCodec(mapper);
- return parser.readValueAs(CloudError.class);
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/TypedErrorInfoDeserializer.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/TypedErrorInfoDeserializer.java
deleted file mode 100644
index efcb60459..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/TypedErrorInfoDeserializer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.azure.serializer;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonDeserializer;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.microsoft.bot.azure.PolicyViolation;
-import com.microsoft.bot.azure.TypedErrorInfo;
-
-/**
- * Custom serializer for serializing {@link TypedErrorInfo} objects.
- */
-public class TypedErrorInfoDeserializer extends JsonDeserializer {
- private static final String TYPE_FIELD_NAME = "type";
- private static final String INFO_FIELD_NAME = "info";
-
- @Override
- public TypedErrorInfo deserialize(JsonParser p, DeserializationContext ctxt)
- throws IOException, JsonProcessingException {
- JsonNode errorInfoNode = p.readValueAsTree();
- if (errorInfoNode == null) {
- return null;
- }
-
- JsonNode typeNode = errorInfoNode.get(TYPE_FIELD_NAME);
- JsonNode infoNode = errorInfoNode.get(INFO_FIELD_NAME);
- if (typeNode == null || infoNode == null) {
- Iterator fieldNames = errorInfoNode.fieldNames();
- while (fieldNames.hasNext()) {
- String fieldName = fieldNames.next();
- if (typeNode == null && TYPE_FIELD_NAME.equalsIgnoreCase(fieldName)) {
- typeNode = errorInfoNode.get(fieldName);
-
- }
-
- if (infoNode == null && INFO_FIELD_NAME.equalsIgnoreCase(fieldName)) {
- infoNode = errorInfoNode.get(fieldName);
-
- }
- }
- }
-
- if (typeNode == null || infoNode == null || !(infoNode instanceof ObjectNode)) {
- return null;
- }
-
- // deserialize to any strongly typed error defined
- switch (typeNode.asText()) {
- case "PolicyViolation":
- return new PolicyViolation(typeNode.asText(), (ObjectNode) infoNode);
-
- default:
- return new TypedErrorInfo(typeNode.asText(), (ObjectNode) infoNode);
- }
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/package-info.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/package-info.java
deleted file mode 100644
index 0e35c7905..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/azure/serializer/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * The package contains classes that handle serialization and deserialization
- * for the REST call payloads in Azure.
- */
-package com.microsoft.bot.azure.serializer;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/ConnectorClient.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/ConnectorClient.java
index 8d38e6a09..168439e3b 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/ConnectorClient.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/ConnectorClient.java
@@ -10,8 +10,8 @@
package com.microsoft.bot.connector;
-import com.microsoft.bot.rest.RestClient;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.RestClient;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
/**
* The interface for ConnectorClient class.
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/Conversations.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/Conversations.java
index fb2b43e7a..bd45a8675 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/Conversations.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/Conversations.java
@@ -210,7 +210,7 @@ default CompletableFuture replyToActivity(Activity activity) {
* @param conversationId Conversation ID
* @param activityId activityId to delete
* @throws IllegalArgumentException thrown if parameters fail the validation
- * @return the {@link com.microsoft.bot.rest.ServiceResponse} object if
+ * @return the {@link com.microsoft.bot.restclient.ServiceResponse} object if
* successful.
*/
CompletableFuture deleteActivity(String conversationId, String activityId);
@@ -244,7 +244,7 @@ default CompletableFuture replyToActivity(Activity activity) {
* @param conversationId Conversation ID
* @param memberId ID of the member to delete from this conversation
* @throws IllegalArgumentException thrown if parameters fail the validation
- * @return the {@link com.microsoft.bot.rest.ServiceResponse} object if
+ * @return the {@link com.microsoft.bot.restclient.ServiceResponse} object if
* successful.
*/
CompletableFuture deleteConversationMember(String conversationId, String memberId);
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/authentication/AppCredentials.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/authentication/AppCredentials.java
index 4f0fcd8c3..cf638239c 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/authentication/AppCredentials.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/authentication/AppCredentials.java
@@ -4,7 +4,7 @@
package com.microsoft.bot.connector.authentication;
import com.microsoft.aad.msal4j.IAuthenticationResult;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
import okhttp3.OkHttpClient;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.LoggerFactory;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/ErrorResponseException.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/ErrorResponseException.java
index 247e4893a..ce40b6f09 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/ErrorResponseException.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/ErrorResponseException.java
@@ -6,7 +6,7 @@
package com.microsoft.bot.connector.rest;
-import com.microsoft.bot.rest.RestException;
+import com.microsoft.bot.restclient.RestException;
import com.microsoft.bot.schema.ErrorResponse;
import okhttp3.ResponseBody;
import retrofit2.Response;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestAttachments.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestAttachments.java
index f714b526e..ed713763e 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestAttachments.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestAttachments.java
@@ -10,7 +10,7 @@
import com.microsoft.bot.connector.Attachments;
import com.google.common.reflect.TypeToken;
import com.microsoft.bot.schema.AttachmentInfo;
-import com.microsoft.bot.rest.ServiceResponse;
+import com.microsoft.bot.restclient.ServiceResponse;
import java.io.InputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestBotSignIn.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestBotSignIn.java
index 47bb35564..9628de4e9 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestBotSignIn.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestBotSignIn.java
@@ -8,7 +8,7 @@
import retrofit2.Retrofit;
import com.microsoft.bot.connector.BotSignIn;
-import com.microsoft.bot.rest.ServiceResponse;
+import com.microsoft.bot.restclient.ServiceResponse;
import java.util.concurrent.CompletableFuture;
import okhttp3.ResponseBody;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestConnectorClient.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestConnectorClient.java
index 2e934e1d4..831e126f7 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestConnectorClient.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestConnectorClient.java
@@ -6,16 +6,16 @@
package com.microsoft.bot.connector.rest;
-import com.microsoft.bot.azure.AzureResponseBuilder;
-import com.microsoft.bot.azure.AzureServiceClient;
-import com.microsoft.bot.azure.serializer.AzureJacksonAdapter;
import com.microsoft.bot.connector.Attachments;
import com.microsoft.bot.connector.ConnectorClient;
import com.microsoft.bot.connector.Conversations;
import com.microsoft.bot.connector.UserAgent;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
-import com.microsoft.bot.rest.RestClient;
-import com.microsoft.bot.rest.retry.RetryStrategy;
+import com.microsoft.bot.restclient.ServiceClient;
+import com.microsoft.bot.restclient.ServiceResponseBuilder;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.RestClient;
+import com.microsoft.bot.restclient.retry.RetryStrategy;
+import com.microsoft.bot.restclient.serializer.JacksonAdapter;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
@@ -35,7 +35,7 @@
* accomplished with JWT Bearer tokens, and is described in detail in the
* [Connector Authentication](/en-us/restapi/authentication) document.
*/
-public class RestConnectorClient extends AzureServiceClient implements ConnectorClient {
+public class RestConnectorClient extends ServiceClient implements ConnectorClient {
private static final int RETRY_TIMEOUT = 30;
/**
@@ -281,8 +281,8 @@ public static RestClient.Builder getDefaultRestClientBuilder(
return new RestClient.Builder(new OkHttpClient.Builder(), new Retrofit.Builder())
.withBaseUrl(baseUrl)
.withCredentials(credentials)
- .withSerializerAdapter(new AzureJacksonAdapter())
- .withResponseBuilderFactory(new AzureResponseBuilder.Factory());
+ .withSerializerAdapter(new JacksonAdapter())
+ .withResponseBuilderFactory(new ServiceResponseBuilder.Factory());
}
/**
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestConversations.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestConversations.java
index 44a18a432..ce39d99c3 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestConversations.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestConversations.java
@@ -6,7 +6,7 @@
package com.microsoft.bot.connector.rest;
-import com.microsoft.bot.azure.AzureResponseBuilder;
+import com.microsoft.bot.restclient.ServiceResponseBuilder;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.AttachmentData;
import com.microsoft.bot.schema.ChannelAccount;
@@ -19,8 +19,8 @@
import retrofit2.Retrofit;
import com.microsoft.bot.connector.Conversations;
import com.google.common.reflect.TypeToken;
-import com.microsoft.bot.rest.ServiceResponse;
-import com.microsoft.bot.rest.Validator;
+import com.microsoft.bot.restclient.ServiceResponse;
+import com.microsoft.bot.restclient.Validator;
import java.io.IOException;
import java.net.HttpURLConnection;
@@ -607,7 +607,7 @@ private ServiceResponse getConversationMemberDelegate(
Response response
) throws ErrorResponseException, IOException, IllegalArgumentException {
- return ((AzureResponseBuilder) client.restClient()
+ return ((ServiceResponseBuilder) client.restClient()
.responseBuilderFactory()
.newInstance(client.serializerAdapter())
.register(HttpURLConnection.HTTP_OK, new TypeToken() {
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestOAuthClient.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestOAuthClient.java
index a1119b190..01b11d6e7 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestOAuthClient.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestOAuthClient.java
@@ -1,16 +1,16 @@
package com.microsoft.bot.connector.rest;
-import com.microsoft.bot.azure.AzureServiceClient;
import com.microsoft.bot.connector.BotSignIn;
import com.microsoft.bot.connector.OAuthClient;
import com.microsoft.bot.connector.UserToken;
-import com.microsoft.bot.rest.RestClient;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.RestClient;
+import com.microsoft.bot.restclient.ServiceClient;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
/**
* Rest OAuth client.
*/
-public class RestOAuthClient extends AzureServiceClient implements OAuthClient {
+public class RestOAuthClient extends ServiceClient implements OAuthClient {
/**
* The BotSignIns object to access its operations.
*/
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestTeamsConnectorClient.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestTeamsConnectorClient.java
index 0fb043f45..040ada972 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestTeamsConnectorClient.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestTeamsConnectorClient.java
@@ -6,15 +6,15 @@
package com.microsoft.bot.connector.rest;
-import com.microsoft.bot.azure.AzureResponseBuilder;
-import com.microsoft.bot.azure.AzureServiceClient;
-import com.microsoft.bot.azure.serializer.AzureJacksonAdapter;
import com.microsoft.bot.connector.UserAgent;
import com.microsoft.bot.connector.teams.TeamsConnectorClient;
import com.microsoft.bot.connector.teams.TeamsOperations;
-import com.microsoft.bot.rest.RestClient;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
-import com.microsoft.bot.rest.retry.RetryStrategy;
+import com.microsoft.bot.restclient.RestClient;
+import com.microsoft.bot.restclient.ServiceClient;
+import com.microsoft.bot.restclient.ServiceResponseBuilder;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.retry.RetryStrategy;
+import com.microsoft.bot.restclient.serializer.JacksonAdapter;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
@@ -34,7 +34,7 @@
* accomplished with JWT Bearer tokens, and is described in detail in the
* [Connector Authentication](/en-us/restapi/authentication) document.
*/
-public class RestTeamsConnectorClient extends AzureServiceClient implements TeamsConnectorClient {
+public class RestTeamsConnectorClient extends ServiceClient implements TeamsConnectorClient {
private static final int RETRY_TIMEOUT = 30;
/** Gets or sets the preferred language for the response. */
@@ -259,8 +259,8 @@ public static RestClient.Builder getDefaultRestClientBuilder(
return new RestClient.Builder(new OkHttpClient.Builder(), new Retrofit.Builder())
.withBaseUrl(baseUrl)
.withCredentials(credentials)
- .withSerializerAdapter(new AzureJacksonAdapter())
- .withResponseBuilderFactory(new AzureResponseBuilder.Factory());
+ .withSerializerAdapter(new JacksonAdapter())
+ .withResponseBuilderFactory(new ServiceResponseBuilder.Factory());
}
/**
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestTeamsOperations.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestTeamsOperations.java
index 9f5210fd9..b3a96346a 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestTeamsOperations.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestTeamsOperations.java
@@ -8,7 +8,7 @@
import com.google.common.reflect.TypeToken;
import com.microsoft.bot.connector.teams.TeamsOperations;
-import com.microsoft.bot.rest.ServiceResponse;
+import com.microsoft.bot.restclient.ServiceResponse;
import com.microsoft.bot.schema.teams.ConversationList;
import com.microsoft.bot.schema.teams.TeamDetails;
import com.microsoft.bot.schema.teams.TeamsMeetingParticipant;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestUserToken.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestUserToken.java
index 8ea25134c..b79504d65 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestUserToken.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/rest/RestUserToken.java
@@ -12,8 +12,8 @@
import com.microsoft.bot.schema.AadResourceUrls;
import com.microsoft.bot.schema.TokenResponse;
import com.microsoft.bot.schema.TokenStatus;
-import com.microsoft.bot.rest.ServiceResponse;
-import com.microsoft.bot.rest.Validator;
+import com.microsoft.bot.restclient.ServiceResponse;
+import com.microsoft.bot.restclient.Validator;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/teams/TeamsConnectorClient.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/teams/TeamsConnectorClient.java
index 9b3af4342..97e135c97 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/teams/TeamsConnectorClient.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/connector/teams/TeamsConnectorClient.java
@@ -1,7 +1,7 @@
package com.microsoft.bot.connector.teams;
-import com.microsoft.bot.rest.RestClient;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.RestClient;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
/**
* Teams operations.
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/DateTimeRfc1123.java.dep b/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/DateTimeRfc1123.java.dep
deleted file mode 100644
index 4201472f6..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/DateTimeRfc1123.java.dep
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.rest;
-
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
-import java.util.Locale;
-
-/**
- * Simple wrapper over joda.time.DateTime used for specifying RFC1123 format during serialization/deserialization.
- */
-public final class DateTimeRfc1123 {
- /**
- * The pattern of the datetime used for RFC1123 datetime format.
- */
- private static final DateTimeFormatter RFC1123_DATE_TIME_FORMATTER =
- DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss 'GMT'").withZoneUTC().withLocale(Locale.US);
-
- /**
- * The actual datetime object.
- */
- private final DateTime dateTime;
-
- /**
- * Creates a new DateTimeRfc1123 object with the specified DateTime.
- * @param dateTime The DateTime object to wrap.
- */
- public DateTimeRfc1123(DateTime dateTime) {
- this.dateTime = dateTime;
- }
-
- /**
- * Creates a new DateTimeRfc1123 object with the specified DateTime.
- * @param formattedString The datetime string in RFC1123 format
- */
- public DateTimeRfc1123(String formattedString) {
- this.dateTime = DateTime.parse(formattedString, RFC1123_DATE_TIME_FORMATTER);
- }
-
- /**
- * Returns the underlying DateTime.
- * @return The underlying DateTime.
- */
- public DateTime dateTime() {
- if (this.dateTime == null) {
- return null;
- }
- return this.dateTime;
- }
-
- @Override
- public String toString() {
- return RFC1123_DATE_TIME_FORMATTER.print(this.dateTime);
- }
-
- @Override
- public int hashCode() {
- return this.dateTime.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
-
- if (!(obj instanceof DateTimeRfc1123)) {
- return false;
- }
-
- DateTimeRfc1123 rhs = (DateTimeRfc1123) obj;
- return this.dateTime.equals(rhs.dateTime());
- }
-}
\ No newline at end of file
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceClient.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceClient.java
deleted file mode 100644
index d93efb43a..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceClient.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.bot.rest;
-
-import com.microsoft.bot.rest.protocol.SerializerAdapter;
-import com.microsoft.bot.rest.serializer.JacksonAdapter;
-import okhttp3.OkHttpClient;
-import retrofit2.Retrofit;
-
-/**
- * ServiceClient is the abstraction for accessing REST operations and their payload data types.
- */
-public abstract class ServiceClient {
- /**
- * The RestClient instance storing all information needed for making REST calls.
- */
- private RestClient restClient;
-
- /**
- * Initializes a new instance of the ServiceClient class.
- *
- * @param baseUrl the service endpoint
- */
- protected ServiceClient(String baseUrl) {
- this(baseUrl, new OkHttpClient.Builder(), new Retrofit.Builder());
- }
-
- /**
- * Initializes a new instance of the ServiceClient class.
- *
- * @param baseUrl the service base uri
- * @param clientBuilder the http client builder
- * @param restBuilder the retrofit rest client builder
- */
- protected ServiceClient(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) {
- this(new RestClient.Builder(clientBuilder, restBuilder)
- .withBaseUrl(baseUrl)
- .withResponseBuilderFactory(new ServiceResponseBuilder.Factory())
- .withSerializerAdapter(new JacksonAdapter())
- .build());
- }
-
- /**
- * Initializes a new instance of the ServiceClient class.
- *
- * @param restClient the REST client
- */
- protected ServiceClient(RestClient restClient) {
- this.restClient = restClient;
- }
-
- /**
- * @return the {@link RestClient} instance.
- */
- public RestClient restClient() {
- return restClient;
- }
-
- /**
- * @return the Retrofit instance.
- */
- public Retrofit retrofit() {
- return restClient.retrofit();
- }
-
- /**
- * @return the HTTP client.
- */
- public OkHttpClient httpClient() {
- return this.restClient.httpClient();
- }
-
- /**
- * @return the adapter to a Jackson {@link com.fasterxml.jackson.databind.ObjectMapper}.
- */
- public SerializerAdapter> serializerAdapter() {
- return this.restClient.serializerAdapter();
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceFuture.java.dep b/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceFuture.java.dep
deleted file mode 100644
index 50fc8f564..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceFuture.java.dep
+++ /dev/null
@@ -1,216 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.rest;
-
-import com.google.common.util.concurrent.AbstractFuture;
-import rx.Completable;
-import rx.Observable;
-import rx.Subscription;
-import rx.functions.Action0;
-import rx.functions.Action1;
-
-/**
- * An instance of this class provides access to the underlying REST call invocation.
- * This class wraps around the Retrofit Call object and allows updates to it in the
- * progress of a long running operation or a paging operation.
- *
- * @param the type of the returning object
- */
-public class ServiceFuture extends AbstractFuture {
- /**
- * The Retrofit method invocation.
- */
- private Subscription subscription;
-
- protected ServiceFuture() {
- }
-
- /**
- * Creates a ServiceCall from an observable object.
- *
- * @param observable the observable to create from
- * @param the type of the response
- * @return the created ServiceCall
- */
- public static ServiceFuture fromResponse(final Observable> observable) {
- final ServiceFuture serviceFuture = new ServiceFuture<>();
- serviceFuture.subscription = observable
- .last()
- .subscribe(new Action1>() {
- @Override
- public void call(ServiceResponse t) {
- serviceFuture.set(t.body());
- }
- }, new Action1() {
- @Override
- public void call(Throwable throwable) {
- serviceFuture.setException(throwable);
- }
- });
- return serviceFuture;
- }
-
- /**
- * Creates a ServiceCall from an observable object and a callback.
- *
- * @param observable the observable to create from
- * @param callback the callback to call when events happen
- * @param the type of the response
- * @return the created ServiceCall
- */
- public static ServiceFuture fromResponse(final Observable> observable, final ServiceCallback callback) {
- final ServiceFuture serviceFuture = new ServiceFuture<>();
- serviceFuture.subscription = observable
- .last()
- .subscribe(new Action1>() {
- @Override
- public void call(ServiceResponse t) {
- if (callback != null) {
- callback.success(t.body());
- }
- serviceFuture.set(t.body());
- }
- }, new Action1() {
- @Override
- public void call(Throwable throwable) {
- if (callback != null) {
- callback.failure(throwable);
- }
- serviceFuture.setException(throwable);
- }
- });
- return serviceFuture;
- }
-
- /**
- * Creates a ServiceFuture from an observable object and a callback.
- *
- * @param observable the observable to create from
- * @param callback the callback to call when events happen
- * @param the type of the response
- * @return the created ServiceFuture
- */
- public static ServiceFuture fromBody(final Observable observable, final ServiceCallback callback) {
- final ServiceFuture serviceFuture = new ServiceFuture<>();
- serviceFuture.subscription = observable
- .last()
- .subscribe(new Action1() {
- @Override
- public void call(T t) {
- if (callback != null) {
- callback.success(t);
- }
- serviceFuture.set(t);
- }
- }, new Action1() {
- @Override
- public void call(Throwable throwable) {
- if (callback != null) {
- callback.failure(throwable);
- }
- serviceFuture.setException(throwable);
- }
- });
- return serviceFuture;
- }
-
- /**
- * Creates a ServiceFuture from an Completable object and a callback.
- *
- * @param completable the completable to create from
- * @param callback the callback to call when event happen
- * @return the created ServiceFuture
- */
- public static ServiceFuture fromBody(final Completable completable, final ServiceCallback callback) {
- final ServiceFuture serviceFuture = new ServiceFuture<>();
- completable.subscribe(new Action0() {
- Void value = null;
- @Override
- public void call() {
- if (callback != null) {
- callback.success(value);
- }
- serviceFuture.set(value);
- }
- }, new Action1() {
- @Override
- public void call(Throwable throwable) {
- if (callback != null) {
- callback.failure(throwable);
- }
- serviceFuture.setException(throwable);
- }
- });
- return serviceFuture;
- };
-
- /**
- * Creates a ServiceCall from an observable and a callback for a header response.
- *
- * @param observable the observable of a REST call that returns JSON in a header
- * @param callback the callback to call when events happen
- * @param the type of the response body
- * @param the type of the response header
- * @return the created ServiceCall
- */
- public static ServiceFuture fromHeaderResponse(final Observable> observable, final ServiceCallback callback) {
- final ServiceFuture serviceFuture = new ServiceFuture<>();
- serviceFuture.subscription = observable
- .last()
- .subscribe(new Action1>() {
- @Override
- public void call(ServiceResponse t) {
- if (callback != null) {
- callback.success(t.body());
- }
- serviceFuture.set(t.body());
- }
- }, new Action1() {
- @Override
- public void call(Throwable throwable) {
- if (callback != null) {
- callback.failure(throwable);
- }
- serviceFuture.setException(throwable);
- }
- });
- return serviceFuture;
- }
-
- /**
- * @return the current Rx subscription associated with the ServiceCall.
- */
- public Subscription getSubscription() {
- return subscription;
- }
-
- protected void setSubscription(Subscription subscription) {
- this.subscription = subscription;
- }
-
- /**
- * Invoke this method to report completed, allowing
- * {@link AbstractFuture#get()} to be unblocked.
- *
- * @param result the service response returned.
- * @return true if successfully reported; false otherwise.
- */
- public boolean success(T result) {
- return set(result);
- }
-
- @Override
- public boolean cancel(boolean mayInterruptIfRunning) {
- subscription.unsubscribe();
- return super.cancel(mayInterruptIfRunning);
- }
-
- @Override
- public boolean isCancelled() {
- return subscription.isUnsubscribed();
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/package-info.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/package-info.java
deleted file mode 100644
index ae9a87a91..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * The package provides 2 basic credential classes that work with AutoRest
- * generated clients for authentication purposes.
- */
-package com.microsoft.bot.rest.credentials;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/DateTimeRfc1123Serializer.java.dep b/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/DateTimeRfc1123Serializer.java.dep
deleted file mode 100644
index 6d02e97f6..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/DateTimeRfc1123Serializer.java.dep
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.rest.serializer;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.module.SimpleModule;
-import com.microsoft.rest.DateTimeRfc1123;
-
-import java.io.IOException;
-
-/**
- * Custom serializer for serializing {@link DateTimeRfc1123} object into RFC1123 formats.
- */
-public final class DateTimeRfc1123Serializer extends JsonSerializer {
- /**
- * Gets a module wrapping this serializer as an adapter for the Jackson
- * ObjectMapper.
- *
- * @return a simple module to be plugged onto Jackson ObjectMapper.
- */
- public static SimpleModule getModule() {
- SimpleModule module = new SimpleModule();
- module.addSerializer(DateTimeRfc1123.class, new DateTimeRfc1123Serializer());
- return module;
- }
-
- @Override
- public void serialize(DateTimeRfc1123 value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
- if (provider.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)) {
- jgen.writeNumber(value.dateTime().getMillis());
- } else {
- jgen.writeString(value.toString()); //Use the default toString as it is RFC1123.
- }
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/DateTimeSerializer.java.dep b/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/DateTimeSerializer.java.dep
deleted file mode 100644
index 940720c9d..000000000
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/DateTimeSerializer.java.dep
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
-
-package com.microsoft.rest.serializer;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.module.SimpleModule;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.format.ISODateTimeFormat;
-
-import java.io.IOException;
-
-/**
- * Custom serializer for serializing {@link DateTime} object into ISO8601 formats.
- */
-public final class DateTimeSerializer extends JsonSerializer {
- /**
- * Gets a module wrapping this serializer as an adapter for the Jackson
- * ObjectMapper.
- *
- * @return a simple module to be plugged onto Jackson ObjectMapper.
- */
- public static SimpleModule getModule() {
- SimpleModule module = new SimpleModule();
- module.addSerializer(DateTime.class, new DateTimeSerializer());
- return module;
- }
-
- @Override
- public void serialize(DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
- if (provider.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)) {
- jgen.writeNumber(value.getMillis());
- } else {
- value = value.withZone(DateTimeZone.UTC);
- jgen.writeString(value.toString(ISODateTimeFormat.dateTime()));
- }
- }
-}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/Base64Url.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/Base64Url.java
similarity index 90%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/Base64Url.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/Base64Url.java
index fa05c1054..01e0f0ce2 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/Base64Url.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/Base64Url.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
import com.google.common.io.BaseEncoding;
@@ -14,6 +11,7 @@
* Simple wrapper over Base64Url encoded byte array used during serialization/deserialization.
*/
public final class Base64Url {
+
/**
* The Base64Url encoded bytes.
*/
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/CollectionFormat.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/CollectionFormat.java
similarity index 85%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/CollectionFormat.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/CollectionFormat.java
index 13b602dae..1b8438897 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/CollectionFormat.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/CollectionFormat.java
@@ -1,11 +1,9 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
+@SuppressWarnings("checkstyle:linelength")
/**
* Swagger collection format to use for joining {@link java.util.List} parameters in
* paths, queries, and headers.
@@ -42,7 +40,7 @@ public enum CollectionFormat {
/**
* The delimiter separating the values.
*/
- private String delimiter;
+ private final String delimiter;
/**
* Creates an instance of the enum.
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ExpandableStringEnum.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ExpandableStringEnum.java
similarity index 91%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ExpandableStringEnum.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ExpandableStringEnum.java
index 67f80298e..5b5f8fc19 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ExpandableStringEnum.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ExpandableStringEnum.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
import java.util.ArrayList;
import java.util.Collection;
@@ -18,6 +15,7 @@
* @param a specific expandable enum type
*/
public abstract class ExpandableStringEnum> {
+
private static ConcurrentMap> valuesByName = null;
private String name;
@@ -66,9 +64,10 @@ protected static > T fromString(String name, C
@SuppressWarnings("unchecked")
protected static > Collection values(Class clazz) {
// Make a copy of all values
- Collection extends ExpandableStringEnum>> values = new ArrayList<>(valuesByName.values());
+ Collection extends ExpandableStringEnum>> values = new ArrayList<>(
+ valuesByName.values());
- Collection list = new HashSet();
+ Collection list = new HashSet<>();
for (ExpandableStringEnum> value : values) {
if (value.getClass().isAssignableFrom(clazz)) {
list.add((T) value);
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/LogLevel.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/LogLevel.java
similarity index 85%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/LogLevel.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/LogLevel.java
index 4bef98f67..be2971b7f 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/LogLevel.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/LogLevel.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
/**
* Describes the level of HTTP traffic to log.
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/RestClient.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/RestClient.java
similarity index 95%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/RestClient.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/RestClient.java
index e32543a0a..f44e26026 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/RestClient.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/RestClient.java
@@ -1,24 +1,21 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
import com.microsoft.azure.management.apigeneration.Beta;
import com.microsoft.azure.management.apigeneration.Beta.SinceVersion;
-import com.microsoft.bot.rest.credentials.ServiceClientCredentials;
-import com.microsoft.bot.rest.interceptors.BaseUrlHandler;
-import com.microsoft.bot.rest.interceptors.CustomHeadersInterceptor;
-import com.microsoft.bot.rest.interceptors.LoggingInterceptor;
-import com.microsoft.bot.rest.interceptors.RequestIdHeaderInterceptor;
-import com.microsoft.bot.rest.interceptors.UserAgentInterceptor;
-import com.microsoft.bot.rest.protocol.Environment;
-import com.microsoft.bot.rest.protocol.ResponseBuilder;
-import com.microsoft.bot.rest.protocol.SerializerAdapter;
-import com.microsoft.bot.rest.retry.RetryHandler;
-import com.microsoft.bot.rest.retry.RetryStrategy;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.interceptors.BaseUrlHandler;
+import com.microsoft.bot.restclient.interceptors.CustomHeadersInterceptor;
+import com.microsoft.bot.restclient.interceptors.LoggingInterceptor;
+import com.microsoft.bot.restclient.interceptors.RequestIdHeaderInterceptor;
+import com.microsoft.bot.restclient.interceptors.UserAgentInterceptor;
+import com.microsoft.bot.restclient.protocol.Environment;
+import com.microsoft.bot.restclient.protocol.ResponseBuilder;
+import com.microsoft.bot.restclient.protocol.SerializerAdapter;
+import com.microsoft.bot.restclient.retry.RetryHandler;
+import com.microsoft.bot.restclient.retry.RetryStrategy;
import okhttp3.Authenticator;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;
@@ -157,7 +154,7 @@ public static class Builder {
/** The builder to build an {@link OkHttpClient}. */
private OkHttpClient.Builder httpClientBuilder;
/** The builder to build a {@link Retrofit}. */
- private Retrofit.Builder retrofitBuilder;
+ private final Retrofit.Builder retrofitBuilder;
/** The credentials to authenticate. */
private ServiceClientCredentials credentials;
/** The credentials interceptor. */
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/RestException.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/RestException.java
similarity index 85%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/RestException.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/RestException.java
index edf6929c4..936c97e8e 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/RestException.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/RestException.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
import okhttp3.ResponseBody;
import retrofit2.Response;
@@ -16,7 +13,7 @@ public class RestException extends RuntimeException {
/**
* Information about the associated HTTP response.
*/
- private Response response;
+ private final Response response;
/**
* The HTTP response body.
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceCallback.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceCallback.java
similarity index 70%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceCallback.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceCallback.java
index 5f266df1b..3418769ff 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceCallback.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceCallback.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
/**
* The callback used for client side asynchronous operations.
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceClient.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceClient.java
new file mode 100644
index 000000000..e182c4320
--- /dev/null
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceClient.java
@@ -0,0 +1,145 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.microsoft.bot.restclient;
+
+import com.google.common.hash.Hashing;
+import com.microsoft.bot.restclient.credentials.ServiceClientCredentials;
+import com.microsoft.bot.restclient.protocol.SerializerAdapter;
+import com.microsoft.bot.restclient.serializer.JacksonAdapter;
+import java.net.NetworkInterface;
+import java.util.Enumeration;
+import okhttp3.OkHttpClient;
+import retrofit2.Retrofit;
+
+/**
+ * ServiceClient is the abstraction for accessing REST operations and their payload data types.
+ */
+public abstract class ServiceClient {
+ /**
+ * The RestClient instance storing all information needed for making REST calls.
+ */
+ private final RestClient restClient;
+
+ /**
+ * Initializes a new instance of the ServiceClient class.
+ *
+ * @param baseUrl the service endpoint
+ */
+ protected ServiceClient(String baseUrl) {
+ this(baseUrl, new OkHttpClient.Builder(), new Retrofit.Builder());
+ }
+
+ /**
+ * Initializes a new instance of the ServiceClient class.
+ *
+ * @param baseUrl the service base uri
+ * @param clientBuilder the http client builder
+ * @param restBuilder the retrofit rest client builder
+ */
+ protected ServiceClient(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) {
+ this(new RestClient.Builder(clientBuilder, restBuilder)
+ .withBaseUrl(baseUrl)
+ .withResponseBuilderFactory(new ServiceResponseBuilder.Factory())
+ .withSerializerAdapter(new JacksonAdapter())
+ .build());
+ }
+
+ protected ServiceClient(String baseUrl, ServiceClientCredentials credentials) {
+ this(baseUrl, credentials, new OkHttpClient.Builder(), new Retrofit.Builder());
+ }
+
+ /**
+ * Initializes a new instance of the ServiceClient class.
+ *
+ * @param baseUrl the service base uri
+ * @param credentials the credentials
+ * @param clientBuilder the http client builder
+ * @param restBuilder the retrofit rest client builder
+ */
+ protected ServiceClient(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder restBuilder) {
+ this(new RestClient.Builder(clientBuilder, restBuilder)
+ .withBaseUrl(baseUrl)
+ .withCredentials(credentials)
+ .withSerializerAdapter(new JacksonAdapter())
+ .withResponseBuilderFactory(new ServiceResponseBuilder.Factory())
+ .build());
+ }
+
+ /**
+ * Initializes a new instance of the ServiceClient class.
+ *
+ * @param restClient the REST client
+ */
+ protected ServiceClient(RestClient restClient) {
+ this.restClient = restClient;
+ }
+
+ /**
+ * @return the {@link RestClient} instance.
+ */
+ public RestClient restClient() {
+ return restClient;
+ }
+
+ /**
+ * @return the Retrofit instance.
+ */
+ public Retrofit retrofit() {
+ return restClient.retrofit();
+ }
+
+ /**
+ * @return the HTTP client.
+ */
+ public OkHttpClient httpClient() {
+ return this.restClient.httpClient();
+ }
+
+ /**
+ * @return the adapter to a Jackson {@link com.fasterxml.jackson.databind.ObjectMapper}.
+ */
+ public SerializerAdapter> serializerAdapter() {
+ return this.restClient.serializerAdapter();
+ }
+
+ /**
+ * The default User-Agent header. Override this method to override the user agent.
+ *
+ * @return the user agent string.
+ */
+ public String userAgent() {
+ return String.format("Azure-SDK-For-Java/%s OS:%s MacAddressHash:%s Java:%s",
+ getClass().getPackage().getImplementationVersion(),
+ OS,
+ MAC_ADDRESS_HASH,
+ JAVA_VERSION);
+ }
+
+ private static final String MAC_ADDRESS_HASH;
+ private static final String OS;
+ private static final String JAVA_VERSION;
+
+ static {
+ OS = System.getProperty("os.name") + "/" + System.getProperty("os.version");
+ String macAddress = "Unknown";
+
+ try {
+ Enumeration networks = NetworkInterface.getNetworkInterfaces();
+ while (networks.hasMoreElements()) {
+ NetworkInterface network = networks.nextElement();
+ byte[] mac = network.getHardwareAddress();
+
+ if (mac != null) {
+ macAddress = Hashing.sha256().hashBytes(mac).toString();
+ break;
+ }
+ }
+ } catch (Throwable ignore) { //NOPMD
+ // It's okay ignore mac address hash telemetry
+ }
+ MAC_ADDRESS_HASH = macAddress;
+ String version = System.getProperty("java.version");
+ JAVA_VERSION = version != null ? version : "Unknown";
+ }
+}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceResponse.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceResponse.java
similarity index 90%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceResponse.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceResponse.java
index 95af3d33f..60791aeec 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceResponse.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceResponse.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
import okhttp3.ResponseBody;
import retrofit2.Response;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceResponseBuilder.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceResponseBuilder.java
similarity index 90%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceResponseBuilder.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceResponseBuilder.java
index 5f3c03566..c94f7bbd6 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceResponseBuilder.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceResponseBuilder.java
@@ -1,16 +1,12 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
import com.fasterxml.jackson.core.type.TypeReference;
-import com.google.common.base.Function;
import com.google.common.collect.Maps;
-import com.microsoft.bot.rest.protocol.ResponseBuilder;
-import com.microsoft.bot.rest.protocol.SerializerAdapter;
+import com.microsoft.bot.restclient.protocol.ResponseBuilder;
+import com.microsoft.bot.restclient.protocol.SerializerAdapter;
import okhttp3.ResponseBody;
import retrofit2.Response;
@@ -150,12 +146,9 @@ public ServiceResponse buildEmpty(Response response) throws IOException
public ServiceResponseWithHeaders buildWithHeaders(final Response response, Class headerType) throws IOException {
ServiceResponse bodyResponse = build(response);
THeader headers = serializerAdapter.deserialize(
- serializerAdapter.serialize(Maps.asMap(response.headers().names(), new Function() {
- @Override
- public String apply(String s) {
- return response.headers().get(s);
- }
- })),
+ serializerAdapter.serialize(Maps.asMap(response.headers().names(),
+ s -> response.headers().get(s)
+ )),
headerType);
return new ServiceResponseWithHeaders<>(bodyResponse.body(), headers, bodyResponse.response());
}
@@ -164,12 +157,9 @@ public String apply(String s) {
public ServiceResponseWithHeaders buildEmptyWithHeaders(final Response response, Class headerType) throws IOException {
ServiceResponse bodyResponse = buildEmpty(response);
THeader headers = serializerAdapter.deserialize(
- serializerAdapter.serialize(Maps.asMap(response.headers().names(), new Function() {
- @Override
- public String apply(String s) {
- return response.headers().get(s);
- }
- })),
+ serializerAdapter.serialize(Maps.asMap(response.headers().names(),
+ s -> response.headers().get(s)
+ )),
headerType);
ServiceResponseWithHeaders serviceResponse = new ServiceResponseWithHeaders<>(headers, bodyResponse.headResponse());
serviceResponse.withBody(bodyResponse.body());
@@ -240,7 +230,7 @@ public boolean isSuccessful(int statusCode) {
* @param throwOnGet404 true if to throw; false to simply return null. Default is false.
* @return the response builder itself
*/
- public ServiceResponseBuilder withThrowOnGet404(boolean throwOnGet404) {
+ public ServiceResponseBuilder withThrowOnGet404(boolean throwOnGet404) {
this.throwOnGet404 = throwOnGet404;
return this;
}
@@ -251,7 +241,7 @@ public ServiceResponseBuilder withThrowOnGet404(boolean throwOnGet404) {
public static final class Factory implements ResponseBuilder.Factory {
@Override
public ServiceResponseBuilder newInstance(final SerializerAdapter> serializerAdapter) {
- return new ServiceResponseBuilder(serializerAdapter);
+ return new ServiceResponseBuilder<>(serializerAdapter);
}
}
}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceResponseWithHeaders.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceResponseWithHeaders.java
similarity index 85%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceResponseWithHeaders.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceResponseWithHeaders.java
index f13a3842c..58e69f7e0 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/ServiceResponseWithHeaders.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/ServiceResponseWithHeaders.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
import okhttp3.ResponseBody;
import retrofit2.Response;
@@ -19,7 +16,7 @@ public final class ServiceResponseWithHeaders extends ServiceRes
/**
* The response headers object.
*/
- private THeader headers;
+ private final THeader headers;
/**
* Instantiate a ServiceResponse instance with a response object and a raw REST response.
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/SkipParentValidation.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/SkipParentValidation.java
similarity index 67%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/SkipParentValidation.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/SkipParentValidation.java
index e4e034a31..9eb40ae53 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/SkipParentValidation.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/SkipParentValidation.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/Validator.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/Validator.java
similarity index 94%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/Validator.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/Validator.java
index 218f7115b..ef95f8653 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/Validator.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/Validator.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.primitives.Primitives;
@@ -41,7 +38,7 @@ public static void validate(Object parameter) {
return;
}
- Class parameterType = parameter.getClass();
+ Class> parameterType = parameter.getClass();
TypeToken> parameterToken = TypeToken.of(parameterType);
if (Primitives.isWrapperType(parameterType)) {
parameterToken = parameterToken.unwrap();
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/BasicAuthenticationCredentials.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/BasicAuthenticationCredentials.java
similarity index 56%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/BasicAuthenticationCredentials.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/BasicAuthenticationCredentials.java
index a27ad1b06..14ffbfa50 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/BasicAuthenticationCredentials.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/BasicAuthenticationCredentials.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.credentials;
+package com.microsoft.bot.restclient.credentials;
import okhttp3.OkHttpClient;
@@ -16,22 +13,22 @@ public class BasicAuthenticationCredentials implements ServiceClientCredentials
/**
* Basic auth UserName.
*/
- private String userName;
+ private final String userName;
/**
* Basic auth password.
*/
- private String password;
+ private final String password;
/**
* Instantiates a new basic authentication credential.
*
- * @param userName basic auth user name
- * @param password basic auth password
+ * @param withUserName basic auth user name
+ * @param withPassword basic auth password
*/
- public BasicAuthenticationCredentials(String userName, String password) {
- this.userName = userName;
- this.password = password;
+ public BasicAuthenticationCredentials(String withUserName, String withPassword) {
+ this.userName = withUserName;
+ this.password = withPassword;
}
/**
@@ -48,6 +45,11 @@ protected String getPassword() {
return password;
}
+ /**
+ * Apply the credentials to the HTTP client builder.
+ *
+ * @param clientBuilder the builder for building up an {@link OkHttpClient}
+ */
@Override
public void applyCredentialsFilter(OkHttpClient.Builder clientBuilder) {
clientBuilder.interceptors().add(new BasicAuthenticationCredentialsInterceptor(this));
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/BasicAuthenticationCredentialsInterceptor.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/BasicAuthenticationCredentialsInterceptor.java
similarity index 60%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/BasicAuthenticationCredentialsInterceptor.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/BasicAuthenticationCredentialsInterceptor.java
index e1568be39..d0069ea0d 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/BasicAuthenticationCredentialsInterceptor.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/BasicAuthenticationCredentialsInterceptor.java
@@ -1,12 +1,10 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.credentials;
+package com.microsoft.bot.restclient.credentials;
import com.google.common.io.BaseEncoding;
+import java.nio.charset.StandardCharsets;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
@@ -20,22 +18,28 @@ final class BasicAuthenticationCredentialsInterceptor implements Interceptor {
/**
* The credentials instance to apply to the HTTP client pipeline.
*/
- private BasicAuthenticationCredentials credentials;
+ private final BasicAuthenticationCredentials credentials;
/**
* Initialize a BasicAuthenticationCredentialsFilter class with a
* BasicAuthenticationCredentials credential.
*
- * @param credentials a BasicAuthenticationCredentials instance
+ * @param withCredentials a BasicAuthenticationCredentials instance
*/
- BasicAuthenticationCredentialsInterceptor(BasicAuthenticationCredentials credentials) {
- this.credentials = credentials;
+ BasicAuthenticationCredentialsInterceptor(BasicAuthenticationCredentials withCredentials) {
+ this.credentials = withCredentials;
}
+ /**
+ * Handle OKHttp intercept.
+ * @param chain okhttp3 Chain
+ * @return okhttp3 Response
+ * @throws IOException IOException during http IO.
+ */
@Override
public Response intercept(Chain chain) throws IOException {
String auth = credentials.getUserName() + ":" + credentials.getPassword();
- auth = BaseEncoding.base64().encode(auth.getBytes("UTF8"));
+ auth = BaseEncoding.base64().encode(auth.getBytes(StandardCharsets.UTF_8));
Request newRequest = chain.request().newBuilder()
.header("Authorization", "Basic " + auth)
.build();
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/ServiceClientCredentials.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/ServiceClientCredentials.java
similarity index 66%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/ServiceClientCredentials.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/ServiceClientCredentials.java
index bc9af5bae..d98bdb991 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/ServiceClientCredentials.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/ServiceClientCredentials.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.credentials;
+package com.microsoft.bot.restclient.credentials;
import okhttp3.OkHttpClient;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/TokenCredentials.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/TokenCredentials.java
similarity index 57%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/TokenCredentials.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/TokenCredentials.java
index 63c5ad271..1774b8fb2 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/TokenCredentials.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/TokenCredentials.java
@@ -1,38 +1,33 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.credentials;
+package com.microsoft.bot.restclient.credentials;
import okhttp3.OkHttpClient;
import okhttp3.Request;
-import java.io.IOException;
-
/**
* Token based credentials for use with a REST Service Client.
*/
public class TokenCredentials implements ServiceClientCredentials {
/** The authentication scheme. */
- private String scheme;
+ private final String scheme;
/** The secure token. */
- private String token;
+ private final String token;
/**
* Initializes a new instance of the TokenCredentials.
*
- * @param scheme scheme to use. If null, defaults to Bearer
- * @param token valid token
+ * @param withScheme scheme to use. If null, defaults to Bearer
+ * @param withToken valid token
*/
- public TokenCredentials(String scheme, String token) {
- if (scheme == null) {
- scheme = "Bearer";
+ public TokenCredentials(String withScheme, String withToken) {
+ if (withScheme == null) {
+ withScheme = "Bearer";
}
- this.scheme = scheme;
- this.token = token;
+ this.scheme = withScheme;
+ this.token = withToken;
}
/**
@@ -41,9 +36,8 @@ public TokenCredentials(String scheme, String token) {
*
* @param request the context of the HTTP request
* @return the secure token.
- * @throws IOException exception thrown from token acquisition operations.
*/
- protected String getToken(Request request) throws IOException {
+ protected String getToken(Request request) {
return token;
}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/TokenCredentialsInterceptor.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/TokenCredentialsInterceptor.java
similarity index 78%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/TokenCredentialsInterceptor.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/TokenCredentialsInterceptor.java
index c1251e2c3..2ce4abb49 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/credentials/TokenCredentialsInterceptor.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/TokenCredentialsInterceptor.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.credentials;
+package com.microsoft.bot.restclient.credentials;
import okhttp3.Interceptor;
import okhttp3.Request;
@@ -19,7 +16,7 @@ final class TokenCredentialsInterceptor implements Interceptor {
/**
* The credentials instance to apply to the HTTP client pipeline.
*/
- private TokenCredentials credentials;
+ private final TokenCredentials credentials;
/**
* Initialize a TokenCredentialsFilter class with a
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/package-info.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/package-info.java
new file mode 100644
index 000000000..17ac009b9
--- /dev/null
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/credentials/package-info.java
@@ -0,0 +1,8 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+/**
+ * The package provides 2 basic credential classes that work with AutoRest
+ * generated clients for authentication purposes.
+ */
+package com.microsoft.bot.restclient.credentials;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/BaseUrlHandler.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/BaseUrlHandler.java
similarity index 89%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/BaseUrlHandler.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/BaseUrlHandler.java
index 36cb6db7a..099f70f18 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/BaseUrlHandler.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/BaseUrlHandler.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.interceptors;
+package com.microsoft.bot.restclient.interceptors;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/CustomHeadersInterceptor.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/CustomHeadersInterceptor.java
similarity index 89%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/CustomHeadersInterceptor.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/CustomHeadersInterceptor.java
index bd7b257a0..2eb4c6cb8 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/CustomHeadersInterceptor.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/CustomHeadersInterceptor.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.interceptors;
+package com.microsoft.bot.restclient.interceptors;
import okhttp3.Headers;
import okhttp3.Interceptor;
@@ -33,13 +30,13 @@ public Map> headers() {
/**
* A mapping of custom headers.
*/
- private Map> headers;
+ private final Map> headers;
/**
* Initialize an instance of {@link CustomHeadersInterceptor} class.
*/
public CustomHeadersInterceptor() {
- headers = new HashMap>();
+ headers = new HashMap<>();
}
/**
@@ -62,7 +59,7 @@ public CustomHeadersInterceptor(String key, String value) {
* @return the interceptor instance itself.
*/
public CustomHeadersInterceptor replaceHeader(String name, String value) {
- this.headers.put(name, new ArrayList());
+ this.headers.put(name, new ArrayList<>());
this.headers.get(name).add(value);
return this;
}
@@ -77,7 +74,7 @@ public CustomHeadersInterceptor replaceHeader(String name, String value) {
*/
public CustomHeadersInterceptor addHeader(String name, String value) {
if (!this.headers.containsKey(name)) {
- this.headers.put(name, new ArrayList());
+ this.headers.put(name, new ArrayList<>());
}
this.headers.get(name).add(value);
return this;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/LoggingInterceptor.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/LoggingInterceptor.java
similarity index 93%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/LoggingInterceptor.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/LoggingInterceptor.java
index 1d6945e12..7b11988df 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/LoggingInterceptor.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/LoggingInterceptor.java
@@ -1,16 +1,14 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.interceptors;
+package com.microsoft.bot.restclient.interceptors;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
import com.google.common.io.CharStreams;
-import com.microsoft.bot.rest.LogLevel;
+import com.microsoft.bot.restclient.LogLevel;
+import java.nio.charset.StandardCharsets;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
@@ -89,7 +87,7 @@ public Response intercept(Chain chain) throws IOException {
Buffer buffer = new Buffer();
request.body().writeTo(buffer);
- Charset charset = Charset.forName("UTF8");
+ Charset charset = StandardCharsets.UTF_8;
MediaType contentType = request.body().contentType();
if (contentType != null) {
charset = contentType.charset(charset);
@@ -101,7 +99,7 @@ public Response intercept(Chain chain) throws IOException {
try {
content = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(
MAPPER.readValue(content, JsonNode.class));
- } catch (Exception ignore) {
+ } catch (Exception ignore) { //NOPMD
// swallow, keep original content
}
}
@@ -151,7 +149,7 @@ public Response intercept(Chain chain) throws IOException {
source.request(Long.MAX_VALUE); // Buffer the entire body.
Buffer buffer = source.buffer();
- Charset charset = Charset.forName("UTF8");
+ Charset charset = StandardCharsets.UTF_8;
MediaType contentType = responseBody.contentType();
if (contentType != null) {
try {
@@ -182,7 +180,7 @@ public Response intercept(Chain chain) throws IOException {
try {
content = MAPPER.writerWithDefaultPrettyPrinter()
.writeValueAsString(MAPPER.readValue(content, JsonNode.class));
- } catch (Exception ignore) {
+ } catch (Exception ignore) { //NOPMD
// swallow, keep original content
}
}
@@ -209,7 +207,7 @@ public LoggingInterceptor withLogLevel(LogLevel logLevel) {
return this;
}
- private static boolean isPlaintext(Buffer buffer) throws EOFException {
+ private static boolean isPlaintext(Buffer buffer) {
try {
Buffer prefix = new Buffer();
long byteCount = buffer.size() < 64 ? buffer.size() : 64;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/RequestIdHeaderInterceptor.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/RequestIdHeaderInterceptor.java
similarity index 77%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/RequestIdHeaderInterceptor.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/RequestIdHeaderInterceptor.java
index b89f119be..7c0549039 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/RequestIdHeaderInterceptor.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/RequestIdHeaderInterceptor.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.interceptors;
+package com.microsoft.bot.restclient.interceptors;
import okhttp3.Interceptor;
import okhttp3.Request;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/UserAgentInterceptor.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/UserAgentInterceptor.java
similarity index 90%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/UserAgentInterceptor.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/UserAgentInterceptor.java
index 4399b66d8..6dcc7a2dc 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/UserAgentInterceptor.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/UserAgentInterceptor.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.interceptors;
+package com.microsoft.bot.restclient.interceptors;
import okhttp3.Interceptor;
import okhttp3.Request;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/package-info.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/package-info.java
similarity index 60%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/package-info.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/package-info.java
index 9d7089306..76526b810 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/interceptors/package-info.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/interceptors/package-info.java
@@ -1,4 +1,4 @@
/**
* The package contains default interceptors for making HTTP requests.
*/
-package com.microsoft.bot.rest.interceptors;
+package com.microsoft.bot.restclient.interceptors;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/package-info.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/package-info.java
similarity index 86%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/package-info.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/package-info.java
index 6e3503479..b6b410a6d 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/package-info.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/package-info.java
@@ -3,4 +3,4 @@
* clients to compile and function. To learn more about AutoRest generator,
* see https://github.com/azure/autorest.
*/
-package com.microsoft.bot.rest;
+package com.microsoft.bot.restclient;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/Environment.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/Environment.java
similarity index 72%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/Environment.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/Environment.java
index 2670c9eac..6e8f64c21 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/Environment.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/Environment.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.protocol;
+package com.microsoft.bot.restclient.protocol;
/**
* An collection of endpoints in a region or a cloud.
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/ResponseBuilder.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/ResponseBuilder.java
similarity index 93%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/ResponseBuilder.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/ResponseBuilder.java
index 2a5abe120..9492f6f81 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/ResponseBuilder.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/ResponseBuilder.java
@@ -1,14 +1,11 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.protocol;
+package com.microsoft.bot.restclient.protocol;
-import com.microsoft.bot.rest.RestException;
-import com.microsoft.bot.rest.ServiceResponse;
-import com.microsoft.bot.rest.ServiceResponseWithHeaders;
+import com.microsoft.bot.restclient.RestException;
+import com.microsoft.bot.restclient.ServiceResponse;
+import com.microsoft.bot.restclient.ServiceResponseWithHeaders;
import okhttp3.ResponseBody;
import retrofit2.Response;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/SerializerAdapter.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/SerializerAdapter.java
similarity index 88%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/SerializerAdapter.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/SerializerAdapter.java
index 27391b3aa..dc28358d6 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/SerializerAdapter.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/SerializerAdapter.java
@@ -1,12 +1,9 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.protocol;
+package com.microsoft.bot.restclient.protocol;
-import com.microsoft.bot.rest.CollectionFormat;
+import com.microsoft.bot.restclient.CollectionFormat;
import retrofit2.Converter;
import java.io.IOException;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/package-info.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/package-info.java
similarity index 73%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/package-info.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/package-info.java
index ea3be602c..0c47c4a00 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/protocol/package-info.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/protocol/package-info.java
@@ -2,4 +2,4 @@
* The package contains classes that interfaces defining the behaviors
* of the necessary components of a Rest Client.
*/
-package com.microsoft.bot.rest.protocol;
+package com.microsoft.bot.restclient.protocol;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/ExponentialBackoffRetryStrategy.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/ExponentialBackoffRetryStrategy.java
similarity index 92%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/ExponentialBackoffRetryStrategy.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/ExponentialBackoffRetryStrategy.java
index 5a8edc131..f04bf6b18 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/ExponentialBackoffRetryStrategy.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/ExponentialBackoffRetryStrategy.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.retry;
+package com.microsoft.bot.restclient.retry;
import okhttp3.Response;
@@ -32,15 +29,15 @@ public final class ExponentialBackoffRetryStrategy extends RetryStrategy {
* The value that will be used to calculate a random delta in the exponential delay
* between retries.
*/
- private final int deltaBackoff;
+ private final int deltaBackoff; //NOPMD
/**
* The maximum backoff time.
*/
- private final int maxBackoff;
+ private final int maxBackoff; //NOPMD
/**
* The minimum backoff time.
*/
- private final int minBackoff;
+ private final int minBackoff; //NOPMD
/**
* The maximum number of retry attempts.
*/
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/RetryHandler.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/RetryHandler.java
similarity index 90%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/RetryHandler.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/RetryHandler.java
index 5739d0426..feeda4d58 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/RetryHandler.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/RetryHandler.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.retry;
+package com.microsoft.bot.restclient.retry;
import okhttp3.Interceptor;
import okhttp3.Request;
@@ -37,7 +34,7 @@ public final class RetryHandler implements Interceptor {
/**
* The retry strategy to use.
*/
- private RetryStrategy retryStrategy;
+ private final RetryStrategy retryStrategy;
/**
* @return the strategy used by this handler
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/RetryStrategy.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/RetryStrategy.java
similarity index 89%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/RetryStrategy.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/RetryStrategy.java
index 60df99339..5a8d3aaa6 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/RetryStrategy.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/RetryStrategy.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.retry;
+package com.microsoft.bot.restclient.retry;
import okhttp3.Response;
@@ -31,13 +28,13 @@ public abstract class RetryStrategy {
/**
* The name of the retry strategy.
*/
- private String name;
+ private final String name;
/**
* The value indicating whether the first retry attempt will be made immediately,
* whereas subsequent retries will remain subject to the retry interval.
*/
- private boolean fastFirstRetry;
+ private final boolean fastFirstRetry;
/**
* Initializes a new instance of the {@link RetryStrategy} class.
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/package-info.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/package-info.java
similarity index 72%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/package-info.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/package-info.java
index 7e80702a5..65d0fe5aa 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/retry/package-info.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/retry/package-info.java
@@ -2,4 +2,4 @@
* The package contains classes that define the retry behaviors when an error
* occurs during a REST call.
*/
-package com.microsoft.bot.rest.retry;
+package com.microsoft.bot.restclient.retry;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/AdditionalPropertiesDeserializer.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/AdditionalPropertiesDeserializer.java
similarity index 94%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/AdditionalPropertiesDeserializer.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/AdditionalPropertiesDeserializer.java
index e0b0ddc53..ce3021a55 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/AdditionalPropertiesDeserializer.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/AdditionalPropertiesDeserializer.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.serializer;
+package com.microsoft.bot.restclient.serializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonFactory;
@@ -106,7 +103,7 @@ public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOE
}
// put into additional properties
- root.put("additionalProperties", copy);
+ root.set("additionalProperties", copy);
JsonParser parser = new JsonFactory().createParser(root.toString());
parser.nextToken();
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/AdditionalPropertiesSerializer.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/AdditionalPropertiesSerializer.java
similarity index 95%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/AdditionalPropertiesSerializer.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/AdditionalPropertiesSerializer.java
index 8f87f52ac..a34089836 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/AdditionalPropertiesSerializer.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/AdditionalPropertiesSerializer.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.serializer;
+package com.microsoft.bot.restclient.serializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator;
@@ -113,7 +110,7 @@ public void serialize(Object value, JsonGenerator jgen, SerializerProvider provi
fields = extraProperties.fields();
while (fields.hasNext()) {
Entry field = fields.next();
- root.put(field.getKey(), field.getValue());
+ root.set(field.getKey(), field.getValue());
}
}
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/Base64UrlSerializer.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/Base64UrlSerializer.java
similarity index 79%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/Base64UrlSerializer.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/Base64UrlSerializer.java
index 4c0a8035a..8a3f39657 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/Base64UrlSerializer.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/Base64UrlSerializer.java
@@ -1,16 +1,13 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.serializer;
+package com.microsoft.bot.restclient.serializer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.module.SimpleModule;
-import com.microsoft.bot.rest.Base64Url;
+import com.microsoft.bot.restclient.Base64Url;
import java.io.IOException;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/ByteArraySerializer.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/ByteArraySerializer.java
similarity index 83%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/ByteArraySerializer.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/ByteArraySerializer.java
index bb68694e5..37efe77e2 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/ByteArraySerializer.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/ByteArraySerializer.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.serializer;
+package com.microsoft.bot.restclient.serializer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/FlatteningDeserializer.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/FlatteningDeserializer.java
similarity index 93%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/FlatteningDeserializer.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/FlatteningDeserializer.java
index 9b6b0cd10..26206dac0 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/FlatteningDeserializer.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/FlatteningDeserializer.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.serializer;
+package com.microsoft.bot.restclient.serializer;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@@ -91,9 +88,7 @@ public Object deserializeWithType(JsonParser jp, DeserializationContext cxt, Typ
JsonNode currentJsonNode = mapper.readTree(jp);
final Class> tClass = this.defaultDeserializer.handledType();
for (Class> c : TypeToken.of(tClass).getTypes().classes().rawTypes()) {
- if (c.isAssignableFrom(Object.class)) {
- continue;
- } else {
+ if (!c.isAssignableFrom(Object.class)) {
final JsonTypeInfo typeInfo = c.getAnnotation(JsonTypeInfo.class);
if (typeInfo != null) {
String typeId = typeInfo.property();
@@ -101,7 +96,7 @@ public Object deserializeWithType(JsonParser jp, DeserializationContext cxt, Typ
final String typeIdOnWire = unescapeEscapedDots(typeId);
JsonNode typeIdValue = ((ObjectNode) currentJsonNode).remove(typeIdOnWire);
if (typeIdValue != null) {
- ((ObjectNode) currentJsonNode).put(typeId, typeIdValue);
+ ((ObjectNode) currentJsonNode).set(typeId, typeIdValue);
}
}
}
@@ -123,9 +118,7 @@ public Object deserialize(JsonParser jp, DeserializationContext cxt) throws IOEx
}
final Class> tClass = this.defaultDeserializer.handledType();
for (Class> c : TypeToken.of(tClass).getTypes().classes().rawTypes()) {
- if (c.isAssignableFrom(Object.class)) {
- continue;
- } else {
+ if (!c.isAssignableFrom(Object.class)) {
for (Field classField : c.getDeclaredFields()) {
handleFlatteningForField(classField, currentJsonNode);
}
@@ -154,7 +147,7 @@ private static void handleFlatteningForField(Field classField, JsonNode jsonNode
final String jsonPropValue = jsonProperty.value();
if (containsFlatteningDots(jsonPropValue)) {
JsonNode childJsonNode = findNestedNode(jsonNode, jsonPropValue);
- ((ObjectNode) jsonNode).put(jsonPropValue, childJsonNode);
+ ((ObjectNode) jsonNode).set(jsonPropValue, childJsonNode);
}
}
}
@@ -220,7 +213,7 @@ private static String unescapeEscapedDots(String key) {
* @return true if at least one dot found
*/
private static boolean containsDot(String str) {
- return str != null && str != "" && str.contains(".");
+ return str != null && str.length() > 0 && str.contains(".");
}
/**
diff --git a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/FlatteningSerializer.java b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/FlatteningSerializer.java
similarity index 94%
rename from libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/FlatteningSerializer.java
rename to libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/FlatteningSerializer.java
index 7ce216591..13bfc5b9e 100644
--- a/libraries/bot-connector/src/main/java/com/microsoft/bot/rest/serializer/FlatteningSerializer.java
+++ b/libraries/bot-connector/src/main/java/com/microsoft/bot/restclient/serializer/FlatteningSerializer.java
@@ -1,10 +1,7 @@
-/**
- * Copyright (c) Microsoft Corporation. All rights reserved.
- * Licensed under the MIT License. See License.txt in the project root for
- * license information.
- */
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
-package com.microsoft.bot.rest.serializer;
+package com.microsoft.bot.restclient.serializer;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.BeanDescription;
@@ -89,7 +86,7 @@ public JsonSerializer> modifySerializer(SerializationConfig config, BeanDescri
}
private List getAllDeclaredFields(Class> clazz) {
- List fields = new ArrayList