forked from loafle/openapi-generator-original
[Java][Play] Fix compilation issues when using the supportAsync option (#7864)
* fix async in java play generator * add async operation option * Remove the return null and replace with a return at the right place. Co-authored-by: Jean-François Côté <jcote@stingray.com>
This commit is contained in:
parent
3f75691da2
commit
2801c0cb88
@ -52,6 +52,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
|||||||
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|
||||||
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|
||||||
|sourceFolder|source folder for generated code| |/app|
|
|sourceFolder|source folder for generated code| |/app|
|
||||||
|
|supportAsync|Support Async operations| |false|
|
||||||
|title|server title name or client service name| |openapi-java-playframework|
|
|title|server title name or client service name| |openapi-java-playframework|
|
||||||
|useBeanValidation|Use BeanValidation API annotations| |true|
|
|useBeanValidation|Use BeanValidation API annotations| |true|
|
||||||
|useInterfaces|Makes the controllerImp implements an interface to facilitate automatic completion when updating from version x to y of your spec| |true|
|
|useInterfaces|Makes the controllerImp implements an interface to facilitate automatic completion when updating from version x to y of your spec| |true|
|
||||||
|
@ -44,6 +44,7 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
|||||||
public static final String HANDLE_EXCEPTIONS = "handleExceptions";
|
public static final String HANDLE_EXCEPTIONS = "handleExceptions";
|
||||||
public static final String WRAP_CALLS = "wrapCalls";
|
public static final String WRAP_CALLS = "wrapCalls";
|
||||||
public static final String USE_SWAGGER_UI = "useSwaggerUI";
|
public static final String USE_SWAGGER_UI = "useSwaggerUI";
|
||||||
|
public static final String SUPPORT_ASYNC = "supportAsync";
|
||||||
|
|
||||||
protected String title = "openapi-java-playframework";
|
protected String title = "openapi-java-playframework";
|
||||||
protected String configPackage = "org.openapitools.configuration";
|
protected String configPackage = "org.openapitools.configuration";
|
||||||
@ -54,6 +55,7 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
|||||||
protected boolean handleExceptions = true;
|
protected boolean handleExceptions = true;
|
||||||
protected boolean wrapCalls = true;
|
protected boolean wrapCalls = true;
|
||||||
protected boolean useSwaggerUI = true;
|
protected boolean useSwaggerUI = true;
|
||||||
|
protected boolean supportAsync = false;
|
||||||
|
|
||||||
public JavaPlayFrameworkCodegen() {
|
public JavaPlayFrameworkCodegen() {
|
||||||
super();
|
super();
|
||||||
@ -94,6 +96,7 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
|||||||
cliOptions.add(createBooleanCliWithDefault(HANDLE_EXCEPTIONS, "Add a 'throw exception' to each controller function. Add also a custom error handler where you can put your custom logic", handleExceptions));
|
cliOptions.add(createBooleanCliWithDefault(HANDLE_EXCEPTIONS, "Add a 'throw exception' to each controller function. Add also a custom error handler where you can put your custom logic", handleExceptions));
|
||||||
cliOptions.add(createBooleanCliWithDefault(WRAP_CALLS, "Add a wrapper to each controller function to handle things like metrics, response modification, etc..", wrapCalls));
|
cliOptions.add(createBooleanCliWithDefault(WRAP_CALLS, "Add a wrapper to each controller function to handle things like metrics, response modification, etc..", wrapCalls));
|
||||||
cliOptions.add(createBooleanCliWithDefault(USE_SWAGGER_UI, "Add a route to /api which show your documentation in swagger-ui. Will also import needed dependencies", useSwaggerUI));
|
cliOptions.add(createBooleanCliWithDefault(USE_SWAGGER_UI, "Add a route to /api which show your documentation in swagger-ui. Will also import needed dependencies", useSwaggerUI));
|
||||||
|
cliOptions.add(createBooleanCliWithDefault(SUPPORT_ASYNC, "Support Async operations", supportAsync));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -167,6 +170,11 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
|||||||
}
|
}
|
||||||
writePropertyBack(USE_SWAGGER_UI, useSwaggerUI);
|
writePropertyBack(USE_SWAGGER_UI, useSwaggerUI);
|
||||||
|
|
||||||
|
if (additionalProperties.containsKey(SUPPORT_ASYNC)) {
|
||||||
|
this.setSupportAsync(convertPropertyToBoolean(SUPPORT_ASYNC));
|
||||||
|
}
|
||||||
|
writePropertyBack(SUPPORT_ASYNC, supportAsync);
|
||||||
|
|
||||||
//We don't use annotation anymore
|
//We don't use annotation anymore
|
||||||
importMapping.remove("ApiModelProperty");
|
importMapping.remove("ApiModelProperty");
|
||||||
importMapping.remove("ApiModel");
|
importMapping.remove("ApiModel");
|
||||||
@ -287,6 +295,10 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
|
|||||||
this.useSwaggerUI = useSwaggerUI;
|
this.useSwaggerUI = useSwaggerUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSupportAsync(boolean supportAsync) {
|
||||||
|
this.supportAsync = supportAsync;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||||
|
@ -17,6 +17,7 @@ import openapitools.OpenAPIUtils;
|
|||||||
import static play.mvc.Results.ok;
|
import static play.mvc.Results.ok;
|
||||||
import play.api.libs.Files.TemporaryFile;
|
import play.api.libs.Files.TemporaryFile;
|
||||||
{{#supportAsync}}
|
{{#supportAsync}}
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.concurrent.CompletionStage;
|
import java.util.concurrent.CompletionStage;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
{{/supportAsync}}
|
{{/supportAsync}}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
{{^controllerOnly}}
|
{{^controllerOnly}}
|
||||||
{{^returnType}}
|
{{^returnType}}
|
||||||
{{#supportAsync}}
|
{{#supportAsync}}
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
{{/supportAsync}}
|
{{/supportAsync}}
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
{{#returnType}}{{#supportAsync}}CompletionStage<{{>returnTypesNoVoid}}> stage = {{/supportAsync}}{{^supportAsync}}{{>returnTypesNoVoid}} obj = {{/supportAsync}}{{/returnType}}{{^returnType}}{{#supportAsync}} {{/supportAsync}}{{/returnType}}{{^useInterfaces}}imp.{{/useInterfaces}}{{operationId}}(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}{{#supportAsync}}.thenApply(obj -> { {{/supportAsync}}{{/returnType}}{{^supportAsync}};{{/supportAsync}}{{#supportAsync}}{{^returnType}};{{/returnType}}{{/supportAsync}}
|
{{#returnType}}{{#supportAsync}}CompletionStage<{{>returnTypesNoVoid}}> stage = {{/supportAsync}}{{^supportAsync}}{{>returnTypesNoVoid}} obj = {{/supportAsync}}{{/returnType}}{{^returnType}}{{#supportAsync}} {{/supportAsync}}{{/returnType}}{{^useInterfaces}}imp.{{/useInterfaces}}{{operationId}}(request{{#hasParams}}, {{/hasParams}}{{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}{{#supportAsync}}.thenApply(obj -> { {{/supportAsync}}{{/returnType}}{{^supportAsync}};{{/supportAsync}}{{#supportAsync}}{{^returnType}};{{/returnType}}{{/supportAsync}}
|
||||||
@ -53,7 +54,7 @@ return CompletableFuture.supplyAsync(() -> {
|
|||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
{{#supportAsync}}
|
{{#supportAsync}}
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
{{/supportAsync}}
|
{{/supportAsync}}
|
||||||
{{^isResponseFile}}
|
{{^isResponseFile}}
|
||||||
{{#supportAsync}} {{/supportAsync}}JsonNode result = mapper.valueToTree(obj);
|
{{#supportAsync}} {{/supportAsync}}JsonNode result = mapper.valueToTree(obj);
|
||||||
@ -64,11 +65,23 @@ stage.thenApply(obj -> {
|
|||||||
{{/isResponseFile}}
|
{{/isResponseFile}}
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
{{^returnType}}
|
{{^returnType}}
|
||||||
{{#supportAsync}} {{/supportAsync}}return ok();
|
{{#supportAsync}}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
|
return ok();
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
{{/supportAsync}}
|
||||||
|
{{^supportAsync}}
|
||||||
|
return ok();
|
||||||
|
{{/supportAsync}}
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
|
{{#returnType}}
|
||||||
{{#supportAsync}}
|
{{#supportAsync}}
|
||||||
});
|
});
|
||||||
{{/supportAsync}}
|
{{/supportAsync}}
|
||||||
|
{{/returnType}}
|
||||||
{{/controllerOnly}}
|
{{/controllerOnly}}
|
||||||
{{#controllerOnly}}
|
{{#controllerOnly}}
|
||||||
return ok();
|
return ok();
|
||||||
|
@ -17,6 +17,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
import openapitools.OpenAPIUtils;
|
import openapitools.OpenAPIUtils;
|
||||||
import static play.mvc.Results.ok;
|
import static play.mvc.Results.ok;
|
||||||
import play.api.libs.Files.TemporaryFile;
|
import play.api.libs.Files.TemporaryFile;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.concurrent.CompletionStage;
|
import java.util.concurrent.CompletionStage;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@ -28,20 +29,30 @@ public abstract class PetApiControllerImpInterface {
|
|||||||
private ObjectMapper mapper = new ObjectMapper();
|
private ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
public CompletionStage<Result> addPetHttp(Http.Request request, Pet body) throws Exception {
|
public CompletionStage<Result> addPetHttp(Http.Request request, Pet body) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
addPet(request, body);
|
addPet(request, body);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void addPet(Http.Request request, Pet body) throws Exception;
|
public abstract void addPet(Http.Request request, Pet body) throws Exception;
|
||||||
|
|
||||||
public CompletionStage<Result> deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception {
|
public CompletionStage<Result> deletePetHttp(Http.Request request, Long petId, String apiKey) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
deletePet(request, petId, apiKey);
|
deletePet(request, petId, apiKey);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +67,7 @@ public abstract class PetApiControllerImpInterface {
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
});
|
});
|
||||||
@ -74,7 +85,7 @@ stage.thenApply(obj -> {
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
});
|
});
|
||||||
@ -90,7 +101,7 @@ stage.thenApply(obj -> {
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
});
|
});
|
||||||
@ -100,20 +111,30 @@ stage.thenApply(obj -> {
|
|||||||
public abstract CompletionStage<Pet> getPetById(Http.Request request, Long petId) throws Exception;
|
public abstract CompletionStage<Pet> getPetById(Http.Request request, Long petId) throws Exception;
|
||||||
|
|
||||||
public CompletionStage<Result> updatePetHttp(Http.Request request, Pet body) throws Exception {
|
public CompletionStage<Result> updatePetHttp(Http.Request request, Pet body) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
updatePet(request, body);
|
updatePet(request, body);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void updatePet(Http.Request request, Pet body) throws Exception;
|
public abstract void updatePet(Http.Request request, Pet body) throws Exception;
|
||||||
|
|
||||||
public CompletionStage<Result> updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception {
|
public CompletionStage<Result> updatePetWithFormHttp(Http.Request request, Long petId, String name, String status) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
updatePetWithForm(request, petId, name, status);
|
updatePetWithForm(request, petId, name, status);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +147,7 @@ stage.thenApply(obj -> {
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
import openapitools.OpenAPIUtils;
|
import openapitools.OpenAPIUtils;
|
||||||
import static play.mvc.Results.ok;
|
import static play.mvc.Results.ok;
|
||||||
import play.api.libs.Files.TemporaryFile;
|
import play.api.libs.Files.TemporaryFile;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.concurrent.CompletionStage;
|
import java.util.concurrent.CompletionStage;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@ -27,10 +28,15 @@ public abstract class StoreApiControllerImpInterface {
|
|||||||
private ObjectMapper mapper = new ObjectMapper();
|
private ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
public CompletionStage<Result> deleteOrderHttp(Http.Request request, String orderId) throws Exception {
|
public CompletionStage<Result> deleteOrderHttp(Http.Request request, String orderId) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
deleteOrder(request, orderId);
|
deleteOrder(request, orderId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +46,7 @@ public abstract class StoreApiControllerImpInterface {
|
|||||||
CompletionStage<Map<String, Integer>> stage = getInventory(request).thenApply(obj -> {
|
CompletionStage<Map<String, Integer>> stage = getInventory(request).thenApply(obj -> {
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
});
|
});
|
||||||
@ -56,7 +62,7 @@ stage.thenApply(obj -> {
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
});
|
});
|
||||||
@ -72,7 +78,7 @@ stage.thenApply(obj -> {
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
import openapitools.OpenAPIUtils;
|
import openapitools.OpenAPIUtils;
|
||||||
import static play.mvc.Results.ok;
|
import static play.mvc.Results.ok;
|
||||||
import play.api.libs.Files.TemporaryFile;
|
import play.api.libs.Files.TemporaryFile;
|
||||||
|
import java.util.concurrent.CompletionException;
|
||||||
import java.util.concurrent.CompletionStage;
|
import java.util.concurrent.CompletionStage;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@ -27,40 +28,60 @@ public abstract class UserApiControllerImpInterface {
|
|||||||
private ObjectMapper mapper = new ObjectMapper();
|
private ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
public CompletionStage<Result> createUserHttp(Http.Request request, User body) throws Exception {
|
public CompletionStage<Result> createUserHttp(Http.Request request, User body) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
createUser(request, body);
|
createUser(request, body);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void createUser(Http.Request request, User body) throws Exception;
|
public abstract void createUser(Http.Request request, User body) throws Exception;
|
||||||
|
|
||||||
public CompletionStage<Result> createUsersWithArrayInputHttp(Http.Request request, List<User> body) throws Exception {
|
public CompletionStage<Result> createUsersWithArrayInputHttp(Http.Request request, List<User> body) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
createUsersWithArrayInput(request, body);
|
createUsersWithArrayInput(request, body);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void createUsersWithArrayInput(Http.Request request, List<User> body) throws Exception;
|
public abstract void createUsersWithArrayInput(Http.Request request, List<User> body) throws Exception;
|
||||||
|
|
||||||
public CompletionStage<Result> createUsersWithListInputHttp(Http.Request request, List<User> body) throws Exception {
|
public CompletionStage<Result> createUsersWithListInputHttp(Http.Request request, List<User> body) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
createUsersWithListInput(request, body);
|
createUsersWithListInput(request, body);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void createUsersWithListInput(Http.Request request, List<User> body) throws Exception;
|
public abstract void createUsersWithListInput(Http.Request request, List<User> body) throws Exception;
|
||||||
|
|
||||||
public CompletionStage<Result> deleteUserHttp(Http.Request request, String username) throws Exception {
|
public CompletionStage<Result> deleteUserHttp(Http.Request request, String username) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
deleteUser(request, username);
|
deleteUser(request, username);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +94,7 @@ public abstract class UserApiControllerImpInterface {
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
});
|
});
|
||||||
@ -86,7 +107,7 @@ stage.thenApply(obj -> {
|
|||||||
CompletionStage<String> stage = loginUser(request, username, password).thenApply(obj -> {
|
CompletionStage<String> stage = loginUser(request, username, password).thenApply(obj -> {
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
stage.thenApply(obj -> {
|
return stage.thenApply(obj -> {
|
||||||
JsonNode result = mapper.valueToTree(obj);
|
JsonNode result = mapper.valueToTree(obj);
|
||||||
return ok(result);
|
return ok(result);
|
||||||
});
|
});
|
||||||
@ -96,20 +117,30 @@ stage.thenApply(obj -> {
|
|||||||
public abstract CompletionStage<String> loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception;
|
public abstract CompletionStage<String> loginUser(Http.Request request, @NotNull String username, @NotNull String password) throws Exception;
|
||||||
|
|
||||||
public CompletionStage<Result> logoutUserHttp(Http.Request request) throws Exception {
|
public CompletionStage<Result> logoutUserHttp(Http.Request request) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
logoutUser(request);
|
logoutUser(request);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void logoutUser(Http.Request request) throws Exception;
|
public abstract void logoutUser(Http.Request request) throws Exception;
|
||||||
|
|
||||||
public CompletionStage<Result> updateUserHttp(Http.Request request, String username, User body) throws Exception {
|
public CompletionStage<Result> updateUserHttp(Http.Request request, String username, User body) throws Exception {
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
CompletableFuture<Result> result = CompletableFuture.supplyAsync(() -> {
|
||||||
|
try {
|
||||||
updateUser(request, username, body);
|
updateUser(request, username, body);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CompletionException(e);
|
||||||
|
}
|
||||||
return ok();
|
return ok();
|
||||||
});
|
});
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user