Skip to content

Commit

Permalink
Squashed 'runtimes/' changes from 3fa32be..3596f48
Browse files Browse the repository at this point in the history
3596f48 Merge branch 'master' of github.com:jianghaolu/autorest-clientruntime-for-java into runtimes
b108e05 Merge commit 'c0aa84911ceec370c33616c3658df16313b8dfde'
34a1832 Prepare for next development iteration
f0805a7 Use beta2 for other packages
138bca9 Support Base64url (Azure#1238)
f037c79 Re-organize entire code repo (Azure#1220)
762eaa6 Prepare for next development iteration
8825f41 Removing check style for hiding utility class constructor.
f8d2a9c Bump up version numbers for beta2 release
f8a2ad4 Adding javadoc gen as a part of build since javadoc generation catches some of the checkstyle and reference issue
47b9652 Adding publicIp sample, only mark sub-DAGs as non-prepare - the root DAG stay as preparer
f84bd3d improving comment as per review
bf4c5ea Addressing review comments [javadoc, simplfying the map iteration]
4688b88 comment corrections
c841500 Making DAG to work correctly to handle more cases
a56b045 couple of javadoc fixes
f3fe387 Merge pull request Azure#819 from jianghaolu/async
99abc58 Add retry for 404 GET
22f2053 Add a bunch of configs to RestClient
ad7507e Merge branch 'master' of github.com:Azure/azure-sdk-for-java into async
0c8a460 Merge pull request Azure#832 from jianghaolu/restclient
5ab5ddf Merge commit '486acdc633c498d4335711e30817cc70faacc487' into restclient
5e5647f making dag::prepare to work for update
8604dee Fixing the bug of trying to create created resources during update, adding better way to name gen resource names
1fd9e5f use AZURE_GERMANY insteadof AZURE_GERMAN
012a68b ensuring trailing slash for urls
281f61c correcting environment name
91d4bb5 Adding few more Azure environments
b8d6ab8 Add applyAsync()
618091b Basic prototyping of async in fluent
1bc2ab8 Checkstyle passes everywhere
e622549 Merge pull request Azure#783 from jianghaolu/javadocs
b415da0 Merge pull request Azure#779 from jianghaolu/paramhostfix
9ab4ca6 Network passes checkstyle
ef99c9e Merge commit '4aa3dd4b847e747387475e9249c4aba97b6ef8ac' into paramhostfix
0b7ad46 Done storage usages
f1f371c Merge commit '469f44270c1f37e6fe16bc324fea487a6354679a' into rename-setters

git-subtree-dir: runtimes
git-subtree-split: 3596f48
  • Loading branch information
jianghaolu committed Jul 14, 2016
1 parent c0aa849 commit f06ab8e
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 13 deletions.
8 changes: 4 additions & 4 deletions azure-client-authentication/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ version = '1.0.0-SNAPSHOT'

checkstyle {
toolVersion = "6.18"
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")
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")
}

dependencies {
Expand Down Expand Up @@ -92,7 +92,7 @@ artifacts {

test {
reports.getHtml()
reports.html.destination = file("${projectDir}/../../../TestResults/JavaAzureRuntime")
reports.html.destination = file("$rootDir/TestResults/JavaAzureRuntime")
}

tasks.compileJava.dependsOn 'clean'
8 changes: 4 additions & 4 deletions azure-client-runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ version = '1.0.0-SNAPSHOT'

checkstyle {
toolVersion = "6.18"
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")
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")
}

dependencies {
Expand Down Expand Up @@ -90,7 +90,7 @@ artifacts {

test {
reports.getHtml()
reports.html.destination = file("${projectDir}/../../../TestResults/JavaAzureRuntime")
reports.html.destination = file("$rootDir/TestResults/JavaAzureRuntime")
}

tasks.compileJava.dependsOn 'clean'
1 change: 0 additions & 1 deletion build-tools/src/main/resources/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@
-->

<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier">
<property name="protectedAllowed" value="true"/>
Expand Down
8 changes: 4 additions & 4 deletions client-runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ version = '1.0.0-SNAPSHOT'

checkstyle {
toolVersion = "6.18"
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")
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")
}

dependencies {
Expand Down Expand Up @@ -99,7 +99,7 @@ artifacts {

test {
reports.getHtml()
reports.html.destination = file("${projectDir}/../../../TestResults/JavaRuntime")
reports.html.destination = file("$rootDir/TestResults/JavaRuntime")
}

tasks.compileJava.dependsOn 'clean'
Expand Down
94 changes: 94 additions & 0 deletions client-runtime/src/main/java/com/microsoft/rest/Base64Url.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
*
* 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
*
* 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<Base64Url> {
/**
* 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ 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());
Expand Down

0 comments on commit f06ab8e

Please sign in to comment.