Back to index

openldap  2.4.31
Public Member Functions | Static Public Member Functions | Private Attributes
LDAPEntriesHandler Class Reference

List of all members.

Public Member Functions

 LDAPEntriesHandler (TTXlaConnection &conn, const char *ownerP, const char *nameP)
 ~LDAPEntriesHandler ()
virtual void HandleDelete (ttXlaUpdateDesc_t *)
virtual void HandleInsert (ttXlaUpdateDesc_t *)
virtual void HandleUpdate (ttXlaUpdateDesc_t *)

Static Public Member Functions

static void ReverseAndUpper (char *dnP, int id, bool commit=true)

Private Attributes

int Id
int Dn
int Oc_map_id
int Parent
int Keyval
int Dn_ru

Detailed Description

Definition at line 33 of file dnreverse.cpp.


Constructor & Destructor Documentation

LDAPEntriesHandler::LDAPEntriesHandler ( TTXlaConnection &  conn,
const char *  ownerP,
const char *  nameP 
)

Definition at line 57 of file dnreverse.cpp.

                                                                          :
  TTXlaTableHandler(conn, ownerP, nameP)
{
  Id = Dn = Oc_map_id = Parent = Keyval = Dn_ru = -1;

  // We are looking for several particular named columns.  We need to get
  // the ordinal position of the columns by name for later use.

  Id = tbl.getColNumber("ID");
  if (Id < 0) {
    cerr << "target table has no 'ID' column" << endl;
    exit(1);
  }
  Dn = tbl.getColNumber("DN");
  if (Dn < 0) {
    cerr << "target table has no 'DN' column" << endl;
    exit(1);
  }
  Oc_map_id = tbl.getColNumber("OC_MAP_ID");
  if (Oc_map_id < 0) {
    cerr << "target table has no 'OC_MAP_ID' column" << endl;
    exit(1);
  }
  Parent = tbl.getColNumber("PARENT");
  if (Parent < 0) {
    cerr << "target table has no 'PARENT' column" << endl;
    exit(1);
  }
  Keyval = tbl.getColNumber("KEYVAL");
  if (Keyval < 0) {
    cerr << "target table has no 'KEYVAL' column" << endl;
    exit(1);
  }
  Dn_ru = tbl.getColNumber("DN_RU");
  if (Dn_ru < 0) {
    cerr << "target table has no 'DN_RU' column" << endl;
    exit(1);
  }

}

Definition at line 99 of file dnreverse.cpp.

{

}

Member Function Documentation

void LDAPEntriesHandler::HandleDelete ( ttXlaUpdateDesc_t *  p) [virtual]

Definition at line 189 of file dnreverse.cpp.

{    
  char* dnP; 

  row.Get(Dn, &dnP);
  cerr << "DN '" << dnP << "': Deleted ";
}
void LDAPEntriesHandler::HandleInsert ( ttXlaUpdateDesc_t *  p) [virtual]

Definition at line 148 of file dnreverse.cpp.

{
  char* dnP; 
  int   id;

  row.Get(Dn, &dnP);
  cerr << "DN '" << dnP << "': Inserted ";
  row.Get(Id, &id);

  ReverseAndUpper(dnP, id);

}

Here is the call graph for this function:

void LDAPEntriesHandler::HandleUpdate ( ttXlaUpdateDesc_t *  p) [virtual]

Definition at line 161 of file dnreverse.cpp.

{    
  char* newDnP; 
  char* oldDnP;
  char  oDn[512];
  int   id;

  // row is 'old'; row2 is 'new'
  row.Get(Dn, &oldDnP);
  strcpy(oDn, oldDnP);
  row.Get(Id, &id);
  row2.Get(Dn, &newDnP);
  
  cerr << "old DN '" << oDn << "' / new DN '" << newDnP << "' : Updated ";

  if (strcmp(oDn, newDnP) != 0) {  
    // The DN field changed, update it
    cerr << "(new DN: '" << newDnP << "')";
    ReverseAndUpper(newDnP, id);
  }
  else {
    // The DN field did NOT change, leave it alone
  }

  cerr << endl;

}

Here is the call graph for this function:

void LDAPEntriesHandler::ReverseAndUpper ( char *  dnP,
int  id,
bool  commit = true 
) [static]

Definition at line 104 of file dnreverse.cpp.

{
  TTStatus stat;
  char dn_rn[512];
  int i;
  int j;

  // Reverse and upper case the given DN

  for ((j=0, i = strlen(dnP)-1); i > -1; (j++, i--)) {
    dn_rn[j] = toupper(*(dnP+i));
  }
  dn_rn[j] = '\0';


  // Update the database

  try {
    assignDn_ru.setParam(1, (char*) &dn_rn[0]);
    assignDn_ru.setParam(2, id);
    assignDn_ru.Execute(stat);
  }
  catch (TTStatus stat) {
    cerr << "Error updating id " << id << " ('" << dnP << "' to '" 
        << dn_rn << "'): " << stat;
    exit(1);
  }

  // Commit the transaction
  
  if (commit) {
    try {
      conn2.Commit(stat);
    }
    catch (TTStatus stat) {
      cerr << "Error committing update: " << stat;
      exit(1);
    }
  }

}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 37 of file dnreverse.cpp.

Definition at line 41 of file dnreverse.cpp.

Definition at line 36 of file dnreverse.cpp.

Definition at line 40 of file dnreverse.cpp.

Definition at line 38 of file dnreverse.cpp.

Definition at line 39 of file dnreverse.cpp.


The documentation for this class was generated from the following file: