diff --git a/FrontEnd/SailfishFrontEnd/src/main/java/com/exactpro/sf/testwebgui/restapi/MachineLearningResource.java b/FrontEnd/SailfishFrontEnd/src/main/java/com/exactpro/sf/testwebgui/restapi/MachineLearningResource.java index 6ebd6333..a59cb1f6 100644 --- a/FrontEnd/SailfishFrontEnd/src/main/java/com/exactpro/sf/testwebgui/restapi/MachineLearningResource.java +++ b/FrontEnd/SailfishFrontEnd/src/main/java/com/exactpro/sf/testwebgui/restapi/MachineLearningResource.java @@ -15,6 +15,7 @@ ******************************************************************************/ package com.exactpro.sf.testwebgui.restapi; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -37,6 +38,7 @@ import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.StreamingOutput; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -132,7 +134,7 @@ public Response predictTrainingData(InputStream requestBody) { @GET @Produces(MediaType.APPLICATION_OCTET_STREAM) @Path("get_dump") - public Response getDump(@DefaultValue("4") @QueryParam("compression_lvl") int compression) { + public Response getDump(@DefaultValue("4") @QueryParam("compression_lvl") int compression, @DefaultValue("false") @QueryParam("remove") boolean remove) { MachineLearningService mlService = getMachineLearningService(); @@ -140,6 +142,11 @@ public Response getDump(@DefaultValue("4") @QueryParam("compression_lvl") int co try (OutputStream os = outputStream) { mlService.getStorage().zipDocumentsToStream(os, compression); + if (remove) { + for (File doc : mlService.getStorage().getDocuments()) { + FileUtils.deleteQuietly(doc); + } + } } };