Skip to content

Commit

Permalink
NPM Child parent linking issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumanth Kb committed Jul 16, 2024
1 parent 2ea2701 commit 55c3671
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/LCT.PackageIdentifier/BomValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static async Task ValidateAppSettings(CommonAppSettings appSettings, ISw3
Logger.Debug($"ValidateAppSettings() : Sw360 project "+ projectReleases.Name +" is in " + projectReleases.clearingState +" state.");
Environment.Exit(-1);
}
else
else
{
appSettings.SW360ProjectName = projectReleases.Name;
}
Expand Down
9 changes: 2 additions & 7 deletions src/LCT.SW360PackageCreator/CreatorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,11 @@ private static async Task<string> GetAttachmentUrlList(ComparisonBomData compone
public async Task<List<ComparisonBomData>> SetContentsForComparisonBOM(List<Components> lstComponentForBOM, ISW360Service sw360Service)
{
Logger.Debug($"SetContentsForComparisonBOM():Start");
List<ComparisonBomData> comparisonBomData = new List<ComparisonBomData>();
List<ComparisonBomData> comparisonBomData;
Logger.Logger.Log(null, Level.Notice, $"Collecting comparison BOM Data...", null);
componentsAvailableInSw360 = await sw360Service.GetAvailableReleasesInSw360(lstComponentForBOM);

//Checking components count before getting status of individual comp details
if (componentsAvailableInSw360?.Count > 0)
{
comparisonBomData = await GetComparisionBomItems(lstComponentForBOM, sw360Service);
}

comparisonBomData = await GetComparisionBomItems(lstComponentForBOM, sw360Service);
Logger.Debug($"SetContentsForComparisonBOM():End");
return comparisonBomData;
}
Expand Down
21 changes: 11 additions & 10 deletions src/LCT.Services/Sw360CommonService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,6 @@ private async Task<IList<Sw360Components>> GetCompListFromExternalIDCombinations
public async Task<Releasestatus> GetReleaseDataByExternalId(string releaseName, string releaseVersion, string releaseExternalId)
{
Logger.Debug($"GetReleaseDataByExternalId(): Release name - {releaseName}@{releaseVersion}");
string externalIdUriString;
if (releaseExternalId.Contains(Dataconstant.PurlCheck()["NPM"]))
{
externalIdUriString = Uri.EscapeDataString(releaseExternalId);
}
else
{
externalIdUriString = releaseExternalId;
}
Releasestatus releasestatus = new Releasestatus();

releasestatus.isReleaseExist = false;
Expand All @@ -138,11 +129,21 @@ public async Task<Releasestatus> GetReleaseDataByExternalId(string releaseName,
{
foreach (string externalIdKey in externalIdKeyList)
{
HttpResponseMessage httpResponseComponent = await m_SW360ApiCommunicationFacade.GetReleaseByExternalId(externalIdUriString, externalIdKey);
HttpResponseMessage httpResponseComponent = await m_SW360ApiCommunicationFacade.GetReleaseByExternalId(releaseExternalId, externalIdKey);
var responseContent = httpResponseComponent?.Content?.ReadAsStringAsync()?.Result ?? string.Empty;
var componentsRelease = JsonConvert.DeserializeObject<ComponentsRelease>(responseContent);
var sw360releasesdata = componentsRelease?.Embedded?.Sw360Releases ?? new List<Sw360Releases>();

//It's for Local Sw360 servers,making an API call with EscapeDataString..
if (sw360releasesdata.Count == 0 && releaseExternalId.Contains(Dataconstant.PurlCheck()["NPM"]))
{
releaseExternalId = Uri.EscapeDataString(releaseExternalId);
httpResponseComponent = await m_SW360ApiCommunicationFacade.GetReleaseByExternalId(releaseExternalId, externalIdKey);
responseContent = httpResponseComponent?.Content?.ReadAsStringAsync()?.Result ?? string.Empty;
componentsRelease = JsonConvert.DeserializeObject<ComponentsRelease>(responseContent);
sw360releasesdata = componentsRelease?.Embedded?.Sw360Releases ?? new List<Sw360Releases>();
}

if (sw360releasesdata.Count > 0)
{
Releasestatus releaseStatus = GetReleaseExistStatus(releaseName, externalIdKey, sw360releasesdata);
Expand Down

0 comments on commit 55c3671

Please sign in to comment.