Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public final class SW360Release extends SW360HalResource<SW360ReleaseLinkObjects
private boolean isProprietary;
private String name;
private String version;
private String declaredLicense;
private String createdOn;
private String cpeId;
private String downloadurl;
Expand Down Expand Up @@ -175,13 +176,13 @@ public SW360Release setOverriddenLicense(String overriddenLicense) {
return this;
}

@JsonIgnore
@JsonInclude(JsonInclude.Include.NON_NULL)
public String getDeclaredLicense() {
return additionalData.get(DECLARED_LICENSE_KEY);
return declaredLicense != null ? declaredLicense : additionalData.get(DECLARED_LICENSE_KEY);
}

public SW360Release setDeclaredLicense(String declaredLicense) {
additionalData.put(DECLARED_LICENSE_KEY, declaredLicense);
this.declaredLicense = declaredLicense;
return this;
}

Expand Down Expand Up @@ -326,6 +327,7 @@ public boolean shareIdentifier(SW360Release releaseCompare) {
public SW360Release mergeWith(SW360Release releaseWithPrecedence) {
name = getDominantGetterFromVariableMergeOrNull(releaseWithPrecedence, SW360Release::getName);
version = getDominantGetterFromVariableMergeOrNull(releaseWithPrecedence, SW360Release::getVersion);
declaredLicense = getDominantGetterFromVariableMergeOrNull(releaseWithPrecedence, SW360Release::getDeclaredLicense);
cpeId = getDominantGetterFromVariableMergeOrNull(releaseWithPrecedence, SW360Release::getCpeId);
downloadurl = getDominantGetterFromVariableMergeOrNull(releaseWithPrecedence, SW360Release::getDownloadurl);
if (releaseWithPrecedence.isSetMainLicenseIds()) {
Expand Down Expand Up @@ -385,13 +387,14 @@ public boolean equals(Object o) {
Objects.equals(externalIds, release.externalIds) &&
Objects.equals(additionalData, release.additionalData) &&
Objects.equals(createdOn, release.createdOn) &&
Objects.equals(declaredLicense, release.declaredLicense) &&
Objects.equals(sw360ClearingState, release.sw360ClearingState) &&
isProprietary == release.isProprietary;
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), name, version, cpeId, downloadurl, externalIds, additionalData,
return Objects.hash(super.hashCode(), name, version, declaredLicense, cpeId, downloadurl, externalIds, additionalData,
isProprietary, createdOn, sw360ClearingState);
}

Expand Down
1 change: 1 addition & 0 deletions libraries/datahandler/src/main/thrift/components.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ struct Release {

65: optional set<string> mainLicenseIds,
66: optional set<string> otherLicenseIds,
67: optional string declaredLicense,

40: optional Vendor vendor,
41: optional string vendorId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@ public static abstract class RequestSummaryMixin extends RequestSummary {
"rolesIsSet",
"mainLicenseIdsIsSet",
"otherLicenseIdsIsSet",
"declaredLicenseIsSet",
"vendorIsSet",
"vendorIdIsSet",
"clearingInformationIsSet",
Expand Down Expand Up @@ -1231,6 +1232,7 @@ static abstract class ReleaseMixin extends Release {
"rolesIsSet",
"mainLicenseIdsIsSet",
"otherLicenseIdsIsSet",
"declaredLicenseIsSet",
"vendorIsSet",
"vendorIdIsSet",
"clearingInformationIsSet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ public Package convertToEmbeddedPackage(Package pkg) {

public Release convertToEmbeddedReleaseWithDet(Release release) {
List<String> fields = List.of("id", "name", "version", "cpeid", "createdBy", "createdOn", "componentId","componentType",
"additionalData", "clearingState", "mainLicenseIds", "binaryDownloadurl", "sourceCodeDownloadurl",
"additionalData", "clearingState", "declaredLicense", "mainLicenseIds", "binaryDownloadurl", "sourceCodeDownloadurl",
"releaseDate", "externalIds", "languages", "operatingSystems", "softwarePlatforms", "vendor",
"mainlineState", "packageIds");
return convertToEmbeddedRelease(release, fields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ public void before() throws TException, IOException {
release.setLanguages(new HashSet<>(Arrays.asList("C++", "Java")));
release.setMainLicenseIds(new HashSet<>(Arrays.asList("GPL-2.0-or-later", "Apache-2.0")));
release.setOtherLicenseIds(new HashSet<>(Arrays.asList("MIT", "BSD-3-Clause")));
release.setDeclaredLicense("MIT OR GPL-2.0-or-later");
release.setOperatingSystems(ImmutableSet.of("Windows", "Linux"));
release.setSoftwarePlatforms(new HashSet<>(Arrays.asList("Java SE", ".NET")));
release.setEccInformation(eccInformation);
Expand Down Expand Up @@ -759,6 +760,7 @@ public void should_document_get_release_all_details() throws Exception {
subsectionWithPath("_embedded.sw360:releases.[]additionalData").description("A place to store additional data used by external tools").optional(),
subsectionWithPath("_embedded.sw360:releases.[]releaseIdToRelationship").description("Release Id To Relationship of Release").optional(),
subsectionWithPath("_embedded.sw360:releases.[]languages").description("The language of the component"),
subsectionWithPath("_embedded.sw360:releases.[]declaredLicense").description("The declared SPDX license expression").optional(),
subsectionWithPath("_embedded.sw360:releases.[]mainLicenseIds").description("An array of all main licenses").optional(),
subsectionWithPath("_embedded.sw360:releases.[]otherLicenseIds").description("An array of all other licenses associated with the release").optional(),
subsectionWithPath("_embedded.sw360:releases.[]operatingSystems").description("The OS on which the release operates"),
Expand Down Expand Up @@ -910,6 +912,7 @@ public void should_document_get_release() throws Exception {
fieldWithPath("releaseDate").description("The date of this release"),
fieldWithPath("createdOn").description("The creation date of the internal sw360 release"),
fieldWithPath("componentType").description("The componentType of the release, possible values are " + Arrays.asList(ComponentType.values())),
fieldWithPath("declaredLicense").description("The declared SPDX license expression").optional(),
fieldWithPath("mainlineState").description("the mainline state of the release, possible values are: " + Arrays.asList(MainlineState.values())),
subsectionWithPath("eccInformation").description("The eccInformation of this release"),
fieldWithPath("sourceCodeDownloadurl").description("the source code download url of the release"),
Expand Down Expand Up @@ -1457,6 +1460,7 @@ private RestDocumentationResultHandler documentReleaseProperties() {
fieldWithPath("version").description("The version of the release"),
fieldWithPath("createdBy").description("Email of the release creator"),
fieldWithPath("cpeid").description("CpeId of the release"),
fieldWithPath("declaredLicense").description("The declared SPDX license expression").optional(),
fieldWithPath("mainLicenseIds").description("An array of all main licenses"),
fieldWithPath("clearingState").description("The clearing of the release, possible values are " + Arrays.asList(ClearingState.values())),
fieldWithPath("releaseDate").description("The date of this release"),
Expand Down
Loading