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

fix(Attachment): Make get attachment endpoints consistent, allow to update project/component/release with attachment data #2917

Conversation

hoangnt2
Copy link
Contributor

@hoangnt2 hoangnt2 commented Feb 14, 2025

Issue:

  1. Currently, there are two formats when fetching attachments for a project, component, or release
  • For projects and releases:
{
    "_embedded": {
          "sw360:attachments": [....]
    }
}
  • For components:
{
    "_embedded": {
         "sw360:attachmentDTOes": [....]
    }
}
  1. Additionally, project/release attachments cannot be updated when calling the patch project/release endpoint.

=> These two issues make it difficult for us to create a common component for listing and editing attachments in the new front-end

This PR does:

  1. Make get attachment endpoints response format consistent
  2. Allow patching a project/component/release with attachment data (in a consistent way)
  3. Remove AttachmentDTO class

How To Test?

1.Make get attachment endpoints response format consistent

  • Method: GET

  • Url:
    - Project attachments: http://{ip}:8080/resource/api/projects/{project_id}/attachments
    - Component attachments: http://{ip}:8080/resource/api/components/{component_id}/attachments
    - Release attachments: http://{ip}:8080/resource/api/releases/{release_id}/attachments

  • Expected output:

{
    "_embedded": {
          "sw360:attachments": [....]
    }
}

2.Update project/component/response

  • Method: PATCH

  • Url:
    - Update project : http://{ip}:8080/resource/api/projects/{project_id}/
    - Update component: http://{ip}:8080/resource/api/components/{component_id}/attachments
    - Update release: http://{ip}:8080/resource/api/releases/{release_id}/attachments

  • Body:

{
    "attachments": [
         {
          "attachmentContentId": "${attachment_content_id}",
          "filename": "${file_name}",
          "attachmentType": "SOURCE",
          "createdBy": "[email protected]",
          "createdTeam": "DEPARTMENT1",
          "createdComment": "",
          "createdOn": "2025-02-06",
          "checkedBy": "[email protected]"
       }
    ]
}
  • Expected output: Update success with status code = 200

@hoangnt2 hoangnt2 changed the title fix(Attachment): Make get attachment endpoints of component and release consistent fix(Attachment): Make get attachment endpoints consistent Feb 14, 2025
@hoangnt2 hoangnt2 changed the title fix(Attachment): Make get attachment endpoints consistent fix(Attachment): Make get attachment endpoints consistent, allow to update attachments in update project endpoint Feb 14, 2025
@hoangnt2 hoangnt2 changed the title fix(Attachment): Make get attachment endpoints consistent, allow to update attachments in update project endpoint fix(Attachment): Make get attachment endpoints consistent, allow to update project/component/component with attachment data Feb 14, 2025
@hoangnt2 hoangnt2 changed the title fix(Attachment): Make get attachment endpoints consistent, allow to update project/component/component with attachment data fix(Attachment): Make get attachment endpoints consistent, allow to update project/component/release with attachment data Feb 14, 2025
…roject consistent

- Allow updating project/component/release with attachment data (in a consistent way)

Signed-off-by: hoangnt2 <[email protected]>
@hoangnt2 hoangnt2 force-pushed the release/fix-listing-attachment-endpoint branch from 85efa3c to 8273571 Compare February 14, 2025 07:09
@hoangnt2 hoangnt2 added needs code review needs general test This is general testing, meaning that there is no org specific issue to check for New-UI Level for the API and UI level changes for the new-ui POC Proof of Concept REST and removed POC Proof of Concept labels Feb 14, 2025
Copy link
Contributor

@heliocastro heliocastro left a comment

Choose a reason for hiding this comment

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

LGTM

@heliocastro heliocastro merged commit d3aeefc into eclipse-sw360:main Feb 14, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs code review needs general test This is general testing, meaning that there is no org specific issue to check for New-UI Level for the API and UI level changes for the new-ui REST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants