- Mark as New
- Follow
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report
Is it possible to add a Policy to a document stored in the Repository? I've been trying to do this but it does not seen to work. This is what I am doing:
- Retrieve from Repository the Resource containing the Document.
- Extract Document from Resource.
- Apply Policy to the Document.
- Update Resource
Up to this point all works without any problem. However, if a now retrieve the Resource and check the Policy of its Document I get the following exception: SDKException: getRMLicenseID: document has no license or invalid Rights Management encryption -- (error code bin: 774, hex: 0x306) -- Invalid argument(error code bin: 1281, hex: 0x501).
The following is a self-contained program that replicates the problem:
package lctest;
import com.adobe.edc.sdk.SDKException;
import com.adobe.idp.Document;
import com.adobe.repository.RepositoryException;
import java.util.*;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.livecycle.rightsmanagement.RMInspectResult;
import com.adobe.livecycle.rightsmanagement.RMSecureDocumentResult;
import com.adobe.livecycle.rightsmanagement.client.*;
import com.adobe.livecycle.rightsmanagement.client.infomodel.*;
import com.adobe.repository.bindings.dsc.client.ResourceRepositoryClient;
import com.adobe.repository.infomodel.bean.Resource;
public class RepositoryPolicies
{
public static void main(String[] args)
{
try
{
String username = "iftdocs";
String password = "password";
String policySet= "docmgt";
String path = "/IFT Documents/DocManager/Environment/yabby_traps_kill_platypus.pdf";
//Set connection properties required to invoke LiveCycle ES2
Properties connectionProps = new Properties();
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://ift-3:1200");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL, ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, username);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, password);
// Create the service client factory
ServiceClientFactory scFactory = ServiceClientFactory.createInstance(connectionProps);
//Create a RightsManagementClient object
RightsManagementClient rightsClient = new RightsManagementClient(scFactory);
// Create a ResourceRepositoryClient object using the service client factory
ResourceRepositoryClient repositoryClient = new ResourceRepositoryClient(scFactory);
//Create a Document Manager object
DocumentManager documentManager = rightsClient.getDocumentManager();
// Retrieve the resource
Resource r = repositoryClient.readResource(path);
// Retrieve Document
Document d = r.getContent().getDataDocument();
PolicySearchFilter pf = new PolicySearchFilter();
pf.setPolicySetName(policySet);
pf.setName("View");
pf.setType(Policy.ORGANIZATIONAL_POLICY);
PolicyManager policyManager = rightsClient.getPolicyManager();
Policy[] policies = policyManager.getPolicies(pf,100);
Policy lcPolicy = policies[0];
System.out.println("--- Apply Policy: "+lcPolicy.getName());
RMSecureDocumentResult protectDoc =
documentManager.protectDocument(d,"yabby_traps_kill_platypus.pdf",
policySet,lcPolicy.getName(),
null,null,null);
System.out.println("---Policy Applied---------------");
r.getContent().setDataDocument(d);
repositoryClient.updateResource(r.getPath(),r,false);
System.out.println("---Resource Updated---------------");
// Retrieve the resource
r = repositoryClient.readResource(path);
// Retrieve Document
d = r.getContent().getDataDocument();
// Retrieve Policy
RMInspectResult inspectResult = documentManager.inspectDocument(d);
//Get the name of the policy
System.out.println("Policy Set: "+inspectResult.getPolicySetName());
System.out.println("Policy Name: "+inspectResult.getPolicyName());
}
catch (RepositoryException ex)
{
System.out.println("RepositoryException: "+ex.getMessage());
}
catch (SDKException ex)
{
System.out.println("SDKException: "+ex.getMessage());
}
}
}
Views
Replies
Total Likes