From 9eee6eff9a48c2f0b9c009fd0a1a58933449799b Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Wed, 24 Mar 2021 11:55:26 +0100 Subject: [PATCH 01/11] WEBITOOLS-33: hide the call stack in the Api Call Exception --- .../core/exceptions/ApiCallException.java | 2 +- .../exceptions/HiddenStackTraceException.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/HiddenStackTraceException.java diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallException.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallException.java index 95635256..7316020f 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallException.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallException.java @@ -1,6 +1,6 @@ package com.castsoftware.aip.console.tools.core.exceptions; -public class ApiCallException extends Exception { +public class ApiCallException extends HiddenStackTraceException { private int httpStatus = 500; public ApiCallException(int httpStatus) { diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/HiddenStackTraceException.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/HiddenStackTraceException.java new file mode 100644 index 00000000..62b3b5de --- /dev/null +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/HiddenStackTraceException.java @@ -0,0 +1,24 @@ +package com.castsoftware.aip.console.tools.core.exceptions; + +public class HiddenStackTraceException extends Exception { + private static final String EMPTY_MESSAGE = ""; + private static final boolean ENABLE_STACK_TRACE = false; + private static final boolean ENABLE_SUPPRESSION = false; + + public HiddenStackTraceException() { + super(EMPTY_MESSAGE, null, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); + } + + public HiddenStackTraceException(Throwable cause) { + super(cause.toString(), cause, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); + } + + public HiddenStackTraceException(String message, Throwable cause) { + super(message, cause, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); + } + + public HiddenStackTraceException(String message) { + super(message, null, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); + } + +} From fc139d052756d13cbdfdf6177a88a4ed8d876012 Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Wed, 24 Mar 2021 17:37:35 +0100 Subject: [PATCH 02/11] WEBITOOLS-33: grab the API default message instead of whole json --- aip-console-tools-core/pom.xml | 5 ++++ .../core/services/RestApiServiceImpl.java | 25 +++++++++++++++---- pom.xml | 5 ++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/aip-console-tools-core/pom.xml b/aip-console-tools-core/pom.xml index 52d17db3..a0df2b1b 100644 --- a/aip-console-tools-core/pom.xml +++ b/aip-console-tools-core/pom.xml @@ -51,6 +51,11 @@ com.squareup.okhttp3 okhttp + + org.json + json + + junit diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiServiceImpl.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiServiceImpl.java index f218d41c..64675dc9 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiServiceImpl.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiServiceImpl.java @@ -32,6 +32,8 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; +import org.json.JSONArray; +import org.json.JSONObject; import java.io.IOException; import java.io.InputStream; @@ -228,7 +230,12 @@ public T exchangeMultipartForEntity(String method, String endpoint, Map T exchangeForEntity(String method, String endpoint, Object entity, J return mapResponse(response, javaType); } String message = "Response code from API was unexpected : " + response.code(); - message += "\nContent was " + (response.body() == null ? "EMPTY" : response.body().string()); + String messageBody = "EMPTY"; + if (response.body() != null) { + messageBody = new JSONArray(response.body().string()).getJSONObject(0).getString("defaultMessage"); + } + message += "\nContent was: " + messageBody; throw new ApiCallException(response.code(), message); } catch (IOException e) { log.log(Level.SEVERE, "Unable to send request", e); @@ -321,7 +332,11 @@ public void login() throws ApiCallException { return; } log.severe("Login to AIP Console failed (http status is " + response.code() + ")"); - log.severe("Content was " + (response.body() == null ? "EMPTY" : response.body().string())); + String message = "EMPTY"; + if (response.body() != null) { + message = new JSONObject(response.body().string()).getString("defaultMessage"); + } + log.severe("Content was " + message); throw new ApiCallException(response.code(), "Unable to login to AIP Console"); } catch (IOException e) { log.log(Level.SEVERE, "Unable to send request", e); @@ -409,10 +424,10 @@ public Response intercept(Chain chain) throws IOException { // get xsrf cookie if (xsrfCookie != null) { - log.finest("Setting XSRF-TOKEN header to " + xsrfCookie.value()); + RestApiServiceImpl.log.finest("Setting XSRF-TOKEN header to " + xsrfCookie.value()); reqBuilder.header("X-XSRF-TOKEN", xsrfCookie.value()); } else { - log.finest("No xsrf cookie, next request should set it"); + RestApiServiceImpl.log.finest("No xsrf cookie, next request should set it"); } if (request.header("Authorization") != null || diff --git a/pom.xml b/pom.xml index aa591698..c6e8fd3f 100644 --- a/pom.xml +++ b/pom.xml @@ -91,6 +91,11 @@ okhttp 3.8.1 + + org.json + json + 20190722 + From b0b8c597c69456863c5002e3aa8055020c0d7437 Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Mon, 29 Mar 2021 17:04:47 +0200 Subject: [PATCH 03/11] WEBITOOLS-33: use verbose parameter to throw exception --- .../plugins/aipconsole/DeliverBuilder.java | 2 +- .../core/exceptions/ApiCallException.java | 13 +++++- .../ApiCallNoStackTraceException.java | 40 +++++++++++++++++++ .../exceptions/HiddenStackTraceException.java | 24 ----------- .../tools/core/utils/LogUtilsTests.java | 17 ++++++++ 5 files changed, 69 insertions(+), 27 deletions(-) create mode 100644 aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallNoStackTraceException.java delete mode 100644 aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/HiddenStackTraceException.java diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java index 529ae815..53938f27 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java @@ -581,7 +581,7 @@ private void downloadDeliveryReport(FilePath workspace, String appGuid, String v taskListener.error("Failed to download the delivery report", e.getMessage()); } } - + /** * Check some initial elements before running the Job * diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallException.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallException.java index 7316020f..49299663 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallException.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallException.java @@ -1,7 +1,7 @@ package com.castsoftware.aip.console.tools.core.exceptions; -public class ApiCallException extends HiddenStackTraceException { - private int httpStatus = 500; +public class ApiCallException extends Exception { + protected int httpStatus = 500; public ApiCallException(int httpStatus) { super(); @@ -23,6 +23,15 @@ public ApiCallException(int httpStatus, String message, Throwable cause) { this.httpStatus = httpStatus; } + protected ApiCallException(String message, Throwable cause, boolean enableSuppression, boolean enableStackTrace) { + super(message, cause, enableSuppression, enableStackTrace); + } + + protected ApiCallException(int httpStatus, String message, Throwable cause, boolean enableSuppression, boolean enableStackTrace) { + super(message, cause, enableSuppression, enableStackTrace); + this.httpStatus = httpStatus; + } + public int getHttpStatus() { return httpStatus; } diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallNoStackTraceException.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallNoStackTraceException.java new file mode 100644 index 00000000..62f41f1b --- /dev/null +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/ApiCallNoStackTraceException.java @@ -0,0 +1,40 @@ +package com.castsoftware.aip.console.tools.core.exceptions; + +public class ApiCallNoStackTraceException extends ApiCallException { + private static final String EMPTY_MESSAGE = ""; + private static final boolean ENABLE_STACK_TRACE = false; + private static final boolean ENABLE_SUPPRESSION = false; + + public ApiCallNoStackTraceException() { + super(EMPTY_MESSAGE, null, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); + } + + public ApiCallNoStackTraceException(Throwable cause) { + super(cause.toString(), cause, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); + } + + public ApiCallNoStackTraceException(String message, Throwable cause) { + super(message, cause, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); + } + + public ApiCallNoStackTraceException(String message) { + super(message, null, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); + } + + public ApiCallNoStackTraceException(int httpStatus) { + this(); + this.httpStatus = httpStatus; + } + + public ApiCallNoStackTraceException(int httpStatus, String message) { + this(httpStatus, message, null); + } + + public ApiCallNoStackTraceException(int httpStatus, Throwable cause) { + this(httpStatus, cause.toString(), cause); + } + + public ApiCallNoStackTraceException(int httpStatus, String message, Throwable cause) { + super(httpStatus, message, cause, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); + } +} diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/HiddenStackTraceException.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/HiddenStackTraceException.java deleted file mode 100644 index 62b3b5de..00000000 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/HiddenStackTraceException.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.castsoftware.aip.console.tools.core.exceptions; - -public class HiddenStackTraceException extends Exception { - private static final String EMPTY_MESSAGE = ""; - private static final boolean ENABLE_STACK_TRACE = false; - private static final boolean ENABLE_SUPPRESSION = false; - - public HiddenStackTraceException() { - super(EMPTY_MESSAGE, null, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); - } - - public HiddenStackTraceException(Throwable cause) { - super(cause.toString(), cause, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); - } - - public HiddenStackTraceException(String message, Throwable cause) { - super(message, cause, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); - } - - public HiddenStackTraceException(String message) { - super(message, null, ENABLE_SUPPRESSION, ENABLE_STACK_TRACE); - } - -} diff --git a/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/LogUtilsTests.java b/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/LogUtilsTests.java index 6e1e1f7d..2e7be332 100644 --- a/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/LogUtilsTests.java +++ b/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/LogUtilsTests.java @@ -1,9 +1,13 @@ package com.castsoftware.aip.console.tools.core.utils; +import com.castsoftware.aip.console.tools.core.exceptions.ApiCallException; +import com.castsoftware.aip.console.tools.core.exceptions.ApiCallNoStackTraceException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; +import java.lang.reflect.InvocationTargetException; + import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -51,4 +55,17 @@ public void testHideLogSensitiveInformation() { replaced0 = LogUtils.replaceAllSensitiveInformation(line0); assertThat(replaced0.contains("--apiKey=" + LogUtils.REPLACEMENT_STR), is(true)); } + + + private ApiCallException getThrowableApiCallException(boolean verbose, int httpStatus, String message) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { + Class callException = verbose ? ApiCallException.class : + ApiCallNoStackTraceException.class; + return (ApiCallException) callException.getConstructor(int.class, String.class).newInstance(httpStatus, message); + } + + @Test + public void fake() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + ApiCallException thisException = getThrowableApiCallException(false, 201, "Unable to login to AIP Console"); + assertThat(thisException instanceof ApiCallNoStackTraceException, is(true)); + } } From b219efeb0e01540e3a413bda8ea3960be4b34438 Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Tue, 30 Mar 2021 16:10:02 +0200 Subject: [PATCH 04/11] WEBI-9883: use verbose parameter to throw exception in cli --- .../tools/commands/AddVersionCommand.java | 1 + .../tools/commands/AnalyzeCommand.java | 1 + .../commands/CreateApplicationCommand.java | 1 + .../tools/commands/DeliverVersionCommand.java | 1 + .../tools/commands/SnapshotCommand.java | 1 + .../exceptions/AipCallExceptionHelper.java | 40 +++++++++++++++---- .../tools/core/services/RestApiService.java | 3 +- .../core/services/RestApiServiceImpl.java | 19 ++++++--- .../utils/AipCallExceptionHelperTests.java | 36 ++++++++++++----- 9 files changed, 78 insertions(+), 25 deletions(-) diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java index 4ed1a171..9dc92696 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java @@ -130,6 +130,7 @@ public AddVersionCommand(RestApiService restApiService, JobsService jobsService, @Override public Integer call() { ApiInfoDto apiInfo = null; + restApiService.setVerbose(sharedOptions.isVerbose()); try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { restApiService.setTimeout(sharedOptions.getTimeout(), TimeUnit.SECONDS); diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java index faf0e706..4b0bcd5b 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java @@ -82,6 +82,7 @@ public Integer call() throws Exception { log.error("No application name provided. Exiting."); return Constants.RETURN_APPLICATION_INFO_MISSING; } + restApiService.setVerbose(sharedOptions.isVerbose()); try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/CreateApplicationCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/CreateApplicationCommand.java index fa0c2d8e..b1e28833 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/CreateApplicationCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/CreateApplicationCommand.java @@ -70,6 +70,7 @@ public class CreateApplicationCommand implements Callable { @Override public Integer call() { + restApiService.setVerbose(sharedOptions.isVerbose()); try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { restApiService.setTimeout(sharedOptions.getTimeout(), TimeUnit.SECONDS); diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/DeliverVersionCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/DeliverVersionCommand.java index 7c07ae06..19866c00 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/DeliverVersionCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/DeliverVersionCommand.java @@ -138,6 +138,7 @@ public Integer call() throws Exception { log.error("No application name provided. Exiting."); return Constants.RETURN_APPLICATION_INFO_MISSING; } + restApiService.setVerbose(sharedOptions.isVerbose()); try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/SnapshotCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/SnapshotCommand.java index a07bab43..9aeb84b1 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/SnapshotCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/SnapshotCommand.java @@ -86,6 +86,7 @@ public Integer call() throws Exception { log.error("No application name provided. Exiting."); return Constants.RETURN_APPLICATION_INFO_MISSING; } + restApiService.setVerbose(sharedOptions.isVerbose()); try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/AipCallExceptionHelper.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/AipCallExceptionHelper.java index 1a956a20..c40a18d1 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/AipCallExceptionHelper.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/exceptions/AipCallExceptionHelper.java @@ -7,19 +7,43 @@ private static Class getCallExceptionClass(boolean verbose) return verbose ? ApiCallException.class : ApiCallNoStackTraceException.class; } - public static ApiCallException getThrowableApiCallException(boolean verbose, int httpStatus) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - return (ApiCallException) getCallExceptionClass(verbose).getConstructor(int.class).newInstance(httpStatus); + public static ApiCallException getThrowableApiCallException(boolean verbose, int httpStatus) { + try { + return (ApiCallException) getCallExceptionClass(verbose).getConstructor(int.class).newInstance(httpStatus); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + e.printStackTrace(); + return new ApiCallException(httpStatus, e); //here with call stack anyway + } } - public static ApiCallException getThrowableApiCallException(boolean verbose, int httpStatus, String message) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - return (ApiCallException) getCallExceptionClass(verbose).getConstructor(int.class, String.class).newInstance(httpStatus, message); + public static ApiCallException getThrowableApiCallException(boolean verbose, int httpStatus, String message) { + try { + return (ApiCallException) getCallExceptionClass(verbose).getConstructor(int.class, String.class).newInstance(httpStatus, message); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + e.printStackTrace(); + return new ApiCallException(httpStatus, e); //here with call stack anyway + } } - public static ApiCallException getThrowableApiCallException(boolean verbose, int httpStatus, Throwable cause) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - return (ApiCallException) getCallExceptionClass(verbose).getConstructor(int.class, Throwable.class).newInstance(httpStatus, cause); + public static ApiCallException getThrowableApiCallException(boolean verbose, int httpStatus, Throwable cause) { + try { + return (ApiCallException) getCallExceptionClass(verbose).getConstructor(int.class, Throwable.class).newInstance(httpStatus, cause); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + e.printStackTrace(); + return new ApiCallException(httpStatus, e); //here with call stack anyway + } } - public static ApiCallException getThrowableApiCallException(boolean verbose, int httpStatus, String message, Throwable cause) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - return (ApiCallException) getCallExceptionClass(verbose).getConstructor(int.class, String.class, Throwable.class).newInstance(httpStatus, message, cause); + public static ApiCallException getThrowableApiCallException(boolean verbose, ApiCallException cause) { + return getThrowableApiCallException(verbose, cause.getHttpStatus(), cause); + } + + public static ApiCallException getThrowableApiCallException(boolean verbose, int httpStatus, String message, Throwable cause) { + try { + return (ApiCallException) getCallExceptionClass(verbose).getConstructor(int.class, String.class, Throwable.class).newInstance(httpStatus, message, cause); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + e.printStackTrace(); + return new ApiCallException(httpStatus, e); //here with call stack anyway + } } } diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiService.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiService.java index 197ed199..1388a943 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiService.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiService.java @@ -3,7 +3,6 @@ import com.castsoftware.aip.console.tools.core.dto.ApiInfoDto; import com.castsoftware.aip.console.tools.core.exceptions.ApiCallException; import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JavaType; import okhttp3.Response; import java.util.Map; @@ -46,6 +45,8 @@ public interface RestApiService { */ void login() throws ApiCallException; + void setVerbose(boolean verbose); + /** * Retrieve the API Info from AIP Console * diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiServiceImpl.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiServiceImpl.java index 64675dc9..4bd239c8 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiServiceImpl.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiServiceImpl.java @@ -1,6 +1,7 @@ package com.castsoftware.aip.console.tools.core.services; import com.castsoftware.aip.console.tools.core.dto.ApiInfoDto; +import com.castsoftware.aip.console.tools.core.exceptions.AipCallExceptionHelper; import com.castsoftware.aip.console.tools.core.exceptions.ApiCallException; import com.castsoftware.aip.console.tools.core.exceptions.ApiKeyMissingException; import com.castsoftware.aip.console.tools.core.utils.ApiEndpointHelper; @@ -59,6 +60,7 @@ public class RestApiServiceImpl implements RestApiService { private String serverUrl; private String username; private String key; + private boolean verbose; public RestApiServiceImpl() { this.cookieJar = new QueryableCookieJar(); @@ -109,7 +111,7 @@ public void validateUrlAndKey(String serverUrl, String apiKey) throws ApiCallExc if(StringUtils.isBlank(apiKey)) { log.severe("No Password or API Key provided to log in to AIP Console."); - throw new ApiKeyMissingException("No Password or API Key provided to log in to AIP Console."); + throw AipCallExceptionHelper.getThrowableApiCallException(verbose, new ApiKeyMissingException("No Password or API Key provided to log in to AIP Console.")); } if (!StringUtils.startsWithIgnoreCase(serverUrl, "http")) { @@ -279,7 +281,7 @@ private T exchangeForEntity(String method, String endpoint, Object entity, J messageBody = new JSONArray(response.body().string()).getJSONObject(0).getString("defaultMessage"); } message += "\nContent was: " + messageBody; - throw new ApiCallException(response.code(), message); + throw AipCallExceptionHelper.getThrowableApiCallException(verbose, response.code(), message); } catch (IOException e) { log.log(Level.SEVERE, "Unable to send request", e); throw new ApiCallException(500, e); @@ -334,13 +336,13 @@ public void login() throws ApiCallException { log.severe("Login to AIP Console failed (http status is " + response.code() + ")"); String message = "EMPTY"; if (response.body() != null) { - message = new JSONObject(response.body().string()).getString("defaultMessage"); + message = new JSONObject(response.body().string()).getString("error"); } log.severe("Content was " + message); - throw new ApiCallException(response.code(), "Unable to login to AIP Console"); + throw AipCallExceptionHelper.getThrowableApiCallException(verbose, response.code(), "Unable to login to AIP Console"); } catch (IOException e) { log.log(Level.SEVERE, "Unable to send request", e); - throw new ApiCallException(500, e); + throw AipCallExceptionHelper.getThrowableApiCallException(verbose, 500, e); } } @@ -366,7 +368,7 @@ private RequestBody getRequestBodyForEntity(Object entity) throws ApiCallExcepti entity == null ? "" : mapper.writeValueAsString(entity)); } catch (JsonProcessingException e) { log.log(Level.SEVERE, "Unable to map object of type " + entity.getClass().getName() + " to JSON", e); - throw new ApiCallException(500, e); + throw AipCallExceptionHelper.getThrowableApiCallException(verbose, 500, e); } } @@ -444,4 +446,9 @@ public Response intercept(Chain chain) throws IOException { } } } + + @Override + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } } diff --git a/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/AipCallExceptionHelperTests.java b/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/AipCallExceptionHelperTests.java index 04e1a29f..5602a0d9 100644 --- a/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/AipCallExceptionHelperTests.java +++ b/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/AipCallExceptionHelperTests.java @@ -3,13 +3,12 @@ import com.castsoftware.aip.console.tools.core.exceptions.AipCallExceptionHelper; import com.castsoftware.aip.console.tools.core.exceptions.ApiCallException; import com.castsoftware.aip.console.tools.core.exceptions.ApiCallNoStackTraceException; +import com.castsoftware.aip.console.tools.core.exceptions.ApiKeyMissingException; import com.castsoftware.aip.console.tools.core.exceptions.UploadException; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; -import java.lang.reflect.InvocationTargetException; - import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -17,50 +16,67 @@ public class AipCallExceptionHelperTests { @Test - public void testApiCallException_StatusAndMessageVverbose() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + public void testApiCallException_StatusAndMessageVverbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(true, 201, "Unable to login to AIP Console"); assertThat(thisException instanceof ApiCallException, is(true)); } @Test - public void testApiCallException_StatusVerbose() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + public void testApiCallException_StatusVerbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(true, 201); assertThat(thisException instanceof ApiCallException, is(true)); } @Test - public void testApiCallException_StatusAndMessageAndThrowableVerbose() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + public void testApiCallException_StatusAndMessageAndThrowableVerbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(true, 201, "Unable to login to AIP Console", new UploadException("Bla bla")); assertThat(thisException instanceof ApiCallException, is(true)); } @Test - public void testApiCallException_StatusAndThrowableVerbose() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + public void testApiCallException_StatusAndThrowableVerbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(true, 201, new UploadException("Bla bla")); assertThat(thisException instanceof ApiCallException, is(true)); } @Test - public void testApiCallException_StatusAndMessageNoVerbose() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + public void testApiCallException_ThrowableVerbose() { + ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(true, new ApiKeyMissingException("No Password or API Key provided to log in to AIP Console.")); + assertThat(thisException instanceof ApiCallException, is(true)); + } + + @Test + public void testApiCallException_ThrowableNoVerbose() { + ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(false, new ApiKeyMissingException("No Password or API Key provided to log in to AIP Console.")); + assertThat(thisException instanceof ApiCallNoStackTraceException, is(true)); + assertThat(thisException.getStackTrace().length, is(0)); + } + + @Test + public void testApiCallException_StatusAndMessageNoVerbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(false, 201, "Unable to login to AIP Console"); assertThat(thisException instanceof ApiCallNoStackTraceException, is(true)); + assertThat(thisException.getStackTrace().length, is(0)); } @Test - public void testApiCallException_StatusNoVerbose() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + public void testApiCallException_StatusNoVerbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(false, 201); assertThat(thisException instanceof ApiCallNoStackTraceException, is(true)); + assertThat(thisException.getStackTrace().length, is(0)); } @Test - public void testApiCallException_StatusAndMessageAndThrowableNoVerbose() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + public void testApiCallException_StatusAndMessageAndThrowableNoVerbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(false, 201, "Unable to login to AIP Console", new UploadException("Bla bla")); assertThat(thisException instanceof ApiCallNoStackTraceException, is(true)); + assertThat(thisException.getStackTrace().length, is(0)); } @Test - public void testApiCallException_StatusAndThrowableNoVerbose() throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + public void testApiCallException_StatusAndThrowableNoVerbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(false, 201, new UploadException("Bla bla")); assertThat(thisException instanceof ApiCallNoStackTraceException, is(true)); + assertThat(thisException.getStackTrace().length, is(0)); } } From 9041a23086745f13e6899e5e957a78084b63d1da Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Tue, 30 Mar 2021 17:21:31 +0200 Subject: [PATCH 05/11] WEBI-9883: use verbose parameter to throw exception in plugin --- .../java/io/jenkins/plugins/aipconsole/AddVersionBuilder.java | 3 ++- .../java/io/jenkins/plugins/aipconsole/AnalyzeBuilder.java | 2 ++ .../jenkins/plugins/aipconsole/CreateApplicationBuilder.java | 4 ++++ .../java/io/jenkins/plugins/aipconsole/DeliverBuilder.java | 2 ++ .../java/io/jenkins/plugins/aipconsole/SnapshotBuilder.java | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionBuilder.java index eeccdd2e..e7afe214 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionBuilder.java @@ -290,7 +290,8 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul jobsService = injector.getInstance(JobsService.class); applicationService = injector.getInstance(ApplicationService.class); } - + + apiService.setVerbose(getDescriptor().configuration.isVerbose()); String apiServerUrl = getDescriptor().getAipConsoleUrl(); String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); String username = getDescriptor().getAipConsoleUsername(); diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeBuilder.java index fc597b1f..23ad270e 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeBuilder.java @@ -175,6 +175,8 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul jobsService = injector.getInstance(JobsService.class); applicationService = injector.getInstance(ApplicationService.class); } + + apiService.setVerbose(getDescriptor().configuration.isVerbose()); String apiServerUrl = getDescriptor().getAipConsoleUrl(); String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationBuilder.java index 952c49ed..f3653111 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationBuilder.java @@ -146,6 +146,10 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul Guice.createInjector(new AipConsoleModule()).injectMembers(this); } + if (apiService != null) { + apiService.setVerbose(getDescriptor().configuration.isVerbose()); + } + String apiServerUrl = getDescriptor().getAipConsoleUrl(); String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); String username = getDescriptor().getAipConsoleUsername(); diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java index 53938f27..eac4f4b8 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java @@ -315,6 +315,8 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul jobsService = injector.getInstance(JobsService.class); applicationService = injector.getInstance(ApplicationService.class); } + + apiService.setVerbose(getDescriptor().configuration.isVerbose()); String apiServerUrl = getDescriptor().getAipConsoleUrl(); String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotBuilder.java index f26025a7..20864806 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotBuilder.java @@ -167,6 +167,8 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul applicationService = injector.getInstance(ApplicationService.class); } + apiService.setVerbose(getDescriptor().configuration.isVerbose()); + String apiServerUrl = getDescriptor().getAipConsoleUrl(); String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); String username = getDescriptor().getAipConsoleUsername(); From 99109239c01b2616f29f8a8272f8f6121b3be08b Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Mon, 31 May 2021 10:56:48 +0200 Subject: [PATCH 06/11] WEBITOOLS-33 stack trace hidden with debug options --- .../main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java index c791cd07..3ef1f87c 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java @@ -589,7 +589,7 @@ private void downloadDeliveryReport(FilePath workspace, String appGuid, String v taskListener.error("Failed to download the delivery report", e.getMessage()); } } - + /** * Check some initial elements before running the Job * From 2049114d53c39368bcf4578f54af8413aef71a43 Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Mon, 31 May 2021 16:51:12 +0200 Subject: [PATCH 07/11] WEBITOOLS-33 stack trace management with verbose option --- .../AddVersionCommandIntegrationTest.java | 1 - .../tools/AipConsoleToolsCliBaseTest.java | 14 +- .../tools/CallStackManagementTest.java | 120 ++++++++++++++++++ .../tools/core/services/RestApiService.java | 6 + .../utils/AipCallExceptionHelperTests.java | 7 + 5 files changed, 141 insertions(+), 7 deletions(-) create mode 100644 aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/CallStackManagementTest.java diff --git a/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AddVersionCommandIntegrationTest.java b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AddVersionCommandIntegrationTest.java index 21bead38..db1040e5 100644 --- a/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AddVersionCommandIntegrationTest.java +++ b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AddVersionCommandIntegrationTest.java @@ -138,5 +138,4 @@ public void testAddVersionCommand() throws ApplicationServiceException { assertThat(spec, is(notNullValue())); } - } diff --git a/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AipConsoleToolsCliBaseTest.java b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AipConsoleToolsCliBaseTest.java index 21235264..bc817c92 100644 --- a/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AipConsoleToolsCliBaseTest.java +++ b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AipConsoleToolsCliBaseTest.java @@ -81,12 +81,14 @@ protected void resetSharedOptions(SharedOptions command) { if (unExpectedParameters != null) { unExpectedParameters.clear(); } - command.setApiKey(null); - command.setApiKeyEnvVariable(null); - command.setServerRootUrl(null); - command.setUsername(null); - if (command.getUnmatchedOptions() != null) { - command.getUnmatchedOptions().clear(); + if (command != null) { + command.setApiKey(null); + command.setApiKeyEnvVariable(null); + command.setServerRootUrl(null); + command.setUsername(null); + if (command.getUnmatchedOptions() != null) { + command.getUnmatchedOptions().clear(); + } } } diff --git a/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/CallStackManagementTest.java b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/CallStackManagementTest.java new file mode 100644 index 00000000..ad84e90e --- /dev/null +++ b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/CallStackManagementTest.java @@ -0,0 +1,120 @@ +package com.castsoftware.aip.console.tools; + +import com.castsoftware.aip.console.tools.core.exceptions.ApiCallException; +import com.castsoftware.aip.console.tools.core.exceptions.ApiCallNoStackTraceException; +import com.castsoftware.aip.console.tools.core.exceptions.ApplicationServiceException; +import com.castsoftware.aip.console.tools.core.exceptions.JobServiceException; +import com.castsoftware.aip.console.tools.core.exceptions.PackagePathInvalidException; +import com.castsoftware.aip.console.tools.core.exceptions.UploadException; +import com.castsoftware.aip.console.tools.core.services.RestApiServiceImpl; +import okhttp3.Call; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Protocol; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.apache.commons.lang3.StringUtils; +import org.hamcrest.core.Is; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.springframework.test.util.ReflectionTestUtils; + +import java.io.IOException; +import java.util.Arrays; +import java.util.stream.Collectors; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +@RunWith(MockitoJUnitRunner.class) +public class CallStackManagementTest { + @Test + public void testAddVersionCommand_loginFailedWithVerbose() throws ApiCallException, ApplicationServiceException, UploadException, JobServiceException, PackagePathInvalidException, IOException { + OkHttpClient client = Mockito.mock(OkHttpClient.class); + Call realCall = Mockito.mock(Call.class); + final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + String bodyJson = "{\n" + + " \"error\": \"Unauthorized\",\n" + + " \"message\": \"fake Unauthorized user message\",\n" + + " \"path\": \"/api/applications/61bc26f5-365c-40b6-b821-29338d879f08/debug-options\",\n" + + " \"status\": 401,\n" + + " \"timestamp\": \"2021-05-31T13:47:33.089Z\"\n" + + "}"; + RequestBody body = RequestBody.create(JSON, bodyJson); + Request request = new Request.Builder() + .url("https://demo-eu.castsoftware.com/ui/index.html#/") + .post(body) + .build(); + + Response.Builder responseBuilder = new Response.Builder(); + Response response = responseBuilder.request(request).protocol(Protocol.HTTP_1_0).code(401) + .message(body.toString()) + .body(ResponseBody.create(JSON, bodyJson)) + .build(); + when(realCall.execute()).thenReturn(response); + when(client.newCall(any(Request.class))).thenReturn(realCall); + RestApiServiceImpl restApiService = new RestApiServiceImpl(); + ReflectionTestUtils.setField(restApiService, "client", client); + ReflectionTestUtils.setField(restApiService, "serverUrl", "https://demo-eu.castsoftware.com"); + ReflectionTestUtils.setField(restApiService, "verbose", true); + + try { + restApiService.login(); + fail(); + } catch (ApiCallException e) { + //Mage sure stack trace is there + assertThat(e.getStackTrace().length, greaterThan(1)); + assertThat(StringUtils.isEmpty(Arrays.stream(e.getStackTrace()).map(StackTraceElement::getClassName).collect(Collectors.joining(";"))), is(false)); + } + } + + @Test + public void testAddVersionCommand_loginFailedWithoutVerbose() throws ApiCallException, ApplicationServiceException, UploadException, JobServiceException, PackagePathInvalidException, IOException { + OkHttpClient client = Mockito.mock(OkHttpClient.class); + Call realCall = Mockito.mock(Call.class); + final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + String bodyJson = "{\n" + + " \"error\": \"Unauthorized\",\n" + + " \"message\": \"fake Unauthorized user message\",\n" + + " \"path\": \"/api/applications/61bc26f5-365c-40b6-b821-29338d879f08/debug-options\",\n" + + " \"status\": 401,\n" + + " \"timestamp\": \"2021-05-31T13:47:33.089Z\"\n" + + "}"; + RequestBody body = RequestBody.create(JSON, bodyJson); + Request request = new Request.Builder() + .url("https://demo-eu.castsoftware.com/ui/index.html#/") + .post(body) + .build(); + + Response.Builder responseBuilder = new Response.Builder(); + Response response = responseBuilder.request(request).protocol(Protocol.HTTP_1_0).code(401) + .message(body.toString()) + .body(ResponseBody.create(JSON, bodyJson)) + .build(); + when(realCall.execute()).thenReturn(response); + when(client.newCall(any(Request.class))).thenReturn(realCall); + RestApiServiceImpl restApiService = new RestApiServiceImpl(); + ReflectionTestUtils.setField(restApiService, "client", client); + ReflectionTestUtils.setField(restApiService, "serverUrl", "https://demo-eu.castsoftware.com"); + ReflectionTestUtils.setField(restApiService, "verbose", false); + + try { + restApiService.login(); + fail(); + } catch (ApiCallException e) { + //Mage sure stack trace is not there + Assert.assertThat(e instanceof ApiCallNoStackTraceException, Is.is(true)); + assertThat(e.getStackTrace().length, is(0)); + assertThat(StringUtils.isEmpty(Arrays.stream(e.getStackTrace()).map(StackTraceElement::getClassName).collect(Collectors.joining(";"))), is(true)); + } + } +} diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiService.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiService.java index 1388a943..a1d36a37 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiService.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/RestApiService.java @@ -45,6 +45,12 @@ public interface RestApiService { */ void login() throws ApiCallException; + /** + * Used by the service to display the stack trace depending on whether the argument + * is set to true or not.

Each Action or Builder should manage this by itself + * + * @param verbose enable or disable stack trace output. + */ void setVerbose(boolean verbose); /** diff --git a/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/AipCallExceptionHelperTests.java b/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/AipCallExceptionHelperTests.java index 5602a0d9..a067c4de 100644 --- a/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/AipCallExceptionHelperTests.java +++ b/aip-console-tools-core/src/test/java/com/castsoftware/aip/console/tools/core/utils/AipCallExceptionHelperTests.java @@ -5,10 +5,13 @@ import com.castsoftware.aip.console.tools.core.exceptions.ApiCallNoStackTraceException; import com.castsoftware.aip.console.tools.core.exceptions.ApiKeyMissingException; import com.castsoftware.aip.console.tools.core.exceptions.UploadException; +import org.apache.commons.lang3.StringUtils; +import org.hamcrest.Matchers; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.junit.MockitoJUnitRunner; +import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -31,6 +34,8 @@ public void testApiCallException_StatusVerbose() { public void testApiCallException_StatusAndMessageAndThrowableVerbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(true, 201, "Unable to login to AIP Console", new UploadException("Bla bla")); assertThat(thisException instanceof ApiCallException, is(true)); + assertThat(thisException.getStackTrace().length, greaterThan(1)); + assertThat(StringUtils.isEmpty(thisException.getStackTrace().toString()), Matchers.is(false)); } @Test @@ -43,6 +48,8 @@ public void testApiCallException_StatusAndThrowableVerbose() { public void testApiCallException_ThrowableVerbose() { ApiCallException thisException = AipCallExceptionHelper.getThrowableApiCallException(true, new ApiKeyMissingException("No Password or API Key provided to log in to AIP Console.")); assertThat(thisException instanceof ApiCallException, is(true)); + assertThat(thisException.getStackTrace().length, greaterThan(1)); + assertThat(StringUtils.isEmpty(thisException.getStackTrace().toString()), Matchers.is(false)); } @Test From be422a10a211ee70b14495bdade5b26af1c34c60 Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Wed, 16 Jun 2021 15:39:22 +0200 Subject: [PATCH 08/11] WEBITOOLS-33: updates due to code review --- .../tools/commands/AddVersionCommand.java | 14 ++------ .../tools/commands/AnalyzeCommand.java | 11 ++----- .../tools/commands/BaseCollableCommand.java | 32 +++++++++++++++++++ .../commands/CreateApplicationCommand.java | 26 ++++----------- .../tools/commands/DeliverVersionCommand.java | 16 +++------- .../tools/commands/SnapshotCommand.java | 12 ++----- 6 files changed, 52 insertions(+), 59 deletions(-) create mode 100644 aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/BaseCollableCommand.java diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java index 32104f32..66b1a79f 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java @@ -28,7 +28,6 @@ import java.nio.file.Files; import java.util.Date; import java.util.List; -import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -42,17 +41,13 @@ @Slf4j @Getter @Setter -public class AddVersionCommand implements Callable { - private final RestApiService restApiService; +public class AddVersionCommand extends BaseCollableCommand { private final JobsService jobsService; private final UploadService uploadService; private final ApplicationService applicationService; - @CommandLine.Mixin - private SharedOptions sharedOptions; - public AddVersionCommand(RestApiService restApiService, JobsService jobsService, UploadService uploadService, ApplicationService applicationService) { - this.restApiService = restApiService; + super(restApiService); this.jobsService = jobsService; this.uploadService = uploadService; this.applicationService = applicationService; @@ -134,9 +129,8 @@ public AddVersionCommand(RestApiService restApiService, JobsService jobsService, private List unmatchedOptions; @Override - public Integer call() { + public Integer doCall() { ApiInfoDto apiInfo = null; - restApiService.setVerbose(sharedOptions.isVerbose()); try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { restApiService.setTimeout(sharedOptions.getTimeout(), TimeUnit.SECONDS); @@ -149,8 +143,6 @@ public Integer call() { return Constants.RETURN_LOGIN_ERROR; } - log.info("AddVersion version command has triggered with log output = '{}'", sharedOptions.isVerbose()); - if (StringUtils.isBlank(applicationName) && StringUtils.isBlank(applicationGuid)) { log.error("No application name or application guid provided. Exiting."); return Constants.RETURN_APPLICATION_INFO_MISSING; diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java index 1f9fb15a..995f767a 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java @@ -27,7 +27,6 @@ import java.util.Comparator; import java.util.Date; import java.util.Set; -import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -44,13 +43,10 @@ @Slf4j @Getter @Setter -public class AnalyzeCommand implements Callable { +public class AnalyzeCommand extends BaseCollableCommand { private static final DateFormat RELEASE_DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - private final RestApiService restApiService; private final JobsService jobsService; private final ApplicationService applicationService; - @CommandLine.Mixin - private SharedOptions sharedOptions; @CommandLine.Option(names = {"-n", "--app-name"}, paramLabel = "APPLICATION_NAME", @@ -73,18 +69,17 @@ public class AnalyzeCommand implements Callable { private boolean processImaging = false; public AnalyzeCommand(RestApiService restApiService, JobsService jobsService, ApplicationService applicationService) { - this.restApiService = restApiService; + super(restApiService); this.jobsService = jobsService; this.applicationService = applicationService; } @Override - public Integer call() throws Exception { + public Integer doCall() throws Exception { if (StringUtils.isBlank(applicationName)) { log.error("No application name provided. Exiting."); return Constants.RETURN_APPLICATION_INFO_MISSING; } - restApiService.setVerbose(sharedOptions.isVerbose()); try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/BaseCollableCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/BaseCollableCommand.java new file mode 100644 index 00000000..93b97064 --- /dev/null +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/BaseCollableCommand.java @@ -0,0 +1,32 @@ +package com.castsoftware.aip.console.tools.commands; + +import com.castsoftware.aip.console.tools.core.services.RestApiService; +import lombok.extern.slf4j.Slf4j; +import picocli.CommandLine; + +import java.util.concurrent.Callable; + +@Slf4j +public abstract class BaseCollableCommand implements Callable { + protected final RestApiService restApiService; + + @CommandLine.Mixin + protected SharedOptions sharedOptions; + + protected BaseCollableCommand(RestApiService restApiService) { + this.restApiService = restApiService; + } + + protected abstract Integer doCall() throws Exception; + + public SharedOptions getSharedOptions() { + return sharedOptions; + } + + @Override + public Integer call() throws Exception { + log.info("AddVersion version command has triggered with log verbose mode = '{}'", sharedOptions.isVerbose()); + restApiService.setVerbose(sharedOptions.isVerbose()); + return doCall(); + } +} diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/CreateApplicationCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/CreateApplicationCommand.java index 998241ed..07365671 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/CreateApplicationCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/CreateApplicationCommand.java @@ -8,19 +8,15 @@ import com.castsoftware.aip.console.tools.core.services.JobsService; import com.castsoftware.aip.console.tools.core.services.RestApiService; import com.castsoftware.aip.console.tools.core.utils.Constants; -import lombok.AllArgsConstructor; import lombok.Getter; -import lombok.NoArgsConstructor; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import picocli.CommandLine; import java.util.Arrays; import java.util.List; -import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; @Component @@ -33,18 +29,13 @@ @Slf4j @Getter @Setter -@NoArgsConstructor -@AllArgsConstructor -public class CreateApplicationCommand implements Callable { +public class CreateApplicationCommand extends BaseCollableCommand { + private final JobsService jobsService; - @Autowired - private JobsService jobsService; - - @Autowired - private RestApiService restApiService; - - @CommandLine.Mixin - private SharedOptions sharedOptions; + public CreateApplicationCommand(RestApiService restApiService, JobsService jobsService) { + super(restApiService); + this.jobsService = jobsService; + } /** * options for the upload and job startup @@ -70,8 +61,7 @@ public class CreateApplicationCommand implements Callable { private List unmatchedOptions; @Override - public Integer call() { - restApiService.setVerbose(sharedOptions.isVerbose()); + public Integer doCall() { try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { restApiService.setTimeout(sharedOptions.getTimeout(), TimeUnit.SECONDS); @@ -83,8 +73,6 @@ public Integer call() { return Constants.RETURN_LOGIN_ERROR; } - log.info("Create application command has triggered with log output = '{}'", sharedOptions.isVerbose()); - try { String nodeGuid = null; if (StringUtils.isNotBlank(nodeName)) { diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/DeliverVersionCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/DeliverVersionCommand.java index 300d1f14..1afa5720 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/DeliverVersionCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/DeliverVersionCommand.java @@ -26,7 +26,6 @@ import java.io.File; import java.nio.file.Files; import java.util.Date; -import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -43,15 +42,11 @@ @Slf4j @Getter @Setter -public class DeliverVersionCommand implements Callable { - private final RestApiService restApiService; +public class DeliverVersionCommand extends BaseCollableCommand { private final JobsService jobsService; private final UploadService uploadService; private final ApplicationService applicationService; - @CommandLine.Mixin - private SharedOptions sharedOptions; - @CommandLine.Option(names = {"-n", "--app-name"}, paramLabel = "APPLICATION_NAME", description = "The Name of the application to rescan", @@ -136,14 +131,14 @@ public class DeliverVersionCommand implements Callable { private String domainName; public DeliverVersionCommand(RestApiService restApiService, JobsService jobsService, UploadService uploadService, ApplicationService applicationService) { - this.restApiService = restApiService; + super(restApiService); this.jobsService = jobsService; this.uploadService = uploadService; this.applicationService = applicationService; } @Override - public Integer call() throws Exception { + public Integer doCall() { // Same as a part of the AddVersion command // Upload a local file or register a remote path // And then starts a job up to "Delivery" @@ -152,7 +147,6 @@ public Integer call() throws Exception { log.error("No application name provided. Exiting."); return Constants.RETURN_APPLICATION_INFO_MISSING; } - restApiService.setVerbose(sharedOptions.isVerbose()); try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { @@ -164,9 +158,7 @@ public Integer call() throws Exception { } catch (ApiCallException e) { return Constants.RETURN_LOGIN_ERROR; } - - log.info("Deliver version command has triggered with log output = '{}'", sharedOptions.isVerbose()); - + String applicationGuid; Thread shutdownHook = null; diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/SnapshotCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/SnapshotCommand.java index 57b6e813..bbb800d4 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/SnapshotCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/SnapshotCommand.java @@ -29,7 +29,6 @@ import java.util.Date; import java.util.Optional; import java.util.Set; -import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import java.util.function.Function; @@ -46,13 +45,10 @@ @Slf4j @Getter @Setter -public class SnapshotCommand implements Callable { +public class SnapshotCommand extends BaseCollableCommand { private static final DateFormat RELEASE_DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - private final RestApiService restApiService; private final JobsService jobsService; private final ApplicationService applicationService; - @CommandLine.Mixin - private SharedOptions sharedOptions; @CommandLine.Option(names = {"-n", "--app-name"}, paramLabel = "APPLICATION_NAME", @@ -75,20 +71,18 @@ public class SnapshotCommand implements Callable { private boolean processImaging = false; public SnapshotCommand(RestApiService restApiService, JobsService jobsService, ApplicationService applicationService) { - this.restApiService = restApiService; + super(restApiService); this.jobsService = jobsService; this.applicationService = applicationService; } - @Override - public Integer call() throws Exception { + public Integer doCall() { // Runs snapshot + upload if (StringUtils.isBlank(applicationName)) { log.error("No application name provided. Exiting."); return Constants.RETURN_APPLICATION_INFO_MISSING; } - restApiService.setVerbose(sharedOptions.isVerbose()); try { if (sharedOptions.getTimeout() != Constants.DEFAULT_HTTP_TIMEOUT) { From 6f1472578c3602abe8a7168af93eb262a1e7dee4 Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Wed, 16 Jun 2021 16:23:21 +0200 Subject: [PATCH 09/11] WEBITOOLS-33: update local develop --- .../tools/commands/AddVersionCommand.java | 36 +++++++++++++++- .../tools/commands/AnalyzeCommand.java | 35 ++++++++++++++++ .../AddVersionCommandIntegrationTest.java | 5 +++ .../tools/AnalyzeCommandIntegrationTest.java | 5 +++ .../tools/core/dto/DebugOptionsDto.java | 16 ++++++++ .../aip/console/tools/core/dto/JsonDto.java | 22 ++++++++++ .../core/services/ApplicationService.java | 18 +++++++- .../core/services/ApplicationServiceImpl.java | 41 +++++++++++++++++++ .../tools/core/utils/ApiEndpointHelper.java | 19 +++++++++ 9 files changed, 194 insertions(+), 3 deletions(-) create mode 100644 aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/dto/DebugOptionsDto.java create mode 100644 aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/dto/JsonDto.java diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java index 258b4f35..2867c89f 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java @@ -2,6 +2,7 @@ import com.castsoftware.aip.console.tools.core.dto.ApiInfoDto; import com.castsoftware.aip.console.tools.core.dto.ApplicationDto; +import com.castsoftware.aip.console.tools.core.dto.DebugOptionsDto; import com.castsoftware.aip.console.tools.core.dto.jobs.JobRequestBuilder; import com.castsoftware.aip.console.tools.core.dto.jobs.JobState; import com.castsoftware.aip.console.tools.core.dto.jobs.JobStatusWithSteps; @@ -16,6 +17,7 @@ import com.castsoftware.aip.console.tools.core.services.JobsService; import com.castsoftware.aip.console.tools.core.services.RestApiService; import com.castsoftware.aip.console.tools.core.services.UploadService; +import com.castsoftware.aip.console.tools.core.utils.ApiEndpointHelper; import com.castsoftware.aip.console.tools.core.utils.Constants; import lombok.Getter; import lombok.Setter; @@ -130,6 +132,20 @@ public AddVersionCommand(RestApiService restApiService, JobsService jobsService, @CommandLine.Option(names = "--domain-name", paramLabel = "DOMAIN_NAME", description = "The name of the domain to assign to the application. Will be created if it doesn't exists. No domain will be assigned if left empty.") private String domainName; + /** + * Application debug options + */ + @CommandLine.Option(names = {"-sql", "--show-sql"} + , description = "Enable or Desible application' Show Sql debug option (default: ${DEFAULT-VALUE})" + + " if specified without parameter: ${FALLBACK-VALUE}", fallbackValue = "true" + , defaultValue = "false") + private boolean showSql; + @CommandLine.Option(names = {"-amt", "--amt-profiling"} + , description = "Enable or Desible application' AMT Profiling debug option (default: ${DEFAULT-VALUE})" + + " if specified without parameter: ${FALLBACK-VALUE}", fallbackValue = "true" + , defaultValue = "false") + private boolean amtProfiling; + @CommandLine.Unmatched private List unmatchedOptions; @@ -149,6 +165,8 @@ public Integer call() { } log.info("AddVersion version command has triggered with log output = '{}'", sharedOptions.isVerbose()); + log.info("[Debug options] Show Sql is '{}'", showSql); + log.info("[Debug options] AMT Profiling is '{}'", amtProfiling); if (StringUtils.isBlank(applicationName) && StringUtils.isBlank(applicationGuid)) { log.error("No application name or application guid provided. Exiting."); @@ -200,6 +218,17 @@ public Integer call() { builder.snapshotName(snapshotName); } + //============== + // Ony set debug option when ON. Run Analysis always consider these options as OFF(disabled) + //============== + DebugOptionsDto oldDebugOptions = applicationService.getDebugOptions(applicationGuid); + if (showSql) { + applicationService.updateShowSqlDebugOption(applicationGuid, showSql); + } + if (amtProfiling) { + applicationService.updateAmtProfileDebugOption(applicationGuid, amtProfiling); + } + String jobGuid = jobsService.startAddVersionJob(builder); // add a shutdown hook, to cancel the job Thread shutdownHook = getShutdownHookForJobGuid(jobGuid); @@ -208,12 +237,17 @@ public Integer call() { JobStatusWithSteps jobStatus = jobsService.pollAndWaitForJobFinished(jobGuid, Function.identity(), sharedOptions.isVerbose()); // Deregister the shutdown hook since the job is finished and we won't need to cancel it Runtime.getRuntime().removeShutdownHook(shutdownHook); + DebugOptionsDto debugOptions = applicationService.getDebugOptions(applicationGuid); + applicationService.resetDebugOptions(applicationGuid, oldDebugOptions); if (JobState.COMPLETED == jobStatus.getState()) { + if (debugOptions.isActivateAmtMemoryProfile()) { + log.info("[Debug options] Amt Profiling file download URL: {}", + sharedOptions.getFullServerRootUrl() + ApiEndpointHelper.getAmtProfilingDownloadUrl(applicationGuid)); + } log.info("Job completed successfully."); return Constants.RETURN_OK; } - log.error("Job did not complete. Status is '{}' on step '{}'", jobStatus.getState(), jobStatus.getFailureStep()); return Constants.RETURN_JOB_FAILED; diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java index 317db6cb..cb283cf0 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AnalyzeCommand.java @@ -1,6 +1,7 @@ package com.castsoftware.aip.console.tools.commands; import com.castsoftware.aip.console.tools.core.dto.ApiInfoDto; +import com.castsoftware.aip.console.tools.core.dto.DebugOptionsDto; import com.castsoftware.aip.console.tools.core.dto.VersionDto; import com.castsoftware.aip.console.tools.core.dto.VersionStatus; import com.castsoftware.aip.console.tools.core.dto.jobs.JobRequestBuilder; @@ -14,6 +15,7 @@ import com.castsoftware.aip.console.tools.core.services.ApplicationService; import com.castsoftware.aip.console.tools.core.services.JobsService; import com.castsoftware.aip.console.tools.core.services.RestApiService; +import com.castsoftware.aip.console.tools.core.utils.ApiEndpointHelper; import com.castsoftware.aip.console.tools.core.utils.Constants; import lombok.Getter; import lombok.Setter; @@ -71,6 +73,19 @@ public class AnalyzeCommand implements Callable { @CommandLine.Option(names = "--process-imaging", description = "If provided, will upload data to Imaging. Note: Parameter will be ignored if snapshot option is not provided and Imaging is not setup in AIP Console" + " if specified without parameter: ${FALLBACK-VALUE}", fallbackValue = "true") private boolean processImaging = false; + /** + * Application debug options + */ + @CommandLine.Option(names = {"-sql", "--show-sql"} + , description = "Enable or Desible application' Show Sql debug option (default: ${DEFAULT-VALUE})" + + " if specified without parameter: ${FALLBACK-VALUE}", fallbackValue = "true" + , defaultValue = "false") + private boolean showSql; + @CommandLine.Option(names = {"-amt", "--amt-profiling"} + , description = "Enable or Desible application' AMT Profiling debug option (default: ${DEFAULT-VALUE})" + + " if specified without parameter: ${FALLBACK-VALUE}", fallbackValue = "true" + , defaultValue = "false") + private boolean amtProfiling; public AnalyzeCommand(RestApiService restApiService, JobsService jobsService, ApplicationService applicationService) { this.restApiService = restApiService; @@ -97,6 +112,8 @@ public Integer call() throws Exception { } String applicationGuid; ApiInfoDto apiInfoDto = restApiService.getAipConsoleApiInfo(); + log.info("[Debug options] Show Sql is '{}'", showSql); + log.info("[Debug options] AMT Profiling is '{}'", amtProfiling); try { log.info("Searching for application '{}' on AIP Console", applicationName); @@ -146,6 +163,17 @@ public Integer call() throws Exception { .versionGuid(versionToAnalyze.getGuid()) .releaseAndSnapshotDate(new Date()); + //============== + // Ony set debug option when ON. Run Analysis always consider these options as OFF(disabled) + //============== + DebugOptionsDto oldDebugOptions = applicationService.getDebugOptions(applicationGuid); + if (showSql) { + applicationService.updateShowSqlDebugOption(applicationGuid, showSql); + } + if (amtProfiling) { + applicationService.updateShowSqlDebugOption(applicationGuid, amtProfiling); + } + log.info("Running analysis for application '{}' with version '{}'", applicationName, versionToAnalyze.getName()); String jobGuid = jobsService.startJob(builder); Thread shutdownHook = getShutdownHookForJobGuid(jobGuid); @@ -153,7 +181,14 @@ public Integer call() throws Exception { Runtime.getRuntime().addShutdownHook(shutdownHook); JobStatusWithSteps jobStatus = jobsService.pollAndWaitForJobFinished(jobGuid, Function.identity(), sharedOptions.isVerbose()); Runtime.getRuntime().removeShutdownHook(shutdownHook); + + DebugOptionsDto debugOptions = applicationService.getDebugOptions(applicationGuid); + applicationService.resetDebugOptions(applicationGuid, oldDebugOptions); if (JobState.COMPLETED == jobStatus.getState()) { + if (debugOptions.isActivateAmtMemoryProfile()) { + log.info("[Debug options] Amt Profiling file download URL: {}", + sharedOptions.getFullServerRootUrl() + ApiEndpointHelper.getAmtProfilingDownloadUrl(applicationGuid)); + } log.info("Application Analysis completed successfully"); return Constants.RETURN_OK; } diff --git a/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AddVersionCommandIntegrationTest.java b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AddVersionCommandIntegrationTest.java index 21bead38..21048508 100644 --- a/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AddVersionCommandIntegrationTest.java +++ b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AddVersionCommandIntegrationTest.java @@ -1,6 +1,7 @@ package com.castsoftware.aip.console.tools; import com.castsoftware.aip.console.tools.commands.AddVersionCommand; +import com.castsoftware.aip.console.tools.core.dto.DebugOptionsDto; import com.castsoftware.aip.console.tools.core.dto.jobs.JobRequestBuilder; import com.castsoftware.aip.console.tools.core.dto.jobs.JobState; import com.castsoftware.aip.console.tools.core.dto.jobs.JobStatusWithSteps; @@ -11,6 +12,7 @@ import com.castsoftware.aip.console.tools.core.utils.Constants; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; @@ -108,6 +110,9 @@ public void testAddVersionCommand_RunAddVersionJobCompleted() throws Application when(applicationService.applicationHasVersion(TestConstants.TEST_APP_GUID)).thenReturn(false); when(applicationService.createDeliveryConfiguration(TestConstants.TEST_APP_GUID, sflPath.toString(), null, false)).thenReturn(TestConstants.TEST_DELIVERY_CONFIG_GUID); when(jobsService.startAddVersionJob(any(JobRequestBuilder.class))).thenReturn(TestConstants.TEST_JOB_GUID); + DebugOptionsDto debugOptions = Mockito.mock(DebugOptionsDto.class); + when(debugOptions.isActivateAmtMemoryProfile()).thenReturn(false); + when(applicationService.getDebugOptions(TestConstants.TEST_APP_GUID)).thenReturn(debugOptions); JobStatusWithSteps jobStatus = new JobStatusWithSteps(); jobStatus.setAppGuid(TestConstants.TEST_APP_GUID); diff --git a/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AnalyzeCommandIntegrationTest.java b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AnalyzeCommandIntegrationTest.java index 983f0020..229720da 100644 --- a/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AnalyzeCommandIntegrationTest.java +++ b/aip-console-tools-cli/src/test/java/com/castsoftware/aip/console/tools/AnalyzeCommandIntegrationTest.java @@ -1,6 +1,7 @@ package com.castsoftware.aip.console.tools; import com.castsoftware.aip.console.tools.commands.AnalyzeCommand; +import com.castsoftware.aip.console.tools.core.dto.DebugOptionsDto; import com.castsoftware.aip.console.tools.core.dto.VersionDto; import com.castsoftware.aip.console.tools.core.dto.VersionStatus; import com.castsoftware.aip.console.tools.core.dto.jobs.JobRequestBuilder; @@ -13,6 +14,7 @@ import com.castsoftware.aip.console.tools.core.utils.Constants; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.mockito.internal.util.collections.Sets; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -163,6 +165,9 @@ public void testAnalyzeCommand_JobCompleted() throws ApplicationServiceException versionDto.setStatus(VersionStatus.DELIVERED); when(applicationService.getApplicationVersion(TestConstants.TEST_APP_GUID)).thenReturn(Sets.newSet(versionDto)); when(jobsService.startJob(any(JobRequestBuilder.class))).thenReturn(TestConstants.TEST_JOB_GUID); + DebugOptionsDto debugOptions = Mockito.mock(DebugOptionsDto.class); + when(debugOptions.isActivateAmtMemoryProfile()).thenReturn(false); + when(applicationService.getDebugOptions(TestConstants.TEST_APP_GUID)).thenReturn(debugOptions); JobStatusWithSteps jobStatus = new JobStatusWithSteps(); jobStatus.setAppGuid(TestConstants.TEST_APP_GUID); diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/dto/DebugOptionsDto.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/dto/DebugOptionsDto.java new file mode 100644 index 00000000..929040c5 --- /dev/null +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/dto/DebugOptionsDto.java @@ -0,0 +1,16 @@ +package com.castsoftware.aip.console.tools.core.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class DebugOptionsDto { + boolean showSql; + boolean activateAmtMemoryProfile; + private boolean amtMemoryProfilingLogAvailable; +} diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/dto/JsonDto.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/dto/JsonDto.java new file mode 100644 index 00000000..9977689e --- /dev/null +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/dto/JsonDto.java @@ -0,0 +1,22 @@ +package com.castsoftware.aip.console.tools.core.dto; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class JsonDto { + + @NonNull + T data; + + public static JsonDto of(T data) { + return new JsonDto<>(data); + } +} diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/ApplicationService.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/ApplicationService.java index 37aeb9f4..b0e5f3c8 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/ApplicationService.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/ApplicationService.java @@ -1,9 +1,8 @@ package com.castsoftware.aip.console.tools.core.services; import com.castsoftware.aip.console.tools.core.dto.ApplicationDto; +import com.castsoftware.aip.console.tools.core.dto.DebugOptionsDto; import com.castsoftware.aip.console.tools.core.dto.VersionDto; -import com.castsoftware.aip.console.tools.core.dto.jobs.DeliveryPackageDto; -import com.castsoftware.aip.console.tools.core.exceptions.ApiCallException; import com.castsoftware.aip.console.tools.core.exceptions.ApplicationServiceException; import com.castsoftware.aip.console.tools.core.exceptions.JobServiceException; import com.castsoftware.aip.console.tools.core.exceptions.PackagePathInvalidException; @@ -88,4 +87,19 @@ public interface ApplicationService { * @return */ String createDeliveryConfiguration(String appGuid, String sourcePath, String exclusionPatterns, boolean rescan) throws JobServiceException, PackagePathInvalidException; + + /** + * Get the existing {@code }debug options} settings + * + * @param appGuid host application + * @return debug options + * @throws ApplicationServiceException + */ + DebugOptionsDto getDebugOptions(String appGuid) throws ApplicationServiceException; + + void updateShowSqlDebugOption(String appGuid, boolean showSql) throws ApplicationServiceException; + + void updateAmtProfileDebugOption(String appGuid, boolean amtProfile) throws ApplicationServiceException; + + void resetDebugOptions(String appGuid, DebugOptionsDto debugOptionsDto) throws ApplicationServiceException; } diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/ApplicationServiceImpl.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/ApplicationServiceImpl.java index 0f301e51..f4c7508a 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/ApplicationServiceImpl.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/services/ApplicationServiceImpl.java @@ -3,7 +3,9 @@ import com.castsoftware.aip.console.tools.core.dto.ApplicationDto; import com.castsoftware.aip.console.tools.core.dto.Applications; import com.castsoftware.aip.console.tools.core.dto.BaseDto; +import com.castsoftware.aip.console.tools.core.dto.DebugOptionsDto; import com.castsoftware.aip.console.tools.core.dto.DeliveryConfigurationDto; +import com.castsoftware.aip.console.tools.core.dto.JsonDto; import com.castsoftware.aip.console.tools.core.dto.NodeDto; import com.castsoftware.aip.console.tools.core.dto.PendingResultDto; import com.castsoftware.aip.console.tools.core.dto.VersionDto; @@ -159,6 +161,45 @@ public Set getApplicationVersion(String appGuid) throws ApplicationS } } + @Override + public DebugOptionsDto getDebugOptions(String appGuid) throws ApplicationServiceException { + try { + return restApiService.getForEntity(ApiEndpointHelper.getDebugOptionsPath(appGuid), new TypeReference() { + }); + } catch (ApiCallException e) { + throw new ApplicationServiceException("Unable to retrieve the applications' debug options settings", e); + } + } + + @Override + public void updateShowSqlDebugOption(String appGuid, boolean showSql) throws ApplicationServiceException { + try { + restApiService.putForEntity(ApiEndpointHelper.getDebugOptionShowSqlPath(appGuid), JsonDto.of(showSql), String.class); + } catch (ApiCallException e) { + throw new ApplicationServiceException("Unable to update the application' Show Sql debug option", e); + } + } + + @Override + public void updateAmtProfileDebugOption(String appGuid, boolean amtProfile) throws ApplicationServiceException { + try { + //-------------------------------------------------------------- + //The PUT shouldn't returned anything than void.class, but doing so clashed as object mapper is trying to map + //Some response body. The response interpreter here does behave as expected. + //Using String.class prevents from type clash (!#?) + //-------------------------------------------------------------- + restApiService.putForEntity(ApiEndpointHelper.getDebugOptionAmtProfilePath(appGuid), JsonDto.of(amtProfile), String.class); + } catch (ApiCallException e) { + throw new ApplicationServiceException("Unable to update the application' AMT Profiling debug option", e); + } + } + + @Override + public void resetDebugOptions(String appGuid, DebugOptionsDto debugOptionsDto) throws ApplicationServiceException { + updateShowSqlDebugOption(appGuid, debugOptionsDto.isShowSql()); + updateAmtProfileDebugOption(appGuid, debugOptionsDto.isActivateAmtMemoryProfile()); + } + @Override public String createDeliveryConfiguration(String appGuid, String sourcePath, String exclusionPatterns, boolean rescan) throws JobServiceException, PackagePathInvalidException { try { diff --git a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/utils/ApiEndpointHelper.java b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/utils/ApiEndpointHelper.java index 96fa2aa6..15d22b51 100644 --- a/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/utils/ApiEndpointHelper.java +++ b/aip-console-tools-core/src/main/java/com/castsoftware/aip/console/tools/core/utils/ApiEndpointHelper.java @@ -8,6 +8,9 @@ public class ApiEndpointHelper { private static final String UPLOAD_ENDPOINT = "/upload"; private static final String VERSIONS_ENDPOINT = "/versions"; private static final String EXTRACT_ENDPOINT = "/extract"; + private static final String DEBUG_OPTIONS_ENDPOINT = "/debug-options"; + private static final String SHOW_SQL_ENDPOINT = "/show-sql"; + private static final String AMT_PROFILE_ENDPOINT = "/activate-amt-memory-profile"; public static String getRootPath() { return ROOT_PATH + "/"; @@ -45,6 +48,22 @@ public static String getApplicationExtractUploadPath(String appGuid, String uplo return getApplicationUploadPath(appGuid, uploadGuid) + EXTRACT_ENDPOINT; } + public static String getDebugOptionsPath(String appGuid) { + return getApplicationPath(appGuid) + DEBUG_OPTIONS_ENDPOINT; + } + + public static String getDebugOptionShowSqlPath(String appGuid) { + return getDebugOptionsPath(appGuid) + SHOW_SQL_ENDPOINT; + } + + public static String getDebugOptionAmtProfilePath(String appGuid) { + return getDebugOptionsPath(appGuid) + AMT_PROFILE_ENDPOINT; + } + + public static String getAmtProfilingDownloadUrl(String appGuid) { + return ApiEndpointHelper.getDebugOptionsPath(appGuid) + "/logs" + AMT_PROFILE_ENDPOINT + "/download"; + } + public static String getJobsEndpoint() { return ROOT_PATH + JOBS_ENDPOINT; } From 4431c9728c14b00aa8ff92d6569acea809a474ff Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Wed, 16 Jun 2021 16:36:21 +0200 Subject: [PATCH 10/11] WEBITOOLS-33: updates for resolving conflicts --- .../aip/console/tools/commands/AddVersionCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java index 1847b9f4..5fe526ca 100644 --- a/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java +++ b/aip-console-tools-cli/src/main/java/com/castsoftware/aip/console/tools/commands/AddVersionCommand.java @@ -159,7 +159,6 @@ public Integer doCall() { return Constants.RETURN_LOGIN_ERROR; } - log.info("AddVersion version command has triggered with log output = '{}'", sharedOptions.isVerbose()); log.info("[Debug options] Show Sql is '{}'", showSql); log.info("[Debug options] AMT Profiling is '{}'", amtProfiling); From 8c228b8eb812bec950aff073773e4a90bd719154 Mon Sep 17 00:00:00 2001 From: leon2Meudon92 Date: Thu, 17 Jun 2021 10:49:04 +0200 Subject: [PATCH 11/11] WEBITOOLS-33: updates for resolving conflicts --- aip-console-jenkins/README.md | 21 ++++++-- .../doc/images/custom_URL_ApiKey.png | Bin 0 -> 10657 bytes aip-console-jenkins/pom.xml | 2 +- .../plugins/aipconsole/AddVersionAction.java | 2 +- .../plugins/aipconsole/AddVersionBuilder.java | 20 ++++---- .../plugins/aipconsole/AnalyzeAction.java | 2 +- .../plugins/aipconsole/AnalyzeBuilder.java | 18 +++---- .../plugins/aipconsole/BaseAction.java | 30 ++++++++++++ .../plugins/aipconsole/BaseActionBuilder.java | 45 ++++++++++++++++++ .../BaseActionBuilderDescriptor.java | 18 +++++++ .../aipconsole/CreateApplicationAction.java | 3 +- .../aipconsole/CreateApplicationBuilder.java | 14 +++--- .../plugins/aipconsole/DeliverAction.java | 2 +- .../plugins/aipconsole/DeliverBuilder.java | 18 +++---- .../plugins/aipconsole/SnapshotAction.java | 2 +- .../plugins/aipconsole/SnapshotBuilder.java | 18 +++---- .../aipconsole/AddVersionBuilder/config.jelly | 6 +++ .../AddVersionBuilder/config.properties | 4 ++ .../AddVersionBuilder/config_fr.properties | 34 +++++++------ .../aipconsole/AnalyzeBuilder/config.jelly | 6 +++ .../AnalyzeBuilder/config.properties | 4 ++ .../AnalyzeBuilder/config_fr.properties | 4 ++ .../CreateApplicationBuilder/config.jelly | 6 +++ .../config.properties | 4 ++ .../config_fr.properties | 16 ++++--- .../aipconsole/DeliverBuilder/config.jelly | 6 +++ .../DeliverBuilder/config.properties | 6 ++- .../DeliverBuilder/config_fr.properties | 7 ++- .../aipconsole/SnapshotBuilder/config.jelly | 6 +++ .../SnapshotBuilder/config.properties | 6 ++- .../SnapshotBuilder/config_fr.properties | 4 ++ .../aipconsole/AddVersionBuilderTest.java | 14 +++++- aip-console-tools-cli/pom.xml | 2 +- aip-console-tools-core/pom.xml | 2 +- pom.xml | 2 +- 35 files changed, 279 insertions(+), 75 deletions(-) create mode 100644 aip-console-jenkins/doc/images/custom_URL_ApiKey.png create mode 100644 aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseAction.java create mode 100644 aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseActionBuilder.java create mode 100644 aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseActionBuilderDescriptor.java diff --git a/aip-console-jenkins/README.md b/aip-console-jenkins/README.md index d35854fc..20f3d7a3 100644 --- a/aip-console-jenkins/README.md +++ b/aip-console-jenkins/README.md @@ -38,14 +38,29 @@ To configure the AIP Console plugin, go to the "Configure System" page in the "M On this page, go to the **AIP Console global configuration** section and enter the following required elements : -* *AIP Console URL* : The URL to access the AIP Console server. Make sure that this address is accessible from the Jenkins Server and the Jenkins Node that might run the plugin as well. +* *AIP Console URL* : The URL to access the AIP Console server. Make sure that this address is accessible from the + Jenkins Server and the Jenkins Node that might run the plugin as well. * *API Key* : The API key that will be used to authenticate to AIP Console. * *Timeout* : A global timeout setting in seconds before calls to AIP Console will be considered in error. -* *verbose* : If it's checked then AIP Console log output will be display on screen. To hide major information keep - this unchecked. +* *verbose* : If it's checked then AIP Console log output will be display on screen. To hide major information keep this + unchecked. ![log-output](./doc/images/log-output.png) +#### Using different AIP Console URL and API Key + +In case the Job needs to target different AIP Console URL and use a different API Key, it's still possible. To do so, +proceed as follows. + +* Create dedicated Job as describe in the next section +* Expand the "Advanced Settings" section and fill fields with desired values. + ![custom_URL_ApiKey](./doc/images/custom_URL_ApiKey.png) + +##### Precedence rule + +* The value used for AIP Console URL and API Key is always coming from the Job itself when assigned. +* If one field is not assigned then the one from the *Global Configuration* will be used. + ### Quick Start #### Create Application diff --git a/aip-console-jenkins/doc/images/custom_URL_ApiKey.png b/aip-console-jenkins/doc/images/custom_URL_ApiKey.png new file mode 100644 index 0000000000000000000000000000000000000000..ba89cc972c1d6ba5dacc1acad1e518a5c59906a6 GIT binary patch literal 10657 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 literal 0 HcmV?d00001 diff --git a/aip-console-jenkins/pom.xml b/aip-console-jenkins/pom.xml index fe9d1036..579244ff 100644 --- a/aip-console-jenkins/pom.xml +++ b/aip-console-jenkins/pom.xml @@ -10,7 +10,7 @@ com.castsoftware.aip.jenkins aip-console-jenkins - 1.24.1 + 1.24.2 hpi diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionAction.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionAction.java index 4b9ebf6a..043be123 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionAction.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionAction.java @@ -9,7 +9,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class AddVersionAction implements RunAction2 { +public class AddVersionAction extends BaseAction implements RunAction2 { private static final Logger LOGGER = LoggerFactory.getLogger(AddVersionAction.class); @CheckForNull diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionBuilder.java index 2ce22317..dc6a9dca 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AddVersionBuilder.java @@ -30,8 +30,6 @@ import hudson.model.Result; import hudson.model.Run; import hudson.model.TaskListener; -import hudson.tasks.BuildStepDescriptor; -import hudson.tasks.Builder; import hudson.util.Secret; import io.jenkins.plugins.aipconsole.config.AipConsoleGlobalConfiguration; import jenkins.tasks.SimpleBuildStep; @@ -78,7 +76,7 @@ import static io.jenkins.plugins.aipconsole.Messages.GenericError_error_accessDenied; import static io.jenkins.plugins.aipconsole.Messages.JobsSteps_changed; -public class AddVersionBuilder extends Builder implements SimpleBuildStep { +public class AddVersionBuilder extends BaseActionBuilder implements SimpleBuildStep { public static final int BUFFER_SIZE = 10 * 1024 * 1024; @Inject @@ -292,8 +290,8 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul applicationService = injector.getInstance(ApplicationService.class); } - String apiServerUrl = getDescriptor().getAipConsoleUrl(); - String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); + String apiServerUrl = getAipConsoleUrl(); + String apiKey = Secret.toString(getApiKey()); String username = getDescriptor().getAipConsoleUsername(); // Job level timeout different from default ? use it, else use the global config level timeout long actualTimeout = (timeout != Constants.DEFAULT_HTTP_TIMEOUT ? timeout : getDescriptor().getTimeout()); @@ -544,8 +542,10 @@ private String checkJobParameters() { if (StringUtils.isAnyBlank(applicationName, filePath)) { return Messages.GenericError_error_missingRequiredParameters(); } - String apiServerUrl = getDescriptor().getAipConsoleUrl(); - String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); + + //Constraint annotation should have issued error if rule broken + String apiServerUrl = getAipConsoleUrl(); + String apiKey = Secret.toString(getApiKey()); if (StringUtils.isBlank(apiServerUrl)) { return Messages.GenericError_error_noServerUrl(); @@ -576,7 +576,7 @@ private JobState pollJob(String jobGuid, PrintStream log) throws JobServiceExcep @Symbol("aipAddVersion") @Extension - public static final class AddVersionDescriptorImpl extends BuildStepDescriptor { + public static final class AddVersionDescriptorImpl extends BaseActionBuilderDescriptor { @Inject private AipConsoleGlobalConfiguration configuration; @@ -592,18 +592,22 @@ public String getDisplayName() { return AddVersionBuilder_DescriptorImpl_displayName(); } + @Override public String getAipConsoleUrl() { return configuration.getAipConsoleUrl(); } + @Override public Secret getAipConsoleSecret() { return configuration.getApiKey(); } + @Override public String getAipConsoleUsername() { return configuration.getUsername(); } + @Override public int getTimeout() { return configuration.getTimeout(); } diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeAction.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeAction.java index bb5e5f3f..85751562 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeAction.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeAction.java @@ -9,7 +9,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class AnalyzeAction implements RunAction2 { +public class AnalyzeAction extends BaseAction implements RunAction2 { private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeAction.class); @CheckForNull diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeBuilder.java index e4d20780..87281d4b 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/AnalyzeBuilder.java @@ -25,8 +25,6 @@ import hudson.model.Result; import hudson.model.Run; import hudson.model.TaskListener; -import hudson.tasks.BuildStepDescriptor; -import hudson.tasks.Builder; import hudson.util.Secret; import io.jenkins.plugins.aipconsole.config.AipConsoleGlobalConfiguration; import jenkins.tasks.SimpleBuildStep; @@ -56,7 +54,7 @@ import static io.jenkins.plugins.aipconsole.Messages.AnalyzeBuilder_DescriptorImpl_displayName; import static io.jenkins.plugins.aipconsole.Messages.JobsSteps_changed; -public class AnalyzeBuilder extends Builder implements SimpleBuildStep { +public class AnalyzeBuilder extends BaseActionBuilder implements SimpleBuildStep { private static final DateFormat RELEASE_DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); @Inject @@ -177,8 +175,8 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul applicationService = injector.getInstance(ApplicationService.class); } - String apiServerUrl = getDescriptor().getAipConsoleUrl(); - String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); + String apiServerUrl = getAipConsoleUrl(); + String apiKey = Secret.toString(getApiKey()); String username = getDescriptor().getAipConsoleUsername(); // Job level timeout different from default ? use it, else use the global config level timeout long actualTimeout = (timeout != Constants.DEFAULT_HTTP_TIMEOUT ? timeout : getDescriptor().getTimeout()); @@ -316,8 +314,8 @@ private String checkJobParameters() { if (StringUtils.isAnyBlank(applicationName)) { return Messages.GenericError_error_missingRequiredParameters(); } - String apiServerUrl = getDescriptor().getAipConsoleUrl(); - String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); + String apiServerUrl = getAipConsoleUrl(); + String apiKey = Secret.toString(getApiKey()); if (StringUtils.isBlank(apiServerUrl)) { return Messages.GenericError_error_noServerUrl(); @@ -331,7 +329,7 @@ private String checkJobParameters() { @Symbol("aipAnalyze") @Extension - public static final class AnalyzeDescriptorImpl extends BuildStepDescriptor { + public static final class AnalyzeDescriptorImpl extends BaseActionBuilderDescriptor { @Inject private AipConsoleGlobalConfiguration configuration; @@ -347,18 +345,22 @@ public String getDisplayName() { return AnalyzeBuilder_DescriptorImpl_displayName(); } + @Override public String getAipConsoleUrl() { return configuration.getAipConsoleUrl(); } + @Override public Secret getAipConsoleSecret() { return configuration.getApiKey(); } + @Override public String getAipConsoleUsername() { return configuration.getUsername(); } + @Override public int getTimeout() { return configuration.getTimeout(); } diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseAction.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseAction.java new file mode 100644 index 00000000..102f20df --- /dev/null +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseAction.java @@ -0,0 +1,30 @@ +package io.jenkins.plugins.aipconsole; + +import hudson.util.Secret; + +import javax.annotation.Nullable; + +public class BaseAction { + @Nullable + private String aipConsoleUrl; + @Nullable + private Secret apiKey; + + public void setApiKey(Secret apiKey) { + this.apiKey = apiKey; + } + + @Nullable + public Secret getApiKey() { + return apiKey; + } + + public void setAipConsoleUrl(String aipConsoleUrl) { + this.aipConsoleUrl = aipConsoleUrl; + } + + @Nullable + public String getAipConsoleUrl() { + return aipConsoleUrl; + } +} diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseActionBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseActionBuilder.java new file mode 100644 index 00000000..f4e8da61 --- /dev/null +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseActionBuilder.java @@ -0,0 +1,45 @@ +package io.jenkins.plugins.aipconsole; + +import hudson.tasks.Builder; +import hudson.util.Secret; +import org.apache.commons.lang3.StringUtils; +import org.kohsuke.stapler.DataBoundSetter; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +public class BaseActionBuilder extends Builder { + @Nullable + private String aipConsoleUrl; + @Nullable + private Secret apiKey; + + @Override + public BaseActionBuilderDescriptor getDescriptor() { + return (BaseActionBuilderDescriptor) super.getDescriptor(); + } + + @DataBoundSetter + public void setApiKey(Secret apiKey) { + this.apiKey = apiKey; + } + + @CheckForNull + public Secret getApiKey() { + return StringUtils.isEmpty(Secret.toString(getLocalApiKey())) ? getDescriptor().getAipConsoleSecret() : getLocalApiKey(); + } + + public Secret getLocalApiKey() { + return apiKey; + } + + @DataBoundSetter + public void setAipConsoleUrl(String aipConsoleUrl) { + this.aipConsoleUrl = aipConsoleUrl; + } + + @CheckForNull + public String getAipConsoleUrl() { + return StringUtils.isEmpty(aipConsoleUrl) ? getDescriptor().getAipConsoleUrl() : aipConsoleUrl; + } +} diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseActionBuilderDescriptor.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseActionBuilderDescriptor.java new file mode 100644 index 00000000..3231bf42 --- /dev/null +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/BaseActionBuilderDescriptor.java @@ -0,0 +1,18 @@ +package io.jenkins.plugins.aipconsole; + +import hudson.tasks.BuildStepDescriptor; +import hudson.tasks.Builder; +import hudson.util.Secret; + +public abstract class BaseActionBuilderDescriptor extends BuildStepDescriptor { + @Override + public abstract String getDisplayName(); + + public abstract String getAipConsoleUrl(); + + public abstract Secret getAipConsoleSecret(); + + public abstract String getAipConsoleUsername(); + + public abstract int getTimeout(); +} diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationAction.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationAction.java index 532a0007..57d8f11c 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationAction.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationAction.java @@ -11,7 +11,7 @@ * Action for the Create Application step * Stores the application name */ -public class CreateApplicationAction implements RunAction2 { +public class CreateApplicationAction extends BaseAction implements RunAction2 { private Run run; private String applicationName; private boolean failureIgnored = false; @@ -22,6 +22,7 @@ public class CreateApplicationAction implements RunAction2 { @Nullable private String domainName; + public Run getRun() { return run; } diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationBuilder.java index 952c49ed..ba0cfdc4 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/CreateApplicationBuilder.java @@ -16,8 +16,6 @@ import hudson.model.Result; import hudson.model.Run; import hudson.model.TaskListener; -import hudson.tasks.BuildStepDescriptor; -import hudson.tasks.Builder; import hudson.util.Secret; import io.jenkins.plugins.aipconsole.config.AipConsoleGlobalConfiguration; import jenkins.tasks.SimpleBuildStep; @@ -49,7 +47,7 @@ * Builder to run a "Create application" step. * It'll create a new application on AIP Console with the given name */ -public class CreateApplicationBuilder extends Builder implements SimpleBuildStep { +public class CreateApplicationBuilder extends BaseActionBuilder implements SimpleBuildStep { // Holder for dynamic loading of step name translations private final static ResourceBundleHolder holder = ResourceBundleHolder.get(io.jenkins.plugins.aipconsole.Messages.class); @@ -146,8 +144,8 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul Guice.createInjector(new AipConsoleModule()).injectMembers(this); } - String apiServerUrl = getDescriptor().getAipConsoleUrl(); - String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); + String apiServerUrl = getAipConsoleUrl(); + String apiKey = Secret.toString(getApiKey()); String username = getDescriptor().getAipConsoleUsername(); long actualTimeout = timeout != Constants.DEFAULT_HTTP_TIMEOUT ? timeout : getDescriptor().getTimeout(); @@ -212,7 +210,7 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul @Symbol("aipCreateApp") @Extension - public static final class CreateAppDescriptorImpl extends BuildStepDescriptor { + public static final class CreateAppDescriptorImpl extends BaseActionBuilderDescriptor { @Inject private AipConsoleGlobalConfiguration configuration; @@ -228,18 +226,22 @@ public String getDisplayName() { return CreateApplicationBuilder_DescriptorImpl_displayName(); } + @Override public String getAipConsoleUrl() { return configuration.getAipConsoleUrl(); } + @Override public Secret getAipConsoleSecret() { return configuration.getApiKey(); } + @Override public String getAipConsoleUsername() { return configuration.getUsername(); } + @Override public int getTimeout() { return configuration.getTimeout(); } diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverAction.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverAction.java index 05281d37..ed537d2a 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverAction.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverAction.java @@ -9,7 +9,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class DeliverAction implements RunAction2 { +public class DeliverAction extends BaseAction implements RunAction2 { private static final Logger LOGGER = LoggerFactory.getLogger(DeliverAction.class); @CheckForNull diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java index 71921a6c..627d5874 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/DeliverBuilder.java @@ -31,8 +31,6 @@ import hudson.model.Result; import hudson.model.Run; import hudson.model.TaskListener; -import hudson.tasks.BuildStepDescriptor; -import hudson.tasks.Builder; import hudson.util.Secret; import io.jenkins.plugins.aipconsole.config.AipConsoleGlobalConfiguration; import jenkins.tasks.SimpleBuildStep; @@ -84,7 +82,7 @@ import static io.jenkins.plugins.aipconsole.Messages.GenericError_error_noServerUrl; import static io.jenkins.plugins.aipconsole.Messages.JobsSteps_changed; -public class DeliverBuilder extends Builder implements SimpleBuildStep { +public class DeliverBuilder extends BaseActionBuilder implements SimpleBuildStep { public static final int BUFFER_SIZE = 10 * 1024 * 1024; @Inject private JobsService jobsService; @@ -316,8 +314,8 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul applicationService = injector.getInstance(ApplicationService.class); } - String apiServerUrl = getDescriptor().getAipConsoleUrl(); - String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); + String apiServerUrl = getAipConsoleUrl(); + String apiKey = Secret.toString(getApiKey()); String username = getDescriptor().getAipConsoleUsername(); // Job level timeout different from default ? use it, else use the global config level timeout long actualTimeout = (timeout != Constants.DEFAULT_HTTP_TIMEOUT ? timeout : getDescriptor().getTimeout()); @@ -597,8 +595,8 @@ private String checkJobParameters() { if (StringUtils.isAnyBlank(applicationName, filePath)) { return GenericError_error_missingRequiredParameters(); } - String apiServerUrl = getDescriptor().getAipConsoleUrl(); - String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); + String apiServerUrl = getAipConsoleUrl(); + String apiKey = Secret.toString(getApiKey()); if (StringUtils.isBlank(apiServerUrl)) { return GenericError_error_noServerUrl(); @@ -629,7 +627,7 @@ private Consumer getPollingCallback(PrintStream log) { @Symbol("aipDeliver") @Extension - public static final class DeliverDescriptorImpl extends BuildStepDescriptor { + public static final class DeliverDescriptorImpl extends BaseActionBuilderDescriptor { @Inject private AipConsoleGlobalConfiguration configuration; @@ -645,18 +643,22 @@ public String getDisplayName() { return DeliverBuilder_DescriptorImpl_displayName(); } + @Override public String getAipConsoleUrl() { return configuration.getAipConsoleUrl(); } + @Override public Secret getAipConsoleSecret() { return configuration.getApiKey(); } + @Override public String getAipConsoleUsername() { return configuration.getUsername(); } + @Override public int getTimeout() { return configuration.getTimeout(); } diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotAction.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotAction.java index 706a66d5..6f772dca 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotAction.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotAction.java @@ -9,7 +9,7 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; -public class SnapshotAction implements RunAction2 { +public class SnapshotAction extends BaseAction implements RunAction2 { private static final Logger LOGGER = LoggerFactory.getLogger(SnapshotAction.class); @CheckForNull private String applicationName; diff --git a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotBuilder.java b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotBuilder.java index 1d687736..b0a6b10e 100644 --- a/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotBuilder.java +++ b/aip-console-jenkins/src/main/java/io/jenkins/plugins/aipconsole/SnapshotBuilder.java @@ -26,8 +26,6 @@ import hudson.model.Result; import hudson.model.Run; import hudson.model.TaskListener; -import hudson.tasks.BuildStepDescriptor; -import hudson.tasks.Builder; import hudson.util.Secret; import io.jenkins.plugins.aipconsole.config.AipConsoleGlobalConfiguration; import jenkins.tasks.SimpleBuildStep; @@ -59,7 +57,7 @@ import static io.jenkins.plugins.aipconsole.Messages.SnapshotBuilder_Snapshot_info_pollJobMessage; import static io.jenkins.plugins.aipconsole.Messages.SnapshotBuilder_Snapshot_success_complete; -public class SnapshotBuilder extends Builder implements SimpleBuildStep { +public class SnapshotBuilder extends BaseActionBuilder implements SimpleBuildStep { @Inject private JobsService jobsService; @@ -168,8 +166,8 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul applicationService = injector.getInstance(ApplicationService.class); } - String apiServerUrl = getDescriptor().getAipConsoleUrl(); - String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); + String apiServerUrl = getAipConsoleUrl(); + String apiKey = Secret.toString(getApiKey()); String username = getDescriptor().getAipConsoleUsername(); // Job level timeout different from default ? use it, else use the global config level timeout long actualTimeout = (timeout != Constants.DEFAULT_HTTP_TIMEOUT ? timeout : getDescriptor().getTimeout()); @@ -294,8 +292,8 @@ private String checkJobParameters() { if (StringUtils.isBlank(applicationName)) { return Messages.GenericError_error_missingRequiredParameters(); } - String apiServerUrl = getDescriptor().getAipConsoleUrl(); - String apiKey = Secret.toString(getDescriptor().getAipConsoleSecret()); + String apiServerUrl = getAipConsoleUrl(); + String apiKey = Secret.toString(getApiKey()); if (StringUtils.isBlank(apiServerUrl)) { return Messages.GenericError_error_noServerUrl(); @@ -309,7 +307,7 @@ private String checkJobParameters() { @Symbol("aipSnapshot") @Extension - public static final class SnapshotDescriptorImpl extends BuildStepDescriptor { + public static final class SnapshotDescriptorImpl extends BaseActionBuilderDescriptor { @Inject private AipConsoleGlobalConfiguration configuration; @@ -325,18 +323,22 @@ public String getDisplayName() { return SnapshotBuilder_DescriptorImpl_displayName(); } + @Override public String getAipConsoleUrl() { return configuration.getAipConsoleUrl(); } + @Override public Secret getAipConsoleSecret() { return configuration.getApiKey(); } + @Override public String getAipConsoleUsername() { return configuration.getUsername(); } + @Override public int getTimeout() { return configuration.getTimeout(); } diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config.jelly b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config.jelly index c153af89..52901dd6 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config.jelly +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config.jelly @@ -19,6 +19,12 @@ + + + + + + diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config.properties index 5e1de1fc..b3d9ed1a 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config.properties @@ -30,3 +30,7 @@ domainName=Domain Name domainName.descr=Name of the domain to assign to this application. Will be created if it doesn't exists in AIP Console. If no specified, no domain will be assigned or created. processImaging=Publish to Imaging processImaging.descr=Publish analysis data to Imaging if an Imaging instance is defined in AIP Console +aipConsoleUrl=AIP Console URL if different than the global configuration +aipConsoleUrl.descr=The root URL to access AIP Console +apiKey=API Key +apiKey.descr=The API Key to access AIP Console diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config_fr.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config_fr.properties index 797bf9ba..2acb866d 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config_fr.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AddVersionBuilder/config_fr.properties @@ -1,28 +1,32 @@ enableSecurity.descr=Active le Security Dataflow pour cette version appGuid=Application GUID (lecture seule) -appGuid.descr=Le GUID de l''application dans AIP Console. Sera renseigné après la première exécution du job. +appGuid.descr=Le GUID de l''application dans AIP Console. Sera renseign� apr�s la premi�re ex�cution du job. appName=Nom de l''application appName.descr=Le nom de l''application dans AIP Console -autoCreate=Créer l''application si absente ? -autoCreate.descr=Si le nom d''application donné n''existe pas, cocher cette case activera la création de l''application avant de créer une nouvelle version +autoCreate=Cr�er l''application si absente ? +autoCreate.descr=Si le nom d''application donn� n''existe pas, cocher cette case activera la cr�ation de l''application avant de cr�er une nouvelle version cloneVersion=Rescan ? -cloneVersion.descr=Cocher pour effectuer un rescan de l''application, c''est-à-dire, créer une nouvelle version en utilisant la configuration de la version précédente mais le nouveau code source. -failureIgnored=Ignorer l''échec de l''analyse ? -failureIgnored.descr=Si ce paramètre est activé, les erreurs d''analyse marqueront la construction comme UNSTABLE plutôt que FAILED. \ -Cela peut être utile pour continuer d''analyser plusieurs applications sans interrompre le build. +cloneVersion.descr=Cocher pour effectuer un rescan de l''application, c''est-�-dire, cr�er une nouvelle version en utilisant la configuration de la version pr�c�dente mais le nouveau code source. +failureIgnored=Ignorer l''�chec de l''analyse ? +failureIgnored.descr=Si ce param�tre est activ�, les erreurs d''analyse marqueront la construction comme UNSTABLE plut�t que FAILED. \ +Cela peut �tre utile pour continuer d''analyser plusieurs applications sans interrompre le build. filePath=Chemin Archive -filePath.descr=Le chemin d''un fichier d''archive qui sera uploadé vers AIP Console +filePath.descr=Le chemin d''un fichier d''archive qui sera upload� vers AIP Console timeout=Timeout de connexion (en secondes) -timeout.descr=Temps en secondes avant que la connexion à AIP Console ne soit marquée comme expirée. +timeout.descr=Temps en secondes avant que la connexion � AIP Console ne soit marqu�e comme expir�e. versionName=Nom de version -versionName.descr=Le nom de la version à créer +versionName.descr=Le nom de la version � cr�er nodeName=Nom du Noeud -nodeName.descr=Le nom du noeud dans lequel l''application doit être créée (si absente) -advancedSettings=Paramètres avancés +nodeName.descr=Le nom du noeud dans lequel l''application doit �tre cr��e (si absente) +advancedSettings=Param�tres avanc�s enableSecurity=Activer Security Dataflow backup=Activer sauvegarde -backup.descr=Sauvegarde l''application avant de créer la nouvelle version +backup.descr=Sauvegarde l''application avant de cr�er la nouvelle version backupName=Nom de la sauvegarde -backupName.descr=Le nom de la sauvegarde. 'backup_date.heure' par défaut si non spécifié +backupName.descr=Le nom de la sauvegarde. 'backup_date.heure' par d�faut si non sp�cifi� processImaging=Envoi vers Imaging -processImaging.descr=Envoi des données vers Imaging si une instance d'Imaging est configuré dans AIP Console +processImaging.descr=Envoi des donn�es vers Imaging si une instance d'Imaging est configur� dans AIP Console +aipConsoleUrl=URL de AIP Console si différente de la configuration globale +aipConsoleUrl.descr=L''URL d''accès à AIP Console +apiKey=Clé d'API +apiKey.descr=La clé d'API permettant l''accès à AIP Console diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config.jelly b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config.jelly index c52b736f..d665d5fd 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config.jelly +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config.jelly @@ -13,6 +13,12 @@ + + + + + + diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config.properties index 9b388282..549857a6 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config.properties @@ -12,3 +12,7 @@ timeout.descr=Time in seconds before the connection to AIP Console will be marke advancedSettings=Advanced Settings processImaging=Publish to Imaging processImaging.descr=Publish analysis data to Imaging if an Imaging instance is defined in AIP Console +aipConsoleUrl=AIP Console URL if different than the global configuration +aipConsoleUrl.descr=The root URL to access AIP Console +apiKey=API Key +apiKey.descr=The API Key to access AIP Console diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config_fr.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config_fr.properties index e69de29b..a5cd808b 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config_fr.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/AnalyzeBuilder/config_fr.properties @@ -0,0 +1,4 @@ +aipConsoleUrl=URL d''AIP Console +aipConsoleUrl.descr=L''URL d''accès à AIP Console +apiKey=Clé d'API +apiKey.descr=La clé d'API permettant l''accès à AIP Console diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config.jelly b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config.jelly index bac4e87f..c3dfdadd 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config.jelly +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config.jelly @@ -13,6 +13,12 @@ + + + + + + diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config.properties index 2cc1335c..7c1cb4d5 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config.properties @@ -12,4 +12,8 @@ domainName.descr=Name of the domain to assign to this application. Will be creat advancedSettings=Advanced Settings inPlaceMode=No Deliveries history inPlaceMode.descr=Source code deliveries history will not be saved when this option checked +aipConsoleUrl=AIP Console URL if different than the global configuration +aipConsoleUrl.descr=The root URL to access AIP Console +apiKey=API Key +apiKey.descr=The API Key to access AIP Console diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config_fr.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config_fr.properties index dac0699d..c332dafc 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config_fr.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/CreateApplicationBuilder/config_fr.properties @@ -1,10 +1,14 @@ appName=Nouveau nom d''application -appName.descr=Le nom de l''application à créer dans AIP Console -failureIgnored=Ignorer l''échec de l''analyse ? -failureIgnored.descr=Si ce paramètre est activé, les erreurs de création marqueront la construction comme UNSTABLE plutôt que FAILED. +appName.descr=Le nom de l''application � cr�er dans AIP Console +failureIgnored=Ignorer l''�chec de l''analyse ? +failureIgnored.descr=Si ce param�tre est activ�, les erreurs de cr�ation marqueront la construction comme UNSTABLE plut�t que FAILED. timeout=Timeout de connexion (en secondes) -timeout.descr=Temps en secondes avant que la connexion à AIP Console ne soit marquée comme expirée. +timeout.descr=Temps en secondes avant que la connexion � AIP Console ne soit marqu�e comme expir�e. nodeName=Nom du Noeud -nodeName.descr=Le nom du noeud dans lequel l''application doit être créée +nodeName.descr=Le nom du noeud dans lequel l''application doit �tre cr��e inPlaceMode=Historique des livraisons -inPlaceMode.descr=L'historique des livraisons ne sera pas conservé: elles sont issues d'un répertoire prédéfini. +inPlaceMode.descr=L'historique des livraisons ne sera pas conserv�: elles sont issues d'un r�pertoire pr�d�fini. +aipConsoleUrl=URL d''AIP Console +aipConsoleUrl.descr=L''URL d''accès à AIP Console +apiKey=Clé d'API +apiKey.descr=La clé d'API permettant l''accès à AIP Console diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config.jelly b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config.jelly index 2fda3f4b..d5bb2348 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config.jelly +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config.jelly @@ -25,6 +25,12 @@ + + + + + + diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config.properties index 418068dd..ed4f0783 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config.properties @@ -33,4 +33,8 @@ backup.descr=Backup the application before creating the new version backupName=Name of the backup backupName.descr=The name of the backup. Defaults to "backup_date.time" if unspecified domainName=Domain Name -domainName.descr=Name of the domain to assign to this application. Will be created if it doesn't exists in AIP Console. If no specified, no domain will be assigned or created. \ No newline at end of file +domainName.descr=Name of the domain to assign to this application. Will be created if it doesn't exists in AIP Console. If no specified, no domain will be assigned or created. +aipConsoleUrl=AIP Console URL if different than the global configuration +aipConsoleUrl.descr=The root URL to access AIP Console +apiKey=API Key +apiKey.descr=The API Key to access AIP Console diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config_fr.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config_fr.properties index a255db1a..3e19eb62 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config_fr.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/DeliverBuilder/config_fr.properties @@ -1,2 +1,7 @@ setAsCurrent=Utiliser cette version pour l'analyse -setAsCurrent.descr=La version ajoutée sera définie comme la version d'analyse +setAsCurrent.descr=La version ajout�e sera d�finie comme la version d'analyse +aipConsoleUrl=URL d''AIP Console +aipConsoleUrl.descr=L''URL d''accès à AIP Console +apiKey=Clé d'API +apiKey.descr=La clé d'API permettant l''accès à AIP Console + diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config.jelly b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config.jelly index c2987a8d..d3be7933 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config.jelly +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config.jelly @@ -10,6 +10,12 @@ + + + + + + diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config.properties index bbff3d93..a00b5325 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config.properties @@ -8,4 +8,8 @@ timeout=Connection Timeout (in seconds) timeout.descr=Time in seconds before the connection to AIP Console will be marked as timed out. advancedSettings=Advanced Settings processImaging=Publish to Imaging -processImaging.descr=Publish analysis data to Imaging if an Imaging instance is defined in AIP Console \ No newline at end of file +processImaging.descr=Publish analysis data to Imaging if an Imaging instance is defined in AIP Console +aipConsoleUrl=AIP Console URL if different than the global configuration +aipConsoleUrl.descr=The root URL to access AIP Console +apiKey=API Key +apiKey.descr=The API Key to access AIP Console diff --git a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config_fr.properties b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config_fr.properties index e69de29b..a5cd808b 100644 --- a/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config_fr.properties +++ b/aip-console-jenkins/src/main/resources/io/jenkins/plugins/aipconsole/SnapshotBuilder/config_fr.properties @@ -0,0 +1,4 @@ +aipConsoleUrl=URL d''AIP Console +aipConsoleUrl.descr=L''URL d''accès à AIP Console +apiKey=Clé d'API +apiKey.descr=La clé d'API permettant l''accès à AIP Console diff --git a/aip-console-jenkins/src/test/java/io/jenkins/plugins/aipconsole/AddVersionBuilderTest.java b/aip-console-jenkins/src/test/java/io/jenkins/plugins/aipconsole/AddVersionBuilderTest.java index 600f63e4..b59b1716 100644 --- a/aip-console-jenkins/src/test/java/io/jenkins/plugins/aipconsole/AddVersionBuilderTest.java +++ b/aip-console-jenkins/src/test/java/io/jenkins/plugins/aipconsole/AddVersionBuilderTest.java @@ -117,7 +117,19 @@ public void testAddVersionStepToJob() throws Exception { job.setDomainName(""); jenkins.assertEqualDataBoundBeans(job, project.getBuildersList().get(0)); } - + + @Test + public void testAddVersionStepToJob_TargetingPrivateConsole() throws Exception { + FreeStyleProject project = jenkins.createFreeStyleProject(); + project.getBuildersList().add(addVersionBuilder); + addVersionBuilder.setApiKey(Secret.fromString("Z-Y-X")); + //addVersionBuilder.setAipConsoleUrl("http://localhost:8083"); + AddVersionBuilder job = new AddVersionBuilder(TEST_APP_NAME, TEST_ARCHIVE_NAME); + job.setApiKey(Secret.fromString("Z-Y-X")); + job.setAipConsoleUrl(addVersionBuilder.getDescriptor().getAipConsoleUrl()); + jenkins.assertEqualDataBoundBeans(job, project.getBuildersList().get(0)); + } + @Test public void testBuildFreestyleDefaultOk() throws Exception { FreeStyleProject project = getProjectWithDefaultAddVersionAndFile(TEST_ARCHIVE_NAME); diff --git a/aip-console-tools-cli/pom.xml b/aip-console-tools-cli/pom.xml index b7019780..d3805a45 100644 --- a/aip-console-tools-cli/pom.xml +++ b/aip-console-tools-cli/pom.xml @@ -5,7 +5,7 @@ com.castsoftware.aip.console.tools aip-console-tools - 1.24.1 + 1.24.2 ../ 4.0.0 diff --git a/aip-console-tools-core/pom.xml b/aip-console-tools-core/pom.xml index 8e70219d..d8649440 100644 --- a/aip-console-tools-core/pom.xml +++ b/aip-console-tools-core/pom.xml @@ -5,7 +5,7 @@ com.castsoftware.aip.console.tools aip-console-tools - 1.24.1 + 1.24.2 ../ 4.0.0 diff --git a/pom.xml b/pom.xml index 72458533..e525cbf0 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.castsoftware.aip.console.tools aip-console-tools - 1.24.1 + 1.24.2 pom AIP Console Integration Tools Integration tools used for AIP Console