1 Reply Latest reply on May 26, 2015 7:46 AM by shawkins

    adding data roles dynamically to VDB using java

    sridhar_reddy

      I am trying to add data roles dynamically to a vdb(update .xml file vdb) using java. Here is the sample code

       

      Admin admin = AdminFactory.getInstance().createAdmin("localhost", 10000, "admin", "admin".toCharArray());

       

       

      List<DataPolicy> policyList = vdb.getDataPolicies();

       

      for(DataPolicy dp:policyList){

      List<String> mrole = dp.getMappedRoleNames(); 

      List<DataPermission> dperm = dp.getPermissions();

      System.out.println("data policy roles details: "+mrole.toString());

      for(DataPermission pmi:dperm){

          System.out.println("resouse name: "+pmi.getResourceName());

          System.out.println("resouse getAllowCreate: "+pmi.getAllowCreate());

          System.out.println("resouse getAllowRead: "+pmi.getAllowRead());

          System.out.println("resouse getAllowRead: "+pmi.getAllowRead());

          System.out.println("resouse getAllowRead: "+pmi.getAllowRead());

       

       

      }

       

      DataPolicyMetadata roleOne = new DataPolicyMetadata();

      roleOne.setName("testrole");

      roleOne.setDescription("testOne described");

      PermissionMetaData perm1 = new PermissionMetaData();

      perm1.setResourceName("testModel.log");

      perm1.setAllowRead(true);

      roleOne.addPermission(perm1);

      roleOne.setMappedRoleNames(Arrays.asList("test_user_role"));

       

      VDBMetaData vdbMeta = (VDBMetaData)vdb;

      vdbMeta.addDataPolicy(roleOne);

       

      //print the resource names again

       

       

      With this code I am able to see new resource name being added and re displayed in the log file. But it is not updating the xml file in VDB.


      Actual requirement is "allow users to add new roles which can be used accessing and constraining the VDB".