Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core) Add update and delete command Java/Rest APIs #4333

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

prajwolbhandari1
Copy link
Contributor

  • DELETE /task/{taskId}/comment/{commentId}
    deletes a comment of a given taskId and commentId
  • DELETE /task/{taskId}/comment
    deletes all comments of a given taskId
  • PUT /task/comment
    updates a comment
  • DELETE /process-instance/{processInstanceId}/comment/{commentId}
    deletes a comment of a given processInstanceId and commentId
  • DELETE /process-instance/{processInstanceId}/comment.
    deletes all comments of a given processInstanceId
  • PUT /process-instance/comment
    updates a comment

related to: #2551

…Instance

DELETE /task/{taskId}/comment/{commentId}
  - deletes a comment of a given taskId and commentId
DELETE /task/{taskId}/comment
  - deletes all comments of a given taskId
PUT /task/comment
  - updates a comment
DELETE /process-instance/{processInstanceId}/comment/{commentId}
 - deletes a comment of a given processInstanceId and commentId
DELETE /process-instance/{processInstanceId}/comment.
 - deletes all comments of a given processInstanceId
PUT /process-instance/comment
 - updates a comment

related to: camunda#2551
…nd processInstance

DELETE /task/{taskId}/comment/{commentId}
  - deletes a comment of a given taskId and commentId
DELETE /task/{taskId}/comment
  - deletes all comments of a given taskId
PUT /task/comment
  - updates a comment
DELETE /process-instance/{processInstanceId}/comment/{commentId}
 - deletes a comment of a given processInstanceId and commentId
DELETE /process-instance/{processInstanceId}/comment.
 - deletes all comments of a given processInstanceId
PUT /process-instance/comment
 - updates a comment

related to: camunda#2551
…k and processInstance

DELETE /task/{taskId}/comment/{commentId}
  - deletes a comment of a given taskId and commentId
DELETE /task/{taskId}/comment
  - deletes all comments of a given taskId
PUT /task/comment
  - updates a comment
DELETE /process-instance/{processInstanceId}/comment/{commentId}
 - deletes a comment of a given processInstanceId and commentId
DELETE /process-instance/{processInstanceId}/comment.
 - deletes all comments of a given processInstanceId
PUT /process-instance/comment
 - updates a comment

related to: camunda#2551
@yanavasileva
Copy link
Member

Hi @prajwolbhandari1,

Thank you for raising this.
We will have a look and get back to you. As the changes are a lot it might take some time to cover everything.

Best,
Yana

@yanavasileva
Copy link
Member

Note to myself:

  • docs for user operation logs and authorizations

@prajwol123
Copy link

@yanavasileva any update on this?

@yanavasileva
Copy link
Member

Thank you for your patience with this.
I didn't have the time to start with the review yet. I will get to it next week.

Copy link
Member

@yanavasileva yanavasileva left a comment

Choose a reason for hiding this comment

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

👍 The changes look good as a start.
Unfortunately, more aspects need to be covered, I left comments below. One more general note:
❌ There's a lot of code duplication in the code of the commands. Please merge the commands (for PI and task) similarly to DeleteAttachmentCmd. That way, the maintenance of the code will be easier.

@@ -493,6 +493,34 @@ public void logAttachmentOperation(String operation, ExecutionEntity processInst
}
}

public void logCommentOperation(String operation, TaskEntity task, PropertyChange propertyChange) {
Copy link
Member

Choose a reason for hiding this comment

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

Note to myself:
❓ What about tenant checks?

Copy link
Member

Choose a reason for hiding this comment

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

✍️ The new user operation logs must be documented here: https://docs.camunda.org/manual/latest/user-guide/process-engine/history/user-operation-log/#glossary-of-operations-logged-in-the-user-operation-log
Could you please raise a PR in the docs repo? (page)

Copy link
Member

Choose a reason for hiding this comment

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

❌ ✍️ Along with the delete API, we need to add a revision field to the entity. Documented here:
https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/persistence/entity/CommentEntity.java#L44
That will require changes in the ACT_HI_COMMENT table and mybatis scripts.

Copy link
Member

Choose a reason for hiding this comment

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

🔧 Consider adding @throws AuthorizationException note to the javadoc where applicable for the new APIs.

Comment on lines +274 to +278
/**
* Check if it is allowed to update a task
*/
void checkUpdateTask(TaskEntity task);

Copy link
Member

@yanavasileva yanavasileva Jun 14, 2024

Choose a reason for hiding this comment

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

❌ After reading the docs, I think #checkTaskAssign() #checkTaskWork() check should be used to perform the command checks for the new commands.
Reference: https://docs.camunda.org/manual/latest/user-guide/process-engine/authorization-service/#additional-task-permissions (✍️ the table should be updated with the actions as well)

Suggested change
/**
* Check if it is allowed to update a task
*/
void checkUpdateTask(TaskEntity task);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense for actions for comments using taskId.

How about update/delete comments using processInstanceId ?

Can we use this?

public void checkUpdateProcessInstanceById(String processInstanceId) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense for actions for comments using taskId.

How about update/delete comments using processInstanceId ?

Can we use this?

public void checkUpdateProcessInstanceById(String processInstanceId) {

Digging more into it, for me using checkTaskAssign makes more sense on this on as well. Let me know if you think otherwise.

Copy link
Member

@yanavasileva yanavasileva Jun 27, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@prajwolbhandari1, by bad for the wrong reference. #checkTaskWork() should be used, it covers both API using task and process checks. https://github.com/camunda/camunda-bpm-platform/blob/master/engine/src/main/java/org/camunda/bpm/engine/impl/cfg/auth/AuthorizationCommandChecker.java#L676C15-L676C28

No worries Yana. I will make these changes. Thank you.

Comment on lines +765 to +768
public void checkUpdateTask(TaskEntity task) {
getAuthorizationManager().checkAuthorization(UPDATE, TASK, task.getId());
}

Copy link
Member

Choose a reason for hiding this comment

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

❌ See above comment, reuse #checkTaskAssign().

Suggested change
public void checkUpdateTask(TaskEntity task) {
getAuthorizationManager().checkAuthorization(UPDATE, TASK, task.getId());
}

Comment on lines +343 to +348
public void checkUpdateTask(TaskEntity task) {
if (task != null && !getTenantManager().isAuthenticatedTenant(task.getTenantId())) {
throw LOG.exceptionCommandWithUnauthorizedTenant("update the task '" + task.getId() + "'");
}
}

Copy link
Member

Choose a reason for hiding this comment

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

❌ See above comment, reuse #checkTaskAssign().

Suggested change
public void checkUpdateTask(TaskEntity task) {
if (task != null && !getTenantManager().isAuthenticatedTenant(task.getTenantId())) {
throw LOG.exceptionCommandWithUnauthorizedTenant("update the task '" + task.getId() + "'");
}
}

import org.camunda.bpm.engine.impl.persistence.entity.TaskEntity;

/**
* see https://github.com/camunda/camunda-bpm-platform/issues/2551
Copy link
Member

Choose a reason for hiding this comment

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

❌ Please remove all of the git ticket references from the code. The modern IDE and GitHub offer enough support to track the origins to ticket and pull request.

Suggested change
* see https://github.com/camunda/camunda-bpm-platform/issues/2551

where TASK_ID_ = #{taskId,jdbcType=VARCHAR}
and ID_ = #{id,jdbcType=VARCHAR}
</select>

<select id="selectCommentByProcessInstanceIdAndCommentId" parameterType="map" resultMap="commentResultMap">
Copy link
Member

Choose a reason for hiding this comment

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

💭 I see a different result map for above query. Maybe we need to consider that for this query as well? The type of FULL_MSG_ is different for postgresql.

@github-actions github-actions bot added the group:stale DRI: Yana label Jun 15, 2024
@prajwolbhandari1
Copy link
Contributor Author

thank you @yanavasileva. I will work on these changes as soon as possible.

@github-actions github-actions bot added group:stale DRI: Yana and removed group:stale DRI: Yana labels Jun 20, 2024
@github-actions github-actions bot removed the group:stale DRI: Yana label Jun 27, 2024
@yanavasileva yanavasileva changed the title feat(engine, engine-rest-core, engine-rest-openapi) Add update and delete Java/Rest APIs of task and processInstance feat(core) Add update and delete command Java/Rest APIs Jun 27, 2024
@github-actions github-actions bot added group:stale DRI: Yana and removed group:stale DRI: Yana labels Jun 28, 2024
Copy link

Closing due to lack of requested feedback. If you would like us to look at this, please provide the requested information to re-open the PR.

@prajwol123
Copy link

prajwol123 commented Jul 12, 2024 via email

@yanavasileva
Copy link
Member

@prajwolbhandari1, you can continue the work in this one, I reopened it for you.

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.

None yet

3 participants