Pages

Sunday, July 1, 2012

tcITResourceInstanceOperationsIntf API example

The tcITResourceInstanceOperationsIntf inteface API being used to add, update, and delete the ITnResource Instance from the Oracle Identity Manager repository.

Pre-Requisite:

Initial Setup.

Please follow the link and setup the OIM client environment to use to create the OIM Objects.


Client Code Setup

tcITResourceInstanceOperationsIntf API Usage:

The following tasks needs to be performed to add, update, and delete the IT Resource Instance from Oracle Identity Manager. They are

1.    Create the OIMClient Handle


OIMClient client= new OIMClient();
client.login(username,password.toCharArray());

2.    Get tcITResourceInstanceOperationsIntf service object


tcITResourceInstanceOperationsIntf itResource = client.getService(tcITResourceInstanceOperationsIntf.class);

3.    Find the It Resource Instance Key

String itResourceName = "ADITResource"
Map filter= new HashMap();
filter.put("IT Resources.Name","IT Resource Name");
tcResultSet trs=itResource.findItResourceInstances(filter);
int rowCount=trs.getRowCount();
long itResourceKey=-1
if(rowCount >0)
{
    trs.goToRow(0);
    itResourceKey = trs.getLongValue("IT Resource.Key");
}

4.    Getting IT Resource Attributes

Map attributes= new HashMap();
If(itResourceKey >0)
{
tcResultSet itrParams=itResource.getITResourceInstanceParameters(itResourceInstanceKey);
int paramCount= itrParams.getRowCount();
 for(int i=0;i<paramCount;i++)
 {
        itrParams.goToRow(i);
        attributes.put itrParams.getStringValue("IT Resources Type Parameter.Name"),itrParams.getLongValue("IT Resource.Parameter.Key"));
}

5.    Updating the IT Resource Instance Attribute



If(attributes.ContainsKey("Admin FQDN"))
{
Map<String, String> updateattributes= new HashMap<String, String>();
updateattributes.put("Admin FQDN","test@test.com");
itResource.updateITResourceInstanceParameters(itResourceKey,  updateAttributes);
}

6.    Getting the tcITResourceDefinitionOperationsIntf Service Handle


tcITResourceDefinitionOperationsIntf  itresdef= client.getService(tcITResourceDefinitionOperationsIntf.class);

7.    Getting the IT Resource Type Key


Map itRtypemap= new HashMap();
itRtypemap.put("IT Resources Type Definition.Server Type","AD Server");
long itresourceTypeKey= -1;
tcResultSet  itrestypers=itresdef. getITResourceDefinition(itRtypemap);
int typecount= itrestypers.getRowCount();
if(typecount >0)
{
    Itrestypers.goToRow(0);
itresourceTypeKey= itrestypers.getLongValue("IT Resources Type Definition.Key
");
}

8.    Adding the It Resource Instance

String itResourceName="AD Test Server";
Map addAttrs= new HashMap();
addAttrs.put("IT Resources Type Definition.Key",""+itresourceTypeKey);addAttrs.put("IT Resources.Name",itResourceName);

itResourceKey=itResource.createITResourceInstance(addAttrs);

9.    Updating the It Resource Instance Parameters

addAttrs.clear();

addAttrs.put("Admin FQDN ","test@test.com");
addAttrs.put("Admin FQDN ","abc123");

itResource.updateITResourceInstanceParameters(itResourceKey,addAttrs);

10.    Removing the It Resource Instance


If(itResourceKey >0)
{
    itResource. deleteITResourceInstance(itResourceKey);
}

No comments:

Post a Comment