Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(batchUpdate): enhance batch update functionality (#1483)
* refactor(web/test): configure the ObjectMapper in PipelineControllerTck to match the one that Front50CoreConfiguration provides. This paves the way to test additional PipelineController functionality. * feat(web/new config): add PipelineControllerConfig to hold the configurations to be used for save/update controller mappings * Add new configuration class PipelineControllerConfig * Update Front50WebConfig to use PipelineControllerConfig * Update PipelineController to use PipelineControllerConfig * Update PipelineControllerSpec to use PipelineControllerConfig * Update PipelineControllerTck to use PipelineControllerConfig * add test to check duplicate pipelines when refreshCacheOnDuplicatesCheck flag is enabled and disabled * feat(sql): make the bulk save operation atomic * refactor SqlStorageService.storeObjects() method to make the bulk save an atomic operation * without this change, in case of db exception, some chunks of pipelines get saved while the others fail leading to inconsistency. * Last Catch block is now removed as it's no longer partial storage of supplied pipelines * add test for bulk create pipelines which tests the atomic behaviour of the SqlStorageService.storeObjects() method * refactor(web): refactor validatePipeline() so that it can be reused for batchUpdate(). checkForDuplicatePipeline() is removed from validatePipeline() and cron trigger validations are moved into validatePipeline() so that reusable code stays at on e place. remove unused overloaded checkForDuplicatePipeline() method Fix NPE caused in a test(should create pipelines in a thread safe way) in PipelineControllerSpec due to a newly added log message in PipelineController.save() * feat(batchUpdate): update /pipelines/batchUpdate POST handler method to address deserialization issues and add some useful log statements * feat(web): add a write permission check and validation to PipelineController.batchUpdate * Check if user has WRITE permissions on the pipeline, if not the pipeline will be added to invalid pipelines list * This change is a first step towards controlling access at pipeline level in a batch update. batchUpdate is still allowed only for admins but in the next few commits, the access level will be equated to that of individual pipeline save. * Check if duplicate pipeline exists in the same app * Validate pipeline id * Adjust test classes for PipelineController changes * feat(web): make batchUpdate return a map response with succeeded and failed pipelines and their counts * The response will be in the following format: [ "successful_pipelines_count" : <int>, "successful_pipelines" : <List<String>>, "failed_pipelines_count" : <int>, "failed_pipelines" : <List<Map<String, Object>>> ] * feat(web): add staleCheck to batchUpdate so that if a submitted pipeline in the batch already exists and their lastModified timestamps don't match then the pipeline is stale and hence added to invalid pipelines list. This behaviour is same as that of individual save and update operations. * add test to validate the code around staleCheck for batchUpdate * feat(web): fine tune permissions on batchUpdate * adjust permissions to batchUpdate (before: isAdmin, now: verifies application write permission). * enforce runAsUser permissions while deserializing pipelines * This puts batchUpdate on a par with individual save w.r.t. access restrictions * adjust test classes according to the changes to the PipelineController * refactor(web): simplify code for setting trigger ids in PipelineController.validatePipeline * test(batchUpdate): add test cases for testing batchUpdate changes Fixed test exceptions by making the following changes: - added @EqualsAndHashCode to Pipeline - added `pipelineDAO.all(true)` in SqlPipelineControllerTck.createPipelineDAO() to initialize the cache with empty set. Otherwise, the tests fail due to NPE. * fix(web): minor fixes/improvements --------- Co-authored-by: David Byron <[email protected]> Co-authored-by: Jason <[email protected]>
- Loading branch information