Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : : *
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/
9 : : *
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
13 : : * License.
14 : : *
15 : : * Major Contributor(s):
16 : : * [ Copyright (C) 2011 SUSE <cbosdonnat@suse.com> (initial developer) ]
17 : : *
18 : : * All Rights Reserved.
19 : : *
20 : : * For minor contributions see the git repository.
21 : : *
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.
27 : : */
28 : :
29 : : #include <stdio.h>
30 : :
31 : : #include <ucbhelper/contentidentifier.hxx>
32 : : #include <ucbhelper/contenthelper.hxx>
33 : : #include <com/sun/star/ucb/ContentCreationException.hpp>
34 : :
35 : : #include "cmis_content.hxx"
36 : : #include "cmis_provider.hxx"
37 : : #include "cmis_repo_content.hxx"
38 : :
39 : : using namespace com::sun::star;
40 : :
41 : : namespace cmis
42 : : {
43 : : uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
44 : 0 : ContentProvider::queryContent(
45 : : const uno::Reference<
46 : : com::sun::star::ucb::XContentIdentifier >& Identifier )
47 : : throw( com::sun::star::ucb::IllegalIdentifierException,
48 : : uno::RuntimeException )
49 : : {
50 : 0 : osl::MutexGuard aGuard( m_aMutex );
51 : :
52 : : // Check, if a content with given id already exists...
53 : 0 : uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier ).get();
54 : 0 : if ( xContent.is() )
55 : : return xContent;
56 : :
57 : : try
58 : : {
59 : 0 : URL aUrl( Identifier->getContentIdentifier( ) );
60 : 0 : if ( aUrl.getRepositoryId( ).isEmpty( ) )
61 : : {
62 : 0 : xContent = new RepoContent( m_xSMgr, this, Identifier );
63 : 0 : registerNewContent( xContent );
64 : : }
65 : : else
66 : : {
67 : 0 : xContent = new Content( m_xSMgr, this, Identifier );
68 : 0 : registerNewContent( xContent );
69 : 0 : }
70 : : }
71 : 0 : catch ( com::sun::star::ucb::ContentCreationException const & )
72 : : {
73 : 0 : throw com::sun::star::ucb::IllegalIdentifierException();
74 : : }
75 : :
76 : 0 : if ( !xContent->getIdentifier().is() )
77 : 0 : throw com::sun::star::ucb::IllegalIdentifierException();
78 : :
79 : 0 : return xContent;
80 : : }
81 : :
82 : 0 : libcmis::Session* ContentProvider::getSession( const rtl::OUString& sBindingUrl )
83 : : {
84 : 0 : libcmis::Session* pSession = NULL;
85 : 0 : std::map< rtl::OUString, libcmis::Session* >::iterator it = m_aSessionCache.find( sBindingUrl );
86 : 0 : if ( it != m_aSessionCache.end( ) )
87 : : {
88 : 0 : pSession = it->second;
89 : : }
90 : 0 : return pSession;
91 : : }
92 : :
93 : 0 : void ContentProvider::registerSession( const rtl::OUString& sBindingUrl, libcmis::Session* pSession )
94 : : {
95 : 0 : m_aSessionCache.insert( std::pair< rtl::OUString, libcmis::Session* >( sBindingUrl, pSession ) );
96 : 0 : }
97 : :
98 : 0 : ContentProvider::ContentProvider(
99 : : const uno::Reference< lang::XMultiServiceFactory >& rSMgr )
100 : 0 : : ::ucbhelper::ContentProviderImplHelper( rSMgr )
101 : : {
102 : 0 : }
103 : :
104 : 0 : ContentProvider::~ContentProvider()
105 : : {
106 : 0 : }
107 : :
108 : 0 : XINTERFACE_IMPL_3( ContentProvider,
109 : : lang::XTypeProvider,
110 : : lang::XServiceInfo,
111 : : com::sun::star::ucb::XContentProvider );
112 : :
113 : 0 : XTYPEPROVIDER_IMPL_3( ContentProvider,
114 : : lang::XTypeProvider,
115 : : lang::XServiceInfo,
116 : : com::sun::star::ucb::XContentProvider );
117 : :
118 : 0 : XSERVICEINFO_IMPL_1( ContentProvider,
119 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
120 : : "com.sun.star.comp.CmisContentProvider" )),
121 : : rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
122 : 0 : "com.sun.star.ucb.CmisContentProvider" )) );
123 : :
124 : 0 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
125 : :
126 : : }
127 : :
128 : 0 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( const sal_Char *pImplName,
129 : : void *pServiceManager, void * )
130 : : {
131 : 0 : void * pRet = 0;
132 : :
133 : : uno::Reference< lang::XMultiServiceFactory > xSMgr
134 : 0 : (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
135 : 0 : uno::Reference< lang::XSingleServiceFactory > xFactory;
136 : :
137 : 0 : if ( !::cmis::ContentProvider::getImplementationName_Static().compareToAscii( pImplName ) )
138 : 0 : xFactory = ::cmis::ContentProvider::createServiceFactory( xSMgr );
139 : :
140 : 0 : if ( xFactory.is() )
141 : : {
142 : 0 : xFactory->acquire();
143 : 0 : pRet = xFactory.get();
144 : : }
145 : :
146 : 0 : return pRet;
147 : 0 : }
148 : :
149 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|