in src/main/java/com/epam/digital/data/platform/el/juel/SaveDigitalDocumentFromUrlJuelFunction.java [54:75]
public static DocumentMetadata save_digital_document_from_url(String remoteFileUrl,
String targetFileName) {
URL remoteFileLocation;
try {
remoteFileLocation = new URL(remoteFileUrl);
} catch (MalformedURLException e) {
return DocumentMetadata.builder().build();
}
var restClient = getBean(DigitalDocumentServiceInternalApiRestClient.class);
var rootProcessInstanceId = getExecution().getRootProcessInstanceId();
var remoteDocumentDto = RemoteDocumentDto.builder()
.remoteFileLocation(remoteFileLocation)
.filename(targetFileName)
.build();
var idmService = getBean("system-user-keycloak-client-service", IdmService.class);
var accessToken = idmService.getClientAccessToken();
var headers = createHeaders(accessToken);
var metadataDto = restClient.upload(rootProcessInstanceId, remoteDocumentDto, headers);
return toDocumentMetadata(metadataDto);
}