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/.
12 #include <comphelper/processfactory.hxx>
13 #include <ucbhelper/contentidentifier.hxx>
14 #include <ucbhelper/contenthelper.hxx>
15 #include <com/sun/star/ucb/ContentCreationException.hpp>
17 #include "cmis_content.hxx"
18 #include "cmis_provider.hxx"
19 #include "cmis_repo_content.hxx"
21 using namespace com::sun::star
;
25 uno::Reference
< com::sun::star::ucb::XContent
> SAL_CALL
26 ContentProvider::queryContent(
28 com::sun::star::ucb::XContentIdentifier
>& Identifier
)
29 throw( com::sun::star::ucb::IllegalIdentifierException
,
30 uno::RuntimeException
)
32 osl::MutexGuard
aGuard( m_aMutex
);
34 // Check, if a content with given id already exists...
35 uno::Reference
< ucb::XContent
> xContent
= queryExistingContent( Identifier
).get();
41 URL
aUrl( Identifier
->getContentIdentifier( ) );
42 if ( aUrl
.getRepositoryId( ).isEmpty( ) )
44 xContent
= new RepoContent( m_xContext
, this, Identifier
);
45 registerNewContent( xContent
);
49 xContent
= new Content( m_xContext
, this, Identifier
);
50 registerNewContent( xContent
);
53 catch ( com::sun::star::ucb::ContentCreationException
const & )
55 throw com::sun::star::ucb::IllegalIdentifierException();
58 if ( !xContent
->getIdentifier().is() )
59 throw com::sun::star::ucb::IllegalIdentifierException();
64 libcmis::Session
* ContentProvider::getSession( const OUString
& sBindingUrl
)
66 libcmis::Session
* pSession
= NULL
;
67 std::map
< OUString
, libcmis::Session
* >::iterator it
= m_aSessionCache
.find( sBindingUrl
);
68 if ( it
!= m_aSessionCache
.end( ) )
70 pSession
= it
->second
;
75 void ContentProvider::registerSession( const OUString
& sBindingUrl
, libcmis::Session
* pSession
)
77 m_aSessionCache
.insert( std::pair
< OUString
, libcmis::Session
* >( sBindingUrl
, pSession
) );
80 ContentProvider::ContentProvider(
81 const uno::Reference
< uno::XComponentContext
>& rxContext
)
82 : ::ucbhelper::ContentProviderImplHelper( rxContext
)
86 ContentProvider::~ContentProvider()
90 XINTERFACE_IMPL_3( ContentProvider
,
93 com::sun::star::ucb::XContentProvider
);
95 XTYPEPROVIDER_IMPL_3( ContentProvider
,
98 com::sun::star::ucb::XContentProvider
);
100 XSERVICEINFO_IMPL_1_CTX( ContentProvider
,
101 OUString("com.sun.star.comp.CmisContentProvider"),
102 OUString("com.sun.star.ucb.CmisContentProvider") );
104 ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider
);
108 extern "C" SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
ucpcmis1_component_getFactory( const sal_Char
*pImplName
,
109 void *pServiceManager
, void * )
113 uno::Reference
< lang::XMultiServiceFactory
> xSMgr
114 (reinterpret_cast< lang::XMultiServiceFactory
* >( pServiceManager
) );
115 uno::Reference
< lang::XSingleServiceFactory
> xFactory
;
117 if ( !::cmis::ContentProvider::getImplementationName_Static().compareToAscii( pImplName
) )
118 xFactory
= ::cmis::ContentProvider::createServiceFactory( xSMgr
);
123 pRet
= xFactory
.get();
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */