1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <comphelper/processfactory.hxx>
11 #include <ucbhelper/contentidentifier.hxx>
12 #include <ucbhelper/contenthelper.hxx>
13 #include <com/sun/star/ucb/ContentCreationException.hpp>
15 #include "cmis_content.hxx"
16 #include "cmis_provider.hxx"
17 #include "cmis_repo_content.hxx"
19 using namespace com::sun::star
;
23 uno::Reference
< com::sun::star::ucb::XContent
> SAL_CALL
24 ContentProvider::queryContent(
26 com::sun::star::ucb::XContentIdentifier
>& Identifier
)
27 throw( com::sun::star::ucb::IllegalIdentifierException
,
28 uno::RuntimeException
, std::exception
)
30 osl::MutexGuard
aGuard( m_aMutex
);
32 // Check, if a content with given id already exists...
33 uno::Reference
< ucb::XContent
> xContent
= queryExistingContent( Identifier
).get();
39 URL
aUrl( Identifier
->getContentIdentifier( ) );
40 if ( aUrl
.getRepositoryId( ).isEmpty( ) )
42 xContent
= new RepoContent( m_xContext
, this, Identifier
);
43 registerNewContent( xContent
);
47 xContent
= new Content( m_xContext
, this, Identifier
);
48 registerNewContent( xContent
);
51 catch ( com::sun::star::ucb::ContentCreationException
const & )
53 throw com::sun::star::ucb::IllegalIdentifierException();
56 if ( !xContent
->getIdentifier().is() )
57 throw com::sun::star::ucb::IllegalIdentifierException();
62 libcmis::Session
* ContentProvider::getSession( const OUString
& sBindingUrl
)
64 libcmis::Session
* pSession
= NULL
;
65 std::map
< OUString
, libcmis::Session
* >::iterator it
= m_aSessionCache
.find( sBindingUrl
);
66 if ( it
!= m_aSessionCache
.end( ) )
68 pSession
= it
->second
;
73 void ContentProvider::registerSession( const OUString
& sBindingUrl
, libcmis::Session
* pSession
)
75 m_aSessionCache
.insert( std::pair
< OUString
, libcmis::Session
* >( sBindingUrl
, pSession
) );
78 ContentProvider::ContentProvider(
79 const uno::Reference
< uno::XComponentContext
>& rxContext
)
80 : ::ucbhelper::ContentProviderImplHelper( rxContext
)
84 ContentProvider::~ContentProvider()
89 void SAL_CALL
ContentProvider::acquire()
92 OWeakObject::acquire();
95 void SAL_CALL
ContentProvider::release()
98 OWeakObject::release();
101 css::uno::Any SAL_CALL
ContentProvider::queryInterface( const css::uno::Type
& rType
)
102 throw( css::uno::RuntimeException
, std::exception
)
104 css::uno::Any aRet
= cppu::queryInterface( rType
,
105 (static_cast< lang::XTypeProvider
* >(this)),
106 (static_cast< lang::XServiceInfo
* >(this)),
107 (static_cast< css::ucb::XContentProvider
* >(this))
109 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
112 XTYPEPROVIDER_IMPL_3( ContentProvider
,
115 com::sun::star::ucb::XContentProvider
);
117 XSERVICEINFO_IMPL_1_CTX( ContentProvider
,
118 OUString("com.sun.star.comp.CmisContentProvider"),
119 "com.sun.star.ucb.CmisContentProvider" );
121 ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider
);
125 extern "C" SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
ucpcmis1_component_getFactory( const sal_Char
*pImplName
,
126 void *pServiceManager
, void * )
130 uno::Reference
< lang::XMultiServiceFactory
> xSMgr
131 (static_cast< lang::XMultiServiceFactory
* >( pServiceManager
) );
132 uno::Reference
< lang::XSingleServiceFactory
> xFactory
;
134 if ( ::cmis::ContentProvider::getImplementationName_Static().equalsAscii( pImplName
) )
135 xFactory
= ::cmis::ContentProvider::createServiceFactory( xSMgr
);
140 pRet
= xFactory
.get();
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */