Skip to content

Commit

Permalink
[RM] Feature #55360. Add functionality to drop ml dump after download
Browse files Browse the repository at this point in the history
(cherry picked from commit dbe3f0c11c901d4d254a506093c88db7e00b0e43)

Change-Id: I22138b3f2c8418a0d7429c97052b795545e24b41
  • Loading branch information
sergey.smirnov authored and Nikita-Smirnov-Exactpro committed May 14, 2019
1 parent 0a38a0b commit 4801483
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -132,14 +134,19 @@ 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();

StreamingOutput streamingOutput = outputStream -> {

try (OutputStream os = outputStream) {
mlService.getStorage().zipDocumentsToStream(os, compression);
if (remove) {
for (File doc : mlService.getStorage().getDocuments()) {
FileUtils.deleteQuietly(doc);
}
}
}
};

Expand Down

0 comments on commit 4801483

Please sign in to comment.