Sample Reader Inbound Connectors

Configuring Synchronization with a Third-Party Directory 17-23 return Object the header part of the changes read. public Object getNextChange throws ODIException { try { if mEnumerate.hasMoreElements { mResult = SearchResultmEnumerate.nextElement; mAttribs = mResult.getAttributes; } catch Exception e BEGIN INFEASIBLE { throw new ODIException ODIException.LDAP_GETNEXT_EXCEPTION, e; } END INFEASIBLE return mAttribs; } Create the change record from the data read from the file. returns ChangeRecord public ChangeRecord createChangeRecordString dn throws ODIException { Create the changerecord based on the mAttribs which contains all the attributes. } public String initAvailableChgKey throws ODIException { set the available changekey value. This reads the value equivalent to the latest changelog number in the ldap world. } }

17.4.2 Outbound Connectors

Perform the following steps to write an outbound connector: 1. Implement the Writer. The Writer generally extends the target system connector class and implements the DISWriteInterface. The different methods of the DISWriteInterface are specified in its the javadoc. Refer to Sample Writer to see an example Reader implementation. 2. Create a sample config file. The following is a typical config file: [INTERFACEDETAILS] Reader: Complete_classname_including_packageName 17-24 Oracle Fusion Middleware Administrators Guide for Oracle Directory Integration Platform SkipErrorToSyncNextChange: false SearchDeltaSize: 500 UpdateSearchCount: 100 3. Create a mapfile containing a set of mapping rules. 4. Create a properties file by setting the configfile, mapfile, and filter parameters. To test the outbound connector: 1. Create a test profile using the register operation of the manageSyncProfiles command. Refer to Managing Synchronization Profiles Using manageSyncProfiles on page 7-15 for more information. 2. Verify your logging messages. 3. Verify synchronization occurred by examining Oracle Internet Directory to see if the appropriate entries were created.

17.4.2.1 Sample Writer

import oracle.ldap.odip.engine.AttrHandler; import oracle.ldap.odip.engine.ChangeRecord; import oracle.ldap.odip.engine.ConfigReader; import oracle.ldap.odip.engine.Connector; import oracle.ldap.odip.engine.Constants; import oracle.ldap.odip.engine.DISWriteInterface; import oracle.ldap.odip.engine.ODIException; import oracle.ldap.odip.map.MapRules; import oracle.ldap.odip.util.Utils; import oracle.core.ojdl.logging.ODLLogger; import oracle.core.ojdl.logging.ODLLevel; import oracle.core.ojdl.logging.ODLHandler; import java.util.logging.Handler; import java.util.logging.Level; import oracle.ldap.odip.DIPLogger; public class SampleWriter implements DISWriteInterface { protected Hashtable mProfile; protected int mErrorCode = 0; protected String mLastKeyValue; protected String mLastWrittenKey; protected Vector mWriteFilter = new Vector; protected MapRules mMapRules; protected String mNamingContext = ; private String mOrigDstDn = ; protected boolean mHandleModAsAdd = false; Constructor public LDAPWriter { } public LDAPWriterConnector conn { superconn; } Configuring Synchronization with a Third-Party Directory 17-25 public void initialiseConnector conn, Hashtable pHash throws ODIException { m_logger.finestEntry: LDAPWriter.initialise; setValuesconn; mProfile = pHash; mMapRules = MapRules pHash.getConstants.MAPRULE_STR; connect; ConfigReader configInfo = ConfigReader pHash.getConstants.CONFINFO_STR; if configInfo = null { mSearchDelta = configInfo.getSearchDeltaSize; mHandleModAsAdd = configInfo.getHandleModAsAdd; } mLastWrittenKey = String pHash.getConstants.READERCHANGEKEY_STR; pHash.putWRITECONTEXT, mLdapCtx; NamingEnumeration filter = NamingEnumeration pHash.getWriteFilter; try { while filter.hasMoreElements { mWriteFilter.addString filter.next; } } catch Exception ex { System.out.printlnError in initializing filter; } Get the lastapplied changekey value from the profile and use that string to determine the lastappliedchangenum or lastappliedchangetime to be stored as the lastkeyvalue Each of the insertmodifydelete routines, if the operation is successful, that lastkeyvalue is updated correspondingly. Otherwise it has the previous successful operation value m_logger.finest Exit: LDAPWriter.initialise ; } public void setChangesChangeRecord chgrec { mChanges = chgrec; } public ChangeRecord getChanges { return mChanges; } public String getLastChangeKey { return mLastKeyValue; } public int writeChanges throws ODIException { m_logger.finestEntry: LDAPWriter.writeChanges; mErrorCode = 0; m_logger.logODLLevel.FINE, \n Output ChangeRecord + mChanges.toString; 17-26 Oracle Fusion Middleware Administrators Guide for Oracle Directory Integration Platform String dn = mChanges.getChangeKey; if mHandleModAsAdd mChanges.getChangeType == Constants.CHGTYPE_ MODIFY { try { mLdapCtx.getAttributes mChanges.getChangeKey ; } catch NameNotFoundException nnfe { m_logger.logODLLevel.ERROR,ERROR_DN_CONN_DIR; mChanges.setChangeTypeConstants.CHGTYPE_MODRADD; } catch NamingException ne { m_logger.logODLLevel.ERROR,LDAP_WNAMING_EXCEPTION , ne; } } m_logger.logODLLevel.FINE, Changetype is + mChanges.getChangeType; mChanges.setChangeKeyndn; if dn.length 1 { testnewdn; switch mChanges.getChangeType { case Constants.CHGTYPE_ADD: if mChanges.size 0 { insert; } break; case Constants.CHGTYPE_MODIFY: non-changelog-based changes if mChanges.size 0 { modify; } else { mErrorCode = -1; } break; case Constants.CHGTYPE_DELETE: delete; break; case Constants.CHGTYPE_MODRADD: non-changelog-based changes if mChanges.size 0 { modifyRadd; } break; case Constants.CHGTYPE_MODRDN: modRDNchangelogdn; Configuring Synchronization with a Third-Party Directory 17-27 break; case Constants.CHGTYPE_MODDN: m_logger.logODLLevel.FINE, Processing moddn; modDNchangelogdn; break; default: INFEASIBLE break; } } else BEGIN INFEASIBLE { m_logger.logODLLevel.ERROR, ENTRY_NOT_EXISTS_DELETE; m_logger.logODLLevel.FINE, Synchrozing a deletion, entry to delete is not found. Ignore.; mErrorCode = 99; return mErrorCode; } END INFEASIBLE Object chgInfo = mChanges.getChangeInfo; try { if chgInfo instanceof Attributes { Attributes attrs = Attributes chgInfo; mLastKeyValue = String Attribute attrs.getmLastWrittenKey.get; } } catch Exception ex { System.out.printlnCaught the exception here + mErrorCode; if mErrorCode = 0 { m_logger.logODLLevel.ERROR, EXCEPTION_FOR_DN, new Object [] { dn, new Integer mErrorCode , ex.toString}; } } mChanges.setChangeKeymOrigDstDn; return mErrorCode; } public void insert throws ODIException { m_logger.finestEntry: LDAPWriter.insert; String dn = mChanges.getChangeKey; Enumeration attrdtls = mChanges.getAll; m_logger.logODLLevel.FINE, Processing Insert Operation ..; while attrdtls.hasMoreElements { AttrHandler temp = AttrHandler attrdtls.nextElement; attr = attrHandlerToAttrAttrHandler temp; if attr = null temp.getAttrChgType = Constants.ATTRCHGTYPE_ DELETE { 17-28 Oracle Fusion Middleware Administrators Guide for Oracle Directory Integration Platform attrs.putattr; } } createEntrydn, attrs; m_logger.finestExit: LDAPWriter.insert; } public void modify throws ODIException { m_logger.finestEntry: LDAPWriter.modify; String attrname = mChanges.getChangeKey; m_logger.logODLLevel.FINE, Processing Modify Operation ..; int pos = attrname.indexOf=; String naming = null; if pos 0 { naming = attrname.substring0, pos.trim; } } Delete the entry public void delete { m_logger.finestEntry: LDAPWriter.delete; try { m_logger.logODLLevel.FINE, Processing Delete Operation ..; } Handle the ModRDN operation throws ODIException protected void modDNchangelogString newDn throws ODIException { String newDN = null; m_logger.logODLLevel.FINE, Processing change log based ModRDN operation .. + DN passed in: + newDn; String dn = mChanges.getChangeKey; } Handle the ModRDN operation throws ODIException protected void modRDNchangelogString newDn throws ODIException { }