allthingssecurity opened a new pull request, #30999:
URL: https://github.com/apache/camel/pull/30999

   # Description
   
   [CAMEL-27611](https://issues.apache.org/jira/browse/CAMEL-27611)
   
   The ticket lists five problems of camel-bonita that came up while the option 
descriptions were written for CAMEL-23832 (#30947). I checked each one against 
main. Four are fixed here, one is left as it is.
   
   Fixed:
   2. **processName was a search term, and the first result was used.** 
`BonitaAPI.getProcessDefinition()` sent `processName` as the search parameter 
`s` of `GET /API/bpm/process` and took the first result. It now filters on the 
exact name (`f=name=...`), so a process whose name only contains `processName` 
is not used. The new `processVersion` option adds the filter `f=version=...`. 
When the process is deployed in several versions and `processVersion` is not 
set, the first version that Bonita returns is used, as before, and a WARN names 
the version used. The lookup runs for every exchange, so the WARN is logged 
once per process name and producer, and later lookups log it at DEBUG; 
otherwise a server with old versions still deployed would get one WARN per 
exchange. I did not add "pick the latest enabled version", as that would change 
which version existing routes start without a way to see it. For the same 
reason I did not add an `f=activationState=ENABLED` filter: a disabled version 
 chosen with `processVersion` would then be "not found" instead of being 
refused by Bonita, and I could not check that filter against a Bonita server 
here. `processVersion` avoids the question.
   3. **processName, username and password were not marked required.** They are 
now `required`, and the producer fails to start with an 
`IllegalArgumentException` that names the missing option, instead of failing 
each exchange (`processName is empty.` from the lookup, or the login filter).
   4. **The context path /bonita could not be configured.** The new `basePath` 
option (default `/bonita`) sets the context path for the REST API, the login 
and the file uploads. A missing leading slash is added and a trailing slash 
removed; `/` is the root of the server. `BonitaAPIConfig` gets a constructor 
with the base path, and the old constructor keeps `/bonita`. While there, 
`BonitaAPIConfig.getProcessFileUploadBaseURI()` (public, but not used by the 
component, which builds the upload path with `WebTarget.path`) missed the `/` 
between the base path and `portal/resource`, giving `.../bonitaportal/...`; it 
now has it.
   5. **BonitaConfiguration.setParameters(Map) was not used.** Camel does not 
call it, and it handles only three options. It is deprecated, not removed, so 
user code that calls it keeps compiling.
   
   Not changed:
   1. **A login before every request.** I agree with the ticket, but reusing 
the session needs session state shared by the concurrent exchanges of a 
producer, and a retry of the request that gets the 401 when the session has 
expired, since a JAX-RS request filter cannot repeat a request. Without the 
retry, every session timeout would fail one exchange, which is worse than 
today. That touches every request path (process lookup, file uploads, 
instantiation), so I would rather do it in its own change.
   
   The behaviour changes (exact name, startup check, the two new options, the 
deprecation) are in the 4.24 upgrade guide.
   
   This touches the same files as #30947 (`BonitaConfiguration` and the 
generated files), so whichever is merged second needs a small rebase. Three 
descriptions in #30947 become wrong with this change:
   - `processName`: "searches the processes of the Bonita REST API for this 
name and uses the first one found". It is now the exact name, with 
`processVersion` to choose a version.
   - `hostname`: "calls the REST API under the /bonita context path of this 
host". The context path is now the `basePath` option.
   - `username` and `password`: "fails if it is not set". That is still true, 
but the producer now fails when it starts, not with the first request. ("logs 
in ... before each request" stays true.)
   
   Tests:
   - `BonitaProcessLookupTest` (new, WireMock as Bonita server): the producer 
starts a case of the process named exactly `orders`, not of `orders-archive` 
that a search returns; `processVersion=2.0` starts a case of that version; 
`basePath=/bpm/engine/` sends the login and the lookup under `/bpm/engine`; a 
route without `processName`, or without `password`, fails to start and sends no 
request. Against the main sources all 5 fail: the search picks 
`orders-archive`, the routes without the options start, and the two new options 
are unknown.
   - `BonitaProcessLookupTest`: three exchanges for a process with two deployed 
versions and no `processVersion` log one WARN and two DEBUG lines (a WARN for 
every lookup would give three).
   - `BonitaAPIConfigTest`: new tests for the normalization of the base path 
and for the file upload URI.
   - The process lookup stubs of `BonitaStartProducerTest`, 
`BonitaStartProducerClientTest` and `BonitaStartCaseFileUploadTest` now match 
the `f=name=orders` filter instead of `s=orders`.
   
   Results (offline, module build of camel-bonita, test phase): 45 tests run, 0 
failures, 0 errors, 0 skipped. The lookup tests passed 5 runs in a row before 
the WARN change; after it the module ran once.
   
   Generated files: `bonita.json` of the component and its catalog copy, 
`BonitaEndpointConfigurer`, `BonitaEndpointUriFactory`, and 
`BonitaEndpointBuilderFactory` of the endpoint DSL (the two new options and the 
`Required: true` lines).
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-27611](https://issues.apache.org/jira/browse/CAMEL-27611).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built camel-bonita and ran its unit tests, and committed the 
regenerated component JSON, configurer and URI factory. The catalog copy and 
the endpoint DSL were updated to match it, as an offline build of those modules 
was not possible here. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to