From 06e316967c39a04bd6591b30f49a54d8394cd95b Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Mon, 18 Jul 2016 09:50:32 -0700 Subject: [PATCH] Revert "Changes from AutoRest & SDK" --- azure-client-authentication/build.gradle | 8 +- azure-client-runtime/build.gradle | 8 +- build-tools/src/main/resources/checkstyle.xml | 1 + client-runtime/build.gradle | 8 +- .../java/com/microsoft/rest/Base64Url.java | 94 ------------------- .../com/microsoft/rest/ServiceClient.java | 3 - .../rest/serializer/Base64UrlSerializer.java | 38 -------- .../rest/serializer/JacksonMapperAdapter.java | 1 - 8 files changed, 13 insertions(+), 148 deletions(-) delete mode 100644 client-runtime/src/main/java/com/microsoft/rest/Base64Url.java delete mode 100644 client-runtime/src/main/java/com/microsoft/rest/serializer/Base64UrlSerializer.java diff --git a/azure-client-authentication/build.gradle b/azure-client-authentication/build.gradle index 65c1c86a20a36..2b40ada004e0e 100644 --- a/azure-client-authentication/build.gradle +++ b/azure-client-authentication/build.gradle @@ -14,9 +14,9 @@ version = '1.0.0-SNAPSHOT' checkstyle { toolVersion = "6.18" - configFile = new File("$rootDir/src/client/Java/build-tools/src/main/resources/checkstyle.xml") - configProperties = [samedir: "$rootDir/src/client/Java/build-tools/src/main/resources"] - reportsDir = new File("$rootDir/src/client/Java/build-tools/reports") + configFile = new File("$rootDir/ClientRuntimes/Java/build-tools/src/main/resources/checkstyle.xml") + configProperties = [samedir: "$rootDir/ClientRuntimes/Java/build-tools/src/main/resources"] + reportsDir = new File("$rootDir/ClientRuntimes/Java/build-tools/reports") } dependencies { @@ -92,7 +92,7 @@ artifacts { test { reports.getHtml() - reports.html.destination = file("$rootDir/TestResults/JavaAzureRuntime") + reports.html.destination = file("${projectDir}/../../../TestResults/JavaAzureRuntime") } tasks.compileJava.dependsOn 'clean' diff --git a/azure-client-runtime/build.gradle b/azure-client-runtime/build.gradle index db64fd0b46abd..5c29359536abc 100644 --- a/azure-client-runtime/build.gradle +++ b/azure-client-runtime/build.gradle @@ -14,9 +14,9 @@ version = '1.0.0-SNAPSHOT' checkstyle { toolVersion = "6.18" - configFile = new File("$rootDir/src/client/Java/build-tools/src/main/resources/checkstyle.xml") - configProperties = [samedir: "$rootDir/src/client/Java/build-tools/src/main/resources"] - reportsDir = new File("$rootDir/src/client/Java/build-tools/reports") + configFile = new File("$rootDir/ClientRuntimes/Java/build-tools/src/main/resources/checkstyle.xml") + configProperties = [samedir: "$rootDir/ClientRuntimes/Java/build-tools/src/main/resources"] + reportsDir = new File("$rootDir/ClientRuntimes/Java/build-tools/reports") } dependencies { @@ -90,7 +90,7 @@ artifacts { test { reports.getHtml() - reports.html.destination = file("$rootDir/TestResults/JavaAzureRuntime") + reports.html.destination = file("${projectDir}/../../../TestResults/JavaAzureRuntime") } tasks.compileJava.dependsOn 'clean' diff --git a/build-tools/src/main/resources/checkstyle.xml b/build-tools/src/main/resources/checkstyle.xml index b7f934898253c..1875d6f100cab 100644 --- a/build-tools/src/main/resources/checkstyle.xml +++ b/build-tools/src/main/resources/checkstyle.xml @@ -231,6 +231,7 @@ --> + diff --git a/client-runtime/build.gradle b/client-runtime/build.gradle index e530072694672..73750c0d3d935 100644 --- a/client-runtime/build.gradle +++ b/client-runtime/build.gradle @@ -16,9 +16,9 @@ version = '1.0.0-SNAPSHOT' checkstyle { toolVersion = "6.18" - configFile = new File("$rootDir/src/client/Java/build-tools/src/main/resources/checkstyle.xml") - configProperties = [samedir: "$rootDir/src/client/Java/build-tools/src/main/resources"] - reportsDir = new File("$rootDir/src/client/Java/build-tools/reports") + configFile = new File("$rootDir/ClientRuntimes/Java/build-tools/src/main/resources/checkstyle.xml") + configProperties = [samedir: "$rootDir/ClientRuntimes/Java/build-tools/src/main/resources"] + reportsDir = new File("$rootDir/ClientRuntimes/Java/build-tools/reports") } dependencies { @@ -99,7 +99,7 @@ artifacts { test { reports.getHtml() - reports.html.destination = file("$rootDir/TestResults/JavaRuntime") + reports.html.destination = file("${projectDir}/../../../TestResults/JavaRuntime") } tasks.compileJava.dependsOn 'clean' diff --git a/client-runtime/src/main/java/com/microsoft/rest/Base64Url.java b/client-runtime/src/main/java/com/microsoft/rest/Base64Url.java deleted file mode 100644 index 61b02879feae1..0000000000000 --- a/client-runtime/src/main/java/com/microsoft/rest/Base64Url.java +++ /dev/null @@ -1,94 +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.io.BaseEncoding; - -import java.util.Arrays; - -/** - * Simple wrapper over Base64Url encoded byte array used during serialization/deserialization. - */ -public final class Base64Url { - /** - * The Base64Url encoded bytes. - */ - private final byte[] bytes; - - /** - * Creates a new Base64Url object with the specified encoded string. - * - * @param string The encoded string. - */ - private Base64Url(String string) { - if (string == null) { - this.bytes = null; - } else { - this.bytes = string.getBytes(); - } - } - - /** - * Encode a byte array into Base64Url encoded bytes. - * - * @param bytes The byte array to encode. - * @return a Base64Url instance - */ - public static Base64Url encode(byte[] bytes) { - if (bytes == null) { - return new Base64Url(null); - } else { - return new Base64Url(BaseEncoding.base64Url().omitPadding().encode(bytes)); - } - } - - /** - * Returns the underlying encoded byte array. - * - * @return The underlying encoded byte array. - */ - public byte[] getEncodedBytes() { - return bytes; - } - - /** - * Decode the bytes and return. - * - * @return The decoded byte array. - */ - public byte[] getDecodedBytes() { - if (this.bytes == null) { - return null; - } - return BaseEncoding.base64Url().decode(new String(bytes)); - } - - @Override - public String toString() { - return new String(bytes); - } - - @Override - public int hashCode() { - return Arrays.hashCode(bytes); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - - if (!(obj instanceof Base64Url)) { - return false; - } - - Base64Url rhs = (Base64Url) obj; - return Arrays.equals(this.bytes, rhs.getEncodedBytes()); - } -} \ No newline at end of file diff --git a/client-runtime/src/main/java/com/microsoft/rest/ServiceClient.java b/client-runtime/src/main/java/com/microsoft/rest/ServiceClient.java index 5d6f0f850336c..8311a243de139 100644 --- a/client-runtime/src/main/java/com/microsoft/rest/ServiceClient.java +++ b/client-runtime/src/main/java/com/microsoft/rest/ServiceClient.java @@ -40,9 +40,6 @@ protected ServiceClient(String baseUrl) { /** * 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) { if (clientBuilder == null) { diff --git a/client-runtime/src/main/java/com/microsoft/rest/serializer/Base64UrlSerializer.java b/client-runtime/src/main/java/com/microsoft/rest/serializer/Base64UrlSerializer.java deleted file mode 100644 index 757ab735e2c0d..0000000000000 --- a/client-runtime/src/main/java/com/microsoft/rest/serializer/Base64UrlSerializer.java +++ /dev/null @@ -1,38 +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.SerializerProvider; -import com.fasterxml.jackson.databind.module.SimpleModule; -import com.microsoft.rest.Base64Url; - -import java.io.IOException; - -/** - * Custom serializer for serializing {@link Byte[]} objects into Base64 strings. - */ -public class Base64UrlSerializer 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(Base64Url.class, new Base64UrlSerializer()); - return module; - } - - @Override - public void serialize(Base64Url value, JsonGenerator jgen, SerializerProvider provider) throws IOException { - jgen.writeString(value.toString()); - } -} diff --git a/client-runtime/src/main/java/com/microsoft/rest/serializer/JacksonMapperAdapter.java b/client-runtime/src/main/java/com/microsoft/rest/serializer/JacksonMapperAdapter.java index ea938fe50c9c5..a59247207502b 100644 --- a/client-runtime/src/main/java/com/microsoft/rest/serializer/JacksonMapperAdapter.java +++ b/client-runtime/src/main/java/com/microsoft/rest/serializer/JacksonMapperAdapter.java @@ -56,7 +56,6 @@ protected void initializeObjectMapper(ObjectMapper mapper) { .setSerializationInclusion(JsonInclude.Include.NON_NULL) .registerModule(new JodaModule()) .registerModule(ByteArraySerializer.getModule()) - .registerModule(Base64UrlSerializer.getModule()) .registerModule(DateTimeSerializer.getModule()) .registerModule(DateTimeRfc1123Serializer.getModule()) .registerModule(HeadersSerializer.getModule());