From accc67f70d87555045797fc9141e7a8123c298a3 Mon Sep 17 00:00:00 2001 From: Tim van der Leeuw Date: Tue, 16 Jul 2024 10:51:50 +0200 Subject: [PATCH] Add method ParameterList#hasParameter and apply where relevant. (#7157) --- .../extensions/akamai/NetStorageSender.java | 6 +++--- .../extensions/cmis/CmisSender.java | 2 +- .../frankframework/compression/ZipWriter.java | 9 +++------ .../jdbc/MessageStoreSender.java | 7 +++---- .../java/org/frankframework/jms/JmsSender.java | 15 +++++++-------- .../frankframework/ldap/LdapChallengePipe.java | 9 ++++----- .../org/frankframework/ldap/LdapSender.java | 8 ++++---- .../frankframework/mongodb/MongoDbSender.java | 2 +- .../parameters/ParameterList.java | 9 ++++++--- .../pipes/CompareIntegerPipe.java | 2 +- .../pipes/CompareStringPipe.java | 7 +++---- .../java/org/frankframework/pipes/JwtPipe.java | 2 +- .../frankframework/pipes/SignaturePipe.java | 4 ++-- .../org/frankframework/senders/LogSender.java | 2 +- .../senders/SenderWithParametersBase.java | 5 ++--- .../parameters/ParameterListTest.java | 8 +++++++- .../filesystem/FileSystemActor.java | 10 +++++----- .../extensions/api/ApiSoapWrapperPipe.java | 5 ++--- .../extensions/esb/EsbJmsSender.java | 2 +- .../extensions/esb/EsbSoapWrapperPipe.java | 18 +++++++++--------- .../extensions/fxf/FxfWrapperPipe.java | 2 +- .../extensions/sap/jco3/SapSenderBase.java | 11 +++++------ .../extensions/sap/jco3/SapSenderImpl.java | 7 +++---- .../extensions/tibco/GetTibcoQueues.java | 2 +- .../extensions/tibco/SendTibcoMessage.java | 2 +- 25 files changed, 77 insertions(+), 79 deletions(-) diff --git a/akamai/src/main/java/org/frankframework/extensions/akamai/NetStorageSender.java b/akamai/src/main/java/org/frankframework/extensions/akamai/NetStorageSender.java index b1e75e69b82..edffc9b42c9 100644 --- a/akamai/src/main/java/org/frankframework/extensions/akamai/NetStorageSender.java +++ b/akamai/src/main/java/org/frankframework/extensions/akamai/NetStorageSender.java @@ -112,13 +112,13 @@ public void configure() throws ConfigurationException { ParameterList parameterList = getParameterList(); - if(getAction() == Action.UPLOAD && parameterList.findParameter(FILE_PARAM_KEY) == null) { + if(getAction() == Action.UPLOAD && !parameterList.hasParameter(FILE_PARAM_KEY)) { throw new ConfigurationException(getLogPrefix()+"the upload action requires a file parameter to be present"); } - if(getAction() == Action.RENAME && parameterList.findParameter(DESTINATION_PARAM_KEY) == null) { + if(getAction() == Action.RENAME && !parameterList.hasParameter(DESTINATION_PARAM_KEY)) { throw new ConfigurationException(getLogPrefix()+"the rename action requires a destination parameter to be present"); } - if(getAction() == Action.MTIME && parameterList.findParameter(MTIME_PARAM_KEY) == null) { + if(getAction() == Action.MTIME && !parameterList.hasParameter(MTIME_PARAM_KEY)) { throw new ConfigurationException(getLogPrefix()+"the mtime action requires a mtime parameter to be present"); } diff --git a/cmis/src/main/java/org/frankframework/extensions/cmis/CmisSender.java b/cmis/src/main/java/org/frankframework/extensions/cmis/CmisSender.java index ad42de852d3..f44c2d84c4e 100644 --- a/cmis/src/main/java/org/frankframework/extensions/cmis/CmisSender.java +++ b/cmis/src/main/java/org/frankframework/extensions/cmis/CmisSender.java @@ -249,7 +249,7 @@ public void configure() throws ConfigurationException { if (getParameterList() != null) { // Legacy; check if the session should be created runtime (and thus for each call) - if(getParameterList().findParameter("authAlias") != null || getParameterList().findParameter("username") != null ) { + if(getParameterList().hasParameter("authAlias") || getParameterList().hasParameter("username")) { runtimeSession = true; } diff --git a/core/src/main/java/org/frankframework/compression/ZipWriter.java b/core/src/main/java/org/frankframework/compression/ZipWriter.java index 51b4f58a5f4..2ce2afba1dc 100644 --- a/core/src/main/java/org/frankframework/compression/ZipWriter.java +++ b/core/src/main/java/org/frankframework/compression/ZipWriter.java @@ -27,7 +27,6 @@ import org.frankframework.collection.ICollector; import org.frankframework.configuration.ConfigurationException; import org.frankframework.core.PipeLineSession; -import org.frankframework.parameters.IParameter; import org.frankframework.parameters.ParameterList; import org.frankframework.parameters.ParameterValueList; import org.frankframework.stream.FileMessage; @@ -54,19 +53,17 @@ static void validateParametersForAction(Action action, ParameterList parameterLi if(parameterList == null) { throw new ConfigurationException("parameter '"+PARAMETER_FILENAME+"' or parameter '"+PARAMETER_CONTENTS+"' is required"); } - IParameter filenameParameter=parameterList.findParameter(PARAMETER_FILENAME); - IParameter contentsParameter=parameterList.findParameter(PARAMETER_CONTENTS); - if (filenameParameter==null && contentsParameter==null) { + if (!parameterList.hasParameter(PARAMETER_FILENAME) && !parameterList.hasParameter(PARAMETER_CONTENTS)) { throw new ConfigurationException("parameter '"+PARAMETER_FILENAME+"' or parameter '"+PARAMETER_CONTENTS+"' is required"); } break; case CLOSE: - if (parameterList != null && parameterList.findParameter(PARAMETER_FILENAME)!=null) { + if (parameterList != null && parameterList.hasParameter(PARAMETER_FILENAME)) { throw new ConfigurationException("parameter '"+PARAMETER_FILENAME+"' cannot not be configured on action [close]"); } break; case STREAM: - if(parameterList == null || parameterList.findParameter(PARAMETER_FILENAME)==null) { + if(parameterList == null || !parameterList.hasParameter(PARAMETER_FILENAME)) { throw new ConfigurationException("parameter '"+PARAMETER_FILENAME+"' is required"); } break; diff --git a/core/src/main/java/org/frankframework/jdbc/MessageStoreSender.java b/core/src/main/java/org/frankframework/jdbc/MessageStoreSender.java index c2d8fff2ced..b18356c3fb1 100644 --- a/core/src/main/java/org/frankframework/jdbc/MessageStoreSender.java +++ b/core/src/main/java/org/frankframework/jdbc/MessageStoreSender.java @@ -20,6 +20,8 @@ import java.util.Date; import java.util.List; +import lombok.Getter; +import lombok.SneakyThrows; import org.apache.commons.lang3.StringUtils; import org.apache.commons.text.StringEscapeUtils; import org.frankframework.configuration.ConfigurationException; @@ -37,9 +39,6 @@ import org.frankframework.stream.Message; import org.frankframework.util.StringUtil; -import lombok.Getter; -import lombok.SneakyThrows; - /** * Send messages to the IBISSTORE database table to have them processed exactly-once by another * adapter which will read the messages using a {@link MessageStoreListener}. @@ -141,7 +140,7 @@ public SenderResult sendMessage(Message message, PipeLineSession session) throws // the messageId to be inserted in the messageStore defaults to the messageId of the session String messageId = session.getMessageId(); String correlationID = session.getCorrelationId(); - if (paramList != null && paramList.findParameter(PARAM_MESSAGEID) != null) { + if (paramList != null && paramList.hasParameter(PARAM_MESSAGEID)) { try { // the messageId to be inserted can also be specified via the parameter messageId messageId = paramList.getValues(message, session).get(PARAM_MESSAGEID).asStringValue(); diff --git a/core/src/main/java/org/frankframework/jms/JmsSender.java b/core/src/main/java/org/frankframework/jms/JmsSender.java index 429b786a19a..e8991227904 100644 --- a/core/src/main/java/org/frankframework/jms/JmsSender.java +++ b/core/src/main/java/org/frankframework/jms/JmsSender.java @@ -25,6 +25,12 @@ import javax.naming.NamingException; import javax.xml.transform.TransformerException; +import jakarta.jms.Destination; +import jakarta.jms.JMSException; +import jakarta.jms.MessageConsumer; +import jakarta.jms.MessageProducer; +import jakarta.jms.Session; +import lombok.Getter; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.frankframework.configuration.ConfigurationException; @@ -47,13 +53,6 @@ import org.frankframework.util.XmlException; import org.xml.sax.SAXException; -import jakarta.jms.Destination; -import jakarta.jms.JMSException; -import jakarta.jms.MessageConsumer; -import jakarta.jms.MessageProducer; -import jakarta.jms.Session; -import lombok.Getter; - /** * This class sends messages with JMS. * @@ -98,7 +97,7 @@ public enum LinkMethod { */ @Override public void configure() throws ConfigurationException { - if (StringUtils.isNotEmpty(getSoapAction()) && (paramList==null || paramList.findParameter("SoapAction")==null)) { + if (StringUtils.isNotEmpty(getSoapAction()) && (paramList==null || !paramList.hasParameter("SoapAction"))) { Parameter p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName("SoapAction"); p.setValue(getSoapAction()); diff --git a/core/src/main/java/org/frankframework/ldap/LdapChallengePipe.java b/core/src/main/java/org/frankframework/ldap/LdapChallengePipe.java index 64912c24cb9..f597c49afea 100644 --- a/core/src/main/java/org/frankframework/ldap/LdapChallengePipe.java +++ b/core/src/main/java/org/frankframework/ldap/LdapChallengePipe.java @@ -18,7 +18,6 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; - import org.frankframework.configuration.ConfigurationException; import org.frankframework.configuration.ConfigurationWarning; import org.frankframework.core.IPipe; @@ -65,16 +64,16 @@ public class LdapChallengePipe extends FixedForwardPipe { public void configure() throws ConfigurationException { super.configure(); - if (StringUtils.isEmpty(ldapProviderURL) && getParameterList().findParameter("ldapProviderURL")==null) { + if (StringUtils.isEmpty(ldapProviderURL) && !getParameterList().hasParameter("ldapProviderURL")) { throw new ConfigurationException("ldapProviderURL must be specified, either as attribute or as parameter"); } - if (StringUtils.isNotEmpty(ldapProviderURL) && getParameterList().findParameter("ldapProviderURL")!=null) { + if (StringUtils.isNotEmpty(ldapProviderURL) && getParameterList().hasParameter("ldapProviderURL")) { throw new ConfigurationException("ldapProviderURL can only be specified once, either as attribute or as parameter"); } - if (getParameterList().findParameter("principal")==null) { + if (!getParameterList().hasParameter("principal")) { throw new ConfigurationException("Parameter 'principal' must be specified"); } - if (getParameterList().findParameter("credentials")==null) { + if (!getParameterList().hasParameter("credentials")) { throw new ConfigurationException("Parameter 'credentials' must be specified"); } } diff --git a/core/src/main/java/org/frankframework/ldap/LdapSender.java b/core/src/main/java/org/frankframework/ldap/LdapSender.java index e373a46daa4..47cb9684445 100644 --- a/core/src/main/java/org/frankframework/ldap/LdapSender.java +++ b/core/src/main/java/org/frankframework/ldap/LdapSender.java @@ -290,7 +290,7 @@ public LdapSender() { @Override public void configure() throws ConfigurationException { - if (paramList == null || (paramList.findParameter(ENTRYNAME) == null && getOperation() != Operation.CHALLENGE)) { + if (paramList == null || (!paramList.hasParameter(ENTRYNAME) && getOperation() != Operation.CHALLENGE)) { throw new ConfigurationException("[" + getName()+ "] Required parameter with the name [entryName] not found!"); } paramList.configure(); @@ -299,7 +299,7 @@ public void configure() throws ConfigurationException { throw new ConfigurationException("["+ getClass().getName() + "] manipulationSubject invalid for update operation (must be ['" + Manipulation.ATTRIBUTE + "'], which is default - remove from )"); } - if (getOperation() == Operation.CHALLENGE && paramList.findParameter("principal") == null) { + if (getOperation() == Operation.CHALLENGE && !paramList.hasParameter("principal")) { throw new ConfigurationException("principal should be specified using a parameter when using operation challenge"); } IParameter credentials = paramList.findParameter("credentials"); @@ -314,8 +314,8 @@ public void configure() throws ConfigurationException { if (newPassword != null && !newPassword.isHidden()) { ConfigurationWarnings.add(this, log, "It's advised to set attribute hidden to true for parameter newPassword."); } - if (paramList.findParameter("principal") != null) { - if (paramList.findParameter("credentials") == null) { + if (paramList.hasParameter("principal")) { + if (!paramList.hasParameter("credentials")) { throw new ConfigurationException("principal set as parameter, but no credentials parameter found"); } principalParameterFound = true; diff --git a/core/src/main/java/org/frankframework/mongodb/MongoDbSender.java b/core/src/main/java/org/frankframework/mongodb/MongoDbSender.java index 7e3648943d9..cff2f15aefd 100644 --- a/core/src/main/java/org/frankframework/mongodb/MongoDbSender.java +++ b/core/src/main/java/org/frankframework/mongodb/MongoDbSender.java @@ -138,7 +138,7 @@ public void configure() throws ConfigurationException { if (getAction()==null) { throw new ConfigurationException("attribute action not specified"); } - if ((getLimit()>0 || (getParameterList()!=null && getParameterList().findParameter(PARAM_LIMIT)!=null)) && getAction()!=MongoAction.FINDMANY) { + if ((getLimit()>0 || (getParameterList()!=null && getParameterList().hasParameter(PARAM_LIMIT))) && getAction()!=MongoAction.FINDMANY) { throw new ConfigurationException("attribute limit or parameter "+PARAM_LIMIT+" can only be used for action "+MongoAction.FINDMANY); } } diff --git a/core/src/main/java/org/frankframework/parameters/ParameterList.java b/core/src/main/java/org/frankframework/parameters/ParameterList.java index 25fd8ca4cdb..950fc5a14d6 100644 --- a/core/src/main/java/org/frankframework/parameters/ParameterList.java +++ b/core/src/main/java/org/frankframework/parameters/ParameterList.java @@ -22,15 +22,14 @@ import java.util.concurrent.atomic.AtomicInteger; import jakarta.annotation.Nonnull; +import lombok.Getter; +import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.frankframework.configuration.ConfigurationException; import org.frankframework.core.ParameterException; import org.frankframework.core.PipeLineSession; import org.frankframework.stream.Message; -import lombok.Getter; -import lombok.Setter; - /** * List of parameters. @@ -92,6 +91,10 @@ public IParameter findParameter(String name) { return null; } + public boolean hasParameter(String name) { + return stream().anyMatch(p -> p.getName().equals(name)); + } + private boolean parameterEvaluationRequiresInputValue() { for (IParameter p:this) { if (p.requiresInputValueForResolution()) { diff --git a/core/src/main/java/org/frankframework/pipes/CompareIntegerPipe.java b/core/src/main/java/org/frankframework/pipes/CompareIntegerPipe.java index 92c8f657088..1944cba47ee 100644 --- a/core/src/main/java/org/frankframework/pipes/CompareIntegerPipe.java +++ b/core/src/main/java/org/frankframework/pipes/CompareIntegerPipe.java @@ -67,7 +67,7 @@ public void configure() throws ConfigurationException { throw new ConfigurationException("forward [" + EQUALSFORWARD + "] is not defined"); ParameterList parameterList = getParameterList(); - if (parameterList.findParameter(OPERAND1) == null && parameterList.findParameter(OPERAND2) == null) { + if (!parameterList.hasParameter(OPERAND1) && !parameterList.hasParameter(OPERAND2)) { throw new ConfigurationException("has neither parameter [" + OPERAND1 + "] nor parameter [" + OPERAND2 + "] specified"); } } diff --git a/core/src/main/java/org/frankframework/pipes/CompareStringPipe.java b/core/src/main/java/org/frankframework/pipes/CompareStringPipe.java index 94a92e7cf45..37e303232ac 100644 --- a/core/src/main/java/org/frankframework/pipes/CompareStringPipe.java +++ b/core/src/main/java/org/frankframework/pipes/CompareStringPipe.java @@ -16,9 +16,6 @@ package org.frankframework.pipes; import org.apache.commons.lang3.StringUtils; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - import org.frankframework.configuration.ConfigurationException; import org.frankframework.core.ParameterException; import org.frankframework.core.PipeLineSession; @@ -32,6 +29,8 @@ import org.frankframework.parameters.ParameterValueList; import org.frankframework.stream.Message; import org.frankframework.util.XmlUtils; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; /** * Pipe that lexicographically compares two strings, that must NOT be empty. @@ -84,7 +83,7 @@ public void configure() throws ConfigurationException { throw new ConfigurationException("forward [" + EQUALSFORWARD + "] is not defined"); ParameterList parameterList = getParameterList(); - if (parameterList.findParameter(OPERAND1) == null && parameterList.findParameter(OPERAND2) == null) { + if (!parameterList.hasParameter(OPERAND1) && !parameterList.hasParameter(OPERAND2)) { throw new ConfigurationException("has neither parameter [" + OPERAND1 + "] nor parameter [" + OPERAND2 + "] specified"); } } diff --git a/core/src/main/java/org/frankframework/pipes/JwtPipe.java b/core/src/main/java/org/frankframework/pipes/JwtPipe.java index a7cc93185ce..e240c14d4a4 100644 --- a/core/src/main/java/org/frankframework/pipes/JwtPipe.java +++ b/core/src/main/java/org/frankframework/pipes/JwtPipe.java @@ -91,7 +91,7 @@ public void configure() throws ConfigurationException { } } - if (globalSigner == null && getParameterList().findParameter(SHARED_SECRET_PARAMETER_NAME) == null) { + if (globalSigner == null && !getParameterList().hasParameter(SHARED_SECRET_PARAMETER_NAME)) { throw new ConfigurationException("must either provide a [sharedSecret] (alias) or parameter"); } } diff --git a/core/src/main/java/org/frankframework/pipes/SignaturePipe.java b/core/src/main/java/org/frankframework/pipes/SignaturePipe.java index 0c1375a2ea1..be3a7563812 100644 --- a/core/src/main/java/org/frankframework/pipes/SignaturePipe.java +++ b/core/src/main/java/org/frankframework/pipes/SignaturePipe.java @@ -95,12 +95,12 @@ public void configure() throws ConfigurationException { AuthSSLContextFactory.verifyKeystoreConfiguration(this, null); if (getAction() == Action.VERIFY) { - if (getParameterList().findParameter(PARAMETER_SIGNATURE)==null) { + if (!getParameterList().hasParameter(PARAMETER_SIGNATURE)) { throw new ConfigurationException("Parameter [" + PARAMETER_SIGNATURE + "] must be specfied for action [" + action + "]"); } failureForward = findForward("failure"); if (failureForward==null) { - throw new ConfigurationException("Forward [failure] must be specfied for action [" + action + "]"); + throw new ConfigurationException("Forward [failure] must be specified for action [" + action + "]"); } } } diff --git a/core/src/main/java/org/frankframework/senders/LogSender.java b/core/src/main/java/org/frankframework/senders/LogSender.java index 9fcf481ad23..b87edc78ec9 100644 --- a/core/src/main/java/org/frankframework/senders/LogSender.java +++ b/core/src/main/java/org/frankframework/senders/LogSender.java @@ -112,7 +112,7 @@ public void setLogLevel(String level) { @Override public String toString() { - String level = getParameterList() != null && getParameterList().findParameter(LOG_LEVEL_ATTRIBUTE_NAME)!=null ? "dynamic" : logLevel; + String level = getParameterList() != null && getParameterList().hasParameter(LOG_LEVEL_ATTRIBUTE_NAME) ? "dynamic" : logLevel; return "LogSender ["+getName()+"] logLevel ["+level+"] logCategory ["+logCategory+"]"; } diff --git a/core/src/main/java/org/frankframework/senders/SenderWithParametersBase.java b/core/src/main/java/org/frankframework/senders/SenderWithParametersBase.java index d34b0055f3c..710a098a840 100644 --- a/core/src/main/java/org/frankframework/senders/SenderWithParametersBase.java +++ b/core/src/main/java/org/frankframework/senders/SenderWithParametersBase.java @@ -15,6 +15,7 @@ */ package org.frankframework.senders; +import jakarta.annotation.Nullable; import org.apache.commons.lang3.StringUtils; import org.frankframework.configuration.ConfigurationException; import org.frankframework.core.ISenderWithParameters; @@ -26,8 +27,6 @@ import org.frankframework.parameters.ParameterValueList; import org.frankframework.stream.Message; -import jakarta.annotation.Nullable; - /** * Provides a base class for senders with parameters. * @@ -64,7 +63,7 @@ public ParameterList getParameterList() { } protected void checkStringAttributeOrParameter(String attributeName, String attributeValue, String parameterName) throws ConfigurationException { - if (StringUtils.isEmpty(attributeValue) && (getParameterList()==null || getParameterList().findParameter(parameterName)==null)) { + if (StringUtils.isEmpty(attributeValue) && (getParameterList()==null || !getParameterList().hasParameter(parameterName))) { throw new ConfigurationException("either attribute "+attributeName+" or parameter "+parameterName+" must be specified"); } } diff --git a/core/src/test/java/org/frankframework/parameters/ParameterListTest.java b/core/src/test/java/org/frankframework/parameters/ParameterListTest.java index 77d7822b69f..bef168fc2a3 100644 --- a/core/src/test/java/org/frankframework/parameters/ParameterListTest.java +++ b/core/src/test/java/org/frankframework/parameters/ParameterListTest.java @@ -1,16 +1,19 @@ package org.frankframework.parameters; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; -import org.frankframework.configuration.ConfigurationException; import org.junit.jupiter.api.Test; +import org.frankframework.configuration.ConfigurationException; + public class ParameterListTest { @Test @@ -25,8 +28,11 @@ public void testParameterList() throws Exception { list.configure(); assertNotNull(list.findParameter("key1")); + assertTrue(list.hasParameter("key1"), "Expected to find parameter [key1] in parameter list"); assertNotNull(list.findParameter("key2")); + assertTrue(list.hasParameter("key2"), "Expected to find parameter [key2] in parameter list"); assertNull(list.findParameter("doesnt-exist")); + assertFalse(list.hasParameter("doesnt-exist"), "Expected not to find parameter [doesnt-exist] in parameter list"); assertEquals(4, list.size()); List sortedList2 = new ArrayList<>(); diff --git a/filesystem/src/main/java/org/frankframework/filesystem/FileSystemActor.java b/filesystem/src/main/java/org/frankframework/filesystem/FileSystemActor.java index 5db0869c046..7890ee9abf7 100644 --- a/filesystem/src/main/java/org/frankframework/filesystem/FileSystemActor.java +++ b/filesystem/src/main/java/org/frankframework/filesystem/FileSystemActor.java @@ -179,7 +179,7 @@ public void configure(S fileSystem, ParameterList parameterList, IConfigurable o actions.addAll(Arrays.asList(ACTIONS_MAIL_FS)); } - if (parameterList!=null && parameterList.findParameter(PARAMETER_CONTENTS2) != null && parameterList.findParameter(PARAMETER_CONTENTS1) == null) { + if (parameterList!=null && parameterList.hasParameter(PARAMETER_CONTENTS2) && !parameterList.hasParameter(PARAMETER_CONTENTS1)) { ConfigurationWarnings.add(owner, log, "parameter ["+PARAMETER_CONTENTS2+"] has been replaced with ["+PARAMETER_CONTENTS1+"]"); parameterList.findParameter(PARAMETER_CONTENTS2).setName(PARAMETER_CONTENTS1); } @@ -193,11 +193,11 @@ public void configure(S fileSystem, ParameterList parameterList, IConfigurable o action=FileSystemAction.WRITE; } checkConfiguration(getAction()); - } else if (parameterList == null || parameterList.findParameter(PARAMETER_ACTION) == null) { + } else if (parameterList == null || !parameterList.hasParameter(PARAMETER_ACTION)) { throw new ConfigurationException(ClassUtils.nameOf(owner)+": either attribute [action] or parameter ["+PARAMETER_ACTION+"] must be specified"); } - if (StringUtils.isNotEmpty(getInputFolder()) && parameterList!=null && parameterList.findParameter(PARAMETER_INPUTFOLDER) != null) { + if (StringUtils.isNotEmpty(getInputFolder()) && parameterList!=null && parameterList.hasParameter(PARAMETER_INPUTFOLDER)) { ConfigurationWarnings.add(owner, log, "inputFolder configured via attribute [inputFolder] as well as via parameter ["+PARAMETER_INPUTFOLDER+"], parameter will be ignored"); } @@ -236,8 +236,8 @@ private void checkConfiguration(FileSystemAction action2) throws ConfigurationEx protected void actionRequiresAtLeastOneOfTwoParametersOrAttribute(INamedObject owner, ParameterList parameterList, FileSystemAction configuredAction, FileSystemAction action, String parameter1, String parameter2, String attributeName, String attributeValue) throws ConfigurationException { if (configuredAction == action) { - boolean parameter1Set = parameterList != null && parameterList.findParameter(parameter1) != null; - boolean parameter2Set = parameterList != null && parameterList.findParameter(parameter2) != null; + boolean parameter1Set = parameterList != null && parameterList.hasParameter(parameter1); + boolean parameter2Set = parameterList != null && parameterList.hasParameter(parameter2); boolean attributeSet = StringUtils.isNotEmpty(attributeValue); if (!parameter1Set && !parameter2Set && !attributeSet) { throw new ConfigurationException(ClassUtils.nameOf(owner)+": the ["+action+"] action requires the parameter ["+parameter1+"] "+(parameter2!=null?"or parameter ["+parameter2+"] ":"")+(attributeName!=null?"or the attribute ["+attributeName+"] ": "")+"to be present"); diff --git a/nn-specials/src/main/java/org/frankframework/extensions/api/ApiSoapWrapperPipe.java b/nn-specials/src/main/java/org/frankframework/extensions/api/ApiSoapWrapperPipe.java index 606066d2d70..9e56cf0a234 100644 --- a/nn-specials/src/main/java/org/frankframework/extensions/api/ApiSoapWrapperPipe.java +++ b/nn-specials/src/main/java/org/frankframework/extensions/api/ApiSoapWrapperPipe.java @@ -16,7 +16,6 @@ package org.frankframework.extensions.api; import org.apache.commons.lang3.StringUtils; - import org.frankframework.configuration.ConfigurationException; import org.frankframework.parameters.Parameter; import org.frankframework.parameters.ParameterList; @@ -77,7 +76,7 @@ public void configure() throws ConfigurationException { private void addParameters() { ParameterList parameterList = getParameterList(); Parameter p; - if (parameterList.findParameter(CONVERSATIONID) == null) { + if (!parameterList.hasParameter(CONVERSATIONID)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(CONVERSATIONID); p.setSessionKey(getSoapHeaderSessionKey()); @@ -88,7 +87,7 @@ private void addParameters() { // p.setDefaultValueMethods("pattern"); addParameter(p); } - if (parameterList.findParameter(FROM_IN) == null) { + if (!parameterList.hasParameter(FROM_IN)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(FROM_IN); p.setSessionKey(getSoapHeaderSessionKey()); diff --git a/nn-specials/src/main/java/org/frankframework/extensions/esb/EsbJmsSender.java b/nn-specials/src/main/java/org/frankframework/extensions/esb/EsbJmsSender.java index 22a2c0dcb81..f13e7d3127c 100644 --- a/nn-specials/src/main/java/org/frankframework/extensions/esb/EsbJmsSender.java +++ b/nn-specials/src/main/java/org/frankframework/extensions/esb/EsbJmsSender.java @@ -57,7 +57,7 @@ public void configure() throws ConfigurationException { throw new ConfigurationException(getLogPrefix() + "replyToName [" + getReplyToName() + "] must not be set for messageProtocol [" + getMessageProtocol() + "]"); } } - if (StringUtils.isEmpty(getSoapAction()) && (paramList==null || paramList.findParameter("SoapAction")==null)) { + if (StringUtils.isEmpty(getSoapAction()) && (paramList==null || !paramList.hasParameter("SoapAction"))) { Parameter p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName("SoapAction"); p.setStyleSheetName("/xml/xsl/esb/soapAction.xsl"); diff --git a/nn-specials/src/main/java/org/frankframework/extensions/esb/EsbSoapWrapperPipe.java b/nn-specials/src/main/java/org/frankframework/extensions/esb/EsbSoapWrapperPipe.java index 1bcd93017e4..69220e6511a 100644 --- a/nn-specials/src/main/java/org/frankframework/extensions/esb/EsbSoapWrapperPipe.java +++ b/nn-specials/src/main/java/org/frankframework/extensions/esb/EsbSoapWrapperPipe.java @@ -537,13 +537,13 @@ private void stripDestination() { private void addParameters() { ParameterList parameterList = getParameterList(); Parameter p; - if (parameterList.findParameter(FROMID_PARAMETER_NAME)==null) { + if (!parameterList.hasParameter(FROMID_PARAMETER_NAME)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(FROMID_PARAMETER_NAME); p.setValue(AppConstants.getInstance().getProperty("instance.name", "")); addParameter(p); } - if (getMode() != Mode.BIS && parameterList.findParameter(CPAID_PARAMETER_NAME)==null) { + if (getMode() != Mode.BIS && !parameterList.hasParameter(CPAID_PARAMETER_NAME)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(CPAID_PARAMETER_NAME); p.setSessionKey(getSoapHeaderSessionKey()); @@ -552,7 +552,7 @@ private void addParameters() { p.setDefaultValue("n/a"); addParameter(p); } - if (parameterList.findParameter(CONVERSATIONID_PARAMETER_NAME)==null) { + if (!parameterList.hasParameter(CONVERSATIONID_PARAMETER_NAME)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(CONVERSATIONID_PARAMETER_NAME); p.setSessionKey(getSoapHeaderSessionKey()); @@ -566,7 +566,7 @@ private void addParameters() { p.setDefaultValueMethods("pattern"); addParameter(p); } - if (parameterList.findParameter(MESSAGEID_PARAMETER_NAME)==null) { + if (!parameterList.hasParameter(MESSAGEID_PARAMETER_NAME)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(MESSAGEID_PARAMETER_NAME); if (isUseFixedValues()) { @@ -576,7 +576,7 @@ private void addParameters() { } addParameter(p); } - if (parameterList.findParameter(EXTERNALREFTOMESSAGEID_PARAMETER_NAME)==null) { + if (!parameterList.hasParameter(EXTERNALREFTOMESSAGEID_PARAMETER_NAME)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(EXTERNALREFTOMESSAGEID_PARAMETER_NAME); p.setSessionKey(getSoapHeaderSessionKey()); @@ -588,7 +588,7 @@ private void addParameters() { p.setRemoveNamespaces(true); addParameter(p); } - if (getMode() != Mode.BIS && parameterList.findParameter(CORRELATIONID_PARAMETER_NAME)==null) { + if (getMode() != Mode.BIS && !parameterList.hasParameter(CORRELATIONID_PARAMETER_NAME)) { String paradigm; IParameter ppn = parameterList.findParameter(PARADIGM_PARAMETER_NAME); if (ppn!=null) { @@ -603,7 +603,7 @@ private void addParameters() { } } } - if (parameterList.findParameter(TIMESTAMP_PARAMETER_NAME)==null) { + if (!parameterList.hasParameter(TIMESTAMP_PARAMETER_NAME)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(TIMESTAMP_PARAMETER_NAME); if (isUseFixedValues()) { @@ -613,13 +613,13 @@ private void addParameters() { } addParameter(p); } - if (parameterList.findParameter(FIXRESULTNAMESPACE_PARAMETER_NAME)==null) { + if (!parameterList.hasParameter(FIXRESULTNAMESPACE_PARAMETER_NAME)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(FIXRESULTNAMESPACE_PARAMETER_NAME); p.setValue(String.valueOf(isFixResultNamespace())); addParameter(p); } - if (parameterList.findParameter(TRANSACTIONID_PARAMETER_NAME)==null) { + if (!parameterList.hasParameter(TRANSACTIONID_PARAMETER_NAME)) { p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(TRANSACTIONID_PARAMETER_NAME); p.setSessionKey(getSoapHeaderSessionKey()); diff --git a/nn-specials/src/main/java/org/frankframework/extensions/fxf/FxfWrapperPipe.java b/nn-specials/src/main/java/org/frankframework/extensions/fxf/FxfWrapperPipe.java index ba26b432918..a7052aa2670 100644 --- a/nn-specials/src/main/java/org/frankframework/extensions/fxf/FxfWrapperPipe.java +++ b/nn-specials/src/main/java/org/frankframework/extensions/fxf/FxfWrapperPipe.java @@ -85,7 +85,7 @@ public void configure() throws ConfigurationException { setRemoveOutputNamespaces(true); if (getDirection()==Direction.WRAP) { ParameterList parameterList = getParameterList(); - if (parameterList.findParameter(DESTINATION_PARAMETER_NAME) == null) { + if (!parameterList.hasParameter(DESTINATION_PARAMETER_NAME)) { Parameter p = SpringUtils.createBean(getApplicationContext(), Parameter.class); p.setName(DESTINATION_PARAMETER_NAME); p.setValue(DESTINATION_PREFIX+"."+retrieveStartTransferVersion()+"."+DESTINATION_SUFFIX); diff --git a/sap/src/main/java/org/frankframework/extensions/sap/jco3/SapSenderBase.java b/sap/src/main/java/org/frankframework/extensions/sap/jco3/SapSenderBase.java index 0f5fb651235..499ccae4bb4 100644 --- a/sap/src/main/java/org/frankframework/extensions/sap/jco3/SapSenderBase.java +++ b/sap/src/main/java/org/frankframework/extensions/sap/jco3/SapSenderBase.java @@ -15,6 +15,10 @@ */ package org.frankframework.extensions.sap.jco3; +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoException; + +import lombok.Getter; import org.apache.commons.lang3.StringUtils; import org.frankframework.configuration.ConfigurationException; import org.frankframework.core.ISenderWithParameters; @@ -27,11 +31,6 @@ import org.frankframework.parameters.ParameterValueList; import org.springframework.transaction.support.TransactionSynchronizationManager; -import com.sap.conn.jco.JCoDestination; -import com.sap.conn.jco.JCoException; - -import lombok.Getter; - /** * Base class for functions that call SAP. * @@ -59,7 +58,7 @@ public void configure() throws ConfigurationException { if (StringUtils.isEmpty(getSapSystemNameParam())) { throw new ConfigurationException(getLogPrefix()+"if attribute sapSystemName is not specified, value of attribute sapSystemNameParam must indicate parameter to obtain name of sapSystem from"); } - if (paramList==null || paramList.findParameter(getSapSystemNameParam())==null) { + if (paramList==null || !paramList.hasParameter(getSapSystemNameParam())) { throw new ConfigurationException(getLogPrefix()+"sapSystem must be specified, either in attribute sapSystemName, or via parameter ["+getSapSystemNameParam()+"]"); } } diff --git a/sap/src/main/java/org/frankframework/extensions/sap/jco3/SapSenderImpl.java b/sap/src/main/java/org/frankframework/extensions/sap/jco3/SapSenderImpl.java index 3b06d2e863e..b5a0243c730 100644 --- a/sap/src/main/java/org/frankframework/extensions/sap/jco3/SapSenderImpl.java +++ b/sap/src/main/java/org/frankframework/extensions/sap/jco3/SapSenderImpl.java @@ -15,12 +15,11 @@ */ package org.frankframework.extensions.sap.jco3; -import org.apache.commons.lang3.StringUtils; - import com.sap.conn.jco.JCoDestination; import com.sap.conn.jco.JCoFunction; import lombok.Getter; +import org.apache.commons.lang3.StringUtils; import org.frankframework.configuration.ConfigurationException; import org.frankframework.core.ISender; import org.frankframework.core.PipeLineSession; @@ -64,11 +63,11 @@ public void configure() throws ConfigurationException { if (StringUtils.isEmpty(getFunctionNameParam())) { throw new ConfigurationException(getLogPrefix()+"if attribute functionName is not specified, value of attribute functionNameParam must indicate parameter to obtain functionName from"); } - if (paramList==null || paramList.findParameter(getFunctionNameParam())==null) { + if (paramList==null || !paramList.hasParameter(getFunctionNameParam())) { throw new ConfigurationException(getLogPrefix()+"functionName must be specified, either in attribute functionName, or via parameter ["+getFunctionNameParam()+"]"); } } else { - if (StringUtils.isNotEmpty(getFunctionNameParam()) && paramList!=null && paramList.findParameter(getFunctionNameParam())!=null) { + if (StringUtils.isNotEmpty(getFunctionNameParam()) && paramList!=null && paramList.hasParameter(getFunctionNameParam())) { throw new ConfigurationException(getLogPrefix()+"functionName cannot be specified both in attribute functionName ["+getFunctionName()+"] and via parameter ["+getFunctionNameParam()+"]"); } } diff --git a/tibco/src/main/java/org/frankframework/extensions/tibco/GetTibcoQueues.java b/tibco/src/main/java/org/frankframework/extensions/tibco/GetTibcoQueues.java index 20d04c5a81b..2249d7bce50 100644 --- a/tibco/src/main/java/org/frankframework/extensions/tibco/GetTibcoQueues.java +++ b/tibco/src/main/java/org/frankframework/extensions/tibco/GetTibcoQueues.java @@ -96,7 +96,7 @@ public class GetTibcoQueues extends TimeoutGuardPipe { @Override public void configure() throws ConfigurationException { - if (getParameterList() != null && getParameterList().findParameter("userName") != null) { + if (getParameterList() != null && getParameterList().hasParameter("userName")) { ConfigurationWarnings.add(this, log, "parameter [userName] has been replaced with [username]"); } diff --git a/tibco/src/main/java/org/frankframework/extensions/tibco/SendTibcoMessage.java b/tibco/src/main/java/org/frankframework/extensions/tibco/SendTibcoMessage.java index b3204addb07..1ca4ea0ae45 100644 --- a/tibco/src/main/java/org/frankframework/extensions/tibco/SendTibcoMessage.java +++ b/tibco/src/main/java/org/frankframework/extensions/tibco/SendTibcoMessage.java @@ -86,7 +86,7 @@ public enum MessageProtocol implements DocumentedEnum { @Override public void configure() throws ConfigurationException { - if (getParameterList() != null && getParameterList().findParameter("userName") != null) { + if (getParameterList() != null && getParameterList().hasParameter("userName")) { ConfigurationWarnings.add(this, log, "parameter [userName] has been replaced with [username]"); }