xref: /AOO41X/main/ucb/source/ucp/webdav/webdavdatasupplier.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_ucb.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir /**************************************************************************
32*cdf0e10cSrcweir 								TODO
33*cdf0e10cSrcweir  **************************************************************************
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir  *************************************************************************/
36*cdf0e10cSrcweir #include <osl/diagnose.h>
37*cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
38*cdf0e10cSrcweir #include <ucbhelper/contentidentifier.hxx>
39*cdf0e10cSrcweir #include <ucbhelper/providerhelper.hxx>
40*cdf0e10cSrcweir #include "webdavdatasupplier.hxx"
41*cdf0e10cSrcweir #include "webdavcontent.hxx"
42*cdf0e10cSrcweir #include "ContentProperties.hxx"
43*cdf0e10cSrcweir #ifndef _WEBDAV_SESSION_HXX
44*cdf0e10cSrcweir #include "DAVSession.hxx"
45*cdf0e10cSrcweir #endif
46*cdf0e10cSrcweir #include "NeonUri.hxx"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir using namespace com::sun::star;
49*cdf0e10cSrcweir using namespace webdav_ucp;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir namespace webdav_ucp
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir //=========================================================================
55*cdf0e10cSrcweir //
56*cdf0e10cSrcweir // struct ResultListEntry.
57*cdf0e10cSrcweir //
58*cdf0e10cSrcweir //=========================================================================
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir struct ResultListEntry
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir     rtl::OUString                             aId;
63*cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifier > xId;
64*cdf0e10cSrcweir     uno::Reference< ucb::XContent >           xContent;
65*cdf0e10cSrcweir     uno::Reference< sdbc::XRow >              xRow;
66*cdf0e10cSrcweir     const ContentProperties*                  pData;
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir 	ResultListEntry( const ContentProperties* pEntry ) : pData( pEntry ) {};
69*cdf0e10cSrcweir  	~ResultListEntry() { delete pData; }
70*cdf0e10cSrcweir };
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir //=========================================================================
73*cdf0e10cSrcweir //
74*cdf0e10cSrcweir // ResultList.
75*cdf0e10cSrcweir //
76*cdf0e10cSrcweir //=========================================================================
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir typedef std::vector< ResultListEntry* > ResultList;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir //=========================================================================
81*cdf0e10cSrcweir //
82*cdf0e10cSrcweir // struct DataSupplier_Impl.
83*cdf0e10cSrcweir //
84*cdf0e10cSrcweir //=========================================================================
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir struct DataSupplier_Impl
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir     osl::Mutex                                   m_aMutex;
89*cdf0e10cSrcweir     ResultList                                   m_aResults;
90*cdf0e10cSrcweir     rtl::Reference< Content >                    m_xContent;
91*cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory > m_xSMgr;
92*cdf0e10cSrcweir     sal_Int32                                    m_nOpenMode;
93*cdf0e10cSrcweir     sal_Bool                                     m_bCountFinal;
94*cdf0e10cSrcweir     sal_Bool                                     m_bThrowException;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir     DataSupplier_Impl(
97*cdf0e10cSrcweir                 const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
98*cdf0e10cSrcweir                 const rtl::Reference< Content >& rContent,
99*cdf0e10cSrcweir                 sal_Int32 nOpenMode )
100*cdf0e10cSrcweir     : m_xContent( rContent ), m_xSMgr( rxSMgr ), m_nOpenMode( nOpenMode ),
101*cdf0e10cSrcweir       m_bCountFinal( sal_False ), m_bThrowException( sal_False ) {}
102*cdf0e10cSrcweir 	~DataSupplier_Impl();
103*cdf0e10cSrcweir };
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir //=========================================================================
106*cdf0e10cSrcweir DataSupplier_Impl::~DataSupplier_Impl()
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir 	ResultList::const_iterator it  = m_aResults.begin();
109*cdf0e10cSrcweir 	ResultList::const_iterator end = m_aResults.end();
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir 	while ( it != end )
112*cdf0e10cSrcweir 	{
113*cdf0e10cSrcweir 		delete (*it);
114*cdf0e10cSrcweir 		it++;
115*cdf0e10cSrcweir 	}
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir //=========================================================================
121*cdf0e10cSrcweir //=========================================================================
122*cdf0e10cSrcweir //
123*cdf0e10cSrcweir // DataSupplier Implementation.
124*cdf0e10cSrcweir //
125*cdf0e10cSrcweir //=========================================================================
126*cdf0e10cSrcweir //=========================================================================
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir DataSupplier::DataSupplier(
129*cdf0e10cSrcweir             const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
130*cdf0e10cSrcweir             const rtl::Reference< Content >& rContent,
131*cdf0e10cSrcweir             sal_Int32 nOpenMode )
132*cdf0e10cSrcweir : m_pImpl( new DataSupplier_Impl( rxSMgr, rContent, nOpenMode ) )
133*cdf0e10cSrcweir {
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir //=========================================================================
137*cdf0e10cSrcweir // virtual
138*cdf0e10cSrcweir DataSupplier::~DataSupplier()
139*cdf0e10cSrcweir {
140*cdf0e10cSrcweir 	delete m_pImpl;
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir //=========================================================================
144*cdf0e10cSrcweir // virtual
145*cdf0e10cSrcweir rtl::OUString DataSupplier::queryContentIdentifierString( sal_uInt32 nIndex )
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
150*cdf0e10cSrcweir 	{
151*cdf0e10cSrcweir         rtl::OUString aId = m_pImpl->m_aResults[ nIndex ]->aId;
152*cdf0e10cSrcweir 		if ( aId.getLength() )
153*cdf0e10cSrcweir 		{
154*cdf0e10cSrcweir 			// Already cached.
155*cdf0e10cSrcweir 			return aId;
156*cdf0e10cSrcweir 		}
157*cdf0e10cSrcweir 	}
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	if ( getResult( nIndex ) )
160*cdf0e10cSrcweir 	{
161*cdf0e10cSrcweir         rtl::OUString aId = m_pImpl->m_xContent->getResourceAccess().getURL();
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir 		const ContentProperties& props
164*cdf0e10cSrcweir 							= *( m_pImpl->m_aResults[ nIndex ]->pData );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir 		if ( ( aId.lastIndexOf( '/' ) + 1 ) != aId.getLength() )
167*cdf0e10cSrcweir             aId += rtl::OUString::createFromAscii( "/" );
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir         aId += props.getEscapedTitle();
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir         if ( props.isTrailingSlash() )
172*cdf0e10cSrcweir             aId += rtl::OUString::createFromAscii( "/" );
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir 		m_pImpl->m_aResults[ nIndex ]->aId = aId;
175*cdf0e10cSrcweir 		return aId;
176*cdf0e10cSrcweir 	}
177*cdf0e10cSrcweir     return rtl::OUString();
178*cdf0e10cSrcweir }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir //=========================================================================
181*cdf0e10cSrcweir // virtual
182*cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifier >
183*cdf0e10cSrcweir DataSupplier::queryContentIdentifier( sal_uInt32 nIndex )
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
188*cdf0e10cSrcweir 	{
189*cdf0e10cSrcweir         uno::Reference< ucb::XContentIdentifier > xId
190*cdf0e10cSrcweir             = m_pImpl->m_aResults[ nIndex ]->xId;
191*cdf0e10cSrcweir 		if ( xId.is() )
192*cdf0e10cSrcweir 		{
193*cdf0e10cSrcweir 			// Already cached.
194*cdf0e10cSrcweir 			return xId;
195*cdf0e10cSrcweir 		}
196*cdf0e10cSrcweir 	}
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     rtl::OUString aId = queryContentIdentifierString( nIndex );
199*cdf0e10cSrcweir 	if ( aId.getLength() )
200*cdf0e10cSrcweir 	{
201*cdf0e10cSrcweir         uno::Reference< ucb::XContentIdentifier > xId
202*cdf0e10cSrcweir             = new ::ucbhelper::ContentIdentifier( aId );
203*cdf0e10cSrcweir 		m_pImpl->m_aResults[ nIndex ]->xId = xId;
204*cdf0e10cSrcweir 		return xId;
205*cdf0e10cSrcweir 	}
206*cdf0e10cSrcweir     return uno::Reference< ucb::XContentIdentifier >();
207*cdf0e10cSrcweir }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir //=========================================================================
210*cdf0e10cSrcweir // virtual
211*cdf0e10cSrcweir uno::Reference< ucb::XContent >
212*cdf0e10cSrcweir DataSupplier::queryContent( sal_uInt32 nIndex )
213*cdf0e10cSrcweir {
214*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
217*cdf0e10cSrcweir 	{
218*cdf0e10cSrcweir         uno::Reference< ucb::XContent > xContent
219*cdf0e10cSrcweir             = m_pImpl->m_aResults[ nIndex ]->xContent;
220*cdf0e10cSrcweir 		if ( xContent.is() )
221*cdf0e10cSrcweir 		{
222*cdf0e10cSrcweir 			// Already cached.
223*cdf0e10cSrcweir 			return xContent;
224*cdf0e10cSrcweir 		}
225*cdf0e10cSrcweir 	}
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifier > xId
228*cdf0e10cSrcweir         = queryContentIdentifier( nIndex );
229*cdf0e10cSrcweir 	if ( xId.is() )
230*cdf0e10cSrcweir 	{
231*cdf0e10cSrcweir 		try
232*cdf0e10cSrcweir 		{
233*cdf0e10cSrcweir             uno::Reference< ucb::XContent > xContent
234*cdf0e10cSrcweir 				= m_pImpl->m_xContent->getProvider()->queryContent( xId );
235*cdf0e10cSrcweir 			m_pImpl->m_aResults[ nIndex ]->xContent = xContent;
236*cdf0e10cSrcweir 			return xContent;
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 		}
239*cdf0e10cSrcweir         catch ( ucb::IllegalIdentifierException& )
240*cdf0e10cSrcweir 		{
241*cdf0e10cSrcweir 		}
242*cdf0e10cSrcweir 	}
243*cdf0e10cSrcweir     return uno::Reference< ucb::XContent >();
244*cdf0e10cSrcweir }
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir //=========================================================================
247*cdf0e10cSrcweir // virtual
248*cdf0e10cSrcweir sal_Bool DataSupplier::getResult( sal_uInt32 nIndex )
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
251*cdf0e10cSrcweir 
252*cdf0e10cSrcweir 	if ( m_pImpl->m_aResults.size() > nIndex )
253*cdf0e10cSrcweir 	{
254*cdf0e10cSrcweir 		// Result already present.
255*cdf0e10cSrcweir 		return sal_True;
256*cdf0e10cSrcweir 	}
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir 	// Obtain values...
259*cdf0e10cSrcweir 	if ( getData() )
260*cdf0e10cSrcweir 	{
261*cdf0e10cSrcweir 		if ( m_pImpl->m_aResults.size() > nIndex )
262*cdf0e10cSrcweir 		{
263*cdf0e10cSrcweir 			// Result already present.
264*cdf0e10cSrcweir 			return sal_True;
265*cdf0e10cSrcweir 		}
266*cdf0e10cSrcweir 	}
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir 	return sal_False;
269*cdf0e10cSrcweir }
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir //=========================================================================
272*cdf0e10cSrcweir // virtual
273*cdf0e10cSrcweir sal_uInt32 DataSupplier::totalCount()
274*cdf0e10cSrcweir {
275*cdf0e10cSrcweir   // Obtain values...
276*cdf0e10cSrcweir   getData();
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir   return m_pImpl->m_aResults.size();
279*cdf0e10cSrcweir }
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir //=========================================================================
282*cdf0e10cSrcweir // virtual
283*cdf0e10cSrcweir sal_uInt32 DataSupplier::currentCount()
284*cdf0e10cSrcweir {
285*cdf0e10cSrcweir 	return m_pImpl->m_aResults.size();
286*cdf0e10cSrcweir }
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir //=========================================================================
289*cdf0e10cSrcweir // virtual
290*cdf0e10cSrcweir sal_Bool DataSupplier::isCountFinal()
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir 	return m_pImpl->m_bCountFinal;
293*cdf0e10cSrcweir }
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir //=========================================================================
296*cdf0e10cSrcweir // virtual
297*cdf0e10cSrcweir uno::Reference< sdbc::XRow > DataSupplier::queryPropertyValues(
298*cdf0e10cSrcweir                                                     sal_uInt32 nIndex  )
299*cdf0e10cSrcweir {
300*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
303*cdf0e10cSrcweir 	{
304*cdf0e10cSrcweir         uno::Reference< sdbc::XRow > xRow = m_pImpl->m_aResults[ nIndex ]->xRow;
305*cdf0e10cSrcweir 		if ( xRow.is() )
306*cdf0e10cSrcweir 		{
307*cdf0e10cSrcweir 			// Already cached.
308*cdf0e10cSrcweir 			return xRow;
309*cdf0e10cSrcweir 		}
310*cdf0e10cSrcweir 	}
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir 	if ( getResult( nIndex ) )
313*cdf0e10cSrcweir 	{
314*cdf0e10cSrcweir         uno::Reference< sdbc::XRow > xRow
315*cdf0e10cSrcweir             = Content::getPropertyValues(
316*cdf0e10cSrcweir                 m_pImpl->m_xSMgr,
317*cdf0e10cSrcweir                 getResultSet()->getProperties(),
318*cdf0e10cSrcweir                 *(m_pImpl->m_aResults[ nIndex ]->pData),
319*cdf0e10cSrcweir                 rtl::Reference< ::ucbhelper::ContentProviderImplHelper >(
320*cdf0e10cSrcweir                     m_pImpl->m_xContent->getProvider().get() ),
321*cdf0e10cSrcweir                 queryContentIdentifierString( nIndex ) );
322*cdf0e10cSrcweir 		m_pImpl->m_aResults[ nIndex ]->xRow = xRow;
323*cdf0e10cSrcweir 		return xRow;
324*cdf0e10cSrcweir 	}
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir     return uno::Reference< sdbc::XRow >();
327*cdf0e10cSrcweir }
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir //=========================================================================
330*cdf0e10cSrcweir // virtual
331*cdf0e10cSrcweir void DataSupplier::releasePropertyValues( sal_uInt32 nIndex )
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir 	osl::Guard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir 	if ( nIndex < m_pImpl->m_aResults.size() )
336*cdf0e10cSrcweir         m_pImpl->m_aResults[ nIndex ]->xRow = uno::Reference< sdbc::XRow >();
337*cdf0e10cSrcweir }
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir //=========================================================================
340*cdf0e10cSrcweir // virtual
341*cdf0e10cSrcweir void DataSupplier::close()
342*cdf0e10cSrcweir {
343*cdf0e10cSrcweir }
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir //=========================================================================
346*cdf0e10cSrcweir // virtual
347*cdf0e10cSrcweir void DataSupplier::validate()
348*cdf0e10cSrcweir     throw( ucb::ResultSetException )
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir     if ( m_pImpl->m_bThrowException )
351*cdf0e10cSrcweir         throw ucb::ResultSetException();
352*cdf0e10cSrcweir }
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir //=========================================================================
355*cdf0e10cSrcweir sal_Bool DataSupplier::getData()
356*cdf0e10cSrcweir {
357*cdf0e10cSrcweir 	osl::ClearableGuard< osl::Mutex > aGuard( m_pImpl->m_aMutex );
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir 	if ( !m_pImpl->m_bCountFinal )
360*cdf0e10cSrcweir 	{
361*cdf0e10cSrcweir         std::vector< rtl::OUString > propertyNames;
362*cdf0e10cSrcweir 		ContentProperties::UCBNamesToDAVNames(
363*cdf0e10cSrcweir 						getResultSet()->getProperties(), propertyNames );
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 		// Append "resourcetype", if not already present. It's value is
366*cdf0e10cSrcweir 		// needed to get a valid ContentProperties::pIsFolder value, which
367*cdf0e10cSrcweir 		// is needed for OpenMode handling.
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir         std::vector< rtl::OUString >::const_iterator it
370*cdf0e10cSrcweir             = propertyNames.begin();
371*cdf0e10cSrcweir         std::vector< rtl::OUString >::const_iterator end
372*cdf0e10cSrcweir             = propertyNames.end();
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir 		while ( it != end )
375*cdf0e10cSrcweir 		{
376*cdf0e10cSrcweir 			if ( (*it).equals( DAVProperties::RESOURCETYPE ) )
377*cdf0e10cSrcweir 				break;
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir 			it++;
380*cdf0e10cSrcweir 		}
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 		if ( it == end )
383*cdf0e10cSrcweir 			propertyNames.push_back( DAVProperties::RESOURCETYPE );
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir 		std::vector< DAVResource > resources;
386*cdf0e10cSrcweir 		try
387*cdf0e10cSrcweir 		{
388*cdf0e10cSrcweir             // propfind depth 1, get property values for parent AND for each
389*cdf0e10cSrcweir             // child
390*cdf0e10cSrcweir     		m_pImpl->m_xContent->getResourceAccess()
391*cdf0e10cSrcweir 				.PROPFIND( DAVONE,
392*cdf0e10cSrcweir 						   propertyNames,
393*cdf0e10cSrcweir 						   resources,
394*cdf0e10cSrcweir 						   getResultSet()->getEnvironment() );
395*cdf0e10cSrcweir   		}
396*cdf0e10cSrcweir   		catch ( DAVException & )
397*cdf0e10cSrcweir 		{
398*cdf0e10cSrcweir //    		OSL_ENSURE( sal_False, "PROPFIND : DAVException" );
399*cdf0e10cSrcweir             m_pImpl->m_bThrowException = sal_True;
400*cdf0e10cSrcweir   		}
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir         if ( !m_pImpl->m_bThrowException )
403*cdf0e10cSrcweir         {
404*cdf0e10cSrcweir             try
405*cdf0e10cSrcweir             {
406*cdf0e10cSrcweir                 NeonUri aURI(
407*cdf0e10cSrcweir                     m_pImpl->m_xContent->getResourceAccess().getURL() );
408*cdf0e10cSrcweir                 rtl::OUString aPath = aURI.GetPath();
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir                 if ( aPath.getStr()[ aPath.getLength() - 1 ]
411*cdf0e10cSrcweir                      == sal_Unicode( '/' ) )
412*cdf0e10cSrcweir                     aPath = aPath.copy( 0, aPath.getLength() - 1 );
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir                 aPath = NeonUri::unescape( aPath );
415*cdf0e10cSrcweir                 bool bFoundParent = false;
416*cdf0e10cSrcweir 
417*cdf0e10cSrcweir                 for ( sal_uInt32 n = 0; n < resources.size(); ++n )
418*cdf0e10cSrcweir                 {
419*cdf0e10cSrcweir                     const DAVResource & rRes = resources[ n ];
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir                     // Filter parent, which is contained somewhere(!) in
422*cdf0e10cSrcweir                     // the vector.
423*cdf0e10cSrcweir                     if ( !bFoundParent )
424*cdf0e10cSrcweir                     {
425*cdf0e10cSrcweir                         try
426*cdf0e10cSrcweir                         {
427*cdf0e10cSrcweir                             NeonUri aCurrURI( rRes.uri );
428*cdf0e10cSrcweir                             rtl::OUString aCurrPath = aCurrURI.GetPath();
429*cdf0e10cSrcweir                             if ( aCurrPath.getStr()[
430*cdf0e10cSrcweir                                      aCurrPath.getLength() - 1 ]
431*cdf0e10cSrcweir                                  == sal_Unicode( '/' ) )
432*cdf0e10cSrcweir                                 aCurrPath
433*cdf0e10cSrcweir                                     = aCurrPath.copy(
434*cdf0e10cSrcweir                                         0,
435*cdf0e10cSrcweir                                         aCurrPath.getLength() - 1 );
436*cdf0e10cSrcweir 
437*cdf0e10cSrcweir                             aCurrPath = NeonUri::unescape( aCurrPath );
438*cdf0e10cSrcweir                             if ( aPath == aCurrPath )
439*cdf0e10cSrcweir                             {
440*cdf0e10cSrcweir                                 bFoundParent = true;
441*cdf0e10cSrcweir                                 continue;
442*cdf0e10cSrcweir                             }
443*cdf0e10cSrcweir                         }
444*cdf0e10cSrcweir                         catch ( DAVException const & )
445*cdf0e10cSrcweir                         {
446*cdf0e10cSrcweir                             // do nothing, ignore error. continue.
447*cdf0e10cSrcweir                         }
448*cdf0e10cSrcweir                     }
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir                     ContentProperties* pContentProperties
451*cdf0e10cSrcweir                         = new ContentProperties( rRes );
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir                     // Check resource against open mode.
454*cdf0e10cSrcweir                     switch ( m_pImpl->m_nOpenMode )
455*cdf0e10cSrcweir                     {
456*cdf0e10cSrcweir                     case ucb::OpenMode::FOLDERS:
457*cdf0e10cSrcweir                         {
458*cdf0e10cSrcweir                             sal_Bool bFolder = sal_False;
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir                             const uno::Any & rValue
461*cdf0e10cSrcweir                                 = pContentProperties->getValue(
462*cdf0e10cSrcweir                                     rtl::OUString(
463*cdf0e10cSrcweir                                         RTL_CONSTASCII_USTRINGPARAM(
464*cdf0e10cSrcweir                                             "IsFolder" ) ) );
465*cdf0e10cSrcweir                             rValue >>= bFolder;
466*cdf0e10cSrcweir 
467*cdf0e10cSrcweir                             if ( !bFolder )
468*cdf0e10cSrcweir                                 continue;
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir                             break;
471*cdf0e10cSrcweir                         }
472*cdf0e10cSrcweir 
473*cdf0e10cSrcweir                     case ucb::OpenMode::DOCUMENTS:
474*cdf0e10cSrcweir                         {
475*cdf0e10cSrcweir                             sal_Bool bDocument = sal_False;
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir                             const uno::Any & rValue
478*cdf0e10cSrcweir                                 = pContentProperties->getValue(
479*cdf0e10cSrcweir                                     rtl::OUString(
480*cdf0e10cSrcweir                                         RTL_CONSTASCII_USTRINGPARAM(
481*cdf0e10cSrcweir                                             "IsDocument" ) ) );
482*cdf0e10cSrcweir                             rValue >>= bDocument;
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir                             if ( !bDocument )
485*cdf0e10cSrcweir                                 continue;
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir                             break;
488*cdf0e10cSrcweir                         }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir                     case ucb::OpenMode::ALL:
491*cdf0e10cSrcweir                     default:
492*cdf0e10cSrcweir                         break;
493*cdf0e10cSrcweir                     }
494*cdf0e10cSrcweir 
495*cdf0e10cSrcweir                     m_pImpl->m_aResults.push_back(
496*cdf0e10cSrcweir                         new ResultListEntry( pContentProperties ) );
497*cdf0e10cSrcweir                 }
498*cdf0e10cSrcweir             }
499*cdf0e10cSrcweir             catch ( DAVException const & )
500*cdf0e10cSrcweir             {
501*cdf0e10cSrcweir             }
502*cdf0e10cSrcweir         }
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir   		m_pImpl->m_bCountFinal = sal_True;
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir 		// Callback possible, because listeners may be informed!
507*cdf0e10cSrcweir 		aGuard.clear();
508*cdf0e10cSrcweir 		getResultSet()->rowCountFinal();
509*cdf0e10cSrcweir 	}
510*cdf0e10cSrcweir     return !m_pImpl->m_bThrowException;
511*cdf0e10cSrcweir }
512*cdf0e10cSrcweir 
513