Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 8, 2026

Workflow information is special content metadata that should not be modified through the general update method. This adds a dedicated updateWorkflow API method following the same pattern as updateMetadata.

Changes

Core API (core-api)

  • WorkflowEditor interface and EditableWorkflow class for editing workflow state and checks
  • EditableWorkflow uses WorkflowInfo as source instead of Content
  • UpdateWorkflowParams and UpdateWorkflowResult for workflow update operations
  • ContentService.updateWorkflow() method

Implementation (core-content)

  • UpdateWorkflowCommand executes workflow updates with version history tracking
  • ContentServiceImpl.updateWorkflow() applies changes to draft branch only
  • Unsets CONTENT and NAME inherit types when updating workflow
  • Audit logging via ContentAuditLogSupport

JavaScript API (lib-content)

  • UpdateWorkflowHandler bridges JS to Java API
  • WorkflowInfoMapper for serializing WorkflowInfo to JavaScript
  • content.ts exports updateWorkflow() function with TypeScript definitions

Usage

// Java API
UpdateWorkflowParams params = UpdateWorkflowParams.create()
    .contentId(contentId)
    .editor(edit -> {
        edit.state = WorkflowState.PENDING_APPROVAL;
        edit.checks.put("Legal review", WorkflowCheckState.PENDING);
        edit.checks.put("Manager approval", WorkflowCheckState.APPROVED);
    })
    .build();
UpdateWorkflowResult result = contentService.updateWorkflow(params);
// JavaScript API
const result = content.updateWorkflow({
    key: contentId,
    editor: (w) => {
        w.state = 'PENDING_APPROVAL';
        w.checks = {
            'Legal review': 'PENDING',
            'Manager approval': 'APPROVED'
        };
        return w;
    }
});
Original prompt

This section details on the original issue you should resolve

<issue_title>updateWorkflow content API</issue_title>
<issue_description>workflow info is a special content metadata and should not be modified via update method
instead a separate method updateWorkflow should be implemented in both Java an JavaScript API

it should add and remove checks, change status</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 8, 2026 16:04
Co-authored-by: rymsha <2891483+rymsha@users.noreply.github.com>
Co-authored-by: rymsha <2891483+rymsha@users.noreply.github.com>
Co-authored-by: rymsha <2891483+rymsha@users.noreply.github.com>
Co-authored-by: rymsha <2891483+rymsha@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement updateWorkflow method for content API Add dedicated updateWorkflow API for content workflow metadata Jan 8, 2026
Copilot AI requested a review from rymsha January 8, 2026 16:20
@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

❌ Patch coverage is 86.25000% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.66%. Comparing base (710f820) to head (d59c1f5).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...i/src/main/java/com/enonic/xp/content/Content.java 22.22% 0 Missing and 7 partials ⚠️
...m/enonic/xp/lib/content/UpdateWorkflowHandler.java 73.91% 4 Missing and 2 partials ⚠️
...ic/xp/core/impl/content/UpdateWorkflowCommand.java 91.11% 1 Missing and 3 partials ⚠️
...n/java/com/enonic/xp/content/EditableWorkflow.java 75.00% 0 Missing and 2 partials ⚠️
.../core/impl/content/ContentAuditLogSupportImpl.java 91.66% 0 Missing and 1 partial ⚠️
.../com/enonic/xp/lib/content/UpdateMediaHandler.java 0.00% 0 Missing and 1 partial ⚠️
...onic/xp/lib/content/mapper/WorkflowInfoMapper.java 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #11645   +/-   ##
=========================================
  Coverage     86.66%   86.66%           
- Complexity    19668    19696   +28     
=========================================
  Files          2529     2536    +7     
  Lines         66677    66776   +99     
  Branches       5340     5336    -4     
=========================================
+ Hits          57784    57874   +90     
- Misses         6308     6315    +7     
- Partials       2585     2587    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rymsha
Copy link
Contributor

rymsha commented Jan 9, 2026

@copilot

  • workflow info must be updated only in draft branch
  • content and name inherit must be unset
  • source of EditableWorkflow is WorkflowInfo, not content

…, WorkflowInfo as source

Co-authored-by: rymsha <2891483+rymsha@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 9, 2026

@copilot

  • workflow info must be updated only in draft branch
  • content and name inherit must be unset
    ...

All three items addressed in commit 0517a1d:

  1. Workflow info now updates only in draft branch (removed BRANCH_MASTER from branches)
  2. CONTENT and NAME inherit types are now unset when updating workflow
  3. EditableWorkflow source changed from Content to WorkflowInfo, with corresponding WorkflowInfoMapper created for JavaScript API

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • scans-in.gradle.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: rymsha <2891483+rymsha@users.noreply.github.com>
@rymsha rymsha force-pushed the copilot/implement-update-workflow-method branch from d59c1f5 to 94b453e Compare January 13, 2026 12:00
@rymsha rymsha force-pushed the copilot/implement-update-workflow-method branch from ab297cf to 6e583c1 Compare January 13, 2026 15:21
@@ -0,0 +1,30 @@
package com.enonic.xp.content;

import java.util.Map;

Choose a reason for hiding this comment

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

Codacy found an issue: Unused import - java.util.Map.

this.contentService.setContentTypeService( contentTypeService );
Mockito.when( contentTypeService.getByName( Mockito.isA( GetContentTypeParams.class ) ) ).
thenReturn( createContentTypeForAllInputTypes() );
Mockito.when( contentTypeService.getByName( Mockito.isA( GetContentTypeParams.class ) ) )

Choose a reason for hiding this comment

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

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.

updateWorkflow content API

2 participants