jsinovassin opened a new pull request, #867: URL: https://github.com/apache/unomi/pull/867
Fixes UNOMI-986, at https://issues.apache.org/jira/browse/UNOMI-986 ### What this changes `ImportConfigurationServiceEndPoint.processOneshotImportConfigurationCSV` writes the uploaded CSV to a directory named after the current tenant, in place of the root of the upload directory. ### Evidence The endpoint and the Camel route that consumes the file disagreed on the path. The endpoint wrote the file to `<uploadDir>/<importConfigId>.csv`: ```java java.nio.file.Path path = Paths.get(configSharingService.getProperty(RouterConstants.IMPORT_ONESHOT_UPLOAD_DIR) + importConfigId + ".csv"); ``` `ImportConfigByFileNameProcessor.process` reads the tenant from the parent directory of the file: ```java String tenantId = extractTenantId(filePath); if (tenantId == null || !isValidTenantId(tenantId) || !isValidTenant(tenantId)) { LOGGER.warn("Invalid or missing tenant ID in path: {}", filePath); exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE); return; } ``` `extractTenantId` returns the name of the parent directory. For a file at the root of the upload directory that name is `unomi_oneshot_import_configs`, which is not a tenant. Every one-shot import uploaded through the endpoint was therefore dropped: ``` WARN ImportConfigByFileNameProcessor | Invalid or missing tenant ID in path: /opt/unomi/data/tmp/unomi_oneshot_import_configs/19d061b5-b03d-41ae-beeb-8d75c4f1bf22.csv ``` The caller saw no failure. The upload answered 200, and the route moved the file to `.camel` unprocessed. ### Mechanism The route already reads sub-directories, because `ProfileImportOneShotRouteBuilder` declares `recursive=true`: ```java from("file://" + uploadDir + "?recursive=true&moveFailed=.error&include=.*.csv") ``` The per-tenant directory is what the route expected all along, so the endpoint is the side that changes. It resolves the current tenant through `ExecutionContextManager`, creates the directory, and writes the file into it. ### Effect Measured on Apache Unomi 3.1.0-SNAPSHOT. Before, the upload answered 200 and no profile was imported. Now: ``` POST /cxs/importConfiguration/oneshot -> 200 <uploadDir>/default/<importConfigId>.csv ``` The route reads the file and the profiles of the CSV are imported. An end to end test that drives the import through the user interface went from failing to passing. ### Notes for the reviewer `router-rest` carries no test source directory, so this pull request adds no unit test. The verification above is end to end. `ExportConfigurationServiceEndPoint` carries a `/oneshot` path as well. This pull request does not cover the export side, which is worth checking for the same disagreement. -- 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]
