Skip to content

Commit

Permalink
review comments, copyrights, checkstyle, spotbugs
Browse files Browse the repository at this point in the history
  • Loading branch information
arjav-desai committed Jun 22, 2023
1 parent 99de2cb commit a24abba
Show file tree
Hide file tree
Showing 84 changed files with 265 additions and 257 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,13 +56,13 @@ public static void main(String[] args) {
// we have three configurations available
// 1. Token based authentication
Vault tokenVault = Vault.builder()
.config(config.get("vault.token"))
.updateWebClient(client -> client.channelOptions(
SocketOptions.builder()
.connectTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(5))
.build()))
.build();
.config(config.get("vault.token"))
.updateWebClient(client -> client.channelOptions(
SocketOptions.builder()
.connectTimeout(Duration.ofSeconds(5))
.readTimeout(Duration.ofSeconds(5))
.build()))
.build();

// 2. App role based authentication - must be created after we obtain the role id an token
// 3. Kubernetes (k8s) based authentication (requires to run on k8s) - must be created after we create
Expand All @@ -82,13 +82,13 @@ public static void main(String[] args) {
// we use await for webserver, as we do not care if we block the main thread - it is not used
// for anything
WebServer webServer = WebServer.builder()
.config(config.get("server"))
.routing(routing -> routing
.register("/cubbyhole", new CubbyholeService(sys, tokenVault.secrets(CubbyholeSecrets.ENGINE)))
.register("/kv1", new Kv1Service(sys, tokenVault.secrets(Kv1Secrets.ENGINE)))
.register("/kv2", new Kv2Service(sys, tokenVault.secrets(Kv2Secrets.ENGINE)))
.register("/transit", new TransitService(sys, tokenVault.secrets(TransitSecrets.ENGINE))))
.start();
.config(config.get("server"))
.routing(routing -> routing
.register("/cubbyhole", new CubbyholeService(sys, tokenVault.secrets(CubbyholeSecrets.ENGINE)))
.register("/kv1", new Kv1Service(sys, tokenVault.secrets(Kv1Secrets.ENGINE)))
.register("/kv2", new Kv2Service(sys, tokenVault.secrets(Kv2Secrets.ENGINE)))
.register("/transit", new TransitService(sys, tokenVault.secrets(TransitSecrets.ENGINE))))
.start();

String baseAddress = "http://localhost:" + webServer.port() + "/";
System.out.println("Server started on " + baseAddress);
Expand Down Expand Up @@ -120,11 +120,11 @@ public static void main(String[] args) {

private static Config buildConfig() {
return Config.builder()
.sources(
// you can use this file to override the defaults that are built-in
file(System.getProperty("user.home") + "/helidon/conf/examples.yaml").optional(),
// in jar file (see src/main/resources/application.yaml)
classpath("application.yaml"))
.build();
.sources(
// you can use this file to override the defaults that are built-in
file(System.getProperty("user.home") + "/helidon/conf/examples.yaml").optional(),
// in jar file (see src/main/resources/application.yaml)
classpath("application.yaml"))
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Oracle and/or its affiliates.
# Copyright (c) 2021, 2023 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021, 2022 Oracle and/or its affiliates.
# Copyright (c) 2021, 2023 Oracle and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -25,7 +25,7 @@
/**
* Common base class for REST requests that have an entity.
* This class acts as a mutable builder of request JSON object.
* <br>
* <p>
* Path is not a part of this request.
*
* @param <T> type of the request
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,6 +30,7 @@ public class ApiOptionalResponse<R> extends ApiResponse {

protected ApiOptionalResponse(BuilderBase<?, ?, ?, ?> builder, Optional<R> entity) {
super(builder);

this.entity = entity;
}

Expand Down Expand Up @@ -58,17 +59,20 @@ public Optional<R> entity() {
* Map the (possible) response entity to a different type.
*
* @param mapper mapper function
* @param <U> new type
* @param <U> new type
* @return new optional response with the mapped entity
*/
public <U> ApiOptionalResponse<U> map(Function<R, U> mapper) {
Builder<U, U> builder = ApiOptionalResponse.apiResponseBuilder();

entity.map(mapper).ifPresent(builder::entity);
return builder.entityProcessor(Function.identity())
.headers(headers())
.requestId(requestId())
.status(status())
.build();

return builder
.entityProcessor(Function.identity())
.headers(headers())
.requestId(requestId())
.status(status())
.build();
}

/**
Expand Down Expand Up @@ -132,7 +136,6 @@ public B entityProcessor(Function<X, R> processor) {

/**
* Entity as received from network.
*
* @return entity if present, empty otherwise
*/
protected Optional<X> entity() {
Expand All @@ -141,7 +144,6 @@ protected Optional<X> entity() {

/**
* The configured entity processor.
*
* @return processor
*/
protected Function<X, R> entityProcessor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,7 @@
* Common base class for REST requests.
* This class acts as a mutable builder without a build method, as the intended use is to pass it
* to a {@code io.helidon.integrations.common.rest.RestApi}, not to send it around for parallel processing.
* <br>
* <p>
* Path is not a part of this request.
*
* @param <T> type of the request
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,7 +28,6 @@
import io.helidon.integrations.common.rest.ApiOptionalResponse.BuilderBase;
import io.helidon.nima.faulttolerance.FaultTolerance;
import io.helidon.nima.faulttolerance.FtHandler;
import io.helidon.nima.http.media.MediaContext;
import io.helidon.nima.http.media.jsonp.JsonpSupport;
import io.helidon.nima.webclient.http1.Http1Client;
import io.helidon.nima.webclient.http1.Http1Client.Http1ClientBuilder;
Expand Down Expand Up @@ -262,8 +261,7 @@ <R, T extends ApiOptionalResponse<R>> T invokeOptional(Method method,
* @param <T> type of the built {@link io.helidon.integrations.common.rest.RestApi}
*/
abstract class Builder<B extends Builder<B, T>, T extends RestApi> implements io.helidon.common.Builder<B, T> {
private final Http1ClientBuilder webClientBuilder = Http1Client.builder();
//.followRedirects(true)
private final Http1ClientBuilder webClientBuilder = Http1Client.builder().followRedirect(true);
//.keepAlive(true);

private FtHandler ftHandler = FaultTolerance.builder().build();
Expand Down Expand Up @@ -360,9 +358,7 @@ protected B me() {
* This implementation builds the web client and sets up JSON factories.
*/
protected void preBuild() {
webClientBuilder.mediaContext(MediaContext.builder()
.addMediaSupport(JsonpSupport.create())
.build());
webClientBuilder.addMediaSupport(JsonpSupport.create()).build();
webClient = webClientBuilder.build();
if (jsonBuilderFactory == null) {
jsonBuilderFactory = Json.createBuilderFactory(Map.of());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,9 +33,9 @@
import io.helidon.common.http.HttpMediaType;
import io.helidon.common.media.type.MediaTypes;
import io.helidon.integrations.common.rest.ApiOptionalResponse.BuilderBase;
import io.helidon.nima.faulttolerance.FtHandler;
import io.helidon.nima.webclient.ClientResponse;
import io.helidon.nima.webclient.http1.Http1Client;
import io.helidon.nima.faulttolerance.FtHandler;
import io.helidon.nima.webclient.http1.Http1ClientRequest;
import io.helidon.nima.webclient.http1.Http1ClientResponse;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
2 changes: 0 additions & 2 deletions integrations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
<configuration>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Xlint:-missing-explicit-ctor</arg>
<arg>-Xlint:-serial</arg>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@
import io.helidon.common.http.Http;
import io.helidon.integrations.common.rest.RestApi;
import io.helidon.integrations.vault.VaultOptionalResponse;

import jakarta.json.JsonObject;

class AppRoleAuthImpl implements AppRoleAuth {
Expand Down Expand Up @@ -49,7 +50,7 @@ public VaultOptionalResponse<ReadRoleId.Response> readRoleId(ReadRoleId.Request
String apiPath = "/auth/" + path + "/role/" + request.roleName() + "/role-id";

return restApi.get(apiPath, request, VaultOptionalResponse.<ReadRoleId.Response, JsonObject>vaultResponseBuilder()
.entityProcessor(ReadRoleId.Response::create));
.entityProcessor(ReadRoleId.Response::create));
}

@Override
Expand All @@ -71,8 +72,8 @@ public Login.Response login(Login.Request request) {
String apiPath = "/auth/" + path + "/login";

return restApi.invokeWithResponse(Http.Method.POST,
apiPath,
request,
Login.Response.builder());
apiPath,
request,
Login.Response.builder());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit a24abba

Please sign in to comment.