Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Policy update Java exception

Avatar

Level 1

I'm getting this exception when trying update a Policy.

                //Get ServiceClientFactory
          ServiceClientFactory myFactory = getServiceClientFactory();
               
          // Create an RightsManagementClient object
          RightsManagementClient rightsClient = new RightsManagementClient(myFactory);
          
          // Create an DirectoryManager object
          DirectoryManager dirManager = new DirectoryManagerServiceClient(myFactory);
               
          
          //Create a policy manager instance
             PolicyManager policyManager = rightsClient.getPolicyManager();
        
             //Retrieve an existing policy
             Policy myPolicy = policyManager.getPolicy(da.getProduct().getPolicySet(),da.getProduct().getPolicyName());
            
            
             //     Grab the Principal (aka User)
             Principal p = retrievePrincipal(da.getCustomer().getEmail(), dirManager);
            
            
             logger.info("Policy grabbed");
            
             List<PolicyEntryImpl> policyEntries = myPolicy.getPolicyEntries();
     
             for(PolicyEntryImpl pe : policyEntries){
                  
                  Principal pep = pe.getPrincipal();
                  if(p.getOid().equals(pep.getCanonicalName())){
                       myPolicy.removePolicyEntry(pe);
                       logger.info("Policy removed");
                  }
                  
                  
             }
            
            
             //Update the policy
             policyManager.updatePolicy(myPolicy);

0 Replies