osaf/services/saf/amf/amfd/ctcstype.cc | 60 ++++++++++++++++++++++++++++++++-
1 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/osaf/services/saf/amf/amfd/ctcstype.cc
b/osaf/services/saf/amf/amfd/ctcstype.cc
--- a/osaf/services/saf/amf/amfd/ctcstype.cc
+++ b/osaf/services/saf/amf/amfd/ctcstype.cc
@@ -26,7 +26,7 @@
#include <include/csi.h>
AmfDb<std::string, AVD_CTCS_TYPE> *ctcstype_db = nullptr;
-
+static void find_ct_name_from_association(const SaNameT *haystack, SaNameT
*dn, const char *needle);
static void ctcstype_db_add(AVD_CTCS_TYPE *ctcstype)
{
unsigned int rc = ctcstype_db->insert(ctcstype->name,ctcstype);
@@ -185,17 +185,73 @@ static SaAisErrorT ctcstype_ccb_complete
report_ccb_validation_error(opdata, "Modification of
SaAmfCtCsType not supported");
break;
case CCBUTIL_DELETE:
+ AVD_CTCS_TYPE *ctcstype;
+ SaNameT ct_name;
+ AVD_COMP_TYPE *comp_type;
+ AVD_COMP *comp;
+ CcbUtilOperationData_t *t_opData;
+
+ ctcstype =
ctcstype_db->find(Amf::to_string(&opdata->objectName));
+ if (ctcstype != nullptr) {
+ find_ct_name_from_association(&opdata->objectName,
&ct_name, ",safVersion");
+ TRACE("'%s'", ct_name.value);
+ comp_type = comptype_db->find(Amf::to_string(&ct_name));
+ if ((comp_type) && (nullptr !=
comp_type->list_of_comp)) {
+ /* check whether there exists a delete
operation for
+ * each of the Comp in the comp_type list in
the current CCB
+ */
+ bool comp_exist = false;
+ TRACE("SaAmfCompType '%s' has components",
comp_type->name.value);
+ comp = comp_type->list_of_comp;
+ while (comp != nullptr) {
+ TRACE("%s", comp->comp_info.name.value);
+ t_opData =
ccbutil_getCcbOpDataByDN(opdata->ccbId, &comp->comp_info.name);
+ TRACE("%p", t_opData);
+ if ((t_opData == nullptr) ||
(t_opData->operationType != CCBUTIL_DELETE)) {
+ TRACE("Here %p", t_opData);
+ comp_exist = true;
+ break;
+ }
+ comp = comp->comp_type_list_comp_next;
+ }
+ if (comp_exist == true) {
+ rc = SA_AIS_ERR_BAD_OPERATION;
+ report_ccb_validation_error(opdata,
"SaAmfCompType '%s' is in use", comp_type->name.value);
+ goto done;
+ }
+ } else
+ TRACE("SaAmfCompType '%p'. SaAmfCompType '%s'
has no components", comp_type, ct_name.value);
+ }
rc = SA_AIS_OK;
break;
default:
osafassert(0);
break;
}
-
+done:
TRACE_LEAVE2("%u", rc);
return rc;
}
+/**
+ * Initialize a DN by searching for needle in haystack where two times
safVersion comes.
+ * @param haystack
+ * @param dn
+ * @param needle
+ * @note:
"safSupportedCsType=safVersion=1\,safCSType=AmfDemo1,safVersion=1,safCompType=AmfDemo1"
+ */
+static void find_ct_name_from_association(const SaNameT *haystack, SaNameT
*dn, const char *needle)
+{
+ char *p;
+
+ memset(dn, 0, sizeof(SaNameT));
+ p = strstr((char*)haystack->value, needle);
+ osafassert(p);
+ p++; /* Increament after comma (,) */
+ dn->length = strlen(p);
+ memcpy(dn->value, p, dn->length);
+}
+
static void ctcstype_ccb_apply_cb(CcbUtilOperationData_t *opdata)
{
AVD_CTCS_TYPE *ctcstype;
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel