UnsupportedOperationException when updating document visibility

0 votes
Hi team, One of our client is encountering an "java.lang.UnsupportedOperationException" error when trying to update document visibility for a package. See their code snippet below:
DocumentVisibilityBuilder documentVisibilityBuilder = DocumentVisibilityBuilder.
OneSpanHelpers.updateDocumentVisibility(documentVisibilityBuilder, eSignDocument.getDocGuid(), signerIds);
eslClient.configureDocumentVisibility(packageId, documentVisibilityBuilder.build()); 
Please share your input, thanks!

Reply to: UnsupportedOperationException when updating document visibility

0 votes
Hi there, As we discussed internally, this issue can be worked around by below code:
                   EslClient eslClient = new EslClient(API_KEY, API_URL);
                   DocumentVisibility documentVisibility = eslClient.getDocumentVisibility(new PackageId("NTrnQyLBKK5jwH1dyvGCqDcxZis="));

                   List configurations = documentVisibility.getConfigurations();
                   System.out.println("before: "+configurations.size());
                   com.silanis.esl.sdk.DocumentVisibility visibility = newDocumentVisibility().build();
                   for (DocumentVisibilityConfiguration documentVisibilityConfiguration : configurations) {
                   DocumentVisibilityConfiguration build = newDocumentVisibilityConfiguration("default-consent").withSignerIds(Arrays.asList("[email protected]")).build();
                   System.out.println("after: " + visibility.getConfigurations().size());
                   //update through eslClient
                   eslClient.configureDocumentVisibility(new PackageId("NTrnQyLBKK5jwH1dyvGCqDcxZis="), visibility);
To elaborate the cause of issue, we can start from below example:
import static com.google.common.collect.Lists.transform;

           ArrayList arrayList = new ArrayList(){{add("line1");add("line2");}};
           List arrayList2 = transform(arrayList, new Function() {
            public String apply(String oldString) {
                    return oldString+" - changed";
            arrayList2.add("try add");
This code snippet is very similar to the one in our SDK source code, which is used to transform API objects to SDK objects. And the transform function will return a list that doesn’t support “add” function. So if you ran this code, you will receive the same “java.lang.UnsupportedOperationException” exception. So in the real scenario, when client was trying to call .addConfiguration() function which internally call the list.add() function, it will yield the same error. Hope this could help! Duo

Duo Liang OneSpan Evangelism and Partner Integrations Developer

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off