Ejemplo n.º 1
0
UtlContainable* UtlHashMapIterator::key() const
{
   UtlContainable* currentKey = NULL;
   
   UtlContainer::acquireIteratorConnectionLock();
   OsLock take(const_cast<OsBSem&>(mContainerRefLock));
   UtlHashMap* myHashMap = dynamic_cast<UtlHashMap*>(mpMyContainer);
   if (myHashMap)
   {
      OsLock container(myHashMap->mContainerLock);
      UtlContainer::releaseIteratorConnectionLock();

      if (   (mPosition < myHashMap->numberOfBuckets())
          && (mpCurrentPair)
          && (mPairIsValid)
          )
      {
         currentKey = mpCurrentPair->data;
      }
   }
   else
   {
      UtlContainer::releaseIteratorConnectionLock();
   }   

   return currentKey;
}
Ejemplo n.º 2
0
UtlContainable* UtlHashMapIterator::value() const
{
   UtlContainable* currentValue = NULL;
   
   UtlContainer::acquireIteratorConnectionLock();
   OsLock take(const_cast<OsBSem&>(mContainerRefLock));
   UtlHashMap* myHashMap = dynamic_cast<UtlHashMap*>(mpMyContainer);
   if (myHashMap)
   {
      OsLock container(myHashMap->mContainerLock);
      UtlContainer::releaseIteratorConnectionLock();

      if (   (mPosition < myHashMap->numberOfBuckets())
          && (mpCurrentPair)
          && (mPairIsValid)
          )
      {
         currentValue = (  mpCurrentPair->value != UtlHashMap::INTERNAL_NULL
                         ? mpCurrentPair->value
                         : NULL
                         );
      }
   }
   else
   {
      UtlContainer::releaseIteratorConnectionLock();
   }   

   return currentValue;
}
Ejemplo n.º 3
0
// Destructor
UtlHashMapIterator::~UtlHashMapIterator()
{
   UtlContainer::acquireIteratorConnectionLock();
   OsLock take(mContainerRefLock);
   UtlHashMap* myHashMap = dynamic_cast<UtlHashMap*>(mpMyContainer);
   if (myHashMap)
   {
      OsLock container(myHashMap->mContainerLock);
      UtlContainer::releaseIteratorConnectionLock();

      myHashMap->removeIterator(this);

      /*
       * A UtlHashMap cannot be resized when there is an iterator associated with it,
       * so it's possible that it has grown while this iterator existed and that it
       * needs to be resized.  Check for and do that now if needed.
       */
      myHashMap->resizeIfNeededAndSafe();

      mpMyContainer = NULL;
   }
   else
   {
      UtlContainer::releaseIteratorConnectionLock();
   }   
}
Ejemplo n.º 4
0
void XmlRpcResponse::cleanUp(UtlContainable* value)
{
   if (value)
   {
      if (value->isInstanceOf(UtlHashMap::TYPE))
      {
         UtlHashMap* map = dynamic_cast<UtlHashMap*>(value);
         UtlHashMapIterator iterator(*map);
         UtlString* key;
         while ((key = dynamic_cast<UtlString*>(iterator())))
         {
            UtlContainable *pName;
            UtlContainable *member;
            pName = map->removeKeyAndValue(key, member);
            delete pName;
            cleanUp(member);
         }
      }
      else if (value->isInstanceOf(UtlSList::TYPE))
      {
         UtlSList* array = dynamic_cast<UtlSList*>(value);
         UtlContainable *element;
         while ((element = array->get()/* pop */))
         {
            cleanUp(element);
         }
      }

      delete value;
   }
}
Ejemplo n.º 5
0
void
DialByNameDB::getContacts (
    const UtlString& digitString,
    ResultSet& rResultSet ) const
{
    // This should erase the contents of the existing resultset
    rResultSet.destroyAll();

    if ( !digitString.isNull() && (m_pFastDB != NULL) )
    {
        // Check the TableInfo table to see whether we need to reload
        // the Tables from the Credential/Permission tables
        SIPDBManager* pSIPDBManager = SIPDBManager::getInstance();
        if ( pSIPDBManager->getDatabaseChangedFlag( "credential" ) || 
             pSIPDBManager->getDatabaseChangedFlag( "permission" )  )
        {
            // Reload this IMDB and rese the changed flags 
            // in the credential and permission tables
            this->load();
        }

        // Thread Local Storage
        m_pFastDB->attach();

        // Search to see if we have a Credential Row
        dbCursor< DialByNameRow > cursor;

        dbQuery query;
        UtlString queryString = "np_digits like '" + digitString + "%'";
        query = queryString;
        if ( cursor.select(query) > 0 ) {
            do {
                UtlHashMap record;
                UtlString* np_identityValue = 
                    new UtlString ( cursor->np_identity );
                UtlString* np_contactValue = 
                    new UtlString ( cursor->np_contact );
                UtlString* np_digitsValue = 
                    new UtlString ( cursor->np_digits );

                // Memory Leak fixes, make shallow copies of static keys
                UtlString* np_identityKey = new UtlString( gNp_identityKey );
                UtlString* np_contactKey = new UtlString( gNp_contactKey );
                UtlString* np_digitsKey = new UtlString( gNp_digitsKey );

                record.insertKeyAndValue ( 
                    np_identityKey, np_identityValue );
                record.insertKeyAndValue ( 
                    np_contactKey, np_contactValue );
                record.insertKeyAndValue ( 
                    np_digitsKey, np_digitsValue );

                rResultSet.addValue(record);
            } while ( cursor.next() );
        }
        // Commit the rows to memory - multiprocess workaround
        m_pFastDB->detach(0);
    }
}
Ejemplo n.º 6
0
 void addPermission(ResultSet& permissions, const char* permissionValue)
    {
       UtlHashMap record;
       record.insertKeyAndValue(new UtlString("identity"),
                                new UtlString("dummy identity"));
       record.insertKeyAndValue(new UtlString("permission"),
                                new UtlString(permissionValue));
       permissions.addValue(record);
    }
Ejemplo n.º 7
0
UtlBoolean
ExtensionDB::insertRow (const UtlHashMap& nvPairs) 
{
    // Note we do not need the identity object here
    // as it is inferred from the uri
    return insertRow (
        Url( *((UtlString*)nvPairs.findValue(&gUriKey)) ),
        *((UtlString*)nvPairs.findValue(&gExtensionKey)) );
}
Ejemplo n.º 8
0
UtlBoolean
AliasDB::insertRow (const UtlHashMap& nvPairs)
{
    // Note we do not need the identity object here
    // as it is inferred from the uri
    UtlString identity, contact;
    identity = *((UtlString*)nvPairs.findValue(&gIdentityKey));
    contact = *((UtlString*)nvPairs.findValue(&gContactKey));
    return insertRow ( Url( identity ), Url( contact ) );
}
Ejemplo n.º 9
0
void
ResultSet::destroyAll()
{
    // the pRecord is actually a UtlHashMap
    UtlHashMap* pRecord;
    while ((pRecord = dynamic_cast<UtlHashMap*>(get())))
    {
        pRecord->destroyAll();
        delete pRecord;
    }
}
Ejemplo n.º 10
0
 void getResult( ResultSet& resultSet
                ,int         index
                ,const char* key
                ,UtlString&  result
                )
 {
    UtlHashMap hash;
    resultSet.getIndex( index, hash );
    UtlString theKey(key);
    result = *((UtlString*)hash.findValue(&theKey));
 }
Ejemplo n.º 11
0
void
DialByNameDB::getAllRows(ResultSet& rResultSet) const
{
    // Clear the results
    rResultSet.destroyAll();

    // Check the TableInfo table to see whether we need to reload
    // the Tables from the Credential/Permission tables
    if ( m_pFastDB != NULL )
    {
        SIPDBManager* pSIPDBManager = SIPDBManager::getInstance();
        if ( pSIPDBManager->getDatabaseChangedFlag( "credential" ) || 
             pSIPDBManager->getDatabaseChangedFlag( "permission" )  )
        {
            // Reload this IMDB and reset the changed flags 
            // in both the credential and permission tables
            this->load();
        }

        // Thread Local Storage
        m_pFastDB->attach();

        dbCursor< DialByNameRow > cursor;
        if ( cursor.select() > 0 )
        {
            do {
                UtlHashMap record;
                UtlString* np_identityValue = 
                    new UtlString ( cursor->np_identity );
                UtlString* np_contactValue = 
                    new UtlString ( cursor->np_contact );
                UtlString* np_digitsValue = 
                    new UtlString ( cursor->np_digits );

                // Memory Leak fixes, make shallow copies of static keys
                UtlString* np_identityKey = new UtlString( gNp_identityKey );
                UtlString* np_contactKey = new UtlString( gNp_contactKey );
                UtlString* np_digitsKey = new UtlString( gNp_digitsKey );

                record.insertKeyAndValue ( 
                    np_identityKey, np_identityValue );
                record.insertKeyAndValue ( 
                    np_contactKey, np_contactValue );
                record.insertKeyAndValue ( 
                    np_digitsKey, np_digitsValue );

                rResultSet.addValue(record);
            } while (cursor.next());
        }
        // Commit rows to memory - multiprocess workaround
        m_pFastDB->detach(0);
    }
}
Ejemplo n.º 12
0
UtlBoolean
CredentialDB::insertRow (const UtlHashMap& nvPairs)
{
    // Note: identity inferred from the uri
    return insertRow (
        Url (*((UtlString*)nvPairs.findValue(&gUriKey))),
        *((UtlString*)nvPairs.findValue(&gRealmKey)),
        *((UtlString*)nvPairs.findValue(&gUseridKey)),
        *((UtlString*)nvPairs.findValue(&gPasstokenKey)),
        *((UtlString*)nvPairs.findValue(&gPintokenKey)),
        *((UtlString*)nvPairs.findValue(&gAuthtypeKey)));
}
Ejemplo n.º 13
0
void
AliasDB::getAliases (
    const Url& contactIdentity,
    ResultSet& rResultSet ) const
{
    UtlString contactIdentityStr;
    contactIdentity.getIdentity(contactIdentityStr);

    // This should erase the contents of the existing resultset
    rResultSet.clear();

    if ( !contactIdentityStr.isNull() && (m_pFastDB != NULL) )
    {
        // Thread Local Storage
        m_pFastDB->attach();

        // Match a all rows where the contact identity matches
        UtlString queryString = "contact like '%" + contactIdentityStr + "%'";

        dbQuery query;
        query=queryString;

        // Search to see if we have a Credential Row
        dbCursor< AliasRow > cursor;

        if ( cursor.select(query) > 0 )
        {
            do {
                UtlHashMap record;
                UtlString* identityValue =
                    new UtlString ( cursor->identity );
                UtlString* contactValue =
                    new UtlString ( cursor->contact );

                // Memory Leak fixes, make shallow copies of static keys
                UtlString* identityKey = new UtlString( gIdentityKey );
                UtlString* contactKey = new UtlString( gContactKey );

                record.insertKeyAndValue (
                    identityKey, identityValue );
                record.insertKeyAndValue (
                    contactKey, contactValue );

                rResultSet.addValue(record);
            } while ( cursor.next() );
        }
        // Commit the rows to memory - multiprocess workaround
        m_pFastDB->detach(0);
    }
}
Ejemplo n.º 14
0
void
ResultSet::addValue( const UtlHashMap& record )
{
    UtlHashMap*     pNewRecord = new UtlHashMap() ;
    UtlContainable* pObj ;

    // Proceed with shallow copy
    UtlHashMapIterator itor(const_cast<UtlHashMap&>(record)) ;
    while ((pObj = (UtlContainable*) itor()) != NULL)
    {
        pNewRecord->insertKeyAndValue(itor.key(), itor.value()) ;
    }
    append(pNewRecord) ;
}
Ejemplo n.º 15
0
void
AliasDB::getContacts (
    const Url& identity,
    ResultSet& rResultSet ) const
{
    UtlString identityStr;
    identity.getIdentity(identityStr);

    // This should erase the contents from the resultset object
    rResultSet.clear();

    if ( !identityStr.isNull() && (m_pFastDB != NULL) )
    {
        // Thread Local Storage
        m_pFastDB->attach();

        dbQuery query;

        // Primary Key is the urialias's identity
        query="identity=",identityStr;

        // Search to see if we have a Credential Row
        dbCursor< AliasRow > cursor;

        if ( cursor.select(query) > 0 )
        {
            do {
                UtlHashMap record;
                UtlString* identityValue =
                    new UtlString ( cursor->identity );
                UtlString* contactValue =
                    new UtlString ( cursor->contact );

                // Memory Leak fixes, make shallow copies of static keys
                UtlString* identityKey = new UtlString( gIdentityKey );
                UtlString* contactKey = new UtlString( gContactKey );

                record.insertKeyAndValue (
                    identityKey, identityValue );
                record.insertKeyAndValue (
                    contactKey, contactValue );

                rResultSet.addValue(record);
            } while ( cursor.next() );
        }
        // Commit the rows to memory - multiprocess workaround
        m_pFastDB->detach(0);
    }
}
Ejemplo n.º 16
0
void requestGet(Url& url, UtlSList& names)
{
    XmlRpcRequest* request;
    XmlRpcResponse response;
    
    request = new XmlRpcRequest(url, "configurationParameter.get");
    request->addParam(&DataSet);        

    if (!names.isEmpty())
    {
        request->addParam(&names);
    }
      
    if (!request->execute(response/*, &pSocket*/))
    {
        exitFault(response);
    }
    else
    {
        UtlContainable* value;
        if (response.getResponse(value))
        {
            UtlHashMap* paramList = dynamic_cast<UtlHashMap*>(value);
            if (paramList)
            {
                UtlHashMapIterator params(*paramList);
                UtlString* name;
                while ((name = dynamic_cast<UtlString*>(params())))
                {
                    UtlString* value = dynamic_cast<UtlString*>(paramList->findValue(name));
                    printf("%s : %s\n", name->data(), value->data());
                }
            }
            else
            {
                fprintf(stderr, "Incorrect type returned.\n");
                exit(1);
            }
        }
        else
        {
            fprintf(stderr, "No value returned.\n");
            exit(1);
        }
    }    
    delete request;
    request = NULL;
}
Ejemplo n.º 17
0
UtlBoolean
DialByNameDB::insertRow ( const UtlHashMap& nvPairs ) const
{
    // Note we do not need the identity object here
    // as it is inferred from the uri
    return insertRow (
        Url( *((UtlString*)nvPairs.findValue(&gNp_contactKey)) ) );
}
Ejemplo n.º 18
0
OsStatus 
ResultSet::getIndex(
    const int& index, 
    UtlHashMap& rRecord) const
{
    // The record must be empty.  We can't clear the content because we don't own it.
    assert(rRecord.isEmpty());

    OsStatus result = OS_FAILED;
    UtlHashMap *m;
    if ((m = dynamic_cast<UtlHashMap*>(at(index))))
    {
        m->copyInto(rRecord);
        result = OS_SUCCESS;
    }
    return result;
}
Ejemplo n.º 19
0
void 
PermissionDB::getIdentities (
    const UtlString& permission,
    ResultSet& rResultSet ) const
{
    // This should erase the contents of the existing resultset
    rResultSet.destroyAll();

    if ( !permission.isNull() && (m_pFastDB != NULL) )
    {
        // Thread Local Storage
        m_pFastDB->attach();

        dbQuery query;

        // Primary Key is the uriPermission's identity
        query="permission=", permission;

        // Search to see if we have a Credential Row
        dbCursor< PermissionRow > cursor;

        if ( cursor.select(query) > 0 )
        {
            do {
                UtlHashMap record;
                UtlString* identityValue = 
                    new UtlString ( cursor->identity );
                UtlString* permissionValue = 
                    new UtlString ( cursor->permission );

                // Memory Leak fixes, make shallow copies of static keys
                UtlString* identityKey = new UtlString( gIdentityKey );
                UtlString* permissionKey = new UtlString( gPermissionKey );

                record.insertKeyAndValue ( 
                    identityKey, identityValue );
                record.insertKeyAndValue ( 
                    permissionKey, permissionValue );

                rResultSet.addValue(record);
            } while ( cursor.next() );
        }
        // Commit the rows to memory - multiprocess workaround
        m_pFastDB->detach(0);
    }
}
Ejemplo n.º 20
0
void UtlHashMap::copyInto(UtlHashMap& into) const
{
    UtlHashMapIterator i(*this);
    while (i() != NULL)
    {
       into.insertKeyAndValue(i.key(), i.value());
    }
}
Ejemplo n.º 21
0
void
RegistrationDB::insertRow(const UtlHashMap& nvPairs)
{
    // For integer values, default to 0 if the datum is missing in the input.

    UtlString* expStr = (UtlString*) nvPairs.findValue(&gExpiresKey);
    UtlString* cseqStr = (UtlString*) nvPairs.findValue(&gCseqKey);

    // If the IMDB does not specify a Q-Value, "%" will be found here
    // (representing a null IMDB column).
    UtlString* qvalue = (UtlString*) nvPairs.findValue(&gQvalueKey);

    UtlString* updateNumberStr = (UtlString*) nvPairs.findValue(&gUpdateNumberKey);
    // Note that updateNumberStr is likely to start with 0x, so we
    // need the full functionality of strtoll here, not just a
    // decimal-to-binary conversion.  But strtoll is in C99, so it
    // should be OK.
    Int64 updateNumber = 
       updateNumberStr ? strtoll(updateNumberStr->data(), NULL, 0) : 0;

    // Get the remaining fields so that we can substitute the null string
    // if the fetched value is 0 (the null pointer) because the field
    // is not present in the disk file.
    UtlString* contact = (UtlString*) nvPairs.findValue(&gContactKey);
    UtlString* callId = (UtlString*) nvPairs.findValue(&gCallidKey);
    UtlString* instanceId = (UtlString*) nvPairs.findValue(&gInstanceIdKey);
    UtlString* gruu = (UtlString*) nvPairs.findValue(&gGruuKey);
    UtlString* path = (UtlString*) nvPairs.findValue(&gPathKey);
    UtlString* primary = (UtlString*) nvPairs.findValue(&gPrimaryKey);

    // Note: identity inferred from the uri
    updateBinding(
       Url(*((UtlString*)nvPairs.findValue(&gUriKey))),
       contact ? *contact : nullString,
       qvalue ? *qvalue : percent,
       callId ? *callId : nullString,
       cseqStr ? atoi(cseqStr->data()) : 0,
       expStr ? atoi(expStr->data()) : 0,
       instanceId ? *instanceId : nullString,
       gruu ? *gruu : nullString,
       path ? *path : nullString,
       primary ? *primary : nullString,
       updateNumber
       );
}
Ejemplo n.º 22
0
// Fill in a map of process names and states (as UtlStrings)
void SipxProcessManager::getProcessStateAll(UtlHashMap& processStates //< key->name, value->state string
                         )
{
   processStates.destroyAll();
   SipxProcess* process;

   // the lock is not required with the Iterator
   UtlHashBagIterator processes(mProcesses);
   while ((process = dynamic_cast<SipxProcess*>(processes())))
   {
      if ( 0 != process->compareTo(SUPERVISOR_PROCESS_NAME) )
      {
         processStates.insertKeyAndValue(new UtlString(process->data()),
                                      new UtlString(process->GetCurrentState()->name())
                                      );
      }
   }
}
Ejemplo n.º 23
0
void SipPublishContentMgr::publishDefault(const char* eventTypeKey,
                                          const char* eventType,
                                          SipPublishContentMgrDefaultConstructor*
                                          defaultConstructor,
                                          UtlBoolean fullState)
{
    Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                  "SipPublishContentMgr::publishDefault eventTypeKey '%s', eventType '%s', fullState %d, defaultConstructor %p",
                  eventTypeKey, eventType, fullState, defaultConstructor);

    // Construct the key to look up.
    UtlString key;
    key.append(CONTENT_KEY_SEPARATOR);
    key.append(eventTypeKey);

    lock();

    // Determine the storage we will be using.
    UtlHashMap* pContent;

    if (fullState)
    {
       pContent = &mDefaultContentConstructors;
    }
    else
    {
       pContent = &mDefaultPartialContentConstructors;
    }

    // Remove any old value first.
    pContent->destroy(&key);

    // Add the default constructor.
    if (defaultConstructor)
    {
       UtlString* key_heap = new UtlString(key);
       pContent->insertKeyAndValue(key_heap, defaultConstructor);
    }

    // Do not call the observer for the content change since this is default
    // content.

    unlock();
}
Ejemplo n.º 24
0
UtlContainable* UtlHashMapIterator::operator()()
{
   UtlContainable* foundKey = NULL;

   UtlContainer::acquireIteratorConnectionLock();
   OsLock take(mContainerRefLock);
   UtlHashMap* myHashMap = dynamic_cast<UtlHashMap*>(mpMyContainer);
   if (myHashMap)
   {
      OsLock container(myHashMap->mContainerLock);
      UtlContainer::releaseIteratorConnectionLock();

      if (mPosition < myHashMap->numberOfBuckets())
      {
         UtlPair* pair;
         for ( pair = (  mpCurrentPair
                       ? static_cast<UtlPair*>(mpCurrentPair->UtlChain::next)
                       : static_cast<UtlPair*>(myHashMap->mpBucket[mPosition].listHead())
                       );
               !pair && ++mPosition < myHashMap->numberOfBuckets();
               pair = static_cast<UtlPair*>(myHashMap->mpBucket[mPosition].listHead())
              )
         {
         }

         if(pair)
         {
            mpCurrentPair = pair;
            foundKey = pair->data;
         }
      }
      else
      {
         // mPosition >= myHashMap->numberOfBuckets(), so we've run off the end of the entries.
         mpCurrentPair = NULL;
      }
   }
   else
   {
      UtlContainer::releaseIteratorConnectionLock();
   }   

   return foundKey;
}
Ejemplo n.º 25
0
UtlBoolean
UserForwardDB::insertRow (const UtlHashMap& nvPairs) 
{
    // Note we do not need the identity object here
    // as it is inferred from the uri
    UtlString identity, cfwdtime;
    identity = *(dynamic_cast <UtlString*> (nvPairs.findValue(&gIdentityKey)));
    cfwdtime = *(dynamic_cast <UtlString*> (nvPairs.findValue(&gCfwdtimeKey)));
    return insertRow ( Url( identity ), cfwdtime );
}
Ejemplo n.º 26
0
void 
UserLocationDB::getLocations (
    const UtlString& identityString,
    ResultSet& rResultSet ) const
{
    // This should erase the contents of the existing resultset
    rResultSet.clear();

    if ( !identityString.isNull() && ( m_pFastDB != NULL) )
    {
        // Thread Local Storage
        m_pFastDB->attach();
        dbQuery query;
        query="identity=",identityString;

        // Search to see if we have a Credential Row
        dbCursor< UserLocationRow > cursor;

        if ( cursor.select(query) > 0 )
        {
            do {
                UtlHashMap record;
                UtlString* identityValue = 
                    new UtlString ( cursor->identity );
                UtlString* locationValue = 
                    new UtlString ( cursor->location );

                // Memory Leak fixes, make shallow copies of static keys
                UtlString* identityKey = new UtlString( gIdentityKey );
                UtlString* locationKey = new UtlString( gLocationKey );

                record.insertKeyAndValue ( 
                    identityKey, identityValue );
                record.insertKeyAndValue ( 
                    locationKey, locationValue );

                rResultSet.addValue(record);
            } while ( cursor.next() );
        }
        // Commit the rows to memory - multiprocess workaround
        m_pFastDB->detach(0);
    }
}
Ejemplo n.º 27
0
void
RegistrationDB::getAllRows ( ResultSet& rResultSet ) const
{
    // Clear out any previous records
    rResultSet.destroyAll();

    if ( m_pFastDB != NULL )
    {
        SMART_DB_ACCESS;
        dbCursor< RegistrationRow > cursor;
        if ( cursor.select() > 0 )
        {
            do {
                UtlHashMap record;
                UtlString* uriValue = new UtlString(cursor->uri);
                UtlString* callidValue = new UtlString(cursor->callid);
                UtlString* contactValue = new UtlString(cursor->contact);
                UtlInt* expiresValue = new UtlInt(cursor->expires);
                UtlInt* cseqValue = new UtlInt(cursor->cseq);
                UtlString* qvalueValue = new UtlString(cursor->qvalue);
                UtlString* primaryValue = new UtlString(cursor->primary);
                UtlLongLongInt* updateNumberValue = new UtlLongLongInt(cursor->update_number);

                // Memory Leak fixes, make shallow copies of static keys
                UtlString* uriKey = new UtlString(gUriKey);
                UtlString* callidKey = new UtlString(gCallidKey);
                UtlString* contactKey = new UtlString(gContactKey);
                UtlString* expiresKey = new UtlString(gExpiresKey);
                UtlString* cseqKey = new UtlString(gCseqKey);
                UtlString* qvalueKey = new UtlString(gQvalueKey);
                UtlString* primaryKey = new UtlString(gPrimaryKey);
                UtlString* updateNumberKey = new UtlString(gUpdateNumberKey);

                record.insertKeyAndValue(uriKey, uriValue);
                record.insertKeyAndValue(callidKey, callidValue);
                record.insertKeyAndValue(contactKey, contactValue);
                record.insertKeyAndValue(expiresKey, expiresValue);
                record.insertKeyAndValue(cseqKey, cseqValue);
                record.insertKeyAndValue(qvalueKey, qvalueValue);
                record.insertKeyAndValue(primaryKey, primaryValue);
                record.insertKeyAndValue(updateNumberKey, updateNumberValue);

                rResultSet.addValue(record);
            } while (cursor.next());
        }
    }
    else
    {
       OsSysLog::add(FAC_DB, PRI_CRIT, "RegistrationDB::getAllRows failed - no DB");
    }       
}
Ejemplo n.º 28
0
   void getOneRowByLocationCodeTest()
   {
      SipDbTestContext sipDbTestContext(TEST_DATA_DIR "/locationdata",
                                        TEST_WORK_DIR "/locationdata"
                                                 );
      sipDbTestContext.inputFile("dummy_loc_db.xml" );
      
      LocationDB* pLocDb = LocationDB::getInstance("dummy_loc_db");
      UtlHashMap hashmap;
      CPPUNIT_ASSERT( !pLocDb->getRowByLocationCode( "5144", hashmap ) );
      CPPUNIT_ASSERT( pLocDb->getRowByLocationCode( "514", hashmap ) );
      CPPUNIT_ASSERT( hashmap.entries() == 4 );

      UtlString* pTempString;
      UtlString key;
      key = "name";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "Montreal", pTempString->data() );
      
      key = "description";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "Go Habs Go!", pTempString->data() );
      
      key = "locationcode";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "514", pTempString->data() );

      key = "subnets";
      pTempString = dynamic_cast<UtlString*>(hashmap.findValue( &key ) );
      CPPUNIT_ASSERT( pTempString );
      ASSERT_STR_EQUAL( "10.10.10.0/24,11.11.11.0/24,12.12.12.0/24", pTempString->data() );
   }
Ejemplo n.º 29
0
void
UserForwardDB::getAllRows(ResultSet& rResultSet) const
{
    // Clear the out any previous records
    rResultSet.destroyAll();

    if (m_pFastDB != NULL)
    {
        // must do this first to ensure process/tls integrity
        m_pFastDB->attach();

        dbCursor< UserForwardRow > cursor;
        if ( cursor.select() > 0 )
        {
            do {
                UtlHashMap record;
                UtlString* identityValue = 
                    new UtlString ( cursor->identity );
                UtlString* cfwdtimeValue = 
                    new UtlString ( cursor->cfwdtime );

                // Memory Leak fixes, make shallow copies of static keys
                UtlString* identityKey = new UtlString( gIdentityKey );
                UtlString* cfwdtimeKey = new UtlString( gCfwdtimeKey );

                record.insertKeyAndValue ( 
                    identityKey, identityValue );
                record.insertKeyAndValue ( 
                    cfwdtimeKey, cfwdtimeValue );

                rResultSet.addValue(record);
            } while (cursor.next());
        }
        // commit rows and also ensure process/tls integrity
        m_pFastDB->detach(0);
    }
}
Ejemplo n.º 30
0
void
ExtensionDB::getAllRows(ResultSet& rResultSet) const
{
    // Clear the out any previous records
    rResultSet.destroyAll();

    if ( m_pFastDB != NULL )
    {
        // must do this first to ensure process/tls integrity
        m_pFastDB->attach();

        dbCursor< ExtensionRow > cursor;
        if ( cursor.select() > 0 )
        {
            do {
                UtlHashMap record;
                UtlString* uriValue = 
                    new UtlString ( cursor->uri );
                UtlString* extensionValue = 
                    new UtlString ( cursor->extension );

                // Memory Leak fixes, make shallow copies of static keys
                UtlString* uriKey = new UtlString( gUriKey );
                UtlString* extensionKey = new UtlString( gExtensionKey );

                record.insertKeyAndValue ( 
                    uriKey, uriValue );
                record.insertKeyAndValue ( 
                    extensionKey, extensionValue );

                rResultSet.addValue(record);
            } while (cursor.next());
        }
        // commit rows and also ensure process/tls integrity
        m_pFastDB->detach(0);
    }
}