|
3 | 3 | import com.google.gson.Gson; |
4 | 4 | import com.regula.documentreader.webclient.model.*; |
5 | 5 | import com.regula.documentreader.webclient.model.ext.authenticity.Authenticity; |
6 | | - |
| 6 | +import com.regula.documentreader.webclient.Base64; |
7 | 7 | import java.io.FileWriter; |
8 | 8 | import java.io.IOException; |
| 9 | +import java.nio.charset.StandardCharsets; |
9 | 10 | import java.util.ArrayList; |
10 | 11 | import java.util.List; |
| 12 | +import java.util.zip.Inflater; |
11 | 13 | import javax.annotation.Nullable; |
12 | 14 |
|
13 | 15 | public class RecognitionResponse { |
@@ -45,6 +47,33 @@ public Text text() { |
45 | 47 | return null; |
46 | 48 | } |
47 | 49 |
|
| 50 | + @Nullable |
| 51 | + public String GetLog() { |
| 52 | + String logBase64 = this.originalResponse.getLog(); |
| 53 | + if (logBase64 == null){ |
| 54 | + return null; |
| 55 | + } |
| 56 | + |
| 57 | + byte[] buffer = Base64.decode(logBase64); |
| 58 | + Inflater inflater = new Inflater(); |
| 59 | + inflater.setInput(buffer); |
| 60 | + byte[] decompressedBuffer = new byte[1024]; |
| 61 | + StringBuilder logText = new StringBuilder(); |
| 62 | + |
| 63 | + try { |
| 64 | + while (!inflater.finished()) { |
| 65 | + int count = inflater.inflate(decompressedBuffer); |
| 66 | + logText.append(new String(decompressedBuffer, 0, count, StandardCharsets.UTF_8)); |
| 67 | + } |
| 68 | + } catch (Exception e) { |
| 69 | + e.printStackTrace(); |
| 70 | + } finally { |
| 71 | + inflater.end(); |
| 72 | + } |
| 73 | + |
| 74 | + return logText.toString(); |
| 75 | + } |
| 76 | + |
48 | 77 | @Nullable |
49 | 78 | public Images images() { |
50 | 79 | ImagesResult result = resultByType(Result.IMAGES); |
|
0 commit comments