예제 #1
0
CORBA::ULong
CDBPropertySet::get_number_of_properties ()
{
    ACS_TRACE("baci::CDBPropertySet::get_number_of_properties");
    
  // check if characteristic model is registered
  CORBA::String_var objId = getObjectId();
  CharacteristicModelImplMap::iterator iter = modelMap.find(objId.in());
  if (iter == modelMap.end())
      throw CORBA::NO_RESOURCES();

  DAONode * node = iter->second->getDAONode();
  if (!node)
      throw CORBA::NO_RESOURCES();

  try
      {
      CDB::stringSeq_var properties = node->get_string_seq("");
      return properties->length();
      }
  catch (...)
      {
      throw CORBA::NO_RESOURCES();
      }

}
예제 #2
0
CDB::stringSeq* DAOProxy::get_string_seq (const char * propertyName)
{
    //ACS_TRACE("cdb::DAOProxy::get_string_seq");

    // check remote mode
    if (m_dao.ptr() != CDB::DAO::_nil()) 
	return m_dao->get_string_seq(propertyName);

    string value;
    try{
    get_field(propertyName, value);
    }catch(cdbErrType::CDBFieldDoesNotExistExImpl ex){
	throw ex.getCDBFieldDoesNotExistEx();
    }

    VectorString array;
    split(value.c_str(), array);

    CDB::stringSeq_var seq = new CDB::stringSeq();
    seq->length(array.size());

    CORBA::ULong i = 0;
    for (VectorString::const_iterator iter = array.begin();
	 iter != array.end(); iter++)
	{
	seq[i++] = CORBA::string_dup(iter->c_str());
	}

    return seq._retn();
}
예제 #3
0
//------------------------------------------------------
    CDBProperties::EventHandlerTimeoutMap
    CDBProperties::getEventHandlerTimeoutMap(const std::string& channelName)
    {
	EventHandlerTimeoutMap retVal;

	//sanity check
	if (cdbChannelConfigExists(channelName)==false)
	    {
	    return retVal;
	    }

	//CDB
	//complete name of the channel within the CDB
	std::string cdbChannelName = "MACI/Channels/" + channelName;
	CDB::DAL_var cdbRef = getCDB();
	CDB::DAO_var tempDAO = cdbRef->get_DAO_Servant(cdbChannelName.c_str());
	CDB::stringSeq_var keys;
	//names of all the events
	try {
	keys = tempDAO->get_string_seq("Events");
	}
	catch(...){
	return retVal;
	}
	    
	//another sanity check
	if (keys.ptr()==0)
	    {
	    return retVal;
	    }
	
	//populate the map
	for (CORBA::ULong i=0; i<keys->length(); i++) 
	    {
	    //get the key's value
	    std::string timeoutLocation = "Events/";
	    timeoutLocation =  timeoutLocation + (const char*)keys[i] + "/MaxProcessTime";
	    double value = tempDAO->get_double(timeoutLocation.c_str());
	    
	    //set the map's contents
	    retVal[(const char*)keys[i]] = value;
	    }
	return retVal;
    }
예제 #4
0
CDB::stringSeq* DAOImpl::get_string_seq (
    const char * propertyName
    
  )
{
	Field fld;
	if( !get_field(propertyName, fld) )
	{
		throw CDBFieldDoesNotExistExImpl (
			__FILE__, __LINE__,
			"DAOImpl::get_long").getCDBFieldDoesNotExistEx();
	}
    
	if(fld.GetType() != Field::tyStringArray)
	{
		throw WrongCDBDataTypeExImpl (
			__FILE__, __LINE__,
			"DAOImpl::get_long").getWrongCDBDataTypeEx();
	}

	// create return value
	CDB::stringSeq_var retSeq;
	ACE_NEW_THROW_EX (retSeq, CDB::stringSeq, CORBA::NO_MEMORY ());
	ACE_CHECK_RETURN (0);

	StringArray * ary = fld.GetStringArray();
	retSeq->length( ary->size() );
	CORBA::ULong n=0;
	for(StringArray::const_iterator aiter = ary->begin(); aiter != ary->end(); ++aiter) 
	{
		retSeq[n++] = CORBA::string_dup( aiter->c_str() );
	}
	
	return retSeq._retn();
	
}
예제 #5
0
//-----------------------------------------------------------------------------
char*
BaseHelper::getNotificationFactoryNameForChannel(CDB::DAL_ptr cdbRef, const char* channelName, const char* domainName)
{
//sanity check
if(CORBA::is_nil(cdbRef))
    {
    ACS_STATIC_SHORT_LOG((LM_DEBUG,
			  "BaseHelper::getNotificationFactoryNameForChannel",
			  "CDB ref null."));
    return 0;
    }

std::string cdbChannelsName = "MACI/Channels";
CDB::DAO_var tempDAO;
//try reading the entry from the CDB
try
    {
		tempDAO = cdbRef->get_DAO_Servant(cdbChannelsName.c_str());
		//sanity check, should not happen
	    if (tempDAO.in()==0)
	      return 0;
//DAL throws exceptions if the entry being searched for does not
//exist
    }
catch(...)
    {
    ACS_STATIC_SHORT_LOG((LM_DEBUG,
			  "BaseHelper::getNotificationFactoryNameForChannel",
			  "No CDB entry found for '%s' channel. OK.",
			  cdbChannelsName.c_str()));
    return 0;
    }

// if channel mapping exists take it, wildchars are also supported
try
    {
    CDB::stringSeq_var channelNameList = tempDAO->get_string_seq("NotificationServiceMapping/Channels_");
    for (CORBA::ULong n = 0; n < channelNameList->length(); n++)
        if (Wildcard::wildcardfit(channelNameList[n], channelName))
            return CORBA::string_dup(tempDAO->get_string((std::string("NotificationServiceMapping/Channels_/") + channelNameList[n].in() + "/NotificationService").c_str())); 
    }
catch(...)
    {
    ACS_STATIC_SHORT_LOG((LM_DEBUG,
			  "BaseHelper::getNotificationFactoryNameForChannel",
			  "No Channel to NotificationService mapping found for channel'%s' channel.",
			  channelName));
    }
    
// if domain mapping, if given
if (domainName)
	try
    {
    return CORBA::string_dup(tempDAO->get_string((std::string("NotificationServiceMapping/Domains/") + domainName + "/NotificationService").c_str())); 
    }
catch(...)
    {
    ACS_STATIC_SHORT_LOG((LM_DEBUG,
			  "BaseHelper::getNotificationFactoryNameForChannel",
			  "No Domain to NotificationService mapping found for domain/channel'%s/%s' channel. OK.",
			  domainName, channelName));
    }
    
// if default
	try
    {
    return CORBA::string_dup(tempDAO->get_string("NotificationServiceMapping/DefaultNotificationService")); 
    }
catch(...)
    {
    ACS_STATIC_SHORT_LOG((LM_DEBUG,
			  "BaseHelper::getNotificationFactoryNameForChannel",
			  "No NotificationServiceMapping/DefaultNotificationService attribute found. OK.",
			  domainName, channelName));
    }

	// not found
    return 0;
}
예제 #6
0
void
CDBPropertySet::get_all_properties (CORBA::ULong how_many,
				    CosPropertyService::Properties_out nproperties,
				    CosPropertyService::PropertiesIterator_out rest)
{
  ACS_TRACE("baci::CDBPropertySet::get_all_properties");

  // Allocate memory for the out parameter.
  ACE_NEW (nproperties,
           CosPropertyService::Properties);

  // check if characteristic model is registered
  CORBA::String_var objId = getObjectId();
  CharacteristicModelImplMap::iterator iter = modelMap.find(objId.in());
  if (iter == modelMap.end())
      throw CORBA::NO_RESOURCES();

   DAONode * node = iter->second->getDAONode();
  if (!node)
      throw CORBA::NO_RESOURCES();

  CDB::stringSeq_var properties;
  try
      {
      properties = node->get_string_seq("");
      }
  catch (...)
      {
      throw CORBA::NO_RESOURCES();
      }
  
  // Validate the length.
  CORBA::ULong numOfProperties = properties->length();

  if (numOfProperties == 0)
      {
      // Nothing to do.
      return;
      }

  // Set the length for the nproperties if how_many > 0.
  CORBA::ULong sequenceLength = 0UL;

  if (how_many > 0)
    {
      if (how_many >= numOfProperties)
	  {
	  sequenceLength = numOfProperties;
	  }
      else
	  {
	  sequenceLength = how_many;
	  }
      nproperties->length(sequenceLength);
    }

  // Prepare an iterator and iterate through the PropertySet. Retrive
  // the values.

  CORBA::Any anyval;
  CORBA::ULong ni = 0UL;
  for (; ni < sequenceLength;
       ni++)
      {
      nproperties[ni].property_name = CORBA::string_dup (properties[ni].in());

      try
	  {
	  CORBA::String_var strVal = node->get_string(properties[ni].in());
	  anyval <<= strVal.in();
	  nproperties[ni].property_value = anyval;
	  }
      catch (...)
	  {
	  CORBA::Any voidany;
	  voidany.type(CORBA::_tc_void);
	  nproperties[ni].property_value = voidany; //CORBA::Any(CORBA::_tc_void);
	  }
      }

  // If there are more properties, put them in the <PropertiesIterator>.
  // Make a new <TAO_PropertySet> and use that to create an Properties
  // iterator.  put that in a iterator and assign that to the out
  // paramerter.

  if (numOfProperties > how_many)
      {
      TAO_PropertySet *propSet_p=0;
      
      ACE_NEW (propSet_p, TAO_PropertySet);
      
      for (CORBA::ULong i = how_many;
           i < numOfProperties;
           i++, ni++)
	  {

	  try
	      {
	      CORBA::String_var strVal = node->get_string(properties[ni].in());
	      anyval <<= strVal.in();
	      propSet_p->define_property(properties[ni].in(), anyval);
	      }
	  catch (...)
	      {
	      CORBA::Any voidany;
	      voidany.type(CORBA::_tc_void);
	      propSet_p->define_property(properties[ni].in(), voidany /*CORBA::Any(CORBA::_tc_void)*/);
	      }
	  
	  }

      // Make the iterator out of the new TAO_Propset.
      TAO_PropertiesIterator *iterator_p = 0;
      ACE_NEW (iterator_p,
               TAO_PropertiesIterator (*propSet_p));

      // Init the out parameter.

      // Get the interface ptr.
      CosPropertyService::PropertiesIterator_ptr iterator2_p =
        iterator_p->_this ();
      

      // POA stuff todo here, since we have <destroy> method in the
      // <NamesIterator> interface.
      // Give ownership of this servant to the POA.
      iterator_p->_remove_ref ();
      

      // Init the out parameter.
      rest = iterator2_p;
    }
}
예제 #7
0
void
CDBPropertySet::get_all_property_names (CORBA::ULong how_many,
					CosPropertyService::PropertyNames_out property_names,
					CosPropertyService::PropertyNamesIterator_out rest)
{
  ACS_TRACE("baci::CDBPropertySet::get_all_property_names");

  // Allocating storage is a must.
  ACE_NEW (property_names,
           CosPropertyService::PropertyNames);

  // check if characteristic model is registered
  CORBA::String_var objId = getObjectId();
  CharacteristicModelImplMap::iterator iter = modelMap.find(objId.in());
  if (iter == modelMap.end())
      throw CORBA::NO_RESOURCES();

   DAONode * node = iter->second->getDAONode();
  if (!node)
      throw CORBA::NO_RESOURCES();

  CDB::stringSeq_var properties;
  try
      {
      properties = node->get_string_seq("");
      }
  catch (...)
      {
      throw CORBA::NO_RESOURCES();
      }
  
  // Validate the length.
  CORBA::ULong numOfProperties = properties->length();

  if (numOfProperties == 0)
      {
      // Nothing to do.
      return;
      }
  
  // Set the length of the property_names appropriately.
  CORBA::ULong sequenceLength = 0UL;

  if (how_many > 0)
      {
      if (how_many >= numOfProperties)
	  {
	  sequenceLength = numOfProperties;
	  }
      else
	  {
        sequenceLength = how_many;
	  }
      property_names->length (sequenceLength);
    }

  // Iterate thru names and put them in the property_names.

  CORBA::ULong ni = 0UL;
  for (; ni < sequenceLength;
       ni++)
      {
      property_names [ni] = CORBA::string_dup (properties[ni].in());
      }
  
  // If there are some more properties, put them in the
  // iterator. How?? Make a new PropertySet and use that to create
  // propertyNames Iterator.

  if (numOfProperties > how_many)
    {
      TAO_PropertySet *propertySet_p=0;

      ACE_NEW (propertySet_p, TAO_PropertySet);

      CORBA::Any anyval;
      anyval.type(CORBA::_tc_void);
      for (CORBA::ULong i = how_many;
           i < numOfProperties;
           i++, ni++)
	  {
	  propertySet_p->define_property(properties[ni].in(), anyval);
	  }

      // Make the NamesIterator out of this TAO_PropertySet.
      TAO_PropertyNamesIterator *namesIterator_p=0;
      ACE_NEW (namesIterator_p, TAO_PropertyNamesIterator (*propertySet_p));

      // Init the out parameter.

      // Get the Interface ptr.
      CosPropertyService::PropertyNamesIterator_ptr iterator_p =
        namesIterator_p->_this ();
      

      // POA stuff todo here, since we have <destroy> method in the
      // <NamesIterator> interface.
      // Give ownership of this servant to the POA.
      namesIterator_p->_remove_ref ();
      

      // Init the out parameter.
      rest = iterator_p;
    }
}