エンティティーの削除

delete (DataObject) メソッドと DeleteControl を使用すれば、エンティティーを除去できます。

このタスクについて

次に、OrgContainer Sales の階層構造を示します。
  • dc=yourco,dc=com
    • cn=users
      • o=Sales
        • ou=CA
          • uid=SalesPerson1
          • uid=SalesPeson2
        • ou=US
          • uid=SalesPerson3
          • uid=SalesPeson4

この例では、OrgContainer Sales とその子孫をリポジトリーから除去します。

エンティティー OrgContainer Sales とその子孫をデータ・リポジトリーから除去するには、 このサンプル・コードをアプリケーション・コードに追加し、変数 をこの要求のために使用する実際の値で置き換えます。
DataObject root = SDOHelper.createRootDataObject();
DataObject entity = SDOHelper.createEntityDataObject(root, null, DO_ENTITY);
DataObject ctrl = SDOHelper.createControlDataObject(root, null, DO_DELETE_CONTROL);
ctrl.setBoolean(PROP_DELETE_DESCENDANTS, true);
ctrl.setBoolean(PROP_RETURN_DELETED, true);
			
				
entity.createDataObject(DO_IDENTIFIER).set(PROP_UNIQUE_NAME, 
                               "o=Sales,cn=users,dc=yourco,dc=com");
	root  = service.delete(root);

入出力データ・グラフのサンプル

この例では、入力データ・グラフは次のようになります。
<?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>
      <wim:identifier uniqueName="o=Sales,cn=users,dc=yourco,dc=com"/>
    </wim:entities>
    <wim:controls xsi:type="wim:DeleteControl" deleteDescendants="true" returnDeleted="true"/> 

  </wim:Root>
</sdo: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:PersonAccount">
      <wim:identifier externalName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"
                      repositoryId="LDAP1" 
                      uniqueId="e7db8c0e-d2b3-43fe-be14-1475125606f4" 
                      uniqueName="uid=SalesPerson1,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
    </wim:entities>
    <wim:entities xsi:type="wim:PersonAccount">
      <wim:identifier externalName="uid=SalesPerson2,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"
                      repositoryId="LDAP1" 
                      uniqueId="a3f9e8a1-117a-4252-840f-6d0cb079a7fb" 
                      uniqueName="uid=SalesPerson2,ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
    </wim:entities>
    <wim:entities xsi:type="wim:OrgContainer">
      <wim:identifier externalName="ou=CA,o=Sales,cn=users,dc=yourco,dc=com" 
                      repositoryId="LDAP1"
                      uniqueId="0dfcccf7-9fb9-4b25-a0f4-ff4b6b33068e" 
                      uniqueName="ou=CA,o=Sales,cn=users,dc=yourco,dc=com"/>
    </wim:entities>
    <wim:entities xsi:type="wim:PersonAccount">
      <wim:identifier externalName="uid=SalesPerson4,ou=US,o=Sales,cn=users,dc=yourco,dc=com"
                      repositoryId="LDAP1" 
                      uniqueId="a2d1be42-212e-44f0-8396-0bfc2d7d346d" 
                      uniqueName="uid=SalesPerson4,ou=US,o=Sales,cn=users,dc=yourco,dc=com"/>
    </wim:entities>
    <wim:entities xsi:type="wim:PersonAccount">
      <wim:identifier externalName="uid=SalesPerson3,ou=US,o=Sales,cn=users,dc=yourco,dc=com"
                      repositoryId="LDAP1" 
                      uniqueId="13ae346f-1e4c-40cd-8896-1c7f0b2b3079" 
                      uniqueName="uid=SalesPerson3,ou=US,o=Sales,cn=users,dc=yourco,dc=com"/>
    </wim:entities>
    <wim:entities xsi:type="wim:OrgContainer">
      <wim:identifier externalName="ou=US,o=Sales,cn=users,dc=yourco,dc=com" 
                      repositoryId="LDAP1"
                      uniqueId="70dd624d-6eb0-4fdf-8338-3ae4090b1c6f" 
                      uniqueName="ou=US,o=Sales,cn=users,dc=yourco,dc=com"/>
    </wim:entities>
    <wim:entities xsi:type="wim:OrgContainer">
      <wim:identifier externalName="o=Sales,cn=users,dc=yourco,dc=com" 
                      repositoryId="LDAP1"
                      uniqueId="eab85abb-9d29-40f1-b502-36c051d3ee96" 
                      uniqueName="o=Sales,cn=users,dc=yourco,dc=com"/>
    </wim:entities>
  </wim:Root>
</sdo:datagraph>
OrgContainer Sales が削除されます。同様に、その子孫 OrganizationUnits CA および US と、その子 SalesPerson1、SalesPerson2、SalesPerson3、および SalesPerson4 も削除されます。

エンドツーエンド・サンプル・コードについては、「ユーザー、グループ、グループ・メンバー、およびグループ・メンバーシップを操作するためのサンプル・コード」トピックを参照してください。



利用条件 | フィードバック