webdavresponseparser.cxx (5f30f85e) webdavresponseparser.cxx (3edf6992)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 15 unchanged lines hidden (view full) ---

24
25#include "webdavresponseparser.hxx"
26#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
27#include <cppuhelper/implbase2.hxx>
28#include <com/sun/star/xml/sax/XParser.hpp>
29#include <com/sun/star/xml/sax/InputSource.hpp>
30#include <comphelper/processfactory.hxx>
31#include <comphelper/seqstream.hxx>
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 15 unchanged lines hidden (view full) ---

24
25#include "webdavresponseparser.hxx"
26#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
27#include <cppuhelper/implbase2.hxx>
28#include <com/sun/star/xml/sax/XParser.hpp>
29#include <com/sun/star/xml/sax/InputSource.hpp>
30#include <comphelper/processfactory.hxx>
31#include <comphelper/seqstream.hxx>
32#include <com/sun/star/ucb/Lock.hpp>
33#include <com/sun/star/ucb/LockDepth.hpp>
32#include <com/sun/star/ucb/LockEntry.hpp>
33#include <com/sun/star/ucb/LockScope.hpp>
34#include <com/sun/star/ucb/LockType.hpp>
35#include <map>
36#include <hash_map>
37
38//////////////////////////////////////////////////////////////////////////////
39

--- 49 unchanged lines hidden (view full) ---

89 WebDAVName_getcontenttype,
90 WebDAVName_supportedlock,
91 WebDAVName_lockentry,
92 WebDAVName_lockscope,
93 WebDAVName_exclusive,
94 WebDAVName_locktype,
95 WebDAVName_write,
96 WebDAVName_shared,
34#include <com/sun/star/ucb/LockEntry.hpp>
35#include <com/sun/star/ucb/LockScope.hpp>
36#include <com/sun/star/ucb/LockType.hpp>
37#include <map>
38#include <hash_map>
39
40//////////////////////////////////////////////////////////////////////////////
41

--- 49 unchanged lines hidden (view full) ---

91 WebDAVName_getcontenttype,
92 WebDAVName_supportedlock,
93 WebDAVName_lockentry,
94 WebDAVName_lockscope,
95 WebDAVName_exclusive,
96 WebDAVName_locktype,
97 WebDAVName_write,
98 WebDAVName_shared,
99 WebDAVName_lockdiscovery,
100 WebDAVName_activelock,
101 WebDAVName_depth,
102 WebDAVName_owner,
103 WebDAVName_timeout,
104 WebDAVName_locktoken,
97 WebDAVName_status,
98 WebDAVName_getlastmodified,
99 WebDAVName_creationdate,
100 WebDAVName_getcontentlength,
101
102 WebDAVName_last
103 };
104

--- 15 unchanged lines hidden (view full) ---

120 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("getcontenttype"), WebDAVName_getcontenttype));
121 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("supportedlock"), WebDAVName_supportedlock));
122 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("lockentry"), WebDAVName_lockentry));
123 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("lockscope"), WebDAVName_lockscope));
124 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("exclusive"), WebDAVName_exclusive));
125 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("locktype"), WebDAVName_locktype));
126 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("write"), WebDAVName_write));
127 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("shared"), WebDAVName_shared));
105 WebDAVName_status,
106 WebDAVName_getlastmodified,
107 WebDAVName_creationdate,
108 WebDAVName_getcontentlength,
109
110 WebDAVName_last
111 };
112

--- 15 unchanged lines hidden (view full) ---

128 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("getcontenttype"), WebDAVName_getcontenttype));
129 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("supportedlock"), WebDAVName_supportedlock));
130 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("lockentry"), WebDAVName_lockentry));
131 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("lockscope"), WebDAVName_lockscope));
132 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("exclusive"), WebDAVName_exclusive));
133 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("locktype"), WebDAVName_locktype));
134 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("write"), WebDAVName_write));
135 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("shared"), WebDAVName_shared));
136 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("lockdiscovery"), WebDAVName_lockdiscovery));
137 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("activelock"), WebDAVName_activelock));
138 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("depth"), WebDAVName_depth));
139 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("owner"), WebDAVName_owner));
140 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("timeout"), WebDAVName_timeout));
141 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("locktoken"), WebDAVName_locktoken));
128 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("status"), WebDAVName_status));
129 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("getlastmodified"), WebDAVName_getlastmodified));
130 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("creationdate"), WebDAVName_creationdate));
131 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("getcontentlength"), WebDAVName_getcontentlength));
132 }
133
134 const WebDAVNameMapper::const_iterator aResult(aWebDAVNameMapperList.find(rStr));
135

--- 147 unchanged lines hidden (view full) ---

283//////////////////////////////////////////////////////////////////////////////
284// the Xml parser itself
285
286namespace
287{
288 enum WebDAVResponseParserMode
289 {
290 WebDAVResponseParserMode_PropFind = 0,
142 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("status"), WebDAVName_status));
143 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("getlastmodified"), WebDAVName_getlastmodified));
144 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("creationdate"), WebDAVName_creationdate));
145 aWebDAVNameMapperList.insert(WebDAVNameValueType(rtl::OUString::createFromAscii("getcontentlength"), WebDAVName_getcontentlength));
146 }
147
148 const WebDAVNameMapper::const_iterator aResult(aWebDAVNameMapperList.find(rStr));
149

--- 147 unchanged lines hidden (view full) ---

297//////////////////////////////////////////////////////////////////////////////
298// the Xml parser itself
299
300namespace
301{
302 enum WebDAVResponseParserMode
303 {
304 WebDAVResponseParserMode_PropFind = 0,
291 WebDAVResponseParserMode_PropName
305 WebDAVResponseParserMode_PropName,
306 WebDAVResponseParserMode_LockResponse
292 };
293
294 class WebDAVResponseParser : public cppu::WeakImplHelper1< com::sun::star::xml::sax::XDocumentHandler >
295 {
296 private:
297 std::vector< http_dav_ucp::DAVResource > maResult_PropFind;
298 std::vector< http_dav_ucp::DAVResourceInfo > maResult_PropName;
307 };
308
309 class WebDAVResponseParser : public cppu::WeakImplHelper1< com::sun::star::xml::sax::XDocumentHandler >
310 {
311 private:
312 std::vector< http_dav_ucp::DAVResource > maResult_PropFind;
313 std::vector< http_dav_ucp::DAVResourceInfo > maResult_PropName;
314 http_dav_ucp::DAVPropertyValue maResult_Lock;
299
300 WebDAVContext* mpContext;
301 ::rtl::OUString maHref;
315
316 WebDAVContext* mpContext;
317 ::rtl::OUString maHref;
318 ::rtl::OUString maHrefLocks; //this is used for locks, when lockdiscoveryactive
319
302 ::rtl::OUString maStatus;
303 std::vector< http_dav_ucp::DAVPropertyValue > maResponseProperties;
304 std::vector< http_dav_ucp::DAVPropertyValue > maPropStatProperties;
305 std::vector< ::rtl::OUString > maResponseNames;
306 std::vector< ::rtl::OUString > maPropStatNames;
320 ::rtl::OUString maStatus;
321 std::vector< http_dav_ucp::DAVPropertyValue > maResponseProperties;
322 std::vector< http_dav_ucp::DAVPropertyValue > maPropStatProperties;
323 std::vector< ::rtl::OUString > maResponseNames;
324 std::vector< ::rtl::OUString > maPropStatNames;
325 uno::Sequence< ::rtl::OUString > maLockTokens;
307 uno::Sequence< ucb::LockEntry > maLockEntries;
326 uno::Sequence< ucb::LockEntry > maLockEntries;
327 uno::Sequence< ucb::Lock > maLocks; //the returned locks following a lockdiscovery request
308 ucb::LockScope maLockScope;
309 ucb::LockType maLockType;
328 ucb::LockScope maLockScope;
329 ucb::LockType maLockType;
310 WebDAVResponseParserMode meWebDAVResponseParserMode;
330 ucb::LockDepth maLockDepth;
331 ::rtl::OUString maLockOwner;
332 sal_Int64 maLockTimeout;
333 ::rtl::OUString maLockToken;
311
334
335 WebDAVResponseParserMode meWebDAVResponseParserMode;
336
312 // bitfield
313 bool mbResourceTypeCollection : 1;
314 bool mbLockScopeSet : 1;
315 bool mbLockTypeSet : 1;
337 // bitfield
338 bool mbResourceTypeCollection : 1;
339 bool mbLockScopeSet : 1;
340 bool mbLockTypeSet : 1;
341 bool mbLockTokenSet : 1;
342 //TODO: add other flag to manage reading od token, depth, timeout, owner
343 bool mbLockDiscoveryActive : 1;
316
317 // local helpers
318 bool whitespaceIsAvailable() const
319 {
320 return mpContext && mpContext->getWhiteSpace().getLength();
321 }
322 bool hasParent(WebDAVName aWebDAVName) const
323 {
324 return mpContext && mpContext->getParent() && aWebDAVName == mpContext->getParent()->getWebDAVName();
325 }
344
345 // local helpers
346 bool whitespaceIsAvailable() const
347 {
348 return mpContext && mpContext->getWhiteSpace().getLength();
349 }
350 bool hasParent(WebDAVName aWebDAVName) const
351 {
352 return mpContext && mpContext->getParent() && aWebDAVName == mpContext->getParent()->getWebDAVName();
353 }
326 bool propertyIsReady() const
327 {
354 bool propertyIsReady() const
355 {
328 return hasParent(WebDAVName_prop) && whitespaceIsAvailable();
329 }
330 bool isCollectingProperties() const
331 {
332 return WebDAVResponseParserMode_PropFind == meWebDAVResponseParserMode;
333 }
334 bool isCollectingPropNames() const
335 {
336 return WebDAVResponseParserMode_PropName == meWebDAVResponseParserMode;
337 }
356 return hasParent(WebDAVName_prop) && whitespaceIsAvailable();
357 }
358 bool isCollectingProperties() const
359 {
360 return WebDAVResponseParserMode_PropFind == meWebDAVResponseParserMode;
361 }
362 bool isCollectingPropNames() const
363 {
364 return WebDAVResponseParserMode_PropName == meWebDAVResponseParserMode;
365 }
366 bool isWaitingLockResponse() const
367 {
368 return WebDAVResponseParserMode_LockResponse == meWebDAVResponseParserMode;
369 }
338 bool collectThisPropertyAsName() const
339 {
340 return isCollectingPropNames() && hasParent(WebDAVName_prop);
341 }
342 void pop_context()
343 {
344 if(mpContext)
345 {

--- 9 unchanged lines hidden (view full) ---

355
356 public:
357 WebDAVResponseParser(WebDAVResponseParserMode eWebDAVResponseParserMode);
358 ~WebDAVResponseParser();
359
360 // Methods XDocumentHandler
361 virtual void SAL_CALL startDocument( ) throw (xml::sax::SAXException, uno::RuntimeException);
362 virtual void SAL_CALL endDocument( ) throw (xml::sax::SAXException, uno::RuntimeException);
370 bool collectThisPropertyAsName() const
371 {
372 return isCollectingPropNames() && hasParent(WebDAVName_prop);
373 }
374 void pop_context()
375 {
376 if(mpContext)
377 {

--- 9 unchanged lines hidden (view full) ---

387
388 public:
389 WebDAVResponseParser(WebDAVResponseParserMode eWebDAVResponseParserMode);
390 ~WebDAVResponseParser();
391
392 // Methods XDocumentHandler
393 virtual void SAL_CALL startDocument( ) throw (xml::sax::SAXException, uno::RuntimeException);
394 virtual void SAL_CALL endDocument( ) throw (xml::sax::SAXException, uno::RuntimeException);
363 virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException);
395 virtual void SAL_CALL startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs )
396 throw (xml::sax::SAXException, uno::RuntimeException);
364 virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (xml::sax::SAXException, uno::RuntimeException);
365 virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (xml::sax::SAXException, uno::RuntimeException);
366 virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (xml::sax::SAXException, uno::RuntimeException);
367 virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (xml::sax::SAXException, uno::RuntimeException);
368 virtual void SAL_CALL setDocumentLocator( const uno::Reference< xml::sax::XLocator >& xLocator ) throw (xml::sax::SAXException, uno::RuntimeException);
369
370 const std::vector< http_dav_ucp::DAVResource >& getResult_PropFind() const { return maResult_PropFind; }
371 const std::vector< http_dav_ucp::DAVResourceInfo >& getResult_PropName() const { return maResult_PropName; }
397 virtual void SAL_CALL endElement( const ::rtl::OUString& aName ) throw (xml::sax::SAXException, uno::RuntimeException);
398 virtual void SAL_CALL characters( const ::rtl::OUString& aChars ) throw (xml::sax::SAXException, uno::RuntimeException);
399 virtual void SAL_CALL ignorableWhitespace( const ::rtl::OUString& aWhitespaces ) throw (xml::sax::SAXException, uno::RuntimeException);
400 virtual void SAL_CALL processingInstruction( const ::rtl::OUString& aTarget, const ::rtl::OUString& aData ) throw (xml::sax::SAXException, uno::RuntimeException);
401 virtual void SAL_CALL setDocumentLocator( const uno::Reference< xml::sax::XLocator >& xLocator ) throw (xml::sax::SAXException, uno::RuntimeException);
402
403 const std::vector< http_dav_ucp::DAVResource >& getResult_PropFind() const { return maResult_PropFind; }
404 const std::vector< http_dav_ucp::DAVResourceInfo >& getResult_PropName() const { return maResult_PropName; }
405 const http_dav_ucp::DAVPropertyValue& getResult_Lock() const { return maResult_Lock; }
372 };
373
374 WebDAVResponseParser::WebDAVResponseParser(WebDAVResponseParserMode eWebDAVResponseParserMode)
375 : maResult_PropFind(),
376 maResult_PropName(),
406 };
407
408 WebDAVResponseParser::WebDAVResponseParser(WebDAVResponseParserMode eWebDAVResponseParserMode)
409 : maResult_PropFind(),
410 maResult_PropName(),
411 maResult_Lock(),
377 mpContext(0),
378 maHref(),
412 mpContext(0),
413 maHref(),
414 maHrefLocks(),
379 maStatus(),
380 maResponseProperties(),
381 maPropStatProperties(),
382 maResponseNames(),
383 maPropStatNames(),
415 maStatus(),
416 maResponseProperties(),
417 maPropStatProperties(),
418 maResponseNames(),
419 maPropStatNames(),
420 maLockTokens(),
384 maLockEntries(),
421 maLockEntries(),
422 maLocks(),
385 maLockScope(ucb::LockScope_EXCLUSIVE),
386 maLockType(ucb::LockType_WRITE),
423 maLockScope(ucb::LockScope_EXCLUSIVE),
424 maLockType(ucb::LockType_WRITE),
425 maLockDepth(ucb::LockDepth_ZERO),
426 maLockOwner(),
427 maLockTimeout(0),
387 meWebDAVResponseParserMode(eWebDAVResponseParserMode),
388 mbResourceTypeCollection(false),
389 mbLockScopeSet(false),
428 meWebDAVResponseParserMode(eWebDAVResponseParserMode),
429 mbResourceTypeCollection(false),
430 mbLockScopeSet(false),
390 mbLockTypeSet(false)
431 mbLockTypeSet(false),
432 mbLockDiscoveryActive(false)
391 {
392 }
393
394 WebDAVResponseParser::~WebDAVResponseParser()
395 {
396 OSL_ENSURE(!mpContext, "Parser destructed with existing content (!)");
397 while(mpContext)
398 {

--- 6 unchanged lines hidden (view full) ---

405 OSL_ENSURE(!mpContext, "Parser start with existing content (!)");
406 }
407
408 void SAL_CALL WebDAVResponseParser::endDocument( ) throw (xml::sax::SAXException, uno::RuntimeException)
409 {
410 OSL_ENSURE(!mpContext, "Parser end with existing content (!)");
411 }
412
433 {
434 }
435
436 WebDAVResponseParser::~WebDAVResponseParser()
437 {
438 OSL_ENSURE(!mpContext, "Parser destructed with existing content (!)");
439 while(mpContext)
440 {

--- 6 unchanged lines hidden (view full) ---

447 OSL_ENSURE(!mpContext, "Parser start with existing content (!)");
448 }
449
450 void SAL_CALL WebDAVResponseParser::endDocument( ) throw (xml::sax::SAXException, uno::RuntimeException)
451 {
452 OSL_ENSURE(!mpContext, "Parser end with existing content (!)");
453 }
454
413 void SAL_CALL WebDAVResponseParser::startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs ) throw (xml::sax::SAXException, uno::RuntimeException)
455 void SAL_CALL WebDAVResponseParser::startElement( const ::rtl::OUString& aName, const uno::Reference< xml::sax::XAttributeList >& xAttribs )
456 throw (xml::sax::SAXException, uno::RuntimeException)
414 {
415 const sal_Int32 nLen(aName.getLength());
416
417 if(nLen)
418 {
419 // create new context (push)
420 mpContext = new WebDAVContext(mpContext, aName, xAttribs);
457 {
458 const sal_Int32 nLen(aName.getLength());
459
460 if(nLen)
461 {
462 // create new context (push)
463 mpContext = new WebDAVContext(mpContext, aName, xAttribs);
421
464
422 if(collectThisPropertyAsName())
423 {
424 // When collecting property names and parent is prop there is no need
425 // to handle the content of this property deeper (evtl. preparations)
426 }
427 else
428 {
429 switch(mpContext->getWebDAVNamespace())

--- 56 unchanged lines hidden (view full) ---

486 }
487 case WebDAVName_lockentry:
488 {
489 // lockentry start, reset maLockEntries
490 mbLockScopeSet = false;
491 mbLockTypeSet = false;
492 break;
493 }
465 if(collectThisPropertyAsName())
466 {
467 // When collecting property names and parent is prop there is no need
468 // to handle the content of this property deeper (evtl. preparations)
469 }
470 else
471 {
472 switch(mpContext->getWebDAVNamespace())

--- 56 unchanged lines hidden (view full) ---

529 }
530 case WebDAVName_lockentry:
531 {
532 // lockentry start, reset maLockEntries
533 mbLockScopeSet = false;
534 mbLockTypeSet = false;
535 break;
536 }
537 case WebDAVName_lockdiscovery:
538 {
539 // lockentry start, reset maLocks
540 maLocks.realloc(0);
541 mbLockDiscoveryActive = true;
542 break;
543 }
544 case WebDAVName_activelock:
545 {
546 // activelockstart, reset vars
547 mbLockScopeSet = false;
548 mbLockTypeSet = false;
549 mbLockTokenSet = false;
550 maLockTokens.realloc(0);
551 maHrefLocks = ::rtl::OUString();
552 break;
553 }
554 case WebDAVName_locktoken:
555 {
556 mbLockTokenSet = true;
557 break;
558 }
494 }
495 break;
496 }
497 case WebDAVNamespace_ucb_openoffice_org_dav_props:
498 {
499 break;
500 }
501 }

--- 30 unchanged lines hidden (view full) ---

532 {
533 break;
534 }
535 case WebDAVName_href:
536 {
537 // href end, save it if we have whitespace
538 if(whitespaceIsAvailable())
539 {
559 }
560 break;
561 }
562 case WebDAVNamespace_ucb_openoffice_org_dav_props:
563 {
564 break;
565 }
566 }

--- 30 unchanged lines hidden (view full) ---

597 {
598 break;
599 }
600 case WebDAVName_href:
601 {
602 // href end, save it if we have whitespace
603 if(whitespaceIsAvailable())
604 {
540 maHref = mpContext->getWhiteSpace();
605 if(mbLockDiscoveryActive)
606 {
607 maHrefLocks = mpContext->getWhiteSpace();
608 }
609 else
610 {
611 maHref = mpContext->getWhiteSpace();
612 }
541 }
542 break;
543 }
544 case WebDAVName_status:
545 {
546 // status end, save it if we have whitespace
547 if(whitespaceIsAvailable())
548 {

--- 108 unchanged lines hidden (view full) ---

657 maLockEntries.realloc(nLength + 1);
658 maLockEntries[nLength] = aEntry;
659 }
660 break;
661 }
662 case WebDAVName_exclusive:
663 {
664 // exclusive lockscope end
613 }
614 break;
615 }
616 case WebDAVName_status:
617 {
618 // status end, save it if we have whitespace
619 if(whitespaceIsAvailable())
620 {

--- 108 unchanged lines hidden (view full) ---

729 maLockEntries.realloc(nLength + 1);
730 maLockEntries[nLength] = aEntry;
731 }
732 break;
733 }
734 case WebDAVName_exclusive:
735 {
736 // exclusive lockscope end
665 if(hasParent(WebDAVName_lockscope))
737 if(hasParent(WebDAVName_lockscope) || hasParent(WebDAVName_activelock))
666 {
667 maLockScope = ucb::LockScope_EXCLUSIVE;
668 mbLockScopeSet = true;
669 }
670 break;
671 }
672 case WebDAVName_shared:
673 {
674 // shared lockscope end
738 {
739 maLockScope = ucb::LockScope_EXCLUSIVE;
740 mbLockScopeSet = true;
741 }
742 break;
743 }
744 case WebDAVName_shared:
745 {
746 // shared lockscope end
675 if(hasParent(WebDAVName_lockscope))
747 if(hasParent(WebDAVName_lockscope) || hasParent(WebDAVName_activelock))
676 {
677 maLockScope = ucb::LockScope_SHARED;
678 mbLockScopeSet = true;
679 }
680 break;
681 }
682 case WebDAVName_write:
683 {
684 // write locktype end
748 {
749 maLockScope = ucb::LockScope_SHARED;
750 mbLockScopeSet = true;
751 }
752 break;
753 }
754 case WebDAVName_write:
755 {
756 // write locktype end
685 if(hasParent(WebDAVName_locktype))
757 if(hasParent(WebDAVName_locktype) || hasParent(WebDAVName_activelock))
686 {
687 maLockType = ucb::LockType_WRITE;
688 mbLockTypeSet = true;
689 }
690 break;
691 }
758 {
759 maLockType = ucb::LockType_WRITE;
760 mbLockTypeSet = true;
761 }
762 break;
763 }
764 case WebDAVName_lockdiscovery:
765 {
766 // lockdiscovery end
767 if(hasParent(WebDAVName_prop))
768 {
769 static ::rtl::OUString aStr(rtl::OUString::createFromAscii("DAV:lockdiscovery"));
770 if(isWaitingLockResponse())
771 {
772 maResult_Lock.Name = aStr;
773 maResult_Lock.Value <<= maLocks;
774 }
775 else
776 {
777 ::http_dav_ucp::DAVPropertyValue aDAVPropertyValue;
778
779 aDAVPropertyValue.Name = aStr;
780 aDAVPropertyValue.Value <<= maLocks;
781 maPropStatProperties.push_back(aDAVPropertyValue);
782 }
783 }
784 mbLockDiscoveryActive = false;
785 break;
786 }
787 case WebDAVName_activelock:
788 {
789 if(hasParent(WebDAVName_lockdiscovery) &&
790 mbLockScopeSet && mbLockTypeSet && mbLockTokenSet)
791 {
792 const sal_Int32 nLength(maLocks.getLength());
793 ucb::Lock aLock;
794
795 aLock.Scope = maLockScope;
796 aLock.Type = maLockType;
797 //add tokens, depth, timeout, owner
798 aLock.LockTokens = maLockTokens;
799 aLock.Depth = maLockDepth;
800 aLock.Owner <<= maLockOwner;
801 aLock.Timeout = maLockTimeout;
802 maLocks.realloc(nLength + 1);
803 maLocks[nLength] = aLock;
804 }
805 break;
806 }
807 case WebDAVName_locktoken:
808 {
809 if(hasParent(WebDAVName_activelock))
810 {
811 //add a token to the list of tokens
812 const sal_Int32 nLength(maLockTokens.getLength());
813 maLockTokens.realloc(nLength + 1);
814 maLockTokens[nLength] = maHrefLocks;
815 mbLockTokenSet = true;
816 }
817 break;
818 }
819 case WebDAVName_timeout:
820 {
821 if(hasParent(WebDAVName_activelock))
822 {
823 ::rtl::OUString aStr( mpContext->getWhiteSpace().toAsciiLowerCase());
824 static ::rtl::OUString aInfinite( ::rtl::OUString::createFromAscii( "infinite" ) );
825 static ::rtl::OUString aSecond( ::rtl::OUString::createFromAscii( "second-" ) );
826 //look for infinity
827 sal_Int32 secondIndex;
828 if(aStr.indexOf(aInfinite) != -1)
829 {
830 maLockTimeout = -1;
831 }
832 else if((secondIndex = aStr.indexOf(aSecond)) != -1)
833 {
834 secondIndex += aSecond.getLength();
835 maLockTimeout = aStr.copy(secondIndex).toInt64();
836 }
837 }
838 break;
839 }
840 case WebDAVName_owner:
841 {
842 if(whitespaceIsAvailable())
843 {
844 if(hasParent(WebDAVName_activelock))
845 {
846 maLockOwner = mpContext->getWhiteSpace();
847 }
848 }
849 break;
850 }
851 case WebDAVName_depth:
852 {
853 if(hasParent(WebDAVName_activelock))
854 {
855 //set depth, one of three values
856 ::rtl::OUString aStr( mpContext->getWhiteSpace() );
857 //default to zero, if not found
858 maLockDepth = ucb::LockDepth_ZERO;
859 if(aStr.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("0")))
860 maLockDepth = ucb::LockDepth_ZERO;
861 else if(aStr.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("1")))
862 maLockDepth = ucb::LockDepth_ONE;
863 else if(aStr.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("infinity")))
864 maLockDepth = ucb::LockDepth_INFINITY;
865 }
866 break;
867 }
692 case WebDAVName_propstat:
693 {
694 // propstat end, check status
695 if(maStatus.getLength())
696 {
697 static ::rtl::OUString aStrStatusOkay(::rtl::OUString::createFromAscii("HTTP/1.1 200 OK"));
698
699 if(maStatus.equals(aStrStatusOkay))

--- 15 unchanged lines hidden (view full) ---

715 }
716 }
717 }
718 }
719 break;
720 }
721 case WebDAVName_response:
722 {
868 case WebDAVName_propstat:
869 {
870 // propstat end, check status
871 if(maStatus.getLength())
872 {
873 static ::rtl::OUString aStrStatusOkay(::rtl::OUString::createFromAscii("HTTP/1.1 200 OK"));
874
875 if(maStatus.equals(aStrStatusOkay))

--- 15 unchanged lines hidden (view full) ---

891 }
892 }
893 }
894 }
895 break;
896 }
897 case WebDAVName_response:
898 {
723 // respose end
899 // response end
724 if(maHref.getLength())
725 {
726 if(isCollectingProperties())
727 {
728 // create DAVResource when we have content
729 if(maResponseProperties.size())
730 {
900 if(maHref.getLength())
901 {
902 if(isCollectingProperties())
903 {
904 // create DAVResource when we have content
905 if(maResponseProperties.size())
906 {
731 http_dav_ucp::DAVResource aDAVResource;
907 ::http_dav_ucp::DAVResource aDAVResource;
732
733 aDAVResource.uri = maHref;
734 aDAVResource.properties = maResponseProperties;
735 maResult_PropFind.push_back(aDAVResource);
736 }
737 }
738 else
739 {

--- 50 unchanged lines hidden (view full) ---

790 }
791 }
792 }
793
794 void SAL_CALL WebDAVResponseParser::ignorableWhitespace( const ::rtl::OUString& /*aWhitespaces*/ ) throw (xml::sax::SAXException, uno::RuntimeException)
795 {
796 }
797
908
909 aDAVResource.uri = maHref;
910 aDAVResource.properties = maResponseProperties;
911 maResult_PropFind.push_back(aDAVResource);
912 }
913 }
914 else
915 {

--- 50 unchanged lines hidden (view full) ---

966 }
967 }
968 }
969
970 void SAL_CALL WebDAVResponseParser::ignorableWhitespace( const ::rtl::OUString& /*aWhitespaces*/ ) throw (xml::sax::SAXException, uno::RuntimeException)
971 {
972 }
973
798 void SAL_CALL WebDAVResponseParser::processingInstruction( const ::rtl::OUString& /*aTarget*/, const ::rtl::OUString& /*aData*/ ) throw (xml::sax::SAXException, uno::RuntimeException)
974 void SAL_CALL WebDAVResponseParser::processingInstruction( const ::rtl::OUString& /*aTarget*/, const ::rtl::OUString& /*aData*/ )
975 throw (xml::sax::SAXException, uno::RuntimeException)
799 {
800 }
801
802 void SAL_CALL WebDAVResponseParser::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& /*xLocator*/ ) throw (xml::sax::SAXException, uno::RuntimeException)
803 {
804 }
805} // end of anonymous namespace
806
807//////////////////////////////////////////////////////////////////////////////
808// wrapper for various calls to the parser
809
810namespace
811{
812 void parseWebDAVPropNameResponse(
813 const uno::Reference< io::XInputStream >& xInputStream,
814 std::vector< http_dav_ucp::DAVResource >& rPropFind,
815 std::vector< http_dav_ucp::DAVResourceInfo >& rPropName,
976 {
977 }
978
979 void SAL_CALL WebDAVResponseParser::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& /*xLocator*/ ) throw (xml::sax::SAXException, uno::RuntimeException)
980 {
981 }
982} // end of anonymous namespace
983
984//////////////////////////////////////////////////////////////////////////////
985// wrapper for various calls to the parser
986
987namespace
988{
989 void parseWebDAVPropNameResponse(
990 const uno::Reference< io::XInputStream >& xInputStream,
991 std::vector< http_dav_ucp::DAVResource >& rPropFind,
992 std::vector< http_dav_ucp::DAVResourceInfo >& rPropName,
993 http_dav_ucp::DAVPropertyValue& rPropValue,
816 WebDAVResponseParserMode eWebDAVResponseParserMode)
817 {
818 if(xInputStream.is())
819 {
820 try
821 {
822 // prepare ParserInputSrouce
823 xml::sax::InputSource myInputSource;
824 myInputSource.aInputStream = xInputStream;
994 WebDAVResponseParserMode eWebDAVResponseParserMode)
995 {
996 if(xInputStream.is())
997 {
998 try
999 {
1000 // prepare ParserInputSrouce
1001 xml::sax::InputSource myInputSource;
1002 myInputSource.aInputStream = xInputStream;
825
1003
826 // get parser
827 uno::Reference< xml::sax::XParser > xParser(
828 comphelper::getProcessServiceFactory()->createInstance(
829 rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
830 uno::UNO_QUERY_THROW );
1004 // get parser
1005 uno::Reference< xml::sax::XParser > xParser(
1006 comphelper::getProcessServiceFactory()->createInstance(
1007 rtl::OUString::createFromAscii("com.sun.star.xml.sax.Parser") ),
1008 uno::UNO_QUERY_THROW );
831
1009
832 // create parser; connect parser and filter
833 WebDAVResponseParser* pWebDAVResponseParser = new WebDAVResponseParser(eWebDAVResponseParserMode);
834 uno::Reference< xml::sax::XDocumentHandler > xWebDAVHdl(pWebDAVResponseParser);
835 xParser->setDocumentHandler(xWebDAVHdl);
1010 // create parser; connect parser and filter
1011 WebDAVResponseParser* pWebDAVResponseParser = new WebDAVResponseParser(eWebDAVResponseParserMode);
1012 uno::Reference< xml::sax::XDocumentHandler > xWebDAVHdl(pWebDAVResponseParser);
1013 xParser->setDocumentHandler(xWebDAVHdl);
836
1014
837 // finally, parse the stream
838 xParser->parseStream(myInputSource);
839
840 // get result
841 switch(eWebDAVResponseParserMode)
842 {
843 case WebDAVResponseParserMode_PropFind:
844 {
845 rPropFind = pWebDAVResponseParser->getResult_PropFind();
846 break;
847 }
848 case WebDAVResponseParserMode_PropName:
849 {
850 rPropName = pWebDAVResponseParser->getResult_PropName();
851 break;
852 }
1015 // finally, parse the stream
1016 xParser->parseStream(myInputSource);
1017
1018 // get result
1019 switch(eWebDAVResponseParserMode)
1020 {
1021 case WebDAVResponseParserMode_PropFind:
1022 {
1023 rPropFind = pWebDAVResponseParser->getResult_PropFind();
1024 break;
1025 }
1026 case WebDAVResponseParserMode_PropName:
1027 {
1028 rPropName = pWebDAVResponseParser->getResult_PropName();
1029 break;
1030 }
1031 case WebDAVResponseParserMode_LockResponse:
1032 {
1033 rPropValue = pWebDAVResponseParser->getResult_Lock();
1034 break;
1035 }
853 }
854 }
855 catch(uno::Exception&)
856 {
857 OSL_ENSURE(false, "WebDAV Parse error (!)");
858 }
859 }
860 }
861} // end of anonymous namespace
862
863//////////////////////////////////////////////////////////////////////////////
864// helper to parse a XML WebDAV response
865
866namespace http_dav_ucp
867{
868 std::vector< DAVResource > parseWebDAVPropFindResponse(const uno::Reference< io::XInputStream >& xInputStream)
869 {
870 std::vector< DAVResource > aRetval;
871 std::vector< DAVResourceInfo > aFoo;
1036 }
1037 }
1038 catch(uno::Exception&)
1039 {
1040 OSL_ENSURE(false, "WebDAV Parse error (!)");
1041 }
1042 }
1043 }
1044} // end of anonymous namespace
1045
1046//////////////////////////////////////////////////////////////////////////////
1047// helper to parse a XML WebDAV response
1048
1049namespace http_dav_ucp
1050{
1051 std::vector< DAVResource > parseWebDAVPropFindResponse(const uno::Reference< io::XInputStream >& xInputStream)
1052 {
1053 std::vector< DAVResource > aRetval;
1054 std::vector< DAVResourceInfo > aFoo;
1055 DAVPropertyValue aFoo2;
872
1056
873 parseWebDAVPropNameResponse(xInputStream, aRetval, aFoo, WebDAVResponseParserMode_PropFind);
1057 parseWebDAVPropNameResponse(xInputStream, aRetval, aFoo, aFoo2, WebDAVResponseParserMode_PropFind);
874 return aRetval;
875 }
1058 return aRetval;
1059 }
876
1060
877 std::vector< DAVResourceInfo > parseWebDAVPropNameResponse(const uno::Reference< io::XInputStream >& xInputStream)
878 {
879 std::vector< DAVResource > aFoo;
880 std::vector< DAVResourceInfo > aRetval;
1061 std::vector< DAVResourceInfo > parseWebDAVPropNameResponse(const uno::Reference< io::XInputStream >& xInputStream)
1062 {
1063 std::vector< DAVResource > aFoo;
1064 std::vector< DAVResourceInfo > aRetval;
1065 DAVPropertyValue aFoo2;
881
1066
882 parseWebDAVPropNameResponse(xInputStream, aFoo, aRetval, WebDAVResponseParserMode_PropName);
1067 parseWebDAVPropNameResponse(xInputStream, aFoo, aRetval, aFoo2, WebDAVResponseParserMode_PropName);
883 return aRetval;
884 }
1068 return aRetval;
1069 }
1070
1071 http_dav_ucp::DAVPropertyValue parseWebDAVLockResponse(const uno::Reference< io::XInputStream >& xInputStream)
1072 {
1073 std::vector< DAVResource > aFoo2;
1074 std::vector< DAVResourceInfo > aFoo;
1075 http_dav_ucp::DAVPropertyValue aRetval;
1076
1077
1078 parseWebDAVPropNameResponse(xInputStream, aFoo2, aFoo, aRetval, WebDAVResponseParserMode_LockResponse);
1079 return aRetval;
1080 }
1081
885} // namespace http_dav_ucp
886
887//////////////////////////////////////////////////////////////////////////////
888// eof
1082} // namespace http_dav_ucp
1083
1084//////////////////////////////////////////////////////////////////////////////
1085// eof