diff --git a/dotCMS/hotfix_tracking.md b/dotCMS/hotfix_tracking.md index 34dadde9c2d9..fdd14d30956b 100644 --- a/dotCMS/hotfix_tracking.md +++ b/dotCMS/hotfix_tracking.md @@ -46,4 +46,5 @@ This maintenance release includes the following code fixes: 40. https://github.com/dotCMS/core/issues/26796 : Reserved names fields should be compared in a case-insensitive manner to avoid errors and inconsistencies. #26796 40. https://github.com/dotCMS/core/issues/26680 : Restoring Reorder Rows Functionality in Content Type Editing #26680 41. https://github.com/dotCMS/core/issues/26774 : text fields validation limit to 255 chars is not longer required #26774 -42. https://github.com/dotCMS/core/issues/26605 : Relation_type field too small #26605 \ No newline at end of file +42. https://github.com/dotCMS/core/issues/26605 : Relation_type field too small #26605 +43. https://github.com/dotCMS/core/issues/22921 : Workflow API unable to archive contentlet #22921 \ No newline at end of file diff --git a/dotCMS/src/curl-test/Workflow_Resource_Tests.json b/dotCMS/src/curl-test/Workflow_Resource_Tests.json index 49f880d00c15..7332452e21da 100644 --- a/dotCMS/src/curl-test/Workflow_Resource_Tests.json +++ b/dotCMS/src/curl-test/Workflow_Resource_Tests.json @@ -16326,6 +16326,164 @@ "response": [] } ] + }, + { + "name": "fireActionByName", + "item": [ + { + "name": "testArchiveContentlet", + "item": [ + { + "name": "Create ContentType", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = pm.response.json();", + "", + "pm.collectionVariables.set(\"contentTypeID\", jsonData.entity[0].id);", + "pm.collectionVariables.set(\"contentTypeVAR\", jsonData.entity[0].variable);", + "pm.collectionVariables.set(\"contentTypeFieldID\", jsonData.entity[0].fields[0].id);", + "", + "pm.test(\"Status code should be ok 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"fields check\", function () {", + " pm.expect(jsonData.entity[0].fields.length).to.eql(1);", + "});", + "", + "pm.test(\"description check\", function () {", + " pm.expect(jsonData.entity[0].description).to.eql('THE DESCRIPTION');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": { + "password": "admin", + "username": "admin@dotcms.com", + "showPassword": false + } + }, + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"clazz\": \"com.dotcms.contenttype.model.type.ImmutableSimpleContentType\", \n \"defaultType\": false, \n \"name\": \"Content Type Test\", \n \"description\": \"THE DESCRIPTION\", \n \"host\": \"SYSTEM_HOST\", \n \"owner\": \"dotcms.org.1\", \n \"fixed\": false, \n \"system\": false, \n \"folder\": \"SYSTEM_FOLDER\",\n \"fields\": [\n {\n \"dataType\": \"LONG_TEXT\",\n \"dbColumn\": \"text_area2\",\n \"fieldVariables\": [],\n \"fixed\": false,\n \"iDate\": 1453474468000,\n \"clazz\": \"com.dotcms.contenttype.model.field.ImmutableTextField\",\n \"indexed\": true,\n \"listed\": false,\n \"modDate\": 1478557845000,\n \"name\": \"Title\",\n \"readOnly\": false,\n \"required\": false,\n \"searchable\": true,\n \"sortOrder\": 3,\n \"unique\": false,\n \"variable\": \"title\"\n }],\n \"workflow\": [\"d61a59e1-a49c-46f2-a929-db2b4bfa88b2\"]\n}\n" + }, + "url": "{{serverURL}}/api/v1/contenttype", + "description": "Given a content type payload containing field variables.\nWhen sending a POST.\nExpect that code is 200.\nExpect content type is created with the provided fields.\nExpect that new properties of content types are set (icon and sortOrder)." + }, + "response": [] + }, + { + "name": "Create contentlet", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = pm.response.json();", + "", + "pm.test(\"Status code should be ok 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.collectionVariables.set(\"contentletID\", jsonData.entity.identifier);", + "pm.collectionVariables.set(\"contentletInode\", jsonData.entity.inode);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": { + "password": "admin", + "username": "admin@dotcms.com" + } + }, + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"contentlet\":{\n\t\t\"stName\": \"{{contentTypeVAR}}\",\n\t\t\"title\": \"test contentlet\"\n\t}\n}" + }, + "url": "http://localhost:8080/api/v1/workflow/actions/default/fire/NEW" + }, + "response": [] + }, + { + "name": "Archive contentlet", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = pm.response.json();", + "", + "pm.test(\"Status code should be ok 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Test the variable value\", function () {", + " var jsonData = pm.response.json();", + " var expectedValue = pm.collectionVariables.get(\"contentletID\");", + " pm.expect(jsonData.entity.identifier).to.eql(expectedValue);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "auth": { + "type": "basic", + "basic": { + "password": "admin", + "username": "admin@dotcms.com", + "showPassword": false + } + }, + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": " {\n \"actionName\": \"Archive\",\n \"contentlet\" : {\n \"identifier\": \"{{contentletID}}\",\n \"inode\": \"{{contentletInode}}\"\n }\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": "{{serverURL}}/api/v1/workflow/actions/fire" + }, + "response": [] + } + ] + } + ] } ], "event": [ diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java b/dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java index 37939bb3d142..a6cb355171b4 100644 --- a/dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java +++ b/dotCMS/src/main/java/com/dotcms/rest/api/v1/workflow/WorkflowResource.java @@ -2715,6 +2715,9 @@ private Contentlet createContentlet(final FireActionForm fireActionForm, contentlet = this.populateContentlet(fireActionForm, contentlet, initDataObject.getUser(),mode); } + if (contentlet.getInode().isEmpty() && !currentContentlet.getInode().isEmpty()) { + contentlet.setInode(currentContentlet.getInode()); + } return contentlet; }