Skip to content

Conversation

@dario-daza
Copy link
Contributor

@dario-daza dario-daza commented Dec 19, 2025

Proposed Changes

This request is to fix the scenario when defining Style Properties for an non-existing Contentlet. A bad request exception should be returned.

Files modified.

  • PagesResourceTest.json: Include Postman test for enriched response and BadRequest.
  • AbstractContentletStylingView.java: Abstract class to define the fields in the view ContentletStylingView used in the response of the Save Contentlet Request.
  • ContentletStylingErrorEntity: Extension of the class ErrorEntity to include more information about the error while saving. Omits null fields being send back to the response body.
  • PageResource: Documentation added and return the new enriched response defined by the class ResponseEntityContentletStylingView.
  • PageResourceHelper: saveContent() method now return information about the Contentlet saved and calls 2 new methods:
    • stylePropertiesValidation(): Validates (before saving) if the style properties belong to an existing Contentlet, otherwise throws a bad request exception.
    • buildSaveContentResponse(): Builds the response with the Contentlet information to be returned when the request is successfully made, the information returned is defined by the class ContentletStylingView.
  • ResponseEntityContentletStylingView: new Response to be returned when saving Contentlets extends from ResponseEntityView.

Enriched Successful Response

Original Updated
image image

BadRequest when trying define style properties for non-existing Contentlet

Original Updated
image image

This PR fixes: #33695
This PR fixes: #34092

@dario-daza dario-daza marked this pull request as ready for review December 23, 2025 17:27
Copy link
Contributor

@fabrizzio-dotCMS fabrizzio-dotCMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t like that we have those unused fields such as error, i18nMessagesMap, messages, etc. However, I do think the entity should be respected and used to return the appropriate payload; at least in that regard our endpoints are consistent.

By sending items outside of the entity, we open the door to more inconsistency and disorder. I would remove 'ok' and send items inside the entity, and then document that change properly.

@dario-daza dario-daza enabled auto-merge December 26, 2025 15:05
@dario-daza dario-daza added this pull request to the merge queue Dec 26, 2025
Any commits made after this event will not be merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Update PageAPI Response when Saving Style Properties [TASK] Update PageAPI to Save Page Contentlet Styling

4 participants