Commit 43ddcc4
authored
fix(CopyContent): Moved Multitree validation before copyContentlet call + added DEFAULT variantId logic in PageResourceHelper (#34696)
## Summary
Moved Multitree validation before copyContentlet call + added DEFAULT
variantId logic in PageResourceHelper in case of null/empty values.
## Changes
- Changed the validation order in PageResourceHelper.copyContentlet()
method. Now we validate the existence of the Multitree before actually
copying the Contentlet.
- Added a default value for variantId in case the value from the request
is null or empty.
- Added integration tests.
## Motivation
The issue related to this PR shows that we return a 404 when attempting
to copy a contentlet and the variantId in the request is empty. To
address this, we added logic to set a default value when the variantId
is null or empty.
Additionally, while investigating this issue, we uncovered another
problem. The contentlet was being copied before doing the required
validations for the Multitree. So when the Multitree call returned null,
the response was still a 404, but the contentlet had already been
copied, and the rollback was not being done.
This means the bug was not limited to the empty variantId scenario. Any
case where the Multitree was null could trigger the same unintended
behavior.
## Related Issue
Fixes: [BUG: PUT /api/v1/page/copyContent returns 404 but successfully
copies content when variantId is empty string
#34473](#34473)1 parent bb1c594 commit 43ddcc4
2 files changed
Lines changed: 126 additions & 9 deletions
File tree
- dotCMS/src/main/java/com/dotcms/rest/api/v1/page
- dotcms-integration/src/test/java/com/dotcms/rest/api/v1/page
Lines changed: 6 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | 495 | | |
500 | 496 | | |
501 | 497 | | |
502 | 498 | | |
503 | | - | |
| 499 | + | |
504 | 500 | | |
505 | 501 | | |
506 | 502 | | |
507 | 503 | | |
508 | | - | |
509 | 504 | | |
510 | 505 | | |
511 | 506 | | |
512 | | - | |
513 | 507 | | |
514 | 508 | | |
515 | 509 | | |
516 | 510 | | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
517 | 516 | | |
518 | 517 | | |
519 | 518 | | |
| |||
Lines changed: 120 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
| |||
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
110 | 228 | | |
111 | 229 | | |
112 | 230 | | |
| |||
0 commit comments