Expand my Community achievements bar.

IllegalStateException when calling applyUsageRights

Avatar

Former Community Member
Hi,



I'm trying to apply usage rights to a pdf document using a ReaderExtensionsServiceClient object.

When I call applyUsageRights() I get an exception:



----------------------------------------------------------------------

java.lang.IllegalStateException

at com.adobe.idp.dsc.clientsdk.ServiceClientFactory$1.handleThrowable(ServiceClientFactory.java:68)

at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:220)

at com.adobe.livecycle.readerextensions.client.ReaderExtensionsServiceClient.invoke(ReaderExtensionsServiceClient.java:61)

at com.adobe.livecycle.readerextensions.client.ReaderExtensionsServiceClient.applyUsageRights(ReaderExtensionsServiceClient.java:97)

at com.cegedim.acrs.d2r2.document.util.ReaderExtensionClient.applyRights(ReaderExtensionClient.java:75)

at com.cegedim.acrs.d2r2.document.test.ReaderExtensionClientTest.testReaderExtensionClient(ReaderExtensionClientTest.java:46)

----------------------------------------------------------------------



The source file is the following:



----------------------------------------------------------------------



import com.adobe.idp.Document;

import com.adobe.idp.dsc.DSCException;

import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;

import com.adobe.livecycle.readerextensions.client.ReaderExtensionsOptionSpec;

import com.adobe.livecycle.readerextensions.client.ReaderExtensionsServiceClient;

import com.adobe.livecycle.readerextensions.client.UsageRights;

import com.adobe.livecycle.readerextensions.client.exceptions.ReaderExtensionsException;

import com.cegedim.acrs.d2r2.document.DocumentException;

import java.io.File;

import java.io.FileInputStream;

import java.io.InputStream;

import java.util.Properties;

import java.util.logging.Level;



public class ReaderExtensionClient {

private ReaderExtensionsServiceClient reClient;

private ReaderExtensionsOptionSpec reOptions;



public ReaderExtensionClient() {

Properties connectionProps = new Properties();



connectionProps.setProperty("DSC_DEFAULT_SOAP_ENDPOINT", PropertiesLoader.getValue("DSC_DEFAULT_SOAP_ENDPOINT"));

connectionProps.setProperty("DSC_TRANSPORT_PROTOCOL", PropertiesLoader.getValue("DSC_TRANSPORT_PROTOCOL"));

connectionProps.setProperty("DSC_SERVER_TYPE", PropertiesLoader.getValue("DSC_SERVER_TYPE"));

connectionProps.setProperty("DSC_CREDENTIAL_USERNAME", PropertiesLoader.getValue("DSC_CREDENTIAL_USERNAME"));

connectionProps.setProperty("DSC_CREDENTIAL_PASSWORD", PropertiesLoader.getValue("DSC_CREDENTIAL_PASSWORD"));

ServiceClientFactory serviceClientFactory = ServiceClientFactory.createInstance(connectionProps);



reClient = new ReaderExtensionsServiceClient(serviceClientFactory);



//Create a UsageRight object and specify specific usage rights

UsageRights useRight = new UsageRights();

useRight.setEnabledDynamicFormFields(true);

useRight.setEnabledFormDataImportExport(true);

useRight.setEnabledFormFillIn(true);

useRight.setEnabledOnlineForms(true);

useRight.setEnabledSubmitStandalone(true);



//Create a ReaderExtensionsOptions object

reOptions = new ReaderExtensionsOptionSpec();

reOptions.setUsageRights(useRight);

reOptions.setMessage("This is a Rights-Enabled PDF Document");

}



public InputStream applyRights(InputStream is) {

InputStream result = null;

try {

//Retrieve the PDF document to which to apply usage rights

Document inputPDF = new Document(is);

//Apply usage rights to a PDF document

Document rightsEnabledPDF = reClient.applyUsageRights(inputPDF, "RE2", null, reOptions);

//

result = rightsEnabledPDF.getInputStream();

} catch (Exception ex) {

}

return result;
1 Reply

Avatar

Level 4
I see there is a null value being passed as the credential password, I may be wrong but I thought all the credentials Adobe supplied were encrypted. Also "RE2" doesn't sound like a valid credential name (all the ones I've seen started 000).



I always try to call getCredentialUsageRights before I make a call to Reader Extensions to detect whether the credential exists and whether it has the permissions I need to set. Have you tried calling this method with the credential name and password to see what comes back?