Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package org.folio.okapi.auth;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.Future;
import io.vertx.core.VerticleBase;
import io.vertx.core.Vertx;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.handler.BodyHandler;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import org.apache.logging.log4j.Logger;
import org.folio.okapi.common.OkapiLogger;
Expand All @@ -22,7 +21,7 @@
*/
@java.lang.SuppressWarnings({"squid:S1192"})

public class MainVerticle extends AbstractVerticle {
public class MainVerticle extends VerticleBase {

private final Logger logger = OkapiLogger.get();

Expand All @@ -40,7 +39,7 @@ public static void main(String[] args) {
}

@Override
public void start(Promise<Void> promise) throws IOException {
public Future<?> start() {
Router router = Router.router(vertx);
Auth auth = new Auth();

Expand All @@ -57,9 +56,9 @@ public void start(Promise<Void> promise) throws IOException {
router.post("/_/tenant").handler(auth::tenantOp);
router.route("/*").handler(auth::filter);

vertx.createHttpServer()
return vertx.createHttpServer()
.requestHandler(router)
.listen(port).onComplete(result -> promise.handle(result.mapEmpty()));
.listen(port);
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package org.folio.okapi.header;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.core.Future;
import io.vertx.core.VerticleBase;
import io.vertx.core.Vertx;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import io.vertx.core.streams.ReadStream;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -22,7 +21,7 @@
* facilities, like supporting a _tenantPermissions interface.
*
*/
public class MainVerticle extends AbstractVerticle {
public class MainVerticle extends VerticleBase {

private final Logger logger = OkapiLogger.get();
private Map<String,JsonArray> savedPermissions = new HashMap<>();
Expand Down Expand Up @@ -89,7 +88,7 @@ private void myPermResult(RoutingContext ctx) {
}

@Override
public void start(Promise<Void> promise) throws IOException {
public Future<?> start() {
Router router = Router.router(vertx);

final int port = Integer.parseInt(
Expand All @@ -102,8 +101,8 @@ public void start(Promise<Void> promise) throws IOException {
router.get("/permResult").handler(this::myPermResult);
router.post("/_/tenantPermissions").handler(this::myPermissionHandle);

vertx.createHttpServer()
return vertx.createHttpServer()
.requestHandler(router)
.listen(port).onComplete(result -> promise.handle(result.mapEmpty()));
.listen(port);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.folio.okapi.sample;

import io.vertx.core.AbstractVerticle;
import static io.vertx.core.http.HttpHeaders.CONTENT_TYPE;

import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.VerticleBase;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerOptions;
Expand All @@ -14,6 +15,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.util.Objects;
import org.apache.logging.log4j.Logger;
import org.folio.okapi.common.HttpResponse;
import org.folio.okapi.common.ModuleVersionReporter;
Expand All @@ -24,14 +26,13 @@
/*
* Test module, to be used in Okapi's own unit tests
*/

@java.lang.SuppressWarnings({"squid:S1192"})
public class MainVerticle extends AbstractVerticle {
public class MainVerticle extends VerticleBase {

private final Logger logger = OkapiLogger.get();
private String helloGreeting;
private String helloGreeting =
Objects.requireNonNullElse(System.getenv("helloGreeting"), "Hello");
private String tenantRequests = "";
private JsonArray tenantParameters;
private JsonArray tenantParameters = null;

Check warning on line 35 in okapi-test-module/src/main/java/org/folio/okapi/sample/MainVerticle.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this initialization to "null", the compiler will do that for you.

See more on https://sonarcloud.io/project/issues?id=org.folio.okapi%3Aokapi&issues=AZq784t9Gp2JzAxoeGs0&open=AZq784t9Gp2JzAxoeGs0&pullRequest=1427

// Report the request headers in response headers, body, and/or log
private void headers(RoutingContext ctx, StringBuilder xmlMsg) {
Expand Down Expand Up @@ -86,7 +87,7 @@
ctx.response().setStatusCode(200);
ctx.response().putHeader("X-Handler-header", "OK");

final String ctype = ctx.request().headers().get("Content-Type");
final String ctype = ctx.request().headers().get(CONTENT_TYPE);
final String accept = ctx.request().headers().get("Accept");
// see if POSTed text should be converted to XML.. To simulate a real handler
// with request/response of different content types
Expand All @@ -99,9 +100,9 @@
msg.append(hv);
}
if (xmlConversion) {
ctx.response().putHeader("Content-Type", "text/xml");
ctx.response().putHeader(CONTENT_TYPE, "text/xml");
} else if (ctype != null) {
ctx.response().putHeader("Content-Type", ctype);
ctx.response().putHeader(CONTENT_TYPE, ctype);
}

String stopper = ctx.request().getHeader("X-stop-here");
Expand Down Expand Up @@ -162,7 +163,7 @@
} else {
ctx.response().setChunked(true);

final String cont = ctx.request().getHeader("Content-Type");
final String cont = ctx.request().getHeader(CONTENT_TYPE);
logger.debug("Tenant api content type: '{}'", cont);
String tok = ctx.request().getHeader(XOkapiHeaders.TOKEN);
if (tok == null) {
Expand Down Expand Up @@ -225,11 +226,7 @@
}

@Override
public void start(Promise<Void> promise) throws IOException {
helloGreeting = System.getenv("helloGreeting");
if (helloGreeting == null) {
helloGreeting = "Hello";
}
public Future<?> start() {
final int port = Integer.parseInt(
System.getProperty("http.port", System.getProperty("port", "8080")));
String name = ManagementFactory.getRuntimeMXBean().getName();
Expand All @@ -253,7 +250,7 @@
router.get("/recurse").handler(this::recurseHandle);

HttpServerOptions so = new HttpServerOptions().setHandle100ContinueAutomatically(true);
Future<Void> future = vertx.createHttpServer(so)
return vertx.createHttpServer(so)
.requestHandler(router)
.listen(port)
.compose(result -> {
Expand All @@ -270,6 +267,5 @@
}
return Future.succeededFuture();
});
future.onComplete(promise::handle);
}
}
Loading