This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 0fc8390956 Allow delete method to have body, fixes #5711 (#5717)
0fc8390956 is described below
commit 0fc83909567a3cc76ae0d458ec1d8ebb9088979d
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Fri Sep 19 16:13:39 2025 +0200
Allow delete method to have body, fixes #5711 (#5717)
---
.../apache/hop/pipeline/transforms/rest/Rest.java | 5 +-
.../hop/pipeline/transforms/rest/RestMeta.java | 346 +--------------------
.../hop/pipeline/transforms/rest/RestMetaTest.java | 64 +---
3 files changed, 23 insertions(+), 392 deletions(-)
diff --git
a/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/Rest.java
b/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/Rest.java
index fdda2ca152..aa15fab436 100644
---
a/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/Rest.java
+++
b/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/Rest.java
@@ -235,7 +235,9 @@ public class Rest extends BaseTransform<RestMeta, RestData>
{
response = invocationBuilder.put(Entity.entity(entityString,
data.mediaType));
}
} else if (data.method.equals(RestMeta.HTTP_METHOD_DELETE)) {
- response = invocationBuilder.delete();
+ Invocation invocation =
+ invocationBuilder.build("DELETE", Entity.entity(entityString,
data.mediaType));
+ response = invocation.invoke();
} else if (data.method.equals(RestMeta.HTTP_METHOD_HEAD)) {
response = invocationBuilder.head();
} else if (data.method.equals(RestMeta.HTTP_METHOD_OPTIONS)) {
@@ -337,6 +339,7 @@ public class Rest extends BaseTransform<RestMeta, RestData>
{
data.config.connectorProvider(new ApacheConnectorProvider());
data.config.property(
ClientProperties.REQUEST_ENTITY_PROCESSING,
RequestEntityProcessing.BUFFERED);
+
data.config.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION,
true);
data.config.property(ClientProperties.READ_TIMEOUT,
data.realReadTimeout);
data.config.property(ClientProperties.CONNECT_TIMEOUT,
data.realConnectionTimeout);
diff --git
a/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/RestMeta.java
b/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/RestMeta.java
index f24ffc5905..3bfc8f4b68 100644
---
a/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/RestMeta.java
+++
b/plugins/transforms/rest/src/main/java/org/apache/hop/pipeline/transforms/rest/RestMeta.java
@@ -19,10 +19,11 @@ package org.apache.hop.pipeline.transforms.rest;
import java.util.ArrayList;
import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.hop.core.CheckResult;
import org.apache.hop.core.ICheckResult;
import org.apache.hop.core.annotations.Transform;
-import org.apache.hop.core.exception.HopTransformException;
import org.apache.hop.core.row.IRowMeta;
import org.apache.hop.core.row.IValueMeta;
import org.apache.hop.core.row.value.ValueMetaInteger;
@@ -40,6 +41,8 @@ import
org.apache.hop.pipeline.transforms.rest.fields.MatrixParameterField;
import org.apache.hop.pipeline.transforms.rest.fields.ParameterField;
import org.apache.hop.pipeline.transforms.rest.fields.ResultField;
+@Setter
+@Getter
@Transform(
id = "Rest",
image = "rest.svg",
@@ -80,10 +83,6 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
APPLICATION_TYPE_SVG_XML,
APPLICATION_TYPE_TEXT_XML
};
- public static final String CONST_RESULT = "result";
- public static final String CONST_SPACES_LONG = " ";
- public static final String CONST_SPACES = " ";
- public static final String CONST_FIELD = "field";
@HopMetadataProperty(key = "applicationType", injectionKey =
"APPLICATION_TYPE")
private String applicationType;
@@ -108,7 +107,6 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
@HopMetadataProperty(key = "connection_name", injectionKey =
"CONNECTION_NAME")
private String connectionName;
- /** URL / service to be called */
@HopMetadataProperty(key = "url", injectionKey = "URL")
private String url;
@@ -118,7 +116,6 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
@HopMetadataProperty(key = "urlField", injectionKey = "URL_IN_FIELD")
private String urlField;
- /** proxy */
@HopMetadataProperty(key = "proxyHost", injectionKey = "PROXY_HOST")
private String proxyHost;
@@ -134,11 +131,9 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
@HopMetadataProperty(key = "preemptive", injectionKey = "PREEMPTIVE")
private boolean preemptive;
- /** Body fieldname */
@HopMetadataProperty(key = "bodyField", injectionKey = "BODY_FIELD")
private String bodyField;
- /** HTTP Method */
@HopMetadataProperty(key = "method", injectionKey = "METHOD")
private String method;
@@ -148,7 +143,6 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
@HopMetadataProperty(key = "methodFieldName", injectionKey =
"METHOD_FIELD_NAME")
private String methodFieldName;
- /** Trust store */
@HopMetadataProperty(key = "trustStoreFile", injectionKey =
"TRUSTSTORE_FILE")
private String trustStoreFile;
@@ -167,7 +161,6 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
@HopMetadataProperty(key = "ignoreSsl", injectionKey = "IGNORE_SSL")
private boolean ignoreSsl;
- /** headers name */
@HopMetadataProperty(
key = "header",
groupKey = "headers",
@@ -200,159 +193,6 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
resultField = new ResultField();
}
- /**
- * @return Returns the method.
- */
- public String getMethod() {
- return method;
- }
-
- /**
- * @param value The method to set.
- */
- public void setMethod(String value) {
- this.method = value;
- }
-
- /**
- * @return Returns the bodyField.
- */
- public String getBodyField() {
- return bodyField;
- }
-
- /**
- * @param value The bodyField to set.
- */
- public void setBodyField(String value) {
- this.bodyField = value;
- }
-
- /**
- * @return Returns the parameterField.
- */
- public List<ParameterField> getParameterFields() {
- return parameterFields;
- }
-
- public void setParameterFields(List<ParameterField> value) {
- this.parameterFields = value;
- }
-
- public List<MatrixParameterField> getMatrixParameterFields() {
- return matrixParameterFields;
- }
-
- public void setMatrixParameterFields(List<MatrixParameterField> value) {
- this.matrixParameterFields = value;
- }
-
- /**
- * @return Returns the headerField.
- */
- public List<HeaderField> getHeaderFields() {
- return headerFields;
- }
-
- /**
- * @param value The headerField to set.
- */
- public void setHeaderFields(List<HeaderField> value) {
- this.headerFields = value;
- }
-
- /**
- * @return Returns the procedure.
- */
- public String getUrl() {
- return url;
- }
-
- /**
- * @param procedure The procedure to set.
- */
- public void setUrl(String procedure) {
- this.url = procedure;
- }
-
- /**
- * @return Is the url coded in a field?
- */
- public boolean isUrlInField() {
- return urlInField;
- }
-
- /**
- * @param urlInField Is the url coded in a field?
- */
- public void setUrlInField(boolean urlInField) {
- this.urlInField = urlInField;
- }
-
- /**
- * @return Is preemptive?
- */
- public boolean isPreemptive() {
- return preemptive;
- }
-
- /**
- * @param preemptive Ispreemptive?
- */
- public void setPreemptive(boolean preemptive) {
- this.preemptive = preemptive;
- }
-
- /**
- * @return Is the method defined in a field?
- */
- public boolean isDynamicMethod() {
- return dynamicMethod;
- }
-
- /**
- * @param dynamicMethod If the method is defined in a field?
- */
- public void setDynamicMethod(boolean dynamicMethod) {
- this.dynamicMethod = dynamicMethod;
- }
-
- /**
- * @return methodFieldName
- */
- public String getMethodFieldName() {
- return methodFieldName;
- }
-
- /**
- * @param methodFieldName
- */
- public void setMethodFieldName(String methodFieldName) {
- this.methodFieldName = methodFieldName;
- }
-
- /**
- * @return The field name that contains the url.
- */
- public String getUrlField() {
- return urlField;
- }
-
- /**
- * @param urlField name of the field that contains the url
- */
- public void setUrlField(String urlField) {
- this.urlField = urlField;
- }
-
- public boolean isIgnoreSsl() {
- return ignoreSsl;
- }
-
- public void setIgnoreSsl(boolean ignoreSsl) {
- this.ignoreSsl = ignoreSsl;
- }
-
@Override
public Object clone() {
RestMeta retval = (RestMeta) super.clone();
@@ -385,8 +225,7 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
IRowMeta[] info,
TransformMeta nextTransform,
IVariables variables,
- IHopMetadataProvider metadataProvider)
- throws HopTransformException {
+ IHopMetadataProvider metadataProvider) {
if (!Utils.isEmpty(resultField.getFieldName())) {
IValueMeta v = new
ValueMetaString(variables.resolve(resultField.getFieldName()));
v.setOrigin(name);
@@ -512,141 +351,14 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
return true;
}
- /**
- * Setter
- *
- * @param proxyHost
- */
- public void setProxyHost(String proxyHost) {
- this.proxyHost = proxyHost;
- }
-
- /**
- * Getter
- *
- * @return
- */
- public String getProxyHost() {
- return proxyHost;
- }
-
- /**
- * Setter
- *
- * @param proxyPort
- */
- public void setProxyPort(String proxyPort) {
- this.proxyPort = proxyPort;
- }
-
- /**
- * Getter
- *
- * @return
- */
- public String getProxyPort() {
- return this.proxyPort;
- }
-
- /**
- * Setter
- *
- * @param applicationType
- */
- public void setApplicationType(String applicationType) {
- this.applicationType = applicationType;
- }
-
- /**
- * Getter
- *
- * @return
- */
- public String getApplicationType() {
- return applicationType;
- }
-
- /**
- * Setter
- *
- * @param httpLogin
- */
- public void setHttpLogin(String httpLogin) {
- this.httpLogin = httpLogin;
- }
-
- /**
- * Getter
- *
- * @return
- */
- public String getHttpLogin() {
- return httpLogin;
- }
-
- /**
- * Setter
- *
- * @param httpPassword
- */
- public void setHttpPassword(String httpPassword) {
- this.httpPassword = httpPassword;
- }
-
- /**
- * @return
- */
- public String getHttpPassword() {
- return httpPassword;
- }
-
- /**
- * Setter
- *
- * @param trustStoreFile
- */
- public void setTrustStoreFile(String trustStoreFile) {
- this.trustStoreFile = trustStoreFile;
- }
-
- /**
- * @return trustStoreFile
- */
- public String getTrustStoreFile() {
- return trustStoreFile;
- }
-
- /**
- * Setter
- *
- * @param trustStorePassword
- */
- public void setTrustStorePassword(String trustStorePassword) {
- this.trustStorePassword = trustStorePassword;
- }
-
- /**
- * @return trustStorePassword
- */
- public String getTrustStorePassword() {
- return trustStorePassword;
- }
-
- public ResultField getResultField() {
- return resultField;
- }
-
- public void setResultField(ResultField resultField) {
- this.resultField = resultField;
- }
-
public static boolean isActiveBody(String method) {
if (Utils.isEmpty(method)) {
return false;
}
return (method.equals(HTTP_METHOD_POST)
|| method.equals(HTTP_METHOD_PUT)
- || method.equals(HTTP_METHOD_PATCH));
+ || method.equals(HTTP_METHOD_PATCH)
+ || method.equals(HTTP_METHOD_DELETE));
}
public static boolean isActiveParameters(String method) {
@@ -659,48 +371,4 @@ public class RestMeta extends BaseTransformMeta<Rest,
RestData> {
|| method.equals(HTTP_METHOD_PATCH)
|| method.equals(HTTP_METHOD_DELETE));
}
-
- /**
- * Returns the connection timeout until a connection is established
(milliseconds).
- *
- * @return
- */
- public String getConnectionTimeout() {
- return connectionTimeout;
- }
-
- /**
- * Define the connection timeout until a connection is established
(milliseconds).
- *
- * @param timeout The connection timeout to set.
- */
- public void setConnectionTimeout(String timeout) {
- this.connectionTimeout = timeout;
- }
-
- /**
- * Returns the timeout for waiting for reading data (milliseconds).
- *
- * @return
- */
- public String getReadTimeout() {
- return readTimeout;
- }
-
- /**
- * Define the timeout for waiting for reading data (milliseconds).
- *
- * @param timeout The read timeout to set.
- */
- public void setReadTimeout(String timeout) {
- this.readTimeout = timeout;
- }
-
- public String getConnectionName() {
- return connectionName;
- }
-
- public void setConnectionName(String connectionName) {
- this.connectionName = connectionName;
- }
}
diff --git
a/plugins/transforms/rest/src/test/java/org/apache/hop/pipeline/transforms/rest/RestMetaTest.java
b/plugins/transforms/rest/src/test/java/org/apache/hop/pipeline/transforms/rest/RestMetaTest.java
index 722c54941d..d84b77088a 100644
---
a/plugins/transforms/rest/src/test/java/org/apache/hop/pipeline/transforms/rest/RestMetaTest.java
+++
b/plugins/transforms/rest/src/test/java/org/apache/hop/pipeline/transforms/rest/RestMetaTest.java
@@ -25,7 +25,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import org.apache.hop.core.Const;
import org.apache.hop.core.ICheckResult;
import org.apache.hop.core.encryption.Encr;
@@ -98,18 +97,7 @@ class RestMetaTest implements IInitializer<ITransformMeta> {
"headerFields",
"parameterFields",
"matrixParameterFields",
- "resultField"
- // "headerField",
- // "headerName",
- // "parameterField",
- // "parameterName",
- // "matrixParameterField",
- // "matrixParameterName",
- // "fieldName",
- // "resultCodeFieldName",
- // "responseTimeFieldName",
- // "responseHeaderFieldName"
- );
+ "resultField");
Map<String, String> getterMap = new HashMap<>();
getterMap.put("applicationType", "getApplicationType");
@@ -181,7 +169,7 @@ class RestMetaTest implements IInitializer<ITransformMeta> {
validatorFactory,
ResultField.class,
Arrays.asList("fieldName", "code", "responseTime",
"responseHeader"),
- new HashMap<String, String>() {
+ new HashMap<>() {
{
put("fieldname", "getFieldName");
put("code", "getCode");
@@ -189,7 +177,7 @@ class RestMetaTest implements IInitializer<ITransformMeta> {
put("responseHeader", "getResponseHeader");
}
},
- new HashMap<String, String>() {
+ new HashMap<>() {
{
put("fieldname", "setFieldName");
put("code", "setCode");
@@ -204,13 +192,13 @@ class RestMetaTest implements
IInitializer<ITransformMeta> {
validatorFactory,
HeaderField.class,
Arrays.asList("name", "headerField"),
- new HashMap<String, String>() {
+ new HashMap<>() {
{
put("name", "getName");
put("headerField", "getHeaderField");
}
},
- new HashMap<String, String>() {
+ new HashMap<>() {
{
put("bame", "setName");
put("headerField", "setHeaderField");
@@ -223,13 +211,13 @@ class RestMetaTest implements
IInitializer<ITransformMeta> {
validatorFactory,
ParameterField.class,
Arrays.asList("name", "headerField"),
- new HashMap<String, String>() {
+ new HashMap<>() {
{
put("name", "getName");
put("headerField", "getHeaderField");
}
},
- new HashMap<String, String>() {
+ new HashMap<>() {
{
put("bame", "setName");
put("headerField", "setHeaderField");
@@ -242,44 +230,18 @@ class RestMetaTest implements
IInitializer<ITransformMeta> {
validatorFactory,
MatrixParameterField.class,
Arrays.asList("name", "headerField"),
- new HashMap<String, String>() {
+ new HashMap<>() {
{
put("name", "getName");
put("headerField", "getHeaderField");
}
},
- new HashMap<String, String>() {
+ new HashMap<>() {
{
put("bame", "setName");
put("headerField", "setHeaderField");
}
}));
-
- // Map<String, IFieldLoadSaveValidator<?>>
fieldLoadSaveValidatorAttributeMap = new
- // HashMap<>();
- //
- // // Arrays need to be consistent length
- // IFieldLoadSaveValidator<String[]> stringArrayLoadSaveValidator =
- // new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(), 25);
- // fieldLoadSaveValidatorAttributeMap.put("headerField",
stringArrayLoadSaveValidator);
- // fieldLoadSaveValidatorAttributeMap.put("headerName",
stringArrayLoadSaveValidator);
- // fieldLoadSaveValidatorAttributeMap.put("parameterField",
stringArrayLoadSaveValidator);
- // fieldLoadSaveValidatorAttributeMap.put("parameterName",
stringArrayLoadSaveValidator);
- // fieldLoadSaveValidatorAttributeMap.put("matrixParameterField",
- // stringArrayLoadSaveValidator);
- // fieldLoadSaveValidatorAttributeMap.put("matrixParameterName",
- // stringArrayLoadSaveValidator);
- //
- // LoadSaveTester<RestMeta> loadSaveTester =
- // new LoadSaveTester<>(
- // RestMeta.class,
- // attributes,
- // new HashMap<>(),
- // new HashMap<>(),
- // fieldLoadSaveValidatorAttributeMap,
- // new HashMap<>());
-
- // loadSaveTester.testSerialization();
}
@Test
@@ -316,10 +278,8 @@ class RestMetaTest implements IInitializer<ITransformMeta>
{
}
private static int getCheckResultErrorCount(List<ICheckResult> remarks) {
- return remarks.stream()
- .filter(p -> p.getType() == ICheckResult.TYPE_RESULT_ERROR)
- .collect(Collectors.toList())
- .size();
+ return (int)
+ remarks.stream().filter(p -> p.getType() ==
ICheckResult.TYPE_RESULT_ERROR).count();
}
@Test
@@ -327,9 +287,9 @@ class RestMetaTest implements IInitializer<ITransformMeta> {
assertTrue(RestMeta.isActiveBody(RestMeta.HTTP_METHOD_POST));
assertTrue(RestMeta.isActiveBody(RestMeta.HTTP_METHOD_PUT));
assertTrue(RestMeta.isActiveBody(RestMeta.HTTP_METHOD_PATCH));
+ assertTrue(RestMeta.isActiveBody(RestMeta.HTTP_METHOD_DELETE));
assertFalse(RestMeta.isActiveBody(RestMeta.HTTP_METHOD_GET));
- assertFalse(RestMeta.isActiveBody(RestMeta.HTTP_METHOD_DELETE));
assertFalse(RestMeta.isActiveBody(RestMeta.HTTP_METHOD_HEAD));
assertFalse(RestMeta.isActiveBody(RestMeta.HTTP_METHOD_OPTIONS));
}