From cb4dd1d2435fe74c76477718e3d8ae1e3cf1d050 Mon Sep 17 00:00:00 2001 From: saidone75 Date: Tue, 2 May 2023 10:41:03 +0200 Subject: [PATCH] delete node permanent param --- README.md | 64 +++++++++++-------- .../processors/DeleteNodeProcessor.java | 2 +- src/main/resources/example-delete-node.json | 15 +++++ ...xample.json => example-log-node-name.json} | 0 4 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 src/main/resources/example-delete-node.json rename src/main/resources/{example.json => example-log-node-name.json} (100%) diff --git a/README.md b/README.md index c0f65e2..d0f96cf 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ If none of the predefined Collectors/Processors meet your needs, simply write yo The QueryNodeCollector takes an Alfresco FTS query, execute it on a separate thread and feed the queue: ```json "collector": { - "name": "QueryNodeCollector", - "args": { - "query": "PATH:'/app:company_home/*' AND TYPE:'cm:folder'" - } + "name": "QueryNodeCollector", + "args": { + "query": "PATH:'/app:company_home/*' AND TYPE:'cm:folder'" } +} ``` #### NodeListCollector The NodeListCollector takes an input file containing a list of node-id with each id on a separate line, e.g.: @@ -37,39 +37,49 @@ and the path of the file need to be specified in the config: ``` ### Processing nodes #### DeleteNodeProcessor -Delete the collected nodes, no further configuration required. +Delete the collected nodes, set the `permanent` flag to true if you want to delete the nodes directly rather than move them into the trashcan: +```json +"processor": { + "name": "DeleteNodeProcessor", + "args": { + "permanent": true + } +} +``` #### AddAspectsAndSetPropertiesProcessor Add a list of aspects and apply a map of properties to the collected nodes: ```json "processor": { - "name": "AddAspectsAndSetPropertiesProcessor", - "args": { - "properties": { - "cm:publisher": "saidone", - "cm:contributor": "saidone" - }, - "aspects": [ - "cm:dublincore" - ] - } + "name": "AddAspectsAndSetPropertiesProcessor", + "args": { + "properties": { + "cm:publisher": "saidone", + "cm:contributor": "saidone" + }, + "aspects": [ + "cm:dublincore" + ] + } +} ``` #### SetPermissionsProcessor Apply a list of permissions and set inheritance flag to the collected nodes: ```json "processor": { - "name": "SetPermissionsProcessor", - "args": { - "permissions": { - "isInheritanceEnabled": false, - "locallySet": [ - { - "authorityId": "GROUP_EVERYONE", - "name": "Collaborator", - "accessStatus": "ALLOWED" - } - ] - } + "name": "SetPermissionsProcessor", + "args": { + "permissions": { + "isInheritanceEnabled": false, + "locallySet": [ + { + "authorityId": "GROUP_EVERYONE", + "name": "Collaborator", + "accessStatus": "ALLOWED" + } + ] } + } +} ``` #### Custom processor Custom processors can be easily created by extending the AbstractNodeProcessor and overwriting the `processNode` method: diff --git a/src/main/java/org/saidone/processors/DeleteNodeProcessor.java b/src/main/java/org/saidone/processors/DeleteNodeProcessor.java index 4808568..cb36290 100644 --- a/src/main/java/org/saidone/processors/DeleteNodeProcessor.java +++ b/src/main/java/org/saidone/processors/DeleteNodeProcessor.java @@ -35,7 +35,7 @@ public class DeleteNodeProcessor extends AbstractNodeProcessor { public void processNode(String nodeId, ProcessorConfig config) { log.debug("deleting node --> {}", nodeId); if (config.getReadOnly() != null && !config.getReadOnly()) { - nodesApi.deleteNode(nodeId, true); + nodesApi.deleteNode(nodeId, config.getArg("permanent") != null ? (Boolean) config.getArg("permanent") : false); } } diff --git a/src/main/resources/example-delete-node.json b/src/main/resources/example-delete-node.json new file mode 100644 index 0000000..5e1976b --- /dev/null +++ b/src/main/resources/example-delete-node.json @@ -0,0 +1,15 @@ +{ + "collector": { + "name": "QueryNodeCollector", + "args": { + "query": "TYPE:'cm:folder' AND PATH:'/app:company_home/*'" + } + }, + "processor": { + "name": "DeleteNodeProcessor", + "args": { + "permanent": true + }, + "readOnly": true + } +} \ No newline at end of file diff --git a/src/main/resources/example.json b/src/main/resources/example-log-node-name.json similarity index 100% rename from src/main/resources/example.json rename to src/main/resources/example-log-node-name.json