|
42 | 42 | import com.formkiq.client.api.DocumentActionsApi; |
43 | 43 | import com.formkiq.client.api.DocumentAttributesApi; |
44 | 44 | import com.formkiq.client.api.DocumentTagsApi; |
| 45 | +import com.formkiq.client.api.DocumentVersionsApi; |
45 | 46 | import com.formkiq.client.api.DocumentsApi; |
46 | 47 | import com.formkiq.client.invoker.ApiClient; |
47 | 48 | import com.formkiq.client.invoker.ApiException; |
|
58 | 59 | import com.formkiq.client.model.GetDocumentResponse; |
59 | 60 | import com.formkiq.client.model.GetDocumentTagResponse; |
60 | 61 | import com.formkiq.client.model.GetDocumentUrlResponse; |
| 62 | +import com.formkiq.client.model.GetDocumentVersionsResponse; |
61 | 63 | import com.google.gson.Gson; |
62 | 64 | import com.google.gson.GsonBuilder; |
63 | 65 |
|
@@ -674,4 +676,37 @@ public static List<DocumentAttribute> getDocumentAttributes(final ApiClient clie |
674 | 676 | return documentAttributesApi.getDocumentAttributes(documentId, siteId, null, null) |
675 | 677 | .getAttributes(); |
676 | 678 | } |
| 679 | + |
| 680 | + /** |
| 681 | + * Wait For Document Versions. |
| 682 | + * |
| 683 | + * @param client {@link ApiClient} |
| 684 | + * @param siteId {@link String} |
| 685 | + * @param documentId {@link String} |
| 686 | + * @param expectedNumbeOfVersions int |
| 687 | + * @return {@link GetDocumentContentResponse} |
| 688 | + * @throws InterruptedException InterruptedException |
| 689 | + */ |
| 690 | + public static GetDocumentVersionsResponse waitForDocumentVersions(final ApiClient client, |
| 691 | + final String siteId, final String documentId, final int expectedNumbeOfVersions) |
| 692 | + throws InterruptedException { |
| 693 | + |
| 694 | + DocumentVersionsApi api = new DocumentVersionsApi(client); |
| 695 | + |
| 696 | + while (true) { |
| 697 | + |
| 698 | + try { |
| 699 | + GetDocumentVersionsResponse response = |
| 700 | + api.getDocumentVersions(documentId, siteId, "100", null, null); |
| 701 | + if (response.getDocuments().size() == expectedNumbeOfVersions) { |
| 702 | + return response; |
| 703 | + } |
| 704 | + |
| 705 | + } catch (ApiException e) { |
| 706 | + // ignore error |
| 707 | + } |
| 708 | + |
| 709 | + TimeUnit.SECONDS.sleep(1); |
| 710 | + } |
| 711 | + } |
677 | 712 | } |
0 commit comments