Skip to content

Commit

Permalink
Merge pull request #183 from catenax-ng/support_externalsubjectid
Browse files Browse the repository at this point in the history
Feign client changes for new DTR
  • Loading branch information
adityagajbhiye9 authored Aug 29, 2023
2 parents 0da0ffa + 545bb8f commit 388738a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Base64;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.tractusx.sde.common.exception.ServiceException;
import org.eclipse.tractusx.sde.digitaltwins.entities.request.CreateSubModelRequest;
import org.eclipse.tractusx.sde.digitaltwins.entities.request.ShellDescriptorRequest;
Expand Down Expand Up @@ -63,16 +64,16 @@ public List<String> shellLookup(ShellLookupRequest request) throws ServiceExcept
}

@SneakyThrows
public List<String> shellLookupFromDDTR(ShellLookupRequest request, String ddtrUrl, String edcBPN)
public List<String> shellLookupFromDDTR(ShellLookupRequest request, String ddtrUrl, String edcBpn)
throws ServiceException {

URI dtURL = (ddtrUrl == null || ddtrUrl.length() <= 0) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl);
URI dtURL = StringUtils.isAllEmpty(ddtrUrl) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl);

List<String> shellIds = List.of();

try {
ResponseEntity<ShellLookupResponse> response = digitalTwinsFeignClient.shellLookup(dtURL,
request.toJsonString(), edcBPN);
request.toJsonString(), edcBpn);

ShellLookupResponse body = response.getBody();
if (response.getStatusCode() == HttpStatus.OK && body != null) {
Expand Down Expand Up @@ -110,17 +111,17 @@ public List<ShellDescriptorResponse> getShellDescriptorsWithSubmodelDetails(List

List<ShellDescriptorResponse> items = new ArrayList<>();
for (String shellId : shellIds) {
items.add(getShellDetailsById(shellId, ddtrUrl));
items.add(getShellDetailsById(shellId, ddtrUrl, manufacturerId));
}
return items;
}

public ShellDescriptorResponse getShellDetailsById(String shellId, String ddtrUrl) {
public ShellDescriptorResponse getShellDetailsById(String shellId, String ddtrUrl, String edcBpn) {

URI dtURL = (ddtrUrl == null || ddtrUrl.length() <= 0) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl);
URI dtURL = StringUtils.isAllEmpty(ddtrUrl) ? getDtURL(digitalTwinsHost) : getDtURL(ddtrUrl);

ResponseEntity<ShellDescriptorResponse> shellDescriptorResponse = digitalTwinsFeignClient
.getShellDescriptorByShellId(dtURL, encodeShellIdBase64Utf8(shellId));
.getShellDescriptorByShellId(dtURL, encodeShellIdBase64Utf8(shellId), edcBpn);
return shellDescriptorResponse.getBody();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public interface DigitalTwinsFeignClient {

@GetMapping(path = "/shell-descriptors/{aasIdentifier}")
ResponseEntity<ShellDescriptorResponse> getShellDescriptorByShellId(URI url,
@PathVariable("aasIdentifier") String shellId);
@PathVariable("aasIdentifier") String shellId, @RequestHeader("Edc-Bpn") String edcBpn);

@DeleteMapping(path = "/shell-descriptors/{aasIdentifier}")
ResponseEntity<Void> deleteShell(URI url, @PathVariable("assetIds") String shellId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ private CreateSubModelRequest getCreateSubModelRequest(AspectRelationship aspect

if (childshellIds.size() == 1) {
ShellDescriptorResponse shellDescriptorResponse = digitalTwinfacilitaor
.getShellDetailsById(childshellIds.get(0), ddtUrl);
.getShellDetailsById(childshellIds.get(0), ddtUrl, aspectRelationShip.getChildManufacturerId());
childUUID = shellDescriptorResponse.getGlobalAssetId();
log.debug(aspectRelationShip.getRowNumber() + ", " + ddtUrl + ", Child aspect found for "
+ shellLookupRequest.toJsonString());
break;
}

}
Expand Down

0 comments on commit 388738a

Please sign in to comment.