Moving an entity

Use the update(DataGraph) method to change the location of an entity.

Use the update function to move an entity to a new location in the WebSphere Identity Manager hierarchy. This example shows how to move (change the parent container) for Person A from cn=users,dc=yourco,dc=com to ou=OrgUnitA,o=OrgA,cn=users,dc=yourco,dc=com.

To move Person A from cn=users,dc=yourco,dc=com to ou=OrgUnitA,o=OrgA,cn=users,dc=yourco,dc=com, add this code to you application code:
try
		{
			//Gets an empty data graph of Person from WIM Service.
			DataGraph dg = service.getEmptyDataGraph();

			DataObject root = dg.getRootObject().getDataObject(Service.ROOT);
			DataObject person = root.createDataObject(Service.ENTITIES, Service.WIM_NS_URI, 
Service.PERSON);
			person.createDataObject(Service.IDENTIFIER).setString(Service.UNIQUENAME, 
"uid=persona,cn=users,dc=yourco,dc=com");
			//
			person.createDataObject("parent").createDataObject(Service.IDENTIFIER).setString(Service.UNIQUENAME, 
getOrgDN"ou=OrgUnitA,o=OrgA,cn=users,dc=yourco,dc=com");
			SDOUtils.printDataGraph(INPUT_DATAGRAPH, dg);
			dg  = service.update(dg);
			SDOUtils.printDataGraph(OUTPUT_DATAGRAPH, dg);

			System.out.println("CLIENT: Person A has been moved to new locaiton: " + 
printIdentifier(dg.getRootObject().getDataObject(Service.ROOT).getDataObject("entities.0")) + "\n");
		}
		catch(Exception e)
		{
			printException(e);
		}
Replace the variables with the actual values that you want to use for this request.
This call generates the input data graph. For this particular example the data graph is:
Input DataGraph ->
<?xml version="1.0" encoding="UTF-8"?>
<sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:sdo="commonj.sdo" xmlns:wim="http://www.ibm.com/websphere/wim">
  <wim:Root>
    <wim:entities xsi:type="wim:Person">
      <wim:identifier uniqueName="uid=persona,cn=users,dc=yourco,dc=com"/>
      <wim:parent>
        <wim:identifier uniqueName="ou=OrgUnitA,o=OrgA,cn=users,dc=yourco,dc=com"/>
      </wim:parent>
    </wim:entities>
  </wim:Root>
</sdo:datagraph>
The resulting output data graph for this example is:
<?xml version="1.0" encoding="UTF-8"?>
<sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo"
    xmlns:wim="http://www.ibm.com/websphere/wim">
  <changeSummary/>
  <wim:Root validated="false">
    <wim:entities xsi:type="wim:Person">
      <wim:identifier uniqueName="uid=persona,ou=OrgUnitA,o=OrgA,cn=users,dc=yourco,dc=com"/>
      <wim:parent>
        <wim:identifier uniqueName="ou=OrgUnitA,o=OrgA,cn=users,dc=yourco,dc=com"/>
      </wim:parent>
    </wim:entities>
  </wim:Root>
</sdo:datagraph>
Related reference
update method
Terms of use | Feedback
(C) Copyright IBM Corporation 2005. All Rights Reserved.
IBM virtual member manager 6.1