Skip to content

Item nav order APIs update#3916

Merged
sumerjabri merged 12 commits into
craftercms:developfrom
jmendeza:feature/6061-item-orders
Jun 9, 2026
Merged

Item nav order APIs update#3916
sumerjabri merged 12 commits into
craftercms:developfrom
jmendeza:feature/6061-item-orders

Conversation

@jmendeza

@jmendeza jmendeza commented Apr 30, 2026

Copy link
Copy Markdown
Member

craftercms/craftercms#6061
Item nav order APIs update

Summary by CodeRabbit

Release Notes

  • New Features

    • Added new v2 content ordering API endpoints for retrieving and reordering content items with improved request/response structures.
  • Breaking Changes

    • Removed legacy v1 content ordering endpoints. Applications should migrate to the new v2 APIs.
  • Chores

    • Updated database schema and procedures to support the new ordering system.

@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR migrates content item ordering from v1 (legacy neighbor-based persistence via DmPageNavigationOrderService) to v2 (item-order retrieval and position-based reordering via REST API). It adds v2 OpenAPI endpoints, a polymorphic ReorderItemRequest model, and controller stubs; updates ContentServiceInternalImpl to remove the v1 service dependency and compute ordering based on sibling items; removes the entire v1 implementation stack including DAL, MyBatis mapper, Groovy wrappers, and REST scripts; and updates the database schema.

Changes

Content ordering v1 to v2 migration

Layer / File(s) Summary
V2 OpenAPI contract, request model, and constants
src/main/api/studio-api.yaml, src/main/java/org/craftercms/studio/model/rest/content/order/ReorderItemRequest.java, src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java, src/main/java/org/craftercms/studio/controller/rest/v2/ResultConstants.java
Adds GET /api/2/content/{siteId}/order and POST /api/2/content/{siteId}/order/reorder endpoints with discriminator-based polymorphic request body (addBefore, insertBetween, addAfter); introduces ReorderItemRequest sealed class hierarchy with ReferenceReorderItemRequest and Insert variants; adds mapping constants and result key constants.
V2 REST controller and service interface/implementation
src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java, src/main/java/org/craftercms/studio/api/v2/service/content/ContentService.java, src/main/java/org/craftercms/studio/impl/v2/service/content/ContentServiceImpl.java
Adds getItemsOrder and reorderItem endpoint methods to ContentController; extends v2 ContentService interface with two new public ordering methods; implements both in ContentServiceImpl with permission/site-ready guards and delegation to internal service.
ContentServiceInternalImpl nav-order logic update and item-order APIs
src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java
Removes v1 DmPageNavigationOrderService dependency and constructor injection; adds DEFAULT_PAGE_NAV_ORDER_INCREMENT config; introduces private updateNavOrder(siteId, path, document, force) method computing order from siblings and increment; adds public getItemsOrder and getItemOrder APIs reading placeInNav and order from descriptor XML; updates lifecycle execution, copy, and move flows to use internal ordering instead of service delegation; modernizes CollectionUtils calls to static imports.
Data model refactoring
src/main/java/org/craftercms/studio/model/rest/content/order/ItemOrder.java, src/main/java/org/craftercms/studio/api/v1/exception/ContentNotFoundException.java, src/main/java/org/craftercms/studio/api/v1/constant/StudioConstants.java, src/main/java/org/craftercms/studio/impl/v1/util/ContentUtils.java, src/main/java/org/craftercms/studio/impl/v2/repository/GitContentRepositoryImpl.java, src/main/java/org/craftercms/studio/impl/v2/repository/blob/BlobAwareContentRepository.java
Repurposes ItemOrder as REST response model with path, label, order fields instead of DAL-style NavigationOrderSequence; makes ContentNotFoundException path/site fields final and restricts public constructors to require both; adds DEFAULT_ORDER_XPATH and PLACE_IN_NAV_XPATH XPath constants; replaces updateSingleDocumentNode with addOrUpdateSingleDocumentNode; adds areSiblings(sourcePath, targetPath) utility; improves error handling in repository reads by including path/site in exception messages.
V1 service interface removal
src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java, src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
Removes entire DmPageNavigationOrderService public interface; removes reorderItems method from v1 ContentService.
V1 implementation removal
src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java, src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
Deletes DmPageNavigationOrderServiceImpl including nav-order computation, XML manipulation (addNavOrder, updateNavOrder), and sequence-management methods; removes DmPageNavigationOrderService import, field, and setter from ContentServiceImpl; deletes public reorderItems method.
Persistence layer cleanup
src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java, src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml, src/main/resources/crafter/studio/database-context.xml, src/main/resources/crafter/studio/studio-services-context.xml
Removes NavigationOrderSequenceMapper MyBatis interface and XML mapper; deletes navigationOrderSequenceMapper Spring bean from database context; removes cstudioPageNavOrderService bean and dmPageNavigationOrderService property wiring from content service bean.
Database schema upgrade
src/main/resources/crafter/studio/database/createDDL.sql, src/main/resources/crafter/studio/database/upgrade/5.0.x/5.0.0.18-to-5.0.0.19.sql, src/main/resources/crafter/studio/upgrade/pipelines.yaml
Removes navigation_order_sequence table from DDL; updates duplicate_site and deleteSiteRelatedItems procedures to skip navigation-order rows; defines new procedures in upgrade script; bumps schema version to 5.0.0.19; fixes pipeline YAML indentation.
Groovy API wrappers and REST scripts removal
src/main/webapp/default-site/scripts/api/ContentServices.groovy, src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy, src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy, src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy, src/main/webapp/default-site/scripts/api/ServiceFactory.groovy, src/main/webapp/default-site/scripts/rest/api/1/content/*.groovy
Removes ContentServices, PageNavigationOrderServices, and SpringPageNavigationOrderServices Groovy classes; deletes getPageNavigationOrderServices factory method; removes v1 REST scripts (get-item-orders.get.groovy, get-next-item-order.get.groovy, reorder-items.get.groovy); removes ordering delegations from SpringContentServices.
Test updates
src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java, src/test/java/org/craftercms/studio/impl/v1/util/ContentUtilsTest.java
Removes DmPageNavigationOrderService mock and pageNavOrderService.move(...) verification from testMovePageSuccess; adds StudioConfiguration mock; adds areSiblingsTest unit test.

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • craftercms/studio#3876: Updates testMove* methods in ContentServiceInternalImplTest to fix DBUtils.runInTransaction mock argument indexing, overlapping with this PR's mock refactoring in the same test class.
  • craftercms/studio#3928: Adds @RequireSiteBootstrapComplete gating on ContentServiceImpl public endpoints, affecting the same file where this PR adds getItemsOrder and reorderItem methods.

Suggested reviewers

  • sumerjabri
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.84% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Item nav order APIs update' accurately describes the main change: removing legacy v1 navigation order APIs and replacing them with new v2 APIs for content item ordering.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (1)
src/main/java/org/craftercms/studio/model/rest/content/ReorderItemRequest.java (1)

31-36: Consider allowing optional boundary anchors to support first/last position reorders.

The current requirement for both pathBefore and pathAfter to be non-empty prevents reordering items to first or last position, where one anchor is naturally absent. When implementing the reorder service, consider making one anchor optional and validating that at least one is provided.

Optional DTO adjustment for future implementation
 import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.AssertTrue;
 import org.craftercms.commons.validation.annotations.param.ValidExistingContentPath;
+import org.springframework.util.StringUtils;
@@
 	`@NotEmpty`
 	`@ValidExistingContentPath`
 	private String parentPath;
-	`@NotEmpty`
+	`@ValidExistingContentPath`
 	private String pathBefore;
-	`@NotEmpty`
+	`@ValidExistingContentPath`
 	private String pathAfter;
+
+	`@AssertTrue`(message = "Either pathBefore or pathAfter must be provided")
+	public boolean hasAnchor() {
+		return StringUtils.hasText(pathBefore) || StringUtils.hasText(pathAfter);
+	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/org/craftercms/studio/model/rest/content/ReorderItemRequest.java`
around lines 31 - 36, Rework the ReorderItemRequest DTO so reordering can target
first/last: remove the `@NotEmpty` requirement from at least one of the two fields
(pathBefore and pathAfter) and add a class-level validation that enforces "at
least one anchor present" (e.g., implement a custom validator annotation like
`@AtLeastOneAnchor` or add an isValid() method used by a class-level `@AssertTrue`)
that checks (pathBefore != null && !pathBefore.isEmpty()) || (pathAfter != null
&& !pathAfter.isEmpty()); keep or adapt `@ValidExistingContentPath` checks to only
run when the corresponding field is non-empty. Ensure validators reference the
ReorderItemRequest class and the pathBefore/pathAfter fields so the service
handling reorders can accept null/empty for one anchor but not both.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/api/studio-api.yaml`:
- Around line 5482-5483: The schema property nextOrder is declared as type
"integer" which will reject valid fractional ordering values; update the OpenAPI
schema entries declaring nextOrder (and any identical order-like fields at the
other occurrence) to use type "number" instead of "integer" so calculated or
between-item order values are accepted; locate the nextOrder definitions in the
YAML (the shown block and the similar block at the other occurrence) and change
their type to "number" while preserving any existing descriptions or
constraints.
- Around line 5475-5491: The response objects for these new TODO endpoints are
missing an interim 501 Not Implemented entry; update the response blocks that
currently list '200', '400', '401', '404', and '500' (including the shown block
and the two other new endpoint response blocks introduced alongside it) by
adding a '501' response entry that references the shared NotImplemented response
(e.g., "501": $ref: '#/components/responses/NotImplemented') so clients see the
interim behavior.
- Line 5460: The OpenAPI spec has a duplicate operationId "getNextItemOrder"
(declared twice), which breaks codegen; rename one of the operations to a unique
identifier (e.g., "getNextItemOrderV2" or a more specific name like
"getNextItemOrderForCollection") and update any references that rely on that
operationId (generated client method names, $ref usages, or tooling configs) so
they point to the new name; ensure the operationId change is applied in the
operation object where "operationId: getNextItemOrder" is declared and verify
downstream codegen and tests compile against the new identifier.

In
`@src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java`:
- Around line 376-377: The endpoint mappings in the controller are out of sync
with the OpenAPI spec; update the mapping constants and `@GetMapping/`@PostMapping
annotations so the routes use the spec's paths (e.g., "/item/next-order",
"/item/orders", "/item/reorder") instead of the current ".../order/..."
variants: rename or adjust GET_ITEM_NEXT_ORDER and its handler getNextItemOrder,
the corresponding constant and handler for the item orders endpoint (referenced
around the getItemOrders method), and the reorder endpoint constant/handler
(around the reorderItems/reorder method) so each mapping and constant exactly
match the OpenAPI contract.
- Around line 376-380: The three REST handlers currently returning null (e.g.,
getNextItemOrder) must call the appropriate content service methods to compute
the values and return them wrapped in a Result payload instead of null; locate
getNextItemOrder (and the two adjacent unimplemented methods referenced) and
replace the TODO/null with calls to your domain service (e.g.,
contentService.getNextItemOrder(siteId, parentPath) or the equivalent method
names used in this class), handle/translate any checked exceptions into proper
error Results, and return Result.success(theComputedValue) (or the project’s
standard Result factory) so the endpoints produce valid responses.

In
`@src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java`:
- Around line 70-72: The path constants GET_ITEM_NEXT_ORDER, GET_ITEMS_ORDER,
and REORDER_ITEM currently use "/order" segments but must match the OpenAPI v2
spec; update the constant values in RequestMappingConstants to SITE_ID +
"/item/next-order", SITE_ID + "/item/orders", and SITE_ID + "/item/reorder"
respectively so the controller-registered routes (GET_ITEM_NEXT_ORDER,
GET_ITEMS_ORDER, REORDER_ITEM) align with the published API paths.

In
`@src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java`:
- Around line 529-531: The method updateNavOrder(String siteId, String path,
Document document) currently returns false unconditionally which silently allows
stale nav-order data; change it to fail fast by throwing an
UnsupportedOperationException (or IllegalStateException) with a clear message
like "updateNavOrder not implemented — legacy nav-order logic removed" inside
ContentServiceInternalImpl.updateNavOrder so callers (page writes/copies and
updateNavOrderForMove) cannot proceed silently; ensure the exception text names
updateNavOrder and suggests the replacement work is required.

---

Nitpick comments:
In
`@src/main/java/org/craftercms/studio/model/rest/content/ReorderItemRequest.java`:
- Around line 31-36: Rework the ReorderItemRequest DTO so reordering can target
first/last: remove the `@NotEmpty` requirement from at least one of the two fields
(pathBefore and pathAfter) and add a class-level validation that enforces "at
least one anchor present" (e.g., implement a custom validator annotation like
`@AtLeastOneAnchor` or add an isValid() method used by a class-level `@AssertTrue`)
that checks (pathBefore != null && !pathBefore.isEmpty()) || (pathAfter != null
&& !pathAfter.isEmpty()); keep or adapt `@ValidExistingContentPath` checks to only
run when the corresponding field is non-empty. Ensure validators reference the
ReorderItemRequest class and the pathBefore/pathAfter fields so the service
handling reorders can accept null/empty for one anchor but not both.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ac1fffea-e171-4114-974f-f75a65826175

📥 Commits

Reviewing files that changed from the base of the PR and between e87478b and fa7060e.

📒 Files selected for processing (23)
  • src/main/api/studio-api.yaml
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequence.java
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java
  • src/main/java/org/craftercms/studio/model/rest/content/ReorderItemRequest.java
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/api/ServiceFactory.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
💤 Files with no reviewable changes (17)
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequence.java
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java

Comment thread src/main/api/studio-api.yaml Outdated
Comment thread src/main/api/studio-api.yaml Outdated
Comment thread src/main/api/studio-api.yaml Outdated
Comment thread src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java Outdated
Comment thread src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java Outdated
@jmendeza jmendeza force-pushed the feature/6061-item-orders branch from fa7060e to b9e01ce Compare May 5, 2026 00:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/api/studio-api.yaml`:
- Around line 5345-5353: The 200 responses return bare payload fields (e.g.,
nextOrder, order and array item schemas) instead of the v2 ApiResponse envelope;
update each affected response schema (the ones returning nextOrder and the
array/item responses referenced around the diff) to wrap the existing schema
under a top-level object property named response (i.e., replace the current
schema with an object that has properties.response equal to the original schema
and preserves type/description), so clients receive { response:
<originalPayload> } consistent with ApiResponse; ensure the referenced fields
nextOrder and any array item schemas are moved unchanged into response.

In
`@src/main/java/org/craftercms/studio/model/rest/content/ReorderItemRequest.java`:
- Around line 31-36: ReorderItemRequest currently requires both pathBefore and
pathAfter which prevents boundary moves; decide if boundary reorders are
allowed, then either (A) if boundaries supported: remove the `@NotEmpty`
constraint from pathBefore/pathAfter (make them nullable) and add a class-level
validator (e.g., an `@Constraint` on ReorderItemRequest or an `@AssertTrue` boolean
method) that enforces the business rule (at least one present or exactly one
present depending on the requirement) and update the reorderItem endpoint
contract to reflect the rule, or (B) if boundaries are not supported: keep
`@NotEmpty` but add documentation to the reorderItem API contract stating both
neighbors are required. Ensure validators reference
ReorderItemRequest.pathBefore and .pathAfter and the endpoint reorderItem in
tests/contract docs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4b14727f-70cd-4317-9296-34bb814ef90f

📥 Commits

Reviewing files that changed from the base of the PR and between fa7060e and b9e01ce.

📒 Files selected for processing (23)
  • src/main/api/studio-api.yaml
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequence.java
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java
  • src/main/java/org/craftercms/studio/model/rest/content/ReorderItemRequest.java
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/api/ServiceFactory.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
💤 Files with no reviewable changes (17)
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequence.java
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java
  • src/main/webapp/default-site/scripts/api/ServiceFactory.groovy
  • src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java

Comment thread src/main/api/studio-api.yaml Outdated
Comment thread src/main/java/org/craftercms/studio/model/rest/content/ReorderItemRequest.java Outdated
@jmendeza jmendeza force-pushed the feature/6061-item-orders branch 4 times, most recently from a55aa73 to a751208 Compare May 5, 2026 17:55

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (3)
src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java (1)

379-387: ⚠️ Potential issue | 🔴 Critical

Endpoints are still exposed as stubs returning null.

Both getItemsOrder(...) and reorderItem(...) are mapped but unimplemented, so these APIs currently return invalid responses instead of a Result payload backed by service logic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java`
around lines 379 - 387, Implement the two stub endpoints to delegate to the
content service and return a proper Result: in getItemsOrder(String siteId,
String parentPath) call the service method that retrieves item order (e.g.,
contentService.getItemsOrder(siteId, parentPath) or equivalent), wrap the
returned data into a successful Result payload and return it; in
reorderItem(String siteId, ReorderItemRequest request) call the service method
that applies the reorder (e.g., contentService.reorderItem(siteId, request)),
handle validation/exceptions as before in this controller, and return a Result
indicating success (or the updated order) instead of null; keep existing
annotations (`@ValidSiteId`, `@ValidExistingContentPath`, `@Valid`) and reuse the
controller’s standard Result creation pattern/methods for consistent response
shape.
src/main/api/studio-api.yaml (2)

5414-5415: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Return order as number (double), not integer.

At Line 5415, order is declared as integer, which can reject valid fractional ordering values produced by reorder calculations.

Suggested fix
                                     order:
-                                        type: integer
+                                        type: number
+                                        format: double
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/api/studio-api.yaml` around lines 5414 - 5415, The OpenAPI schema
property named "order" is currently declared as type: integer which will reject
fractional reorder values; change the "order" property in the studio-api YAML
schema from type: integer to type: number and (optionally) add format: double so
fractional ordering values are accepted (update the property definition for
"order" accordingly).

5349-5356: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use a top-level v2 response envelope instead of per-item response.

At Line 5350 the 200 schema is an array, and at Line 5354 each item contains response. This makes the API contract inconsistent with the v2 envelope pattern used elsewhere ({ response, ... }) and complicates generated clients.

Suggested minimal shape fix
                 '200':
                     description: OK
                     content:
                         application/json:
                             schema:
-                                type: array
-                                items:
-                                    type: object
-                                    properties:
-                                        response:
-                                            $ref: '#/components/schemas/ApiResponse'
-                                        path:
-                                            type: string
-                                        order:
-                                            type: number
-                                            format: double
-                                        label:
-                                            type: string
+                                type: object
+                                properties:
+                                    response:
+                                        $ref: '#/components/schemas/ApiResponse'
+                                    items:
+                                        type: array
+                                        items:
+                                            type: object
+                                            properties:
+                                                path:
+                                                    type: string
+                                                order:
+                                                    type: number
+                                                    format: double
+                                                label:
+                                                    type: string
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/api/studio-api.yaml` around lines 5349 - 5356, The 200 response
currently defines an array whose items each contain a per-item "response" field
(referenced as ApiResponse), which violates the v2 top-level envelope; change
the schema so the operation returns a single object with a top-level "response"
property whose value is the array of item objects. Concretely, replace the
existing schema: type: array / items: { type: object / properties: { response:
$ref: '#/components/schemas/ApiResponse', ... } } with schema: type: object /
properties: { response: { type: array, items: { type: object, properties: { /*
move item properties here except per-item response */ } } } } so ApiResponse is
referenced at the top-level "response" instead of per-item.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@src/main/api/studio-api.yaml`:
- Around line 5414-5415: The OpenAPI schema property named "order" is currently
declared as type: integer which will reject fractional reorder values; change
the "order" property in the studio-api YAML schema from type: integer to type:
number and (optionally) add format: double so fractional ordering values are
accepted (update the property definition for "order" accordingly).
- Around line 5349-5356: The 200 response currently defines an array whose items
each contain a per-item "response" field (referenced as ApiResponse), which
violates the v2 top-level envelope; change the schema so the operation returns a
single object with a top-level "response" property whose value is the array of
item objects. Concretely, replace the existing schema: type: array / items: {
type: object / properties: { response: $ref: '#/components/schemas/ApiResponse',
... } } with schema: type: object / properties: { response: { type: array,
items: { type: object, properties: { /* move item properties here except
per-item response */ } } } } so ApiResponse is referenced at the top-level
"response" instead of per-item.

In
`@src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java`:
- Around line 379-387: Implement the two stub endpoints to delegate to the
content service and return a proper Result: in getItemsOrder(String siteId,
String parentPath) call the service method that retrieves item order (e.g.,
contentService.getItemsOrder(siteId, parentPath) or equivalent), wrap the
returned data into a successful Result payload and return it; in
reorderItem(String siteId, ReorderItemRequest request) call the service method
that applies the reorder (e.g., contentService.reorderItem(siteId, request)),
handle validation/exceptions as before in this controller, and return a Result
indicating success (or the updated order) instead of null; keep existing
annotations (`@ValidSiteId`, `@ValidExistingContentPath`, `@Valid`) and reuse the
controller’s standard Result creation pattern/methods for consistent response
shape.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6c55bed0-f18b-4dca-8965-7c0e4157c51f

📥 Commits

Reviewing files that changed from the base of the PR and between b9e01ce and a751208.

📒 Files selected for processing (23)
  • src/main/api/studio-api.yaml
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequence.java
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java
  • src/main/java/org/craftercms/studio/model/rest/content/ReorderItemRequest.java
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/api/ServiceFactory.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
💤 Files with no reviewable changes (17)
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequence.java
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
✅ Files skipped from review due to trivial changes (2)
  • src/main/java/org/craftercms/studio/model/rest/content/ReorderItemRequest.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/webapp/default-site/scripts/api/ServiceFactory.groovy
  • src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java

@jmendeza jmendeza force-pushed the feature/6061-item-orders branch from a751208 to e577469 Compare May 5, 2026 19:49

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/api/studio-api.yaml`:
- Around line 10750-10792: The base schema ReorderItemRequestBase currently
permits all three type values which allows invalid combinations; restrict the
subtype schemas by adding a concrete type enum in each allOf: update
ReorderItemReferencePathRequest to include a properties.type enum limited to the
reference-path variants (e.g., ["addBefore","addAfter"]) and update
ReorderItemInsertBetweenRequest to include properties.type enum
["insertBetween"] (or equivalent values you use for insertBetween), so each
derived schema narrows the allowed type and enforces correct discriminator
behavior.

In
`@src/main/java/org/craftercms/studio/model/rest/content/order/ReorderItemRequest.java`:
- Around line 34-35: Replace the `@NotEmpty` annotation with `@NotBlank` on all path
fields in the ReorderItemRequest class so whitespace-only strings are rejected
up-front; specifically update the annotations on parentPath, referencePath,
previousPath, nextPath (and the fifth path field annotated similarly) to use
javax.validation.constraints.NotBlank instead of NotEmpty so constraint
validation returns a 400 for blank paths before reaching
`@ValidExistingContentPath`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 50430f18-2688-4255-8792-2fde9650fdcf

📥 Commits

Reviewing files that changed from the base of the PR and between a751208 and e577469.

📒 Files selected for processing (23)
  • src/main/api/studio-api.yaml
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequence.java
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java
  • src/main/java/org/craftercms/studio/model/rest/content/order/ReorderItemRequest.java
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/api/ServiceFactory.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
💤 Files with no reviewable changes (17)
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequence.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
✅ Files skipped from review due to trivial changes (2)
  • src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java
  • src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java
  • src/main/webapp/default-site/scripts/api/ServiceFactory.groovy

Comment thread src/main/api/studio-api.yaml
@jmendeza jmendeza force-pushed the feature/6061-item-orders branch 2 times, most recently from cc20aad to 816c727 Compare May 5, 2026 20:05
@jmendeza jmendeza force-pushed the feature/6061-item-orders branch from 816c727 to f2a4381 Compare May 22, 2026 22:35
@jmendeza jmendeza force-pushed the feature/6061-item-orders branch from 3b00094 to 506cf21 Compare June 5, 2026 16:18
@jmendeza

jmendeza commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java`:
- Line 2197: The move operation calls updateNavOrderForCopyOrMove(...) with the
wrong root path: change the argument passed from sourcePath to repoPath in
moveInternal(...) so updateNavOrderForCopyOrMove(repoPath, sourcePath,
lifecycleContents, sourcePathChildren) uses the destination root for matching;
also apply the same correction at the other similar call site (around the block
corresponding to lines 2409-2424) so both move-related invocations pass repoPath
as the target root parameter.
- Around line 997-1002: The parent-equality check in reorderItem is executed
even when previousPath or nextPath is null (add-before/add-after cases), causing
InvalidParametersException; fix by only computing/ comparing parents when both
previousPath and nextPath are non-null: move or guard the calls to
getParentUrl(previousPath)/getParentUrl(nextPath) and the CS.equals check behind
a conditional like "if (previousPath != null && nextPath != null) { ... }" (or
equivalently check previousParent/nextParent for null) so add-before/add-after
requests are allowed; update the code in ContentServiceInternalImpl.reorderItem
accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 872fb5e0-a91f-4713-b9bf-4541c339ea38

📥 Commits

Reviewing files that changed from the base of the PR and between e577469 and 13d1a84.

📒 Files selected for processing (35)
  • src/main/api/studio-api.yaml
  • src/main/java/org/craftercms/studio/api/v1/constant/StudioConstants.java
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
  • src/main/java/org/craftercms/studio/api/v1/exception/ContentNotFoundException.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/java/org/craftercms/studio/api/v2/service/content/ContentService.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java
  • src/main/java/org/craftercms/studio/controller/rest/v2/ResultConstants.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v1/util/ContentUtils.java
  • src/main/java/org/craftercms/studio/impl/v2/repository/GitContentRepositoryImpl.java
  • src/main/java/org/craftercms/studio/impl/v2/repository/blob/BlobAwareContentRepository.java
  • src/main/java/org/craftercms/studio/impl/v2/service/content/ContentServiceImpl.java
  • src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java
  • src/main/java/org/craftercms/studio/model/rest/content/order/ItemOrder.java
  • src/main/java/org/craftercms/studio/model/rest/content/order/ReorderItemRequest.java
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/resources/crafter/studio/database/createDDL.sql
  • src/main/resources/crafter/studio/database/upgrade/5.0.x/5.0.0.18-to-5.0.0.19.sql
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/main/resources/crafter/studio/upgrade/pipelines.yaml
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/api/ServiceFactory.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/test/java/org/craftercms/studio/impl/v1/util/ContentUtilsTest.java
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
💤 Files with no reviewable changes (17)
  • src/test/java/org/craftercms/studio/impl/v1/util/ContentUtilsTest.java
  • src/main/resources/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.xml
  • src/main/webapp/default-site/scripts/api/impl/content/SpringPageNavigationOrderServices.groovy
  • src/main/java/org/craftercms/studio/api/v1/service/content/DmPageNavigationOrderService.java
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-item-orders.get.groovy
  • src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java
  • src/main/resources/crafter/studio/database-context.xml
  • src/main/java/org/craftercms/studio/impl/v1/service/content/DmPageNavigationOrderServiceImpl.java
  • src/main/webapp/default-site/scripts/api/ContentServices.groovy
  • src/main/java/org/craftercms/studio/api/v1/dal/NavigationOrderSequenceMapper.java
  • src/main/webapp/default-site/scripts/api/PageNavigationOrderServices.groovy
  • src/main/webapp/default-site/scripts/rest/api/1/content/get-next-item-order.get.groovy
  • src/main/webapp/default-site/scripts/api/ServiceFactory.groovy
  • src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java
  • src/main/webapp/default-site/scripts/rest/api/1/content/reorder-items.get.groovy
  • src/main/webapp/default-site/scripts/api/impl/content/SpringContentServices.groovy
  • src/main/api/studio-api.yaml
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/org/craftercms/studio/controller/rest/v2/ResultConstants.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/java/org/craftercms/studio/controller/rest/v2/RequestMappingConstants.java
  • src/main/resources/crafter/studio/studio-services-context.xml
  • src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java

@jmendeza jmendeza marked this pull request as ready for review June 5, 2026 18:47
@jmendeza jmendeza requested a review from sumerjabri as a code owner June 5, 2026 18:47
@sumerjabri

Copy link
Copy Markdown
Member

@coderabbitai, we're done with development. Please give it a once-over before we send this to a human. Make sure to itemize any issues and you can ignore Travis CI.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect ContentServiceInternalImpl for the new ordering methods
rg -n "getItemsOrder\|reorderItem\|updateNavOrder\|getItemOrder\|pageNavOrderIncrement\|DEFAULT_PAGE_NAV_ORDER" src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java | head -80

echo "---FULL METHOD---"
ast-grep --pattern 'private $_ updateNavOrder($$$) {
  $$$
}'

echo "---getItemsOrder impl---"
ast-grep --pattern 'public $_ getItemsOrder($$$) {
  $$$
}'

echo "---getItemOrder impl---"
ast-grep --pattern 'private $_ getItemOrder($$$) {
  $$$
}'

echo "---reorderItem impl---"
ast-grep --pattern 'public $_ reorderItem($$$) {
  $$$
}'

Length of output: 996


🏁 Script executed:

#!/bin/bash
# Inspect ReorderItemRequest model
cat src/main/java/org/craftercms/studio/model/rest/content/order/ReorderItemRequest.java

Length of output: 2539


🏁 Script executed:

#!/bin/bash
# Inspect ContentController new endpoints
rg -n "getItemsOrder\|reorderItem\|GET_ITEMS_ORDER\|REORDER_ITEM" src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java -A 20 -B 5

Length of output: 451


🏁 Script executed:

#!/bin/bash
# Inspect ItemOrder model
cat src/main/java/org/craftercms/studio/model/rest/content/order/ItemOrder.java

Length of output: 1509


🏁 Script executed:

#!/bin/bash
# Check for any remaining references to NavigationOrderSequence
rg -rn "NavigationOrderSequence\|navigationOrderSequence\|navigation_order_sequence" --type java --type xml --type sql --type groovy

echo "---Check for any unused import in ContentService v1---"
cat src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java | tail -30

Length of output: 1212


🏁 Script executed:

#!/bin/bash
# Inspect ContentServiceInternalImpl for reorderItem and getItemsOrder full implementations
cat src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java | grep -n "getItemsOrder\|getItemOrder\|reorderItem\|updateNavOrder\|pageNavOrder\|DEFAULT_PAGE_NAV\|ItemOrder\|ReorderItem" | head -60

Length of output: 3004


🏁 Script executed:

#!/bin/bash
# Check DB upgrade script
cat src/main/resources/crafter/studio/database/upgrade/5.0.x/5.0.0.18-to-5.0.0.19.sql | head -120

echo "---createDDL.sql nav order section---"
rg -n "navigation_order\|5.0.0.19\|5.0.0.18" src/main/resources/crafter/studio/database/createDDL.sql | head -20

echo "---pipelines.yaml---"
cat src/main/resources/crafter/studio/upgrade/pipelines.yaml | grep -A5 -B5 "5.0.0.18\|5.0.0.19"

Length of output: 5602


🏁 Script executed:

#!/bin/bash
# Check for missing parentPath in ReorderItemRequest & API YAML schema alignment
rg -n "parentPath\|siteId\|ReorderItemRequest\|ReorderItemReferencePathRequest\|ReorderItemInsertBetweenRequest" src/main/api/studio-api.yaml | head -40

echo "---API YAML for reorderItem endpoint---"
rg -n "reorderItem\|reorder\|getItemsOrder\|/order" src/main/api/studio-api.yaml -A 30 | head -120

Length of output: 477


🏁 Script executed:

#!/bin/bash
# Check v2 ContentService interface for new methods
cat src/main/java/org/craftercms/studio/api/v2/service/content/ContentService.java | grep -A5 "getItemsOrder\|reorderItem"

# Check v2 ContentServiceImpl for new methods
cat src/main/java/org/craftercms/studio/impl/v2/service/content/ContentServiceImpl.java | grep -A15 "getItemsOrder\|reorderItem"

Length of output: 1472


🏁 Script executed:

#!/bin/bash
# Check if getItemOrders was left in v1 ContentService (AI summary says reorderItems was removed but getItemOrders remains)
rg -n "getItemOrders\|getItemsOrder\|reorderItems\|reorderItem" src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java

echo "---v1 ContentServiceImpl - check for computeReorder still present---"
rg -n "computeReorder" src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java -A10

echo "---check for computeReorder usage---"
rg -rn "computeReorder" --type java

Length of output: 1435


🏁 Script executed:

#!/bin/bash
# Inspect test for ContentServiceInternalImpl  
cat src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java | grep -n "StudioConfiguration\|studioConfiguration\|pageNavOrder\|reorderItem\|getItemsOrder\|ItemOrder" | head -40

# Check if there are any tests for the new controller endpoints
rg -rn "getItemsOrder\|reorderItem" --type java src/test/

echo "---Check for any test for ContentController---"
fd "ContentControllerTest" src/test/

Length of output: 1480


🏁 Script executed:

#!/bin/bash
# Check for potential NPE in ContentServiceInternalImpl - does getItemsOrder handle null items?
cat src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java | grep -n -A 30 "public.*getItemsOrder\|private.*getItemOrder\|private.*updateNavOrder"

Length of output: 3355


🏁 Script executed:

#!/bin/bash
# Get full reorderItem protected method and getItemOrder
sed -n '953,1040p' src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java

Length of output: 4144


🏁 Script executed:

#!/bin/bash
# Check ContentServiceImpl getItemsOrder annotations
rg -n "getItemsOrder\|reorderItem" src/main/java/org/craftercms/studio/impl/v2/service/content/ContentServiceImpl.java -B 10

Length of output: 432


🏁 Script executed:

#!/bin/bash
# Check if ReorderItemRequest is missing parentPath (the POST endpoint uses siteId from path but where does parentPath come from?)
rg -n "parentPath\|reorderItem\|ReorderItemRequest" src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java -A 15 -B 5

echo "---full ContentController new endpoints---"
cat src/main/java/org/craftercms/studio/controller/rest/v2/ContentController.java | grep -n "getItemsOrder\|reorderItem\|order" | head -20

Length of output: 1231


🏁 Script executed:

#!/bin/bash
# Check API YAML for the new endpoints
grep -n "order\|reorder\|getItemsOrder\|reorderItem" src/main/api/studio-api.yaml | head -60

Length of output: 2489


🏁 Script executed:

#!/bin/bash
# Check the full reorderItem test coverage
sed -n '895,960p' src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java

Length of output: 2901


🏁 Script executed:

#!/bin/bash
# Check if v1 getItemOrders still has an implementation in ContentServiceImpl (v1)
rg -n "getItemOrders\|DmOrderTO" src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java -A5 | head -40

Length of output: 469


🏁 Script executed:

#!/bin/bash
# Look for computeReorder references and any dead code
rg -rn "computeReorder\|getOrders\b" --type java | head -20

# Check if there's a dead reorderItem(String, String, String) overload in ContentServiceInternalImpl
sed -n '977,1030p' src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java

Length of output: 3066


🏁 Script executed:

#!/bin/bash
# Check the full API YAML for the new order endpoints
python3 -c "
import re
with open('src/main/api/studio-api.yaml') as f:
    content = f.read()
# Find the sections around 'order'
matches = [(m.start(), m.end()) for m in re.finditer(r'/api/2/content/\{siteId\}/order', content)]
for start, end in matches:
    print(content[max(0,start-50):start+2000])
    print('---')
"

Length of output: 4541



@sumerjabri — here's the full itemized review. Overall the implementation is solid — the new v2 API shape is clean, the sealed ReorderItemRequest hierarchy is well-structured, the DB migration is correct, and test coverage for reorderItem is good. The items below need attention before sending to the human reviewer.


🔴 High Priority

1. getItemsOrder is missing access-control annotations in ContentServiceImpl

reorderItem is correctly guarded, but the getItemsOrder override in ContentServiceImpl has no @RequireSiteReady or @HasPermission:

// ContentServiceImpl.java — as-is
public List<ItemOrder> getItemsOrder(`@SiteId` String siteId, `@ContentPath` String parentPath) throws ServiceLayerException {
    return contentServiceInternal.getItemsOrder(siteId, parentPath);
}

Should match the pattern used by reorderItem:

`@Override`
`@RequireSiteReady`
`@HasPermission`(type = DefaultPermission.class, action = PERMISSION_CONTENT_READ)
public List<ItemOrder> getItemsOrder(`@SiteId` String siteId, `@ContentPath` String parentPath) throws ServiceLayerException {
    return contentServiceInternal.getItemsOrder(siteId, parentPath);
}

2. NumberFormatException escapes as an uncaught RuntimeException in the reorderItem path

getItemOrder calls Double.parseDouble(orderString) without a catch. In getItemsOrder this is caught at the outer loop level, but when getItemOrder is called from reorderItem(siteId, previousPath, nextPath), a malformed orderDefault_f value produces a raw RuntimeException instead of a proper InvalidParametersException (resulting in a confusing 500 rather than a 400).

Recommend wrapping the parse in getItemOrder itself:

// inside getItemOrder, replacing the bare parse:
try {
    order = Double.parseDouble(orderString);
} catch (NumberFormatException e) {
    throw new ServiceLayerException(
        format("Invalid order value '%s' in descriptor for site '%s' path '%s'", orderString, siteId, path), e);
}

🟡 Medium Priority

3. Dead code: computeReorder(...) in v1 ContentServiceImpl

reorderItems() (the only caller of computeReorder) was deleted in this PR, leaving computeReorder as unreachable dead code. It should be removed.

4. v1 ContentService interface still declares getItemOrders

The Groovy REST script (get-item-orders.get.groovy) was removed, but List<DmOrderTO> getItemOrders(String site, String path) throws ContentNotFoundException; still lives in the v1 interface. If the implementation in ContentServiceImpl was also removed, the interface declaration should be cleaned up. If it's intentionally retained for some other caller, a comment explaining why would help.

5. No unit tests for getItemsOrder

ContentServiceInternalImplTest covers the three reorderItem variants, but getItemsOrder has zero test coverage. Suggested cases:

  • Returns sorted list when children have valid nav order
  • Excludes children where placeInNav = false
  • Excludes children with no orderDefault_f value
  • Returns empty list when parent has no children

🟢 Low Priority

6. Integer.MAX_VALUE paging limit in getItemsOrder

List<ContentItem> pages = itemDao.getChildrenByPath(site.getId(), parentPath, null, null,
        List.of(CONTENT_TYPE_PAGE), null, null, null, null, 0, Integer.MAX_VALUE);

For very large sites this could cause memory pressure. Consider capping at a reasonable max (e.g. 10,000) or at minimum adding a // intentional comment.

7. No sibling validation for AddBefore / AddAfter in reorderItem

reorderItem(siteId, previousPath, nextPath) correctly validates that previousPath and nextPath share the same parent (for the Insert case), but AddBefore / AddAfter pass only one path so the check is skipped. A caller passing a reference path from a different parent directory would receive a nonsensical order value with no error. A simple areSiblings guard (the utility was added in this PR) would cover this.


That's the full list. Items 1 and 2 should definitely be fixed before merge; the rest can be addressed in this PR or tracked for a follow-up.


🧠 Learnings used
Learnt from: jmendeza
Repo: craftercms/studio PR: 3916
File: src/main/api/studio-api.yaml:5345-5361
Timestamp: 2026-05-05T00:11:46.400Z
Learning: Repo: craftercms/studio — Preference from maintainer (jmendeza) on PR `#3916`: For API v2 specs in src/main/api/studio-api.yaml, do not add interim '501 Not Implemented' responses to newly added endpoints when the PR will only be merged after the backend implementation is completed (draft/placeholder endpoints). Applies to the item order endpoints: GET /api/2/content/{siteId}/item/next-order, GET /api/2/content/{siteId}/item/orders, POST /api/2/content/{siteId}/item/reorder.

Learnt from: alhambrav
Repo: craftercms/studio PR: 3932
File: src/main/api/studio-api.yaml:2089-2089
Timestamp: 2026-06-03T09:58:37.863Z
Learning: Repo: craftercms/studio PR `#3932` — Maintainer preference from alhambrav: For the OpenAPI module-name description update in `src/main/api/studio-api.yaml`, endpoints whose operation descriptions only say `Module: Studio` can be left without permission/role details in this PR; any permission/role-detail standardization should be handled in a separate ticket/PR if needed.

@sumerjabri sumerjabri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please see the CR comments.

@jmendeza

jmendeza commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@CodeRabbit reassess your last review now that there are new commits

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 1. Check getItemsOrder annotations in v2 ContentServiceImpl
echo "=== ContentServiceImpl v2 getItemsOrder & reorderItem annotations ==="
rg -n "getItemsOrder\|reorderItem\|RequireSiteReady\|HasPermission\|RequireContentExists\|SiteId\|ContentPath" \
  src/main/java/org/craftercms/studio/impl/v2/service/content/ContentServiceImpl.java -B3 -A3 | head -80

echo ""
echo "=== Full getItemsOrder method in ContentServiceImpl ==="
grep -n "getItemsOrder" src/main/java/org/craftercms/studio/impl/v2/service/content/ContentServiceImpl.java -A 10

echo ""
echo "=== Full reorderItem method in ContentServiceImpl ==="
grep -n "reorderItem" src/main/java/org/craftercms/studio/impl/v2/service/content/ContentServiceImpl.java -A 10

Length of output: 1909


🏁 Script executed:

#!/bin/bash
# 2. Check getItemOrder for NumberFormatException handling
echo "=== getItemOrder in ContentServiceInternalImpl ==="
grep -n "getItemOrder\|parseDouble\|NumberFormat\|catch" \
  src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java -A 3 -B 1 | head -80

echo ""
echo "=== reorderItem internal implementations ==="
grep -n "reorderItem\|previousPath\|nextPath\|referencePath\|AddBefore\|AddAfter\|Insert" \
  src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java -A 5 | head -80

Length of output: 7622


🏁 Script executed:

#!/bin/bash
# 3. Check computeReorder dead code in v1 ContentServiceImpl
echo "=== computeReorder in v1 ContentServiceImpl ==="
grep -n "computeReorder" src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java -A 5

echo ""
echo "=== getItemOrders in v1 ContentService interface ==="
grep -n "getItemOrders\|getItemsOrder" src/main/java/org/craftercms/studio/api/v1/service/content/ContentService.java -A 5

echo ""
echo "=== getItemOrders in v1 ContentServiceImpl ==="
grep -n "getItemOrders\|getItemsOrder" src/main/java/org/craftercms/studio/impl/v1/service/content/ContentServiceImpl.java -A 5

Length of output: 1373


🏁 Script executed:

#!/bin/bash
# 4. Check unit tests for getItemsOrder and reorderItem
echo "=== Tests in ContentServiceInternalImplTest ==="
grep -n "getItemsOrder\|reorderItem\|ItemOrder\|computeReorder\|`@Test`" \
  src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java | head -60

echo ""
echo "=== Count test methods ==="
grep -c "`@Test`" src/test/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImplTest.java

echo ""
# 5. Check sibling validation for AddBefore/AddAfter
echo "=== areSiblings usage in ContentServiceInternalImpl ==="
grep -n "areSiblings\|AddBefore\|AddAfter\|ReferenceReorder\|referencePath" \
  src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java -A 5 | head -50

echo ""
# 6. Check paging limit
echo "=== Integer.MAX_VALUE or paging in getItemsOrder ==="
grep -n "MAX_VALUE\|getChildrenByPath\|CONTENT_TYPE_PAGE" \
  src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java -A 3 | head -30

Length of output: 6600


🏁 Script executed:

#!/bin/bash
# Get the full getItemsOrder implementation
echo "=== Full getItemsOrder region ==="
grep -n "getItemsOrder" src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java

Length of output: 484


🏁 Script executed:

#!/bin/bash
# Get line ranges for getItemsOrder and reorderItem implementations in ContentServiceInternalImpl
echo "=== Line numbers for key methods ==="
grep -n "public.*getItemsOrder\|public.*reorderItem\|private.*getItemOrder\|private.*updateNavOrder\|private.*reorderItem" \
  src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java

Length of output: 804


🏁 Script executed:

#!/bin/bash
# Get full getItemOrder implementation
echo "=== getItemOrder full body ==="
sed -n '956,985p' src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java

echo ""
echo "=== MAX_CHILDREN_FOR_GET_NAV_ORDER constant ==="
grep -n "MAX_CHILDREN_FOR_GET_NAV_ORDER" \
  src/main/java/org/craftercms/studio/impl/v2/service/content/internal/ContentServiceInternalImpl.java

echo ""
echo "=== Check getItemsOrder annotations in v2 ContentServiceImpl - full context ==="
sed -n '350,370p' src/main/java/org/craftercms/studio/impl/v2/service/content/ContentServiceImpl.java

Length of output: 2970



@jmendeza — the new commits have addressed all the high and medium priority items from the previous review. Here's the updated status:

# Item Priority Status
1 getItemsOrder missing @RequireSiteReady / @HasPermission 🔴 High ✅ Fixed — now has @RequireSiteReady, @RequireContentExists, and @HasPermission
2 NumberFormatException escaping as 500 in reorderItem path 🔴 High ✅ Fixed — getItemOrder now catches NFE internally, logs it, and returns null; callers convert that to InvalidParametersException
3 Dead computeReorder(...) in v1 ContentServiceImpl 🟡 Medium ✅ Fixed — removed
4 v1 ContentService interface still declaring getItemOrders 🟡 Medium ✅ Fixed — removed
5 No unit tests for getItemsOrder 🟡 Medium ✅ Fixed — multiple test cases added covering sorted results, null-order skipping, and empty parent
6 Integer.MAX_VALUE paging limit in getItemsOrder 🟢 Low ✅ Fixed — now uses named constant MAX_CHILDREN_FOR_GET_NAV_ORDER = 10000
7 No sibling validation for AddBefore/AddAfter in reorderItem 🟢 Low ⚠️ Still open — a cross-parent referencePath on single-sided reorder yields no error

The only remaining item is the low-priority sibling check (#7) — for AddBefore/AddAfter, the inner reorderItem(siteId, previousPath, nextPath) skips the sibling guard when one path is null. Whether to address that here or in a follow-up is up to you. Everything else looks good for the human reviewer. 🐇


🧠 Learnings used
Learnt from: jmendeza
Repo: craftercms/studio PR: 3916
File: src/main/api/studio-api.yaml:5345-5361
Timestamp: 2026-05-05T00:11:46.400Z
Learning: Repo: craftercms/studio — Preference from maintainer (jmendeza) on PR `#3916`: For API v2 specs in src/main/api/studio-api.yaml, do not add interim '501 Not Implemented' responses to newly added endpoints when the PR will only be merged after the backend implementation is completed (draft/placeholder endpoints). Applies to the item order endpoints: GET /api/2/content/{siteId}/item/next-order, GET /api/2/content/{siteId}/item/orders, POST /api/2/content/{siteId}/item/reorder.

Learnt from: alhambrav
Repo: craftercms/studio PR: 3932
File: src/main/api/studio-api.yaml:2089-2089
Timestamp: 2026-06-03T09:58:37.863Z
Learning: Repo: craftercms/studio PR `#3932` — Maintainer preference from alhambrav: For the OpenAPI module-name description update in `src/main/api/studio-api.yaml`, endpoints whose operation descriptions only say `Module: Studio` can be left without permission/role details in this PR; any permission/role-detail standardization should be handled in a separate ticket/PR if needed.

Learnt from: jmendeza
Repo: craftercms/studio PR: 3906
File: src/main/api/studio-api.yaml:1940-1947
Timestamp: 2026-03-23T21:00:40.800Z
Learning: Repo: craftercms/studio — For API v2, maintainers may keep forward-looking request variants in the OpenAPI spec even if the backend is not yet implemented (e.g., POST /api/2/sites includes a 'remote' discriminator branch by design). Prefer documenting the planned status and expected interim response (e.g., 501 Not Implemented) over removing the design.

Learnt from: jmendeza
Repo: craftercms/studio PR: 0
File: :0-0
Timestamp: 2026-05-06T19:31:22.055Z
Learning: In the craftercms/studio repository, Codacy static analysis findings are often considered minor or intentionally deferred (e.g., long parameter lists are acceptable and will not be addressed). Do not flag these as blockers for PR readiness.

Learnt from: alhambrav
Repo: craftercms/studio PR: 3814
File: src/main/api/studio-api.yaml:7-7
Timestamp: 2025-09-22T21:12:13.850Z
Learning: Repo: craftercms/studio — Versioning workflow: maintainers update pom.xml, docs, and runtime version endpoints close to release; PRs that only bump OpenAPI info.version (src/main/api/studio-api.yaml) are acceptable without immediate pom/docs changes.

Learnt from: jmendeza
Repo: craftercms/studio PR: 3922
File: src/main/java/org/craftercms/studio/impl/v2/utils/spring/context/BootstrapManagerImpl.java:68-118
Timestamp: 2026-05-12T23:14:27.236Z
Learning: In CrafterCMS Studio (PR `#3922`), BootstrapManagerImpl uses bare Order (Ordered.LOWEST_PRECEDENCE) on its EventListener methods for CleanupRepositoriesEvent, StartSystemUpgradeEvent, and StartSitesUpgradeEvent. Worker classes (RepositoryStartupCleanup Order(20), StudioUpgradeManagerImpl Order(10)) handle these same events first, ensuring actual work completes before BootstrapManagerImpl advances the bootstrap sequence. A Semaphore synchronizes the async sites-bootstrap thread with the synchronous system-upgrade chain. This is intentional design — do not flag BootstrapManagerImpl for treating kickoff events as completion signals, as Order guarantees workers finish first.

@jmendeza

jmendeza commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

@CodeRabbit
For item 7. No sibling check makes sense. There is only one reference path

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@jmendeza — that makes sense. For AddBefore/AddAfter the parent context is implicitly defined by the single reference path itself, so a separate sibling check would be redundant. Item #7 is not an issue. All items are now cleared — the PR looks good to go to the human reviewer. 🐇


✏️ Learnings added
Learnt from: jmendeza
URL: https://github.com/craftercms/studio/pull/3916

Timestamp: 2026-06-08T16:59:02.440Z
Learning: Repo: craftercms/studio PR `#3916` — Maintainer clarification (jmendeza): For `ReorderItemRequest.AddBefore` and `ReorderItemRequest.AddAfter` in `ContentServiceInternalImpl`, a sibling-path validation is intentionally omitted. There is only one reference path for these single-sided reorder variants, and the parent context is implicitly determined by that reference path alone. Do not flag the absence of `areSiblings` checks for `AddBefore`/`AddAfter` as a missing validation.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@jmendeza jmendeza requested a review from sumerjabri June 8, 2026 17:03
@sumerjabri sumerjabri merged commit 0e767f2 into craftercms:develop Jun 9, 2026
2 of 4 checks passed
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.

2 participants