Author: gwinn
Date: Thu Dec  7 09:05:29 2006
New Revision: 483552

URL: http://svn.apache.org/viewvc?view=rev&rev=483552
Log:
TUSCANY-97

Modified:
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
    
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
    incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h

Modified: 
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp?view=diff&rev=483552&r1=483551&r2=483552
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp 
(original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp 
Thu Dec  7 09:05:29 2006
@@ -141,6 +141,7 @@
         return 0;\
     }
 
+#define ASSERT_SETTABLE(property,primval) ASSERT_WRITABLE(*property, 
set##primval)
 
 /** @def setPrimitive
  *
@@ -161,6 +162,7 @@
                 SDO_THROW_EXCEPTION("set 
value",SDOUnsupportedOperationException,\
                 msg.c_str());\
             }\
+            ASSERT_SETTABLE(pl, primval)\
             PropertyValueMap::iterator i;\
             for (i = PropertyValues.begin(); i != PropertyValues.end();++i)\
             {\
@@ -203,6 +205,7 @@
                 SDO_THROW_EXCEPTION("setter",SDOUnsupportedOperationException,\
                 msg.c_str());\
             }\
+            ASSERT_SETTABLE(pl, primval)\
             PropertyValueMap::iterator i;\
             for (i = PropertyValues.begin(); i != PropertyValues.end();++i)\
             {\
@@ -263,6 +266,7 @@
                          SDO_THROW_EXCEPTION("setter", 
SDOPathNotFoundException,\
                          msg.c_str());\
                     }\
+                    ASSERT_SETTABLE(p, primval)\
                     if (p->isMany()|| p->getTypeImpl()->isFromList())\
                     {\
                         long l;\
@@ -440,6 +444,7 @@
                          SDO_THROW_EXCEPTION("setter", 
SDOPathNotFoundException,\
                          msg.c_str());\
                     }\
+                    ASSERT_SETTABLE(p, primval)\
                     if (p->isMany()|| p->getTypeImpl()->isFromList())\
                     {\
                         long l;\
@@ -486,7 +491,6 @@
         return get ##primval (getPropertyIndex(property), val, max);\
     }
 
-
 /** @def setPrimitiveFromProperty
  *
  * A macro for the setting of primitive values in a data object by property
@@ -1127,14 +1131,16 @@
    {
       validateIndex(propertyIndex);
       PropertyValueMap::iterator i;
-      if ((getProperty(propertyIndex).isMany())
-          || getPropertyImpl(propertyIndex)->getTypeImpl()->isFromList())
+      PropertyImpl*const p = getPropertyImpl(propertyIndex);
+      if ((p->isMany())
+          || p->getTypeImpl()->isFromList())
       {
          string msg("Set value not available on many valued property:");
-         msg += getProperty(propertyIndex).getName();
+         msg += p->getName();
          SDO_THROW_EXCEPTION("setString", SDOUnsupportedOperationException,
                              msg.c_str());
       }
+      ASSERT_SETTABLE(p, CString)
       for (i = PropertyValues.begin(); i != PropertyValues.end(); ++i)
       {
          if ((*i).first == propertyIndex)
@@ -1245,6 +1251,7 @@
                }
                if (p != 0)
                {
+                  ASSERT_SETTABLE(p, CString)
                   if (p->isMany()|| p->getTypeImpl()->isFromList()) {
                      long l;
                      DataObjectList& dol = d->getList((Property&)*p);
@@ -1347,14 +1354,17 @@
     void DataObjectImpl::setNull(const unsigned int propertyIndex)
     {
         validateIndex(propertyIndex);
-        if ((getProperty(propertyIndex).isMany()))
+        const Property& property = getProperty(propertyIndex);
+        if ((property.isMany()))
         {
             string msg("Setting a list to null is not supported:");
-            msg += getProperty(propertyIndex).getName();
+            msg += property.getName();
             SDO_THROW_EXCEPTION("setNull", SDOUnsupportedOperationException,
                 msg.c_str());
         }
 
+        ASSERT_WRITABLE(property, setNull)
+
         PropertyValueMap::iterator i;
         for (i = PropertyValues.begin(); i != PropertyValues.end();++i)
             {
@@ -1408,6 +1418,7 @@
                         pc++;   // pc is the index of the first character 
following the /
                   }
                   const Property& pcont = cont->getProperty(path.substr(pc));
+                  ASSERT_WRITABLE(pcont, setNull)
                   cont->logChange(pcont);
                }
                catch (SDORuntimeException&)
@@ -1434,6 +1445,7 @@
                                          msg.c_str());
                   }
                }
+               ASSERT_SETTABLE(p, Null)
                d->setNull((Property&)*p);
                return;
             }
@@ -2274,6 +2286,7 @@
                 }
                 if (p != 0)
                 {
+                    ASSERT_SETTABLE(p, DataObject)
                     if (p->isMany())
                     {
                         DataObjectList& dol = d->getList((Property&)*p);
@@ -2459,6 +2472,7 @@
                 msg.c_str());
         }
 
+        ASSERT_WRITABLE(prop, setDataObject)
 
         if (value == 0) 
         {
@@ -2672,6 +2686,7 @@
             if (!prop.empty())
             {
                 const Property& p = d->getProperty(prop);
+                ASSERT_WRITABLE(p, unset)
                 if (p.isMany())
                 {
                     SDOString subscript;
@@ -2718,6 +2733,8 @@
 
     void DataObjectImpl::unset(const Property& p)
     {
+        ASSERT_WRITABLE(p, unset)
+
         PropertyValueMap::iterator i;
         unsigned int index = getPropertyIndex(p);
 

Modified: 
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp?view=diff&rev=483552&r1=483551&r2=483552
==============================================================================
--- 
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp 
(original)
+++ 
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp 
Thu Dec  7 09:05:29 2006
@@ -231,6 +231,9 @@
             msg.c_str());
     }
 
+    const Property& property = container->getProperty(pindex);
+    ASSERT_WRITABLE(property,insert)
+
     DataObject* dob = d; // unwrap the data object ready for a downcasting 
hack.
     DataObjectImpl* con  = ((DataObjectImpl*)dob)->getContainerImpl();  
     if (!isReference)
@@ -254,7 +257,7 @@
             ((DataObjectImpl*)dob)->setApplicableChangeSummary();
             ((DataObjectImpl*)dob)->logCreation((DataObjectImpl*)dob,
                 (DataObjectImpl*)container,
-                container->getProperty(pindex));
+                property);
         }
     }
 
@@ -265,7 +268,7 @@
         if (container->getType().isSequencedType())
         {
             SequenceImpl* sq = container->getSequenceImpl();
-            if (sq)sq->push(container->getProperty(pindex),index);
+            if (sq)sq->push(property,index);
         }
     }
 
@@ -424,6 +427,9 @@
     checkType(theFactory->getType(typeURI,typeName),
                 d->getType());
 
+    const Property& property = container->getProperty(pindex);
+    ASSERT_WRITABLE(property,append)
+
     DataObject* dob = d; // unwrap the data object ready for a downcasting 
hack.
     DataObjectImpl* con  = ((DataObjectImpl*)dob)->getContainerImpl();  
     
@@ -449,7 +455,7 @@
             if (!container->getProperty(pindex).getType().isDataType())
             {
                 ((DataObjectImpl*)dob)->logCreation((DataObjectImpl*)dob,
-                    container,container->getProperty(pindex));
+                    container,property);
             }
 
         }
@@ -460,7 +466,7 @@
         if (container->getType().isSequencedType())
         {
             SequenceImpl* sq = container->getSequenceImpl();
-            if (sq)sq->push(container->getProperty(pindex),plist.size()-1);
+            if (sq)sq->push(property,plist.size()-1);
         }
     }
 }

Modified: 
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h
URL: 
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h?view=diff&rev=483552&r1=483551&r2=483552
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h 
(original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h 
Thu Dec  7 09:05:29 2006
@@ -209,4 +209,13 @@
 };
 };
 };
+
+#define ASSERT_WRITABLE(property,method)\
+      if ((property).isReadOnly())\
+      {\
+          SDOString stringBuffer = (property).getName();\
+          stringBuffer += "is read-only.";\
+          SDO_THROW_EXCEPTION(method, SDOUnsupportedOperationException, 
stringBuffer.c_str())\
+      }
+
 #endif



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to