From 927b3371b0b0e73412ad7184ef0a656d7e240ddb Mon Sep 17 00:00:00 2001 From: Andre Strothmann Date: Fri, 22 Mar 2024 09:17:16 +0100 Subject: [PATCH] chore: simplify code --- .../services/KubeflowConnectorExecutor.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main/java/de/viadee/bpm/camunda/connectors/kubeflow/services/KubeflowConnectorExecutor.java b/src/main/java/de/viadee/bpm/camunda/connectors/kubeflow/services/KubeflowConnectorExecutor.java index c2dc4c1..185e63c 100644 --- a/src/main/java/de/viadee/bpm/camunda/connectors/kubeflow/services/KubeflowConnectorExecutor.java +++ b/src/main/java/de/viadee/bpm/camunda/connectors/kubeflow/services/KubeflowConnectorExecutor.java @@ -191,27 +191,23 @@ private void addFilter(URIBuilder uriBuilder) throws UnsupportedEncodingExceptio protected void addNamespaceFilter(URIBuilder uriBuilder) { if (isMultiUserMode) { var namespace = connectorRequest.getKubeflowapi().namespace(); - if (kubeflowApiOperationsEnum.isNamespaceFilterRequired()) { - if (KubeflowApisEnum.PIPELINES_V1.equals(kubeflowApisEnum)) { - uriBuilder.addParameter(URI_PARAMETER_PAIR_V1_TYPE_NS.getKey(), - URI_PARAMETER_PAIR_V1_TYPE_NS.getValue()); - uriBuilder.addParameter(URI_PARAMETER_V1_ID, namespace); - } else { - uriBuilder.addParameter(URI_PARAMETER_V2_NS, namespace); - } - } else if (KubeflowApiOperationsEnum.GET_PIPELINES.equals(kubeflowApiOperationsEnum) - && namespace != null) { - if (KubeflowApisEnum.PIPELINES_V1.equals(kubeflowApisEnum)) { - uriBuilder.addParameter(URI_PARAMETER_PAIR_V1_TYPE_NS.getKey(), - URI_PARAMETER_PAIR_V1_TYPE_NS.getValue()); - uriBuilder.addParameter(URI_PARAMETER_V1_ID, namespace); - } else { - uriBuilder.addParameter(URI_PARAMETER_V2_NS, namespace); - } + if (kubeflowApiOperationsEnum.isNamespaceFilterRequired() || + (KubeflowApiOperationsEnum.GET_PIPELINES.equals(kubeflowApiOperationsEnum) && namespace != null)) { + setNamespaceParameter(uriBuilder, namespace); } } } + private void setNamespaceParameter(URIBuilder uriBuilder, String namespace) { + if (KubeflowApisEnum.PIPELINES_V1.equals(kubeflowApisEnum)) { + uriBuilder.addParameter(URI_PARAMETER_PAIR_V1_TYPE_NS.getKey(), + URI_PARAMETER_PAIR_V1_TYPE_NS.getValue()); + uriBuilder.addParameter(URI_PARAMETER_V1_ID, namespace); + } else { + uriBuilder.addParameter(URI_PARAMETER_V2_NS, namespace); + } + } + public static HttpRequest.BodyPublisher ofFormData(Map data) { var builder = new StringBuilder(); for (Map.Entry entry : data.entrySet()) {