@ SuppressWarnings ( "squid:S2083" ) @ PostMapping ( "/importByUrl" ) @ ResponseBody public ResponseEntity < String > importFileByUrl ( HttpServletRequest request , @ RequestParam ( "url" ) String url , @ RequestParam ( value = "entityTypeId" , required = false ) String entityTypeId , @ RequestParam ( value = "packageId" , required = false ) String packageId , @ RequestParam ( value = "metadataAction" , required = false ) String metadataAction , @ RequestParam ( value = "action" , required = false ) String action , @ RequestParam ( value = "notify" , required = false ) Boolean notify ) throws URISyntaxException { ImportRun importRun ; try { File tmpFile = fileLocationToStoredRenamedFile ( url , entityTypeId ) ; if ( packageId != null && ! dataService . getMeta ( ) . getPackage ( packageId ) . isPresent ( ) ) { return ResponseEntity . badRequest ( ) . contentType ( TEXT_PLAIN ) . body ( MessageFormat . format ( "Package [{0}] does not exist." , packageId ) ) ; } importRun = importFile ( request , tmpFile , metadataAction , action , notify , packageId ) ; } catch ( Exception e ) { LOG . error ( e . getMessage ( ) ) ; return ResponseEntity . badRequest ( ) . contentType ( TEXT_PLAIN ) . body ( e . getMessage ( ) ) ; } return createCreatedResponseEntity ( importRun ) ; }
Imports entities present in a file from a URL