public void createPolicy(String policy_url) throws GovernanceException {
   PolicyManager policyManager = new PolicyManager(governance);
   Policy policy = null;
   try {
     policy = policyManager.newPolicy(policy_url);
     policy.addAttribute("creator", "Aaaa");
     policy.addAttribute("version", "1.0.0");
     policyManager.addPolicy(policy);
   } catch (GovernanceException e) {
     log.error("Failed to add Policy:" + e);
     throw new GovernanceException("Failed to add Policy :" + e);
   }
 }
 private void addPolicy() throws RegistryException, IOException {
   PolicyManager policyManager = new PolicyManager(governance);
   String policyFilePath =
       ProductConstant.getResourceLocations(ProductConstant.GREG_SERVER_NAME)
           + File.separator
           + "policy"
           + File.separator;
   Policy policy =
       policyManager.newPolicy(
           FileManager.readFile(policyFilePath + "UTPolicy.xml").getBytes(), "UTPolicy.xml");
   policyManager.addPolicy(policy);
   policy = policyManager.getPolicy(policy.getId());
   Resource resource = governance.get(policy.getPath());
   resource.addProperty("abcxyzpqr", "40");
   governance.put(policy.getPath(), resource);
 }
  /** tags verification */
  @Test(groups = "wso2.greg", description = "tags verification")
  public void testAddPolicy()
      throws RemoteException, ResourceAdminServiceExceptionException, GovernanceException,
          MalformedURLException {

    policy =
        policyManager.newPolicy(
            "https://svn.wso2.org/repos/wso2/carbon/platform/trunk/"
                + "platform-integration/platform-automated-test-suite/"
                + "org.wso2.carbon.automation.test.repo/src/main/"
                + "resources/artifacts/GREG/policy/policy.xml");

    policy.addAttribute("version", "1.0.0");
    policy.addAttribute("author", "Aparna");
    policy.addAttribute("description", "added policy using url");
    policyManager.addPolicy(policy);

    assertFalse(policy.getId().isEmpty());
    assertNotNull(policy);
    assertTrue(policy.getAttribute("author").contentEquals("Aparna"));
  }