incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o..@apache.org
Subject svn commit: r1293281 - in /incubator/ooo/trunk/main/ucb/source/ucp/webdav: SerfPropFindReqProcImpl.cxx SerfPropPatchReqProcImpl.cxx
Date Fri, 24 Feb 2012 14:58:55 GMT
Author: orw
Date: Fri Feb 24 14:58:55 2012
New Revision: 1293281

URL: http://svn.apache.org/viewvc?rev=1293281&view=rev
Log:
some refactoring to PROPPATCH and PROPFIND requests

Modified:
    incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
    incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx

Modified: incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx?rev=1293281&r1=1293280&r2=1293281&view=diff
==============================================================================
--- incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx (original)
+++ incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropFindReqProcImpl.cxx Fri Feb 24
14:58:55 2012
@@ -92,12 +92,9 @@ serf_bucket_t * SerfPropFindReqProcImpl:
 
     // body bucket - certain properties OR all properties OR only property names
     serf_bucket_t* body_bkt = 0;
-    sal_Int32 nDataLen = 0;
+    rtl::OUString aBodyText;
     {
         // create and fill body bucket with requested properties
-        body_bkt = serf_bucket_aggregate_create( pSerfBucketAlloc );
-
-        serf_bucket_t* tmp = 0;
         const int nPropCount = ( !mbOnlyPropertyNames && mpPropNames )
                                ? mpPropNames->size() 
                                : 0;
@@ -111,72 +108,34 @@ serf_bucket_t * SerfPropFindReqProcImpl:
                                                    thePropName );
 
                 /* <*propname* xmlns="*propns*" /> */
-                tmp = SERF_BUCKET_SIMPLE_STRING_LEN("<", 1, pSerfBucketAlloc );
-                serf_bucket_aggregate_append( body_bkt, tmp );
-                nDataLen += 1;
-
-                tmp = SERF_BUCKET_SIMPLE_STRING( thePropName.name, pSerfBucketAlloc );
-                serf_bucket_aggregate_append( body_bkt, tmp );
-                nDataLen += strlen(thePropName.name);
-
-                tmp = SERF_BUCKET_SIMPLE_STRING_LEN( " xmlns=\"",
-                                                     sizeof(" xmlns=\"")-1,
-                                                     pSerfBucketAlloc );
-                serf_bucket_aggregate_append( body_bkt, tmp );
-                nDataLen += sizeof(" xmlns=\"")-1;
-
-                tmp = SERF_BUCKET_SIMPLE_STRING( thePropName.nspace, pSerfBucketAlloc );
-                serf_bucket_aggregate_append( body_bkt, tmp );
-                nDataLen += strlen(thePropName.nspace);
-
-                tmp = SERF_BUCKET_SIMPLE_STRING_LEN( "\"/>", sizeof("\"/>")-1,
-                                                     pSerfBucketAlloc );
-                serf_bucket_aggregate_append( body_bkt, tmp );
-                nDataLen += sizeof("\"/>")-1;
+                aBodyText += rtl::OUString::createFromAscii( "<" );
+                aBodyText += rtl::OUString::createFromAscii( thePropName.name );
+                aBodyText += rtl::OUString::createFromAscii( " xmlnx=\"" );
+                aBodyText += rtl::OUString::createFromAscii( thePropName.nspace );
+                aBodyText += rtl::OUString::createFromAscii( "\"/>" );
             }
 
-            tmp = SERF_BUCKET_SIMPLE_STRING_LEN("<prop>",
-                                                sizeof("<prop>")-1,
-                                                pSerfBucketAlloc );
-            serf_bucket_aggregate_prepend(body_bkt, tmp);
-            nDataLen += sizeof("<prop>")-1;
-
-            tmp = SERF_BUCKET_SIMPLE_STRING_LEN("</prop>",
-                                                sizeof("</prop>")-1,
-                                                pSerfBucketAlloc );
-            serf_bucket_aggregate_append(body_bkt, tmp);
-            nDataLen += sizeof("</prop>")-1;
+            aBodyText = rtl::OUString::createFromAscii( "<prop>" ) + 
+                        aBodyText +
+                        rtl::OUString::createFromAscii( "</prop>" );
         }
         else
         {
             if ( mbOnlyPropertyNames )
             {
-                tmp = SERF_BUCKET_SIMPLE_STRING_LEN( "<propname/>",
-                                                     sizeof("<propname/>")-1,
-                                                     pSerfBucketAlloc );
-                nDataLen += sizeof("<propname/>")-1;
+                aBodyText = rtl::OUString::createFromAscii( "<propname/>" );
             }
             else
             {
-                tmp = SERF_BUCKET_SIMPLE_STRING_LEN( "<allprop/>",
-                                                     sizeof("<allprop/>")-1,
-                                                     pSerfBucketAlloc );
-                nDataLen += sizeof("<allprop/>")-1;
+                aBodyText = rtl::OUString::createFromAscii( "<allprop/>" );
             }
-            serf_bucket_aggregate_append( body_bkt, tmp );
         }
 
-        tmp = SERF_BUCKET_SIMPLE_STRING_LEN( PROPFIND_HEADER,
-                                             sizeof(PROPFIND_HEADER)-1,
-                                             pSerfBucketAlloc );
-        serf_bucket_aggregate_prepend(body_bkt, tmp);
-        nDataLen += sizeof(PROPFIND_HEADER)-1;
-
-        tmp = SERF_BUCKET_SIMPLE_STRING_LEN(PROPFIND_TRAILER,
-                                            sizeof(PROPFIND_TRAILER)-1,
-                                            pSerfBucketAlloc );
-        serf_bucket_aggregate_append(body_bkt, tmp);
-        nDataLen += sizeof(PROPFIND_TRAILER)-1;
+        aBodyText = rtl::OUString::createFromAscii( PROPFIND_HEADER ) + 
+                    aBodyText +
+                    rtl::OUString::createFromAscii( PROPFIND_TRAILER );
+        body_bkt = SERF_BUCKET_SIMPLE_STRING( rtl::OUStringToOString( aBodyText, RTL_TEXTENCODING_UTF8
), 
+                                                pSerfBucketAlloc );
     }
 
     // create serf request
@@ -193,10 +152,14 @@ serf_bucket_t * SerfPropFindReqProcImpl:
     serf_bucket_headers_setn( hdrs_bkt, "Accept-Encoding", "gzip");
 
     // request specific header fields
+    // request specific header fields
     serf_bucket_headers_setn( hdrs_bkt, "Depth", mDepthStr );
-    serf_bucket_headers_setn( hdrs_bkt, "Content-Type", "application/xml" );
-    serf_bucket_headers_setn( hdrs_bkt, "Content-Length", 
-                              rtl::OUStringToOString( rtl::OUString::valueOf( nDataLen ),
RTL_TEXTENCODING_UTF8 ) );
+    if ( body_bkt != 0 && aBodyText.getLength() > 0 )
+    {
+        serf_bucket_headers_setn( hdrs_bkt, "Content-Type", "application/xml" );
+        serf_bucket_headers_setn( hdrs_bkt, "Content-Length", 
+                                  rtl::OUStringToOString( rtl::OUString::valueOf( aBodyText.getLength()
), RTL_TEXTENCODING_UTF8 ) );
+    }
 
     return req_bkt;
 }

Modified: incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx?rev=1293281&r1=1293280&r2=1293281&view=diff
==============================================================================
--- incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx (original)
+++ incubator/ooo/trunk/main/ucb/source/ucp/webdav/SerfPropPatchReqProcImpl.cxx Fri Feb 24
14:58:55 2012
@@ -132,7 +132,6 @@ serf_bucket_t * SerfPropPatchReqProcImpl
             // add PropPatch xml trailer at end
             aBodyText += rtl::OUString::createFromAscii( PROPPATCH_TRAILER );
 
-            const char* pTestValue = rtl::OUStringToOString( aBodyText, RTL_TEXTENCODING_UTF8
);
             body_bkt = SERF_BUCKET_SIMPLE_STRING( rtl::OUStringToOString( aBodyText, RTL_TEXTENCODING_UTF8
), 
                                                   pSerfBucketAlloc );
         }



Mime
View raw message