UtlBoolean SipPublishContentMgr::getContent(const char* resourceId,
                                          const char* eventTypeKey,
                                          const char* acceptHeaderValue,
                                          HttpBody*& content,
                                          UtlBoolean& isDefaultContent)
{
#ifdef TEST_PRINT
    osPrintf("SipPublishContentMgr::getContent(%s, %s, %s, ...)\n",
        resourceId, eventTypeKey, acceptHeaderValue);
#endif

    UtlBoolean foundContent = FALSE;
    UtlString key(resourceId);
    key.append(eventTypeKey);
    PublishContentContainer* container = NULL;
    UtlHashMap contentTypes;
    isDefaultContent = FALSE;

    UtlBoolean acceptedTypesGiven = buildContentTypesContainer(acceptHeaderValue, contentTypes);

    lock();
    // See if resource specific content exists
    container = 
        (PublishContentContainer*) mContentEntries.find(&key);

    // No resource specific content check if the default exists
    if(container == NULL)
    {
        key = eventTypeKey;
        container = 
            (PublishContentContainer*) mDefaultContentEntries.find(&key);

        if(container)
        {
            isDefaultContent = TRUE;
        }
    }

    if(container)
    {
        HttpBody* bodyPtr = NULL;
        UtlSListIterator contentIterator(container->mEventContent);
        while((bodyPtr = (HttpBody*)contentIterator()))
        {
            // No MIME types specified, take the first one
            if(!acceptedTypesGiven)
            {
                content = HttpBody::copyBody(*bodyPtr);
                foundContent = TRUE;
                break;
            }

            // Find the first match.  The container has the bodies
            // in the servers preferred order.
            if(contentTypes.find(bodyPtr))
            {
                content = HttpBody::copyBody(*bodyPtr);
                foundContent = TRUE;
                break;
            }
        }
    }
    else
    {
         OsSysLog::add(FAC_SIP, PRI_WARNING,
                  "SipPublishContentMgr::getContent no container is found\n");
                  
    }

    unlock();

    contentTypes.destroyAll();
    return(foundContent);
}