Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import com.google.gson.Gson;
import com.regula.documentreader.webclient.model.*;
import com.regula.documentreader.webclient.model.ext.authenticity.Authenticity;

import com.regula.documentreader.webclient.Base64;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.Inflater;
import javax.annotation.Nullable;

public class RecognitionResponse {
Expand Down Expand Up @@ -45,6 +47,33 @@ public Text text() {
return null;
}

@Nullable
public String GetLog() {
String logBase64 = this.originalResponse.getLog();
if (logBase64 == null){
return null;
}

byte[] buffer = Base64.decode(logBase64);
Inflater inflater = new Inflater();
inflater.setInput(buffer);
byte[] decompressedBuffer = new byte[1024];
StringBuilder logText = new StringBuilder();

try {
while (!inflater.finished()) {
int count = inflater.inflate(decompressedBuffer);
logText.append(new String(decompressedBuffer, 0, count, StandardCharsets.UTF_8));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
inflater.end();
}

return logText.toString();
}

@Nullable
public Images images() {
ImagesResult result = resultByType(Result.IMAGES);
Expand Down