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

Create new endpoints that allow to add/update/edit project with dependency network #2615

Conversation

hoangnt2
Copy link
Contributor

Create new endpoints that allow to add/update/edit project with dependency network

I have split this PR to separate commits, that will make it easier for reviewers to review. (Will squash commits after review successfully if needed)

This PR contains 6 new endpoints:

  1. Get linked releases in dependency network of a project
  2. Get linked releases of a release
  3. Get linked releases from sub projects of a project
  4. Compare project network (relationship in project network) with default network (relationship between release in release table)
  5. Check cyclic links between releases
  6. Duplicate project with network

Pre-condition:

Turn on feature by adding this property into /etc/sw360/sw360.properties: enable.flexible.project.release.relationship=true

Create a new project with dependency network:

{
    "name": "Test_PR",
    "dependencyNetwork": [
        {
            "releaseId": "${release_id_1_in_sw360}", // Replace this by an existing release id in sw360
            "releaseRelationship": "CONTAINED",
            "mainlineState": "OPEN",
            "comment": ""
            "releaseLink": [
                {
                    "releaseId": "${release_id_2_in_sw360}", // Replace this by an existing release id in sw360 (difference from above)
                    "releaseRelationship": "OPTIONAL",
                    "mainlineState": "MAINLINE",
                    "comment": "",
                    "releaseLink": []
                }
            ]
        }
    ]
}

How To Test?

1. Get linked releases in dependency network of a project**

[
    {
        "releaseId": "${release_id_1_in_sw360}",
        "releaseName": "${release_1_name}",
        "releaseVersion": "${release_1_version}",
        "componentId": "${release_1_component_id}",
        "releaseRelationship": "CONTAINED",
        "mainlineState": "OPEN",
        "comment": "",
        "releaseLink": [
            {
                "releaseId": "${release_id_2_in_sw360}",
                "releaseName": "${release_2_name}",
                "releaseVersion": "${release_2_version}",
                "componentId": "${release_2_component_id}",
                "releaseRelationship": "OPTIONAL",
                "mainlineState": "MAINLINE",
                "comment": "",
                "releaseLink": []
            }
        ]
    }
]

2. Get linked releases of a release

{
    "_embedded": {
        "sw360:releaseLinks": [
            {
                "id": "${linked_release_id}",
                "name": "${linked_release_name}",
                "version": "${linked_release_version}",
                "releaseRelationship": "CONTAINED",
                "clearingState": "NEW_CLEARING",
                "licenseIds": [],
                "accessible": true,
                "componentId": "${linked_release_component_id}"
            }
        ]
    },
    "_links": {
        "curies": [
            {
                "href": "http://localhost:8080/resource/docs/{rel}.html",
                "name": "sw360",
                "templated": true
            }
        ]
    }
}

3. Get linked releases from sub projects of a project

Step 1: Create a parent project of create Test_PR (in pre-condition):

{
    "name": "Test_PR_Parent_Project",
    "linkedProjects": {
        "{created_test_project_id}": {
            "projectRelationship": "CONTAINED",
            "enableSvm": true
        }
    }
}

Step 2: Get linked releases of sub projects (Test_PR) from parent project (Test_PR_Parent_Project):

{
    "_embedded": {
        "sw360:releases": [
            {
                "id": "${release_id_1_in_sw360}",
                "cpeid": "",
                "name": "${release_name}",
                "version": "${release_version}",
                "releaseDate": "",
                "sourceCodeDownloadurl": "",
                "binaryDownloadurl": "",
                "mainlineState": "OPEN",
                "clearingState": "NEW_CLEARING",
                "externalToolProcesses": [],
                "_links": {
                    "sw360:component": {
                        "href": "http://localhost:8080/resource/api/components/${release_component_id}"
                    },
                    "self": {
                        "href": "http://localhost:8080/resource/api/releases/${release_id_1_in_sw360}"
                    }
                }
            }
        ]
    },
    "_links": {
        "curies": [
            {
                "href": "http://localhost:8080/resource/docs/{rel}.html",
                "name": "sw360",
                "templated": true
            }
        ]
    }
}

4. Compare project network (relationship in project network) with default network (relationship between release in release table)

 [
        {
            "releaseId": "${release_id_1_in_sw360}", // Replace this by an existing release id in sw360
            "releaseRelationship": "CONTAINED",
            "mainlineState": "OPEN",
            "comment": ""
            "releaseLink": [
                {
                    "releaseId": "${release_id_2_in_sw360}", // Replace this by an existing release id in sw360 (difference from above)
                    "releaseRelationship": "OPTIONAL",
                    "mainlineState": "MAINLINE",
                    "comment": "",
                    "releaseLink": []
                }
            ]
        }
    ]
  • Expected output:
 [
        {
            "releaseId": "${release_id_1_in_sw360}", // Replace this by an existing release id in sw360
            "releaseRelationship": "CONTAINED",
            "mainlineState": "OPEN",
            "comment": ""
            "isDiff": false,
            "releaseLink": [
                {
                    "releaseId": "${release_id_2_in_sw360}", // Replace this by an existing release id in sw360 (difference from above)
                    "releaseRelationship": "OPTIONAL",
                    "mainlineState": "MAINLINE",
                    "comment": "",
                    "releaseLink": [],
                    "isDiff": true,
                }
            ]
        }
    ]

5. Check cyclic links between releases

{
    "linkedToReleases": ["{release_id_1}"],//replace by release id in sw360
    "linkedReleases": ["{release_id_2}"] //replace by release id in sw360
}
  • Example response format:
[
    {
        "message": "m (1) -> m (1)",
        "status": 409
    },
    {
        "message": "There are no cyclic link between 9649fd4f4c7b45849c40aad08f1a625a and 0a4d467b19884d79b53251646c6e7393",
        "status": 200
    }
]

6. Duplicate project with network:

{
    "name": "Test_PR_Duplicate"
}
  • Expected: Dependency network is copied successfully into duplicated project
{
    "name": "Test_PR_Duplicate",
    "createdOn": "2024-09-13",
    "businessUnit": "DEPARTMENT",
    "state": "ACTIVE",
    "clearingState": "OPEN",
    "securityResponsibles": [],
    "enableSvm": false,
    "considerReleasesFromExternalList": false,
    "enableVulnerabilitiesDisplay": false,
    "dependencyNetwork": [
        {
            "releaseId": "${release_id_1_in_sw360}",
            "releaseRelationship": "CONTAINED",
            "mainlineState": "OPEN",
            "comment": "",
            "createOn": "2024-09-13",
            "createBy": "[email protected]",
            "releaseLink": [
                {
                    "releaseId": "${release_id_2_in_sw360}",
                    "releaseRelationship": "OPTIONAL",
                    "mainlineState": "MAINLINE",
                    "comment": "",
                    "createOn": "2024-09-13",
                    "createBy": "[email protected]",
                    "releaseLink": []
                }
            ]
        }
    ],
    "projectType": "PRODUCT",
    "visibility": "EVERYONE",
    "_links": {
        "self": {
            "href": "http://localhost:8080/resource/api/projects/4d13f3f5ec1e49fca4986ebbf5e4f891"
        }
    },
    "_embedded": {
        "createdBy": {
            "email": "[email protected]",
            "wantsMailNotification": false,
            "deactivated": false,
            "_links": {
                "self": {
                    "href": "http://localhost:8080/resource/api/users/byid/sw360-user"
                }
            }
        }
    }
}

@hoangnt2 hoangnt2 added needs code review needs general test This is general testing, meaning that there is no org specific issue to check for REST New-UI Level for the API and UI level changes for the new-ui labels Sep 17, 2024
@hoangnt2 hoangnt2 force-pushed the release/feat_rest-dependency-network-edit-page branch from 2e17069 to 6440152 Compare October 30, 2024 10:15
@hoangnt2 hoangnt2 force-pushed the release/feat_rest-dependency-network-edit-page branch 2 times, most recently from 6396d48 to 917103b Compare November 5, 2024 02:35
@hoangnt2 hoangnt2 force-pushed the release/feat_rest-dependency-network-edit-page branch from 917103b to 5a9b73b Compare November 8, 2024 03:55
Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

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

Minor documentation changes needed.

@hoangnt2 hoangnt2 force-pushed the release/feat_rest-dependency-network-edit-page branch from 5a9b73b to eafef43 Compare November 8, 2024 07:27
Copy link
Member

@GMishx GMishx left a comment

Choose a reason for hiding this comment

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

Changes looks good.

@heliocastro heliocastro merged commit ffd83c6 into eclipse-sw360:main Nov 19, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants