@@ -89,7 +89,7 @@ public Pipeline importPipeline(File zipFile, boolean importUserDataFile, boolean
8989 public Pipeline importPipeline (File zipFile , File tempDirectory , boolean importUserDataFile , boolean importScheduleFile )
9090 throws ImportException , IOException {
9191 // delete tempDirectory
92- FileUtils . deleteQuietly (tempDirectory );
92+ ResourceManager . cleanupQuietly (tempDirectory );
9393
9494 if (authCtx == null ) {
9595 throw new ImportException (Messages .getString ("ImportService.pipeline.authenticationContext.null" ));
@@ -151,11 +151,7 @@ public Pipeline importPipeline(File zipFile, File tempDirectory, boolean importU
151151 } catch (ImportException ex ) {
152152 throw ex ;
153153 } finally {
154- // in every case delte temp directory
155- if (!FileUtils .deleteQuietly (tempDirectory )) {
156- // failed to delete directory
157- LOG .warn ("Failed to delete temp directory." );
158- }
154+ ResourceManager .cleanupQuietly (tempDirectory );
159155 }
160156 return pipe ;
161157 }
@@ -310,66 +306,70 @@ public ImportedFileInformation getImportedInformation(File zipFile)
310306 boolean isScheduleFile = false ;
311307
312308 File tempDirectory = resourceManager .getNewImportTempDir ();
313- ZipCommons .unpack (zipFile , tempDirectory );
314- Pipeline pipeline = loadPipeline (tempDirectory );
315-
316- List <DpuItem > usedDpus = loadUsedDpus (tempDirectory );
317- TreeMap <String , DpuItem > missingDpus = new TreeMap <>();
318-
319- if (pipeline != null ) {
320- PipelineGraph graph = pipeline .getGraph ();
321- if (graph != null ) {
322- Set <Node > nodes = graph .getNodes ();
323- if (nodes != null ) {
324- for (Node node : nodes ) {
325- DPUInstanceRecord dpu = node .getDpuInstance ();
326- if (dpu == null ) {
327- continue ;
328- }
329-
330- DPUTemplateRecord template = dpu .getTemplate ();
331-
332- if (template == null ) {
333- continue ;
334- }
335-
336- // try to detect if dpus are installed
337- DPUTemplateRecord dpuTemplateRecord = dpuFacade
338- .getByName (template .getName ());
339- // TODO jmc add version
340- String version = "unknown" ;
341- DpuItem dpuItem = new DpuItem (dpu .getName (), template .getJarName (), version );
342- if (dpuTemplateRecord == null ) {
343- // these dpus is missing
344- if (!missingDpus .containsKey (dpu .getName ())) {
345- missingDpus .put (dpu .getName (), dpuItem );
309+ try {
310+ ZipCommons .unpack (zipFile , tempDirectory );
311+ Pipeline pipeline = loadPipeline (tempDirectory );
312+
313+ List <DpuItem > usedDpus = loadUsedDpus (tempDirectory );
314+ TreeMap <String , DpuItem > missingDpus = new TreeMap <>();
315+
316+ if (pipeline != null ) {
317+ PipelineGraph graph = pipeline .getGraph ();
318+ if (graph != null ) {
319+ Set <Node > nodes = graph .getNodes ();
320+ if (nodes != null ) {
321+ for (Node node : nodes ) {
322+ DPUInstanceRecord dpu = node .getDpuInstance ();
323+ if (dpu == null ) {
324+ continue ;
325+ }
326+
327+ DPUTemplateRecord template = dpu .getTemplate ();
328+
329+ if (template == null ) {
330+ continue ;
346331 }
332+
333+ // try to detect if dpus are installed
334+ DPUTemplateRecord dpuTemplateRecord = dpuFacade
335+ .getByName (template .getName ());
336+ // TODO jmc add version
337+ String version = "unknown" ;
338+ DpuItem dpuItem = new DpuItem (dpu .getName (), template .getJarName (), version );
339+ if (dpuTemplateRecord == null ) {
340+ // these dpus is missing
341+ if (!missingDpus .containsKey (dpu .getName ())) {
342+ missingDpus .put (dpu .getName (), dpuItem );
343+ }
344+ }
345+ final File userDataFile = new File (tempDirectory ,
346+ ArchiveStructure .DPU_DATA_USER .getValue () + File .separator
347+ + template .getJarDirectory ());
348+
349+ if (userDataFile .exists ()) {
350+ isUserData = true ;
351+
352+ }
353+ LOG .debug ("userDataFile: " + userDataFile .toString ());
347354 }
348- final File userDataFile = new File (tempDirectory ,
349- ArchiveStructure .DPU_DATA_USER .getValue () + File .separator
350- + template .getJarDirectory ());
351-
352- if (userDataFile .exists ()) {
353- isUserData = true ;
354-
355+
356+ final File scheduleFile = new File (tempDirectory ,
357+ ArchiveStructure .SCHEDULE .getValue ());
358+ if (scheduleFile .exists ()) {
359+ isScheduleFile = true ;
355360 }
356- LOG .debug ("userDataFile: " + userDataFile .toString ());
357- }
358-
359- final File scheduleFile = new File (tempDirectory ,
360- ArchiveStructure .SCHEDULE .getValue ());
361- if (scheduleFile .exists ()) {
362- isScheduleFile = true ;
363361 }
364362 }
365363 }
364+
365+ ImportedFileInformation result = new ImportedFileInformation (usedDpus ,
366+ missingDpus , isUserData , isScheduleFile );
367+
368+ LOG .debug ("<<< Leaving getImportedInformation: {}" , result );
369+ return result ;
370+ } finally {
371+ ResourceManager .cleanupQuietly (tempDirectory );
366372 }
367-
368- ImportedFileInformation result = new ImportedFileInformation (usedDpus ,
369- missingDpus , isUserData , isScheduleFile );
370-
371- LOG .debug ("<<< Leaving getImportedInformation: {}" , result );
372- return result ;
373373 }
374374
375375 public boolean hasUserPermission (String permission ) {
0 commit comments