1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Version: MPL 1.1 / GPLv3+ / LGPLv3+
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License or as specified alternatively below. You may obtain a copy of
8 * the License at http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * Major Contributor(s):
16 * [ Copyright (C) 2011 SUSE <cbosdonnat@suse.com> (initial developer) ]
18 * All Rights Reserved.
20 * For minor contributions see the git repository.
22 * Alternatively, the contents of this file may be used under the terms of
23 * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 * instead of those above.
29 #include <ucbhelper/contentidentifier.hxx>
30 #include <ucbhelper/contenthelper.hxx>
31 #include <com/sun/star/ucb/ContentCreationException.hpp>
32 #include "cmis_provider.hxx"
33 #include "cmis_content.hxx"
37 using namespace com::sun::star
;
41 uno::Reference
< com::sun::star::ucb::XContent
> SAL_CALL
42 ContentProvider::queryContent(
44 com::sun::star::ucb::XContentIdentifier
>& Identifier
)
45 throw( com::sun::star::ucb::IllegalIdentifierException
,
46 uno::RuntimeException
)
48 osl::MutexGuard
aGuard( m_aMutex
);
50 // Check, if a content with given id already exists...
51 uno::Reference
< ucb::XContent
> xContent
= queryExistingContent( Identifier
).get();
57 xContent
= new ::cmis::Content( m_xSMgr
, this, Identifier
);
58 registerNewContent( xContent
);
60 catch ( com::sun::star::ucb::ContentCreationException
const & )
62 throw com::sun::star::ucb::IllegalIdentifierException();
65 if ( !xContent
->getIdentifier().is() )
66 throw com::sun::star::ucb::IllegalIdentifierException();
71 libcmis::Session
* ContentProvider::getSession( const rtl::OUString
& sBindingUrl
)
73 libcmis::Session
* pSession
= NULL
;
74 std::map
< rtl::OUString
, libcmis::Session
* >::iterator it
= m_aSessionCache
.find( sBindingUrl
);
75 if ( it
!= m_aSessionCache
.end( ) )
77 pSession
= it
->second
;
82 void ContentProvider::registerSession( const rtl::OUString
& sBindingUrl
, libcmis::Session
* pSession
)
84 m_aSessionCache
.insert( std::pair
< rtl::OUString
, libcmis::Session
* >( sBindingUrl
, pSession
) );
87 ContentProvider::ContentProvider(
88 const uno::Reference
< lang::XMultiServiceFactory
>& rSMgr
)
89 : ::ucbhelper::ContentProviderImplHelper( rSMgr
)
93 ContentProvider::~ContentProvider()
97 XINTERFACE_IMPL_3( ContentProvider
,
100 com::sun::star::ucb::XContentProvider
);
102 XTYPEPROVIDER_IMPL_3( ContentProvider
,
105 com::sun::star::ucb::XContentProvider
);
107 XSERVICEINFO_IMPL_1( ContentProvider
,
108 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
109 "com.sun.star.comp.CmisContentProvider" )),
110 rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
111 "com.sun.star.ucb.CmisContentProvider" )) );
113 ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider
);
117 extern "C" SAL_DLLPUBLIC_EXPORT
void * SAL_CALL
component_getFactory( const sal_Char
*pImplName
,
118 void *pServiceManager
, void * )
122 uno::Reference
< lang::XMultiServiceFactory
> xSMgr
123 (reinterpret_cast< lang::XMultiServiceFactory
* >( pServiceManager
) );
124 uno::Reference
< lang::XSingleServiceFactory
> xFactory
;
126 if ( !::cmis::ContentProvider::getImplementationName_Static().compareToAscii( pImplName
) )
127 xFactory
= ::cmis::ContentProvider::createServiceFactory( xSMgr
);
132 pRet
= xFactory
.get();
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */