bump product version to 7.6.3.2-android
[LibreOffice.git] / ucb / source / ucp / cmis / cmis_provider.cxx
blob290b9c75562985bfa361ae29e9879c431df9e6b1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <comphelper/processfactory.hxx>
11 #include <cppuhelper/queryinterface.hxx>
12 #include <cppuhelper/weak.hxx>
13 #include <ucbhelper/macros.hxx>
14 #include <com/sun/star/ucb/ContentCreationException.hpp>
15 #include <com/sun/star/ucb/IllegalIdentifierException.hpp>
17 #include "cmis_content.hxx"
18 #include "cmis_provider.hxx"
19 #include "cmis_repo_content.hxx"
21 using namespace com::sun::star;
23 namespace cmis
25 uno::Reference< css::ucb::XContent > SAL_CALL
26 ContentProvider::queryContent(
27 const uno::Reference< css::ucb::XContentIdentifier >& Identifier )
29 osl::MutexGuard aGuard( m_aMutex );
31 // Check, if a content with given id already exists...
32 uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier );
33 if ( xContent.is() )
34 return xContent;
36 try
38 URL aUrl( Identifier->getContentIdentifier( ) );
39 if ( aUrl.getRepositoryId( ).isEmpty( ) )
41 xContent = new RepoContent( m_xContext, this, Identifier );
42 registerNewContent( xContent );
44 else
46 xContent = new Content( m_xContext, this, Identifier );
47 registerNewContent( xContent );
50 catch ( css::ucb::ContentCreationException const & )
52 throw css::ucb::IllegalIdentifierException();
55 if ( !xContent->getIdentifier().is() )
56 throw css::ucb::IllegalIdentifierException();
58 return xContent;
61 libcmis::Session* ContentProvider::getSession( const OUString& sBindingUrl, const OUString& sUsername )
63 libcmis::Session* pSession = nullptr;
64 std::map< std::pair< OUString, OUString >, libcmis::Session* >::iterator it
65 = m_aSessionCache.find( std::pair< OUString, OUString >( sBindingUrl, sUsername ) );
66 if ( it != m_aSessionCache.end( ) )
68 pSession = it->second;
70 return pSession;
73 void ContentProvider::registerSession( const OUString& sBindingUrl, const OUString& sUsername, libcmis::Session* pSession )
75 m_aSessionCache.insert( std::pair< std::pair< OUString, OUString >, libcmis::Session* >
77 std::pair< OUString, OUString >( sBindingUrl, sUsername ),
78 pSession
79 ) );
82 ContentProvider::ContentProvider(
83 const uno::Reference< uno::XComponentContext >& rxContext )
84 : ::ucbhelper::ContentProviderImplHelper( rxContext )
88 ContentProvider::~ContentProvider()
92 //XInterface
93 void SAL_CALL ContentProvider::acquire()
94 noexcept
96 OWeakObject::acquire();
99 void SAL_CALL ContentProvider::release()
100 noexcept
102 OWeakObject::release();
105 css::uno::Any SAL_CALL ContentProvider::queryInterface( const css::uno::Type & rType )
107 css::uno::Any aRet = cppu::queryInterface( rType,
108 static_cast< lang::XTypeProvider* >(this),
109 static_cast< lang::XServiceInfo* >(this),
110 static_cast< css::ucb::XContentProvider* >(this)
112 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
115 XTYPEPROVIDER_IMPL_3( ContentProvider,
116 lang::XTypeProvider,
117 lang::XServiceInfo,
118 css::ucb::XContentProvider );
120 sal_Bool ContentProvider::supportsService(const OUString& sServiceName)
122 return cppu::supportsService(this, sServiceName);
124 OUString ContentProvider::getImplementationName()
126 return "com.sun.star.comp.CmisContentProvider";
128 css::uno::Sequence< OUString > ContentProvider::getSupportedServiceNames()
130 return { "com.sun.star.ucb.CmisContentProvider" };
135 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
136 ucb_cmis_ContentProvider_get_implementation(
137 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
139 return cppu::acquire(new cmis::ContentProvider(context));
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */