1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: librdf_repository.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "librdf_repository.hxx"
33 #include <comphelper/stlunosequence.hxx>
34 #include <comphelper/sequenceasvector.hxx>
35 #include <comphelper/makesequence.hxx>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
40 #include <com/sun/star/lang/IllegalArgumentException.hpp>
41 #include <com/sun/star/io/XSeekableInputStream.hpp>
42 #include <com/sun/star/text/XTextRange.hpp>
43 #include "com/sun/star/rdf/XDocumentRepository.hpp"
44 #include <com/sun/star/rdf/XLiteral.hpp>
45 #include <com/sun/star/rdf/FileFormat.hpp>
46 #include <com/sun/star/rdf/URIs.hpp>
47 #include <com/sun/star/rdf/BlankNode.hpp>
48 #include <com/sun/star/rdf/URI.hpp>
49 #include <com/sun/star/rdf/Literal.hpp>
51 #include <cppuhelper/implbase1.hxx>
52 #include <cppuhelper/implbase3.hxx>
53 #include <cppuhelper/basemutex.hxx>
54 #include <rtl/ref.hxx>
55 #include <rtl/ustring.hxx>
59 #include <boost/utility.hpp>
60 #include <boost/shared_ptr.hpp>
61 #include <boost/shared_array.hpp>
62 #include <boost/bind.hpp>
72 Implementation of the service com.sun.star.rdf.Repository.
74 This implementation uses the Redland RDF library (librdf).
76 There are several classes involved:
77 librdf_TypeConverter: helper class to convert data types redland <-> uno
78 librdf_Repository: the main repository, does almost all the work
79 librdf_NamedGraph: the XNamedGraph, forwards everything to repository
80 librdf_GraphResult: an XEnumeration<Statement>
81 librdf_QuerySelectResult: an XEnumeration<sequence<XNode>>
86 /// anonymous implementation namespace
89 class librdf_NamedGraph
;
90 class librdf_Repository
;
92 using namespace ::com::sun::star
;
94 typedef std::map
< ::rtl::OUString
, ::rtl::Reference
<librdf_NamedGraph
> >
97 const char s_sparql
[] = "sparql";
98 const char s_nsRDFs
[] = "http://www.w3.org/2000/01/rdf-schema#";
99 const char s_label
[] = "label";
100 const char s_nsOOo
[] = "http://openoffice.org/2004/office/rdfa/";
102 ////////////////////////////////////////////////////////////////////////////
104 //FIXME: this approach is not ideal. can we use blind nodes instead?
105 bool isInternalContext(librdf_node
*i_pNode
) throw ()
107 OSL_ENSURE(i_pNode
, "isInternalContext: context null");
108 OSL_ENSURE(librdf_node_is_resource(i_pNode
),
109 "isInternalContext: context not resource");
111 librdf_uri
*pURI(librdf_node_get_uri(i_pNode
));
112 OSL_ENSURE(pURI
, "isInternalContext: URI null");
114 unsigned char *pContextURI(librdf_uri_as_string(pURI
));
115 OSL_ENSURE(pContextURI
,
116 "isInternalContext: URI string null");
117 // if prefix matches reserved uri, it is RDFa context
118 if (!strncmp(reinterpret_cast<char *>(pContextURI
),
119 s_nsOOo
, sizeof(s_nsOOo
)-1)) {
129 ////////////////////////////////////////////////////////////////////////////
132 class librdf_Statement
:
133 public ::cppu::WeakImplHelper1
<
139 uno::Reference
< rdf::XResource
> const & i_xSubject
,
140 uno::Reference
< rdf::XResource
> const & i_xPredicate
,
141 uno::Reference
< rdf::XNode
> const & i_xObject
,
142 uno::Reference
< rdf::XURI
> const & i_xGraph
)
143 : m_xSubject(i_xSubject
), m_xPredicate(i_xPredicate
),
144 m_xObject(i_xObject
), m_xGraph(i_xGraph
)
146 virtual ~librdf_Statement() {}
148 // ::com::sun::star::rdf::XStatement:
149 virtual uno::Reference
< rdf::XResource
> SAL_CALL
getSubject()
150 throw (uno::RuntimeException
);
151 virtual uno::Reference
< rdf::XResource
> SAL_CALL
getPredicate()
152 throw (uno::RuntimeException
);
153 virtual uno::Reference
< rdf::XNode
> SAL_CALL
getObject()
154 throw (uno::RuntimeException
);
155 virtual uno::Reference
< rdf::XURI
> SAL_CALL
getGraph()
156 throw (uno::RuntimeException
);
160 uno::Reference
< rdf::XResource
> m_xSubject
;
161 uno::Reference
< rdf::XResource
> m_xPredicate
;
162 uno::Reference
< rdf::XNode
> m_xObject
;
163 uno::Reference
< rdf::XURI
> m_xGraph
;
166 // ::com::sun::star::rdf::XStatement:
167 uno::Reference
< rdf::XResource
> SAL_CALL
168 librdf_Statement::getSubject() throw (uno::RuntimeException
)
173 uno::Reference
< rdf::XResource
> SAL_CALL
174 librdf_Statement::getPredicate() throw (uno::RuntimeException
)
179 uno::Reference
< rdf::XNode
> SAL_CALL
180 librdf_Statement::getObject() throw (uno::RuntimeException
)
185 uno::Reference
< rdf::XURI
> SAL_CALL
186 librdf_Statement::getGraph() throw (uno::RuntimeException
)
193 ////////////////////////////////////////////////////////////////////////////
195 /** converts between librdf types and UNO API types.
197 class librdf_TypeConverter
200 librdf_TypeConverter(
201 uno::Reference
< uno::XComponentContext
> const & i_xContext
,
202 librdf_Repository
&i_rRep
)
203 : m_xContext(i_xContext
)
207 librdf_world
*createWorld() const;
208 librdf_storage
*createStorage(librdf_world
*i_pWorld
) const;
209 librdf_model
*createModel(librdf_world
*i_pWorld
,
210 librdf_storage
* i_pStorage
) const;
211 librdf_uri
* mkURI( librdf_world
* i_pWorld
,
212 const uno::Reference
< rdf::XURI
> & i_xURI
) const;
213 librdf_node
* mkResource( librdf_world
* i_pWorld
,
214 const uno::Reference
< rdf::XResource
> & i_xResource
) const;
215 librdf_node
* mkNode( librdf_world
* i_pWorld
,
216 const uno::Reference
< rdf::XNode
> & i_xNode
) const;
217 librdf_statement
* mkStatement( librdf_world
* i_pWorld
,
218 const uno::Reference
< rdf::XResource
> & i_xSubject
,
219 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
220 const uno::Reference
< rdf::XNode
> & i_xObject
) const;
221 uno::Reference
<rdf::XURI
> convertToXURI(librdf_uri
* i_pURI
) const;
222 uno::Reference
<rdf::XURI
> convertToXURI(librdf_node
* i_pURI
) const;
223 uno::Reference
<rdf::XResource
>
224 convertToXResource(librdf_node
* i_pNode
) const;
225 uno::Reference
<rdf::XNode
> convertToXNode(librdf_node
* i_pNode
) const;
226 // uno::Reference<rdf::XStatement>
227 // convertToXStatement(librdf_statement* i_pStmt, librdf_node* i_pContext)
230 convertToStatement(librdf_statement
* i_pStmt
, librdf_node
* i_pContext
)
232 uno::Reference
<rdf::XURI
> getRDFsLabel() const;
235 uno::Reference
< uno::XComponentContext
> m_xContext
;
236 librdf_Repository
& m_rRep
;
240 ////////////////////////////////////////////////////////////////////////////
242 /** implements the repository service.
244 class librdf_Repository
:
245 private boost::noncopyable
,
246 // private ::cppu::BaseMutex,
247 public ::cppu::WeakImplHelper3
<
249 rdf::XDocumentRepository
,
250 lang::XInitialization
>
254 explicit librdf_Repository(
255 uno::Reference
< uno::XComponentContext
> const & i_xContext
);
256 virtual ~librdf_Repository();
258 // ::com::sun::star::lang::XServiceInfo:
259 virtual ::rtl::OUString SAL_CALL
getImplementationName()
260 throw (uno::RuntimeException
);
261 virtual ::sal_Bool SAL_CALL
supportsService(
262 const ::rtl::OUString
& ServiceName
) throw (uno::RuntimeException
);
263 virtual uno::Sequence
< ::rtl::OUString
> SAL_CALL
264 getSupportedServiceNames() throw (uno::RuntimeException
);
266 // ::com::sun::star::rdf::XRepository:
267 virtual uno::Reference
< rdf::XBlankNode
> SAL_CALL
createBlankNode()
268 throw (uno::RuntimeException
);
269 virtual uno::Reference
<rdf::XNamedGraph
> SAL_CALL
importGraph(
270 ::sal_Int16 i_Format
,
271 const uno::Reference
< io::XInputStream
> & i_xInStream
,
272 const uno::Reference
< rdf::XURI
> & i_xGraphName
,
273 const uno::Reference
< rdf::XURI
> & i_xBaseURI
)
274 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
275 datatransfer::UnsupportedFlavorException
,
276 container::ElementExistException
, rdf::ParseException
,
277 rdf::RepositoryException
, io::IOException
);
278 virtual void SAL_CALL
exportGraph(::sal_Int16 i_Format
,
279 const uno::Reference
< io::XOutputStream
> & i_xOutStream
,
280 const uno::Reference
< rdf::XURI
> & i_xGraphName
,
281 const uno::Reference
< rdf::XURI
> & i_xBaseURI
)
282 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
283 datatransfer::UnsupportedFlavorException
,
284 container::NoSuchElementException
, rdf::RepositoryException
,
286 virtual uno::Sequence
< uno::Reference
< rdf::XURI
> > SAL_CALL
287 getGraphNames() throw (uno::RuntimeException
, rdf::RepositoryException
);
288 virtual uno::Reference
< rdf::XNamedGraph
> SAL_CALL
getGraph(
289 const uno::Reference
< rdf::XURI
> & i_xGraphName
)
290 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
291 rdf::RepositoryException
);
292 virtual uno::Reference
< rdf::XNamedGraph
> SAL_CALL
createGraph(
293 const uno::Reference
< rdf::XURI
> & i_xGraphName
)
294 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
295 container::ElementExistException
, rdf::RepositoryException
);
296 virtual void SAL_CALL
destroyGraph(
297 const uno::Reference
< rdf::XURI
> & i_xGraphName
)
298 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
299 container::NoSuchElementException
, rdf::RepositoryException
);
300 virtual uno::Reference
< container::XEnumeration
> SAL_CALL
getStatements(
301 const uno::Reference
< rdf::XResource
> & i_xSubject
,
302 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
303 const uno::Reference
< rdf::XNode
> & i_xObject
)
304 throw (uno::RuntimeException
,
305 rdf::RepositoryException
);
306 virtual uno::Reference
< rdf::XQuerySelectResult
> SAL_CALL
307 querySelect(const ::rtl::OUString
& i_rQuery
)
308 throw (uno::RuntimeException
, rdf::QueryException
,
309 rdf::RepositoryException
);
310 virtual uno::Reference
< container::XEnumeration
> SAL_CALL
311 queryConstruct(const ::rtl::OUString
& i_rQuery
)
312 throw (uno::RuntimeException
, rdf::QueryException
,
313 rdf::RepositoryException
);
314 virtual ::sal_Bool SAL_CALL
queryAsk(const ::rtl::OUString
& i_rQuery
)
315 throw (uno::RuntimeException
, rdf::QueryException
,
316 rdf::RepositoryException
);
318 // ::com::sun::star::rdf::XDocumentRepository:
319 virtual void SAL_CALL
setStatementRDFa(
320 const uno::Reference
< rdf::XResource
> & i_xSubject
,
321 const uno::Sequence
< uno::Reference
< rdf::XURI
> > & i_rPredicates
,
322 const uno::Reference
< rdf::XMetadatable
> & i_xObject
,
323 const ::rtl::OUString
& i_rRDFaContent
,
324 const uno::Reference
< rdf::XURI
> & i_xRDFaDatatype
)
325 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
326 rdf::RepositoryException
);
327 virtual void SAL_CALL
removeStatementRDFa(
328 const uno::Reference
< rdf::XMetadatable
> & i_xElement
)
329 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
330 rdf::RepositoryException
);
331 virtual uno::Sequence
<rdf::Statement
> SAL_CALL
getStatementRDFa(
332 const uno::Reference
< rdf::XMetadatable
> & i_xElement
)
333 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
334 rdf::RepositoryException
);
335 virtual uno::Reference
< container::XEnumeration
> SAL_CALL
337 const uno::Reference
< rdf::XResource
> & i_xSubject
,
338 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
339 const uno::Reference
< rdf::XNode
> & i_xObject
)
340 throw (uno::RuntimeException
,
341 rdf::RepositoryException
);
343 // ::com::sun::star::lang::XInitialization:
344 virtual void SAL_CALL
initialize(
345 const uno::Sequence
< ::com::sun::star::uno::Any
> & i_rArguments
)
346 throw (uno::RuntimeException
, uno::Exception
);
348 // XNamedGraph forwards ---------------------------------------------
349 const NamedGraphMap_t::iterator SAL_CALL
clearGraph(
350 const uno::Reference
< rdf::XURI
> & i_xName
,
351 bool i_Internal
= false );
352 void SAL_CALL
addStatementGraph(
353 const uno::Reference
< rdf::XResource
> & i_xSubject
,
354 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
355 const uno::Reference
< rdf::XNode
> & i_xObject
,
356 const uno::Reference
< rdf::XURI
> & i_xName
,
357 bool i_Internal
= false );
358 // throw (uno::RuntimeException, lang::IllegalArgumentException,
359 // container::NoSuchElementException, rdf::RepositoryException);
360 void SAL_CALL
removeStatementsGraph(
361 const uno::Reference
< rdf::XResource
> & i_xSubject
,
362 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
363 const uno::Reference
< rdf::XNode
> & i_xObject
,
364 const uno::Reference
< rdf::XURI
> & i_xName
);
365 // throw (uno::RuntimeException, lang::IllegalArgumentException,
366 // container::NoSuchElementException, rdf::RepositoryException);
367 uno::Reference
< container::XEnumeration
> SAL_CALL
getStatementsGraph(
368 const uno::Reference
< rdf::XResource
> & i_xSubject
,
369 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
370 const uno::Reference
< rdf::XNode
> & i_xObject
,
371 const uno::Reference
< rdf::XURI
> & i_xName
,
372 bool i_Internal
= false );
373 // throw (uno::RuntimeException, lang::IllegalArgumentException,
374 // container::NoSuchElementException, rdf::RepositoryException);
376 const librdf_TypeConverter
& getTypeConverter() { return m_TypeConverter
; };
380 uno::Reference
< uno::XComponentContext
> m_xContext
;
382 /// librdf global data
383 /** N.B.: The redland documentation gives the impression that you can have
384 as many librdf_worlds as you like. This is true in the same sense
385 that you can physically be in as many places as you like.
386 Well, you can, just not at the same time.
387 The ugly truth is that destroying a librdf_world kills a bunch
388 of static variables; other librdf_worlds become very unhappy
389 when they access these.
390 And of course this is not documented anywhere that I could find.
391 So we allocate a single world, and refcount that.
393 static boost::shared_ptr
<librdf_world
> m_pWorld
;
395 static sal_uInt32 m_NumInstances
;
396 /// mutex for m_pWorld - redland is not as threadsafe as is often claimed
397 static osl::Mutex m_aMutex
;
399 // NB: sequence of the shared pointers is important!
400 /// librdf repository storage
401 boost::shared_ptr
<librdf_storage
> m_pStorage
;
402 /// librdf repository model
403 boost::shared_ptr
<librdf_model
> m_pModel
;
406 NamedGraphMap_t m_NamedGraphs
;
408 /// type conversion helper
409 librdf_TypeConverter m_TypeConverter
;
413 ////////////////////////////////////////////////////////////////////////////
415 /** result of operations that return a graph, i.e.,
416 an XEnumeration of statements.
418 class librdf_GraphResult
:
419 private boost::noncopyable
,
420 public ::cppu::WeakImplHelper1
<
421 container::XEnumeration
>
425 librdf_GraphResult(librdf_Repository
*i_pRepository
,
426 ::osl::Mutex
& i_rMutex
,
427 boost::shared_ptr
<librdf_stream
> const& i_pStream
,
428 boost::shared_ptr
<librdf_query
> const& i_pQuery
=
429 boost::shared_ptr
<librdf_query
>() )
430 : m_xRep(i_pRepository
)
433 , m_pStream(i_pStream
)
436 virtual ~librdf_GraphResult() {}
438 // ::com::sun::star::container::XEnumeration:
439 virtual ::sal_Bool SAL_CALL
hasMoreElements()
440 throw (uno::RuntimeException
);
441 virtual uno::Any SAL_CALL
nextElement()
442 throw (uno::RuntimeException
, container::NoSuchElementException
,
443 lang::WrappedTargetException
);
446 // NB: this is not a weak pointer: streams _must_ be deleted before the
447 // storage they point into, so we keep the repository alive here
448 // also, sequence is important: the stream must be destroyed first.
449 ::rtl::Reference
< librdf_Repository
> m_xRep
;
450 // needed for synchronizing access to librdf (it doesnt do win32 threading)
451 ::osl::Mutex
& m_rMutex
;
452 // the query (in case this is a result of a graph query)
453 // not that the redland documentation spells this out explicity, but
454 // queries must be freed only after all the results are completely read
455 boost::shared_ptr
<librdf_query
> m_pQuery
;
456 boost::shared_ptr
<librdf_stream
> m_pStream
;
460 // ::com::sun::star::container::XEnumeration:
462 librdf_GraphResult::hasMoreElements() throw (uno::RuntimeException
)
464 ::osl::MutexGuard
g(m_rMutex
);
465 return m_pStream
.get() && !librdf_stream_end(m_pStream
.get());
468 ::com::sun::star::uno::Any SAL_CALL
469 librdf_GraphResult::nextElement()
470 throw (uno::RuntimeException
, container::NoSuchElementException
,
471 lang::WrappedTargetException
)
473 ::osl::MutexGuard
g(m_rMutex
);
474 if (!m_pStream
.get() || !librdf_stream_end(m_pStream
.get())) {
475 librdf_node
*pCtxt( static_cast<librdf_node
*>
476 (librdf_stream_get_context(m_pStream
.get())) );
477 librdf_statement
*pStmt( librdf_stream_get_object(m_pStream
.get()) );
479 rdf::QueryException
e(::rtl::OUString::createFromAscii(
480 "librdf_GraphResult::nextElement: "
481 "librdf_stream_get_object failed"), *this);
482 throw lang::WrappedTargetException(::rtl::OUString::createFromAscii(
483 "librdf_GraphResult::nextElement: "
484 "librdf_stream_get_object failed"), *this,
487 // NB: pCtxt may be null here if this is result of a graph query
488 if (pCtxt
&& isInternalContext(pCtxt
)) {
489 pCtxt
= 0; // XML ID context is implementation detail!
492 m_xRep
->getTypeConverter().convertToStatement(pStmt
, pCtxt
) );
493 // NB: this will invalidate current item.
494 librdf_stream_next(m_pStream
.get());
495 return uno::makeAny(Stmt
);
497 throw container::NoSuchElementException();
502 ////////////////////////////////////////////////////////////////////////////
504 /** result of tuple queries ("SELECT").
506 class librdf_QuerySelectResult
:
507 private boost::noncopyable
,
508 public ::cppu::WeakImplHelper1
<
509 rdf::XQuerySelectResult
>
513 librdf_QuerySelectResult(librdf_Repository
*i_pRepository
,
514 ::osl::Mutex
& i_rMutex
,
515 boost::shared_ptr
<librdf_query
> const& i_pQuery
,
516 boost::shared_ptr
<librdf_query_results
> const& i_pQueryResult
,
517 uno::Sequence
< ::rtl::OUString
> const& i_rBindingNames
)
518 : m_xRep(i_pRepository
)
521 , m_pQueryResult(i_pQueryResult
)
522 , m_BindingNames(i_rBindingNames
)
525 virtual ~librdf_QuerySelectResult() {}
527 // ::com::sun::star::container::XEnumeration:
528 virtual ::sal_Bool SAL_CALL
hasMoreElements()
529 throw (uno::RuntimeException
);
530 virtual uno::Any SAL_CALL
nextElement()
531 throw (uno::RuntimeException
, container::NoSuchElementException
,
532 lang::WrappedTargetException
);
534 // ::com::sun::star::rdf::XQuerySelectResult:
535 virtual uno::Sequence
< ::rtl::OUString
> SAL_CALL
getBindingNames()
536 throw (uno::RuntimeException
);
540 // NB: this is not a weak pointer: streams _must_ be deleted before the
541 // storage they point into, so we keep the repository alive here
542 // also, sequence is important: the stream must be destroyed first.
543 ::rtl::Reference
< librdf_Repository
> m_xRep
;
544 // needed for synchronizing access to librdf (it doesnt do win32 threading)
545 ::osl::Mutex
& m_rMutex
;
546 // not that the redland documentation spells this out explicity, but
547 // queries must be freed only after all the results are completely read
548 boost::shared_ptr
<librdf_query
> m_pQuery
;
549 boost::shared_ptr
<librdf_query_results
> m_pQueryResult
;
550 uno::Sequence
< ::rtl::OUString
> m_BindingNames
;
554 // ::com::sun::star::container::XEnumeration:
556 librdf_QuerySelectResult::hasMoreElements() throw (uno::RuntimeException
)
558 ::osl::MutexGuard
g(m_rMutex
);
559 return !librdf_query_results_finished(m_pQueryResult
.get());
562 class NodeArrayDeleter
: public std::unary_function
<librdf_node
**, void>
567 NodeArrayDeleter(int i_Count
) : m_Count(i_Count
) { }
569 void operator() (librdf_node
** io_pArray
) const throw ()
571 std::for_each(io_pArray
, io_pArray
+ m_Count
, librdf_free_node
);
576 ::com::sun::star::uno::Any SAL_CALL
577 librdf_QuerySelectResult::nextElement()
578 throw (uno::RuntimeException
, container::NoSuchElementException
,
579 lang::WrappedTargetException
)
581 ::osl::MutexGuard
g(m_rMutex
);
582 if (!librdf_query_results_finished(m_pQueryResult
.get())) {
583 sal_Int32
count(m_BindingNames
.getLength());
584 OSL_ENSURE(count
>= 0, "negative length?");
585 boost::shared_array
<librdf_node
*> pNodes( new librdf_node
*[count
],
586 NodeArrayDeleter(count
));
587 for (int i
= 0; i
< count
; ++i
) {
590 if (librdf_query_results_get_bindings(m_pQueryResult
.get(), NULL
,
593 rdf::QueryException
e(::rtl::OUString::createFromAscii(
594 "librdf_QuerySelectResult::nextElement: "
595 "librdf_query_results_get_bindings failed"), *this);
596 throw lang::WrappedTargetException(::rtl::OUString::createFromAscii(
597 "librdf_QuerySelectResult::nextElement: "
598 "librdf_query_results_get_bindings failed"), *this,
601 uno::Sequence
< uno::Reference
< rdf::XNode
> > ret(count
);
602 for (int i
= 0; i
< count
; ++i
) {
603 ret
[i
] = m_xRep
->getTypeConverter().convertToXNode(pNodes
[i
]);
605 // NB: this will invalidate current item.
606 librdf_query_results_next(m_pQueryResult
.get());
607 return uno::makeAny(ret
);
609 throw container::NoSuchElementException();
613 // ::com::sun::star::rdf::XQuerySelectResult:
614 uno::Sequence
< ::rtl::OUString
> SAL_CALL
615 librdf_QuerySelectResult::getBindingNames() throw (uno::RuntimeException
)
617 return m_BindingNames
;
621 ////////////////////////////////////////////////////////////////////////////
623 /** represents a named graph, and forwards all the work to repository.
625 class librdf_NamedGraph
:
626 private boost::noncopyable
,
627 public ::cppu::WeakImplHelper1
<
631 librdf_NamedGraph(librdf_Repository
* i_pRep
,
632 uno::Reference
<rdf::XURI
> const & i_xName
)
638 virtual ~librdf_NamedGraph() {}
640 // ::com::sun::star::rdf::XNode:
641 virtual ::rtl::OUString SAL_CALL
getStringValue()
642 throw (uno::RuntimeException
);
644 // ::com::sun::star::rdf::XURI:
645 virtual ::rtl::OUString SAL_CALL
getNamespace()
646 throw (uno::RuntimeException
);
647 virtual ::rtl::OUString SAL_CALL
getLocalName()
648 throw (uno::RuntimeException
);
650 // ::com::sun::star::rdf::XNamedGraph:
651 virtual uno::Reference
<rdf::XURI
> SAL_CALL
getName()
652 throw (uno::RuntimeException
);
653 virtual void SAL_CALL
clear()
654 throw (uno::RuntimeException
,
655 container::NoSuchElementException
, rdf::RepositoryException
);
656 virtual void SAL_CALL
addStatement(
657 const uno::Reference
< rdf::XResource
> & i_xSubject
,
658 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
659 const uno::Reference
< rdf::XNode
> & i_xObject
)
660 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
661 container::NoSuchElementException
, rdf::RepositoryException
);
662 virtual void SAL_CALL
removeStatements(
663 const uno::Reference
< rdf::XResource
> & i_xSubject
,
664 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
665 const uno::Reference
< rdf::XNode
> & i_xObject
)
666 throw (uno::RuntimeException
,
667 container::NoSuchElementException
, rdf::RepositoryException
);
668 virtual uno::Reference
< container::XEnumeration
> SAL_CALL
getStatements(
669 const uno::Reference
< rdf::XResource
> & i_xSubject
,
670 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
671 const uno::Reference
< rdf::XNode
> & i_xObject
)
672 throw (uno::RuntimeException
,
673 container::NoSuchElementException
, rdf::RepositoryException
);
677 /// weak reference: this is needed to check if m_pRep is valid
678 uno::WeakReference
< rdf::XRepository
> m_wRep
;
679 librdf_Repository
*m_pRep
;
680 uno::Reference
< rdf::XURI
> m_xName
;
684 // ::com::sun::star::rdf::XNode:
685 ::rtl::OUString SAL_CALL
librdf_NamedGraph::getStringValue()
686 throw (uno::RuntimeException
)
688 return m_xName
->getStringValue();
691 // ::com::sun::star::rdf::XURI:
692 ::rtl::OUString SAL_CALL
librdf_NamedGraph::getNamespace()
693 throw (uno::RuntimeException
)
695 return m_xName
->getNamespace();
698 ::rtl::OUString SAL_CALL
librdf_NamedGraph::getLocalName()
699 throw (uno::RuntimeException
)
701 return m_xName
->getLocalName();
704 // ::com::sun::star::rdf::XNamedGraph:
705 uno::Reference
< rdf::XURI
> SAL_CALL
librdf_NamedGraph::getName()
706 throw (uno::RuntimeException
)
711 void SAL_CALL
librdf_NamedGraph::clear()
712 throw (uno::RuntimeException
,
713 container::NoSuchElementException
, rdf::RepositoryException
)
715 uno::Reference
< rdf::XRepository
> xRep( m_wRep
);
717 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
718 "librdf_NamedGraph::clear: repository is gone"), *this);
721 m_pRep
->clearGraph(m_xName
);
722 } catch (lang::IllegalArgumentException
&) {
723 throw uno::RuntimeException();
727 void SAL_CALL
librdf_NamedGraph::addStatement(
728 const uno::Reference
< rdf::XResource
> & i_xSubject
,
729 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
730 const uno::Reference
< rdf::XNode
> & i_xObject
)
731 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
732 container::NoSuchElementException
, rdf::RepositoryException
)
734 uno::Reference
< rdf::XRepository
> xRep( m_wRep
);
736 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
737 "librdf_NamedGraph::addStatement: repository is gone"), *this);
739 m_pRep
->addStatementGraph(i_xSubject
, i_xPredicate
, i_xObject
, m_xName
);
742 void SAL_CALL
librdf_NamedGraph::removeStatements(
743 const uno::Reference
< rdf::XResource
> & i_xSubject
,
744 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
745 const uno::Reference
< rdf::XNode
> & i_xObject
)
746 throw (uno::RuntimeException
,
747 container::NoSuchElementException
, rdf::RepositoryException
)
749 uno::Reference
< rdf::XRepository
> xRep( m_wRep
);
751 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
752 "librdf_NamedGraph::removeStatements: repository is gone"), *this);
754 m_pRep
->removeStatementsGraph(i_xSubject
, i_xPredicate
, i_xObject
, m_xName
);
757 uno::Reference
< container::XEnumeration
> SAL_CALL
758 librdf_NamedGraph::getStatements(
759 const uno::Reference
< rdf::XResource
> & i_xSubject
,
760 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
761 const uno::Reference
< rdf::XNode
> & i_xObject
)
762 throw (uno::RuntimeException
,
763 container::NoSuchElementException
, rdf::RepositoryException
)
765 uno::Reference
< rdf::XRepository
> xRep( m_wRep
);
767 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
768 "librdf_NamedGraph::getStatements: repository is gone"), *this);
770 return m_pRep
->getStatementsGraph(
771 i_xSubject
, i_xPredicate
, i_xObject
, m_xName
);
775 ////////////////////////////////////////////////////////////////////////////
777 boost::shared_ptr
<librdf_world
> librdf_Repository::m_pWorld
;
778 sal_uInt32
librdf_Repository::m_NumInstances
= 0;
779 osl::Mutex
librdf_Repository::m_aMutex
;
781 librdf_Repository::librdf_Repository(
782 uno::Reference
< uno::XComponentContext
> const & i_xContext
)
783 : /*BaseMutex(),*/ m_xContext(i_xContext
)
784 // m_pWorld (static_cast<librdf_world *>(0), librdf_free_world ),
785 , m_pStorage(static_cast<librdf_storage
*>(0), librdf_free_storage
)
786 , m_pModel (static_cast<librdf_model
*>(0), librdf_free_model
)
788 , m_TypeConverter(i_xContext
, *this)
790 OSL_ENSURE(i_xContext
.is(), "librdf_Repository: null context");
792 ::osl::MutexGuard
g(m_aMutex
);
793 if (!m_NumInstances
++) {
794 m_pWorld
.reset(m_TypeConverter
.createWorld(), librdf_free_world
);
798 librdf_Repository::~librdf_Repository()
800 // must destroy these before world!
804 // FIXME: so it turns out that calling librdf_free_world will
805 // (via raptor_sax2_finish) call xmlCleanupParser, which will
806 // free libxml2's globals! ARRRGH!!! => never call librdf_free_world
808 ::osl::MutexGuard
g(m_aMutex
);
809 if (!--m_NumInstances
) {
815 // com.sun.star.uno.XServiceInfo:
816 ::rtl::OUString SAL_CALL
librdf_Repository::getImplementationName()
817 throw (uno::RuntimeException
)
819 return comp_librdf_Repository::_getImplementationName();
822 ::sal_Bool SAL_CALL
librdf_Repository::supportsService(
823 ::rtl::OUString
const & serviceName
) throw (uno::RuntimeException
)
825 uno::Sequence
< ::rtl::OUString
> serviceNames
826 = comp_librdf_Repository::_getSupportedServiceNames();
827 for (::sal_Int32 i
= 0; i
< serviceNames
.getLength(); ++i
) {
828 if (serviceNames
[i
] == serviceName
)
834 uno::Sequence
< ::rtl::OUString
> SAL_CALL
835 librdf_Repository::getSupportedServiceNames() throw (uno::RuntimeException
)
837 return comp_librdf_Repository::_getSupportedServiceNames();
840 // ::com::sun::star::rdf::XRepository:
841 uno::Reference
< rdf::XBlankNode
> SAL_CALL
librdf_Repository::createBlankNode()
842 throw (uno::RuntimeException
)
844 ::osl::MutexGuard
g(m_aMutex
);
845 const boost::shared_ptr
<librdf_node
> pNode(
846 librdf_new_node_from_blank_identifier(m_pWorld
.get(), NULL
),
849 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
850 "librdf_Repository::createBlankNode: "
851 "librdf_new_node_from_blank_identifier failed"), *this);
853 const unsigned char * id (librdf_node_get_blank_identifier(pNode
.get()));
855 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
856 "librdf_Repository::createBlankNode: "
857 "librdf_node_get_blank_identifier failed"), *this);
859 const ::rtl::OUString
nodeID(::rtl::OUString::createFromAscii(
860 reinterpret_cast<const char *>(id
)));
862 return rdf::BlankNode::create(m_xContext
, nodeID
);
863 } catch (lang::IllegalArgumentException
& iae
) {
864 throw lang::WrappedTargetRuntimeException(
865 ::rtl::OUString::createFromAscii(
866 "librdf_Repository::createBlankNode: "
867 "illegal blank node label"), *this, uno::makeAny(iae
));
871 bool formatNeedsBaseURI(::sal_Int16 i_Format
)
873 (void) i_Format
; //FIXME any which dont?
878 uno::Reference
<rdf::XNamedGraph
> SAL_CALL
879 librdf_Repository::importGraph(::sal_Int16 i_Format
,
880 const uno::Reference
< io::XInputStream
> & i_xInStream
,
881 const uno::Reference
< rdf::XURI
> & i_xGraphName
,
882 const uno::Reference
< rdf::XURI
> & i_xBaseURI
)
883 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
884 datatransfer::UnsupportedFlavorException
,
885 container::ElementExistException
, rdf::ParseException
,
886 rdf::RepositoryException
, io::IOException
)
888 ::osl::MutexGuard
g(m_aMutex
);
889 if (!i_xInStream
.is()) {
890 throw lang::IllegalArgumentException(
891 ::rtl::OUString::createFromAscii("librdf_Repository::importGraph: "
892 "stream is null"), *this, 1);
894 //FIXME: other formats
895 if (i_Format
!= rdf::FileFormat::RDF_XML
) {
896 throw datatransfer::UnsupportedFlavorException(
897 ::rtl::OUString::createFromAscii("librdf_Repository::importGraph: "
898 "file format not supported"), *this);
900 if (!i_xGraphName
.is()) {
901 throw lang::IllegalArgumentException(
902 ::rtl::OUString::createFromAscii("librdf_Repository::importGraph: "
903 "graph name is null"), *this, 2);
905 if (i_xGraphName
->getStringValue().matchAsciiL(s_nsOOo
, sizeof(s_nsOOo
)-1))
907 throw lang::IllegalArgumentException(
908 ::rtl::OUString::createFromAscii("librdf_Repository::importGraph: "
909 "URI is reserved"), *this, 0);
911 if (formatNeedsBaseURI(i_Format
) && !i_xBaseURI
.is()) {
912 throw lang::IllegalArgumentException(
913 ::rtl::OUString::createFromAscii("librdf_Repository::importGraph: "
914 "base URI is null"), *this, 3);
916 OSL_ENSURE(i_xBaseURI
.is(), "no base uri");
917 const ::rtl::OUString
baseURIU( i_xBaseURI
->getStringValue() );
918 if (baseURIU
.indexOf('#') >= 0) {
919 throw lang::IllegalArgumentException(
920 ::rtl::OUString::createFromAscii("librdf_Repository::importGraph: "
921 "base URI is not absolute"), *this, 3);
924 const ::rtl::OUString
contextU( i_xGraphName
->getStringValue() );
925 if (m_NamedGraphs
.find(contextU
) != m_NamedGraphs
.end()) {
926 throw container::ElementExistException(
927 ::rtl::OUString::createFromAscii("librdf_Repository::importGraph: "
928 "graph with given URI exists"), *this);
930 const ::rtl::OString
context(
931 ::rtl::OUStringToOString(contextU
, RTL_TEXTENCODING_UTF8
) );
933 const boost::shared_ptr
<librdf_node
> pContext(
934 librdf_new_node_from_uri_string(m_pWorld
.get(),
935 reinterpret_cast<const unsigned char*> (context
.getStr())),
938 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
939 "librdf_Repository::importGraph: "
940 "librdf_new_node_from_uri_string failed"), *this);
943 const ::rtl::OString
baseURI(
944 ::rtl::OUStringToOString(baseURIU
, RTL_TEXTENCODING_UTF8
) );
945 const boost::shared_ptr
<librdf_uri
> pBaseURI(
946 librdf_new_uri(m_pWorld
.get(),
947 reinterpret_cast<const unsigned char*> (baseURI
.getStr())),
950 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
951 "librdf_Repository::importGraph: "
952 "librdf_new_uri failed"), *this);
955 const boost::shared_ptr
<librdf_parser
> pParser(
956 librdf_new_parser(m_pWorld
.get(), "rdfxml", NULL
, NULL
),
959 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
960 "librdf_Repository::importGraph: "
961 "librdf_new_parser failed"), *this);
964 uno::Sequence
<sal_Int8
> buf
;
965 uno::Reference
<io::XSeekable
> xSeekable(i_xInStream
, uno::UNO_QUERY
);
966 // UGLY: if only that redland junk could read streams...
967 const sal_Int64
sz( xSeekable
.is() ? xSeekable
->getLength() : 1 << 20 );
968 // exceptions are propagated
969 i_xInStream
->readBytes( buf
, static_cast<sal_Int32
>( sz
) );
970 const boost::shared_ptr
<librdf_stream
> pStream(
971 librdf_parser_parse_counted_string_as_stream(pParser
.get(),
972 reinterpret_cast<const unsigned char*>(buf
.getConstArray()),
973 buf
.getLength(), pBaseURI
.get()),
976 throw rdf::ParseException(::rtl::OUString::createFromAscii(
977 "librdf_Repository::importGraph: "
978 "librdf_parser_parse_counted_string_as_stream failed"), *this);
980 m_NamedGraphs
.insert(std::make_pair(contextU
,
981 new librdf_NamedGraph(this, i_xGraphName
)));
982 if (librdf_model_context_add_statements(m_pModel
.get(),
983 pContext
.get(), pStream
.get())) {
984 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
985 "librdf_Repository::importGraph: "
986 "librdf_model_context_add_statements failed"), *this);
988 return getGraph(i_xGraphName
);
992 librdf_Repository::exportGraph(::sal_Int16 i_Format
,
993 const uno::Reference
< io::XOutputStream
> & i_xOutStream
,
994 const uno::Reference
< rdf::XURI
> & i_xGraphName
,
995 const uno::Reference
< rdf::XURI
> & i_xBaseURI
)
996 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
997 datatransfer::UnsupportedFlavorException
,
998 container::NoSuchElementException
, rdf::RepositoryException
,
1001 ::osl::MutexGuard
g(m_aMutex
);
1002 if (!i_xOutStream
.is()) {
1003 throw lang::IllegalArgumentException(
1004 ::rtl::OUString::createFromAscii("librdf_Repository::exportGraph: "
1005 "stream is null"), *this, 1);
1007 // FIXME: other formats
1008 if (i_Format
!= rdf::FileFormat::RDF_XML
) {
1009 throw datatransfer::UnsupportedFlavorException(
1010 ::rtl::OUString::createFromAscii("librdf_Repository::exportGraph: "
1011 "file format not supported"), *this);
1013 if (!i_xGraphName
.is()) {
1014 throw lang::IllegalArgumentException(
1015 ::rtl::OUString::createFromAscii("librdf_Repository::exportGraph: "
1016 "graph name is null"), *this, 2);
1018 if (formatNeedsBaseURI(i_Format
) && !i_xBaseURI
.is()) {
1019 throw lang::IllegalArgumentException(
1020 ::rtl::OUString::createFromAscii("librdf_Repository::exportGraph: "
1021 "base URI is null"), *this, 3);
1023 OSL_ENSURE(i_xBaseURI
.is(), "no base uri");
1024 const ::rtl::OUString
baseURIU( i_xBaseURI
->getStringValue() );
1025 if (baseURIU
.indexOf('#') >= 0) {
1026 throw lang::IllegalArgumentException(
1027 ::rtl::OUString::createFromAscii("librdf_Repository::exportGraph: "
1028 "base URI is not absolute"), *this, 3);
1031 const ::rtl::OUString
contextU( i_xGraphName
->getStringValue() );
1032 if (m_NamedGraphs
.find(contextU
) == m_NamedGraphs
.end()) {
1033 throw container::NoSuchElementException(
1034 ::rtl::OUString::createFromAscii("librdf_Repository::exportGraph: "
1035 "no graph with given URI exists"), *this);
1037 const ::rtl::OString
context(
1038 ::rtl::OUStringToOString(contextU
, RTL_TEXTENCODING_UTF8
) );
1040 const boost::shared_ptr
<librdf_node
> pContext(
1041 librdf_new_node_from_uri_string(m_pWorld
.get(),
1042 reinterpret_cast<const unsigned char*> (context
.getStr())),
1045 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1046 "librdf_Repository::exportGraph: "
1047 "librdf_new_node_from_uri_string failed"), *this);
1049 const ::rtl::OString
baseURI(
1050 ::rtl::OUStringToOString(baseURIU
, RTL_TEXTENCODING_UTF8
) );
1051 const boost::shared_ptr
<librdf_uri
> pBaseURI(
1052 librdf_new_uri(m_pWorld
.get(),
1053 reinterpret_cast<const unsigned char*> (baseURI
.getStr())),
1056 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1057 "librdf_Repository::exportGraph: "
1058 "librdf_new_uri failed"), *this);
1061 const boost::shared_ptr
<librdf_stream
> pStream(
1062 librdf_model_context_as_stream(m_pModel
.get(), pContext
.get()),
1063 librdf_free_stream
);
1065 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1066 "librdf_Repository::exportGraph: "
1067 "librdf_model_context_as_stream failed"), *this);
1069 // const char *format("rdfxml");
1070 const char *format("rdfxml-abbrev");
1071 const boost::shared_ptr
<librdf_serializer
> pSerializer(
1072 librdf_new_serializer(m_pWorld
.get(), format
, NULL
, NULL
),
1073 librdf_free_serializer
);
1075 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1076 "librdf_Repository::exportGraph: "
1077 "librdf_new_serializer failed"), *this);
1080 const boost::shared_ptr
<librdf_uri
> pRelativeURI(
1081 librdf_new_uri(m_pWorld
.get(), reinterpret_cast<const unsigned char*>
1082 ("http://feature.librdf.org/raptor-relativeURIs")),
1084 const boost::shared_ptr
<librdf_uri
> pWriteBaseURI(
1085 librdf_new_uri(m_pWorld
.get(), reinterpret_cast<const unsigned char*>
1086 ("http://feature.librdf.org/raptor-writeBaseURI")),
1088 const boost::shared_ptr
<librdf_node
> p0(
1089 librdf_new_node_from_literal(m_pWorld
.get(),
1090 reinterpret_cast<const unsigned char*> ("0"), NULL
, 0),
1092 const boost::shared_ptr
<librdf_node
> p1(
1093 librdf_new_node_from_literal(m_pWorld
.get(),
1094 reinterpret_cast<const unsigned char*> ("1"), NULL
, 0),
1096 if (!pWriteBaseURI
|| !pRelativeURI
|| !p0
|| !p1
) {
1097 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1098 "librdf_Repository::exportGraph: "
1099 "librdf_new_uri or librdf_new_node_from_literal failed"), *this);
1102 // make URIs relative to base URI
1103 if (librdf_serializer_set_feature(pSerializer
.get(),
1104 pRelativeURI
.get(), p1
.get()))
1106 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1107 "librdf_Repository::exportGraph: "
1108 "librdf_serializer_set_feature relativeURIs failed"), *this);
1110 // but do not write the base URI to the file!
1111 if (librdf_serializer_set_feature(pSerializer
.get(),
1112 pWriteBaseURI
.get(), p0
.get()))
1114 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1115 "librdf_Repository::exportGraph: "
1116 "librdf_serializer_set_feature writeBaseURI failed"), *this);
1120 const boost::shared_ptr
<unsigned char> pBuf(
1121 librdf_serializer_serialize_stream_to_counted_string(
1122 pSerializer
.get(), pBaseURI
.get(), pStream
.get(), &length
), free
);
1124 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1125 "librdf_Repository::exportGraph: "
1126 "librdf_serializer_serialize_stream_to_counted_string failed"),
1129 const uno::Sequence
<sal_Int8
> buf(
1130 reinterpret_cast<sal_Int8
*>(pBuf
.get()), length
);
1131 // exceptions are propagated
1132 i_xOutStream
->writeBytes(buf
);
1135 uno::Sequence
< uno::Reference
< rdf::XURI
> > SAL_CALL
1136 librdf_Repository::getGraphNames()
1137 throw (uno::RuntimeException
, rdf::RepositoryException
)
1139 ::osl::MutexGuard
g(m_aMutex
);
1140 ::comphelper::SequenceAsVector
< uno::Reference
<rdf::XURI
> > ret
;
1141 NamedGraphMap_t::const_iterator
aCurr(m_NamedGraphs
.begin());
1142 NamedGraphMap_t::const_iterator
const aEnd(m_NamedGraphs
.end());
1143 while( aCurr
!= aEnd
)
1145 ret
.push_back(aCurr
->second
->getName());
1148 return ret
.getAsConstList();
1151 uno::Reference
< rdf::XNamedGraph
> SAL_CALL
1152 librdf_Repository::getGraph(const uno::Reference
< rdf::XURI
> & i_xGraphName
)
1153 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
1154 rdf::RepositoryException
)
1156 ::osl::MutexGuard
g(m_aMutex
);
1157 if (!i_xGraphName
.is()) {
1158 throw lang::IllegalArgumentException(
1159 ::rtl::OUString::createFromAscii("librdf_Repository::getGraph: "
1160 "URI is null"), *this, 0);
1162 const NamedGraphMap_t::iterator
iter(
1163 m_NamedGraphs
.find(i_xGraphName
->getStringValue()) );
1164 if (iter
!= m_NamedGraphs
.end()) {
1165 return uno::Reference
<rdf::XNamedGraph
>(iter
->second
.get());
1171 uno::Reference
< rdf::XNamedGraph
> SAL_CALL
1172 librdf_Repository::createGraph(const uno::Reference
< rdf::XURI
> & i_xGraphName
)
1173 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
1174 container::ElementExistException
, rdf::RepositoryException
)
1176 ::osl::MutexGuard
g(m_aMutex
);
1177 if (!i_xGraphName
.is()) {
1178 throw lang::IllegalArgumentException(
1179 ::rtl::OUString::createFromAscii("librdf_Repository::createGraph: "
1180 "URI is null"), *this, 0);
1182 if (i_xGraphName
->getStringValue().matchAsciiL(s_nsOOo
, sizeof(s_nsOOo
)-1))
1184 throw lang::IllegalArgumentException(
1185 ::rtl::OUString::createFromAscii("librdf_Repository::createGraph: "
1186 "URI is reserved"), *this, 0);
1189 // NB: librdf does not have a concept of graphs as such;
1190 // a librdf named graph exists iff the model contains a statement with
1191 // the graph name as context
1192 const ::rtl::OUString
contextU( i_xGraphName
->getStringValue() );
1193 if (m_NamedGraphs
.find(contextU
) != m_NamedGraphs
.end()) {
1194 throw container::ElementExistException(
1195 ::rtl::OUString::createFromAscii("librdf_Repository::createGraph: "
1196 "graph with given URI exists"), *this);
1198 m_NamedGraphs
.insert(std::make_pair(contextU
,
1199 new librdf_NamedGraph(this, i_xGraphName
)));
1200 return uno::Reference
<rdf::XNamedGraph
>(
1201 m_NamedGraphs
.find(contextU
)->second
.get());
1205 librdf_Repository::destroyGraph(
1206 const uno::Reference
< rdf::XURI
> & i_xGraphName
)
1207 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
1208 container::NoSuchElementException
, rdf::RepositoryException
)
1210 ::osl::MutexGuard
g(m_aMutex
);
1211 const NamedGraphMap_t::iterator
iter( clearGraph(i_xGraphName
) );
1212 m_NamedGraphs
.erase(iter
);
1215 static bool isMetadatableWithoutMetadata(
1216 uno::Reference
<uno::XInterface
> const & i_xNode
)
1218 const uno::Reference
<rdf::XMetadatable
> xMeta( i_xNode
, uno::UNO_QUERY
);
1219 return (xMeta
.is() && !xMeta
->getMetadataReference().Second
.getLength());
1222 uno::Reference
< container::XEnumeration
> SAL_CALL
1223 librdf_Repository::getStatements(
1224 const uno::Reference
< rdf::XResource
> & i_xSubject
,
1225 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
1226 const uno::Reference
< rdf::XNode
> & i_xObject
)
1227 throw (uno::RuntimeException
, rdf::RepositoryException
)
1229 if (isMetadatableWithoutMetadata(i_xSubject
) ||
1230 isMetadatableWithoutMetadata(i_xPredicate
) ||
1231 isMetadatableWithoutMetadata(i_xObject
))
1233 return new librdf_GraphResult(this, m_aMutex
,
1234 ::boost::shared_ptr
<librdf_stream
>());
1237 ::osl::MutexGuard
g(m_aMutex
);
1238 const boost::shared_ptr
<librdf_statement
> pStatement(
1239 m_TypeConverter
.mkStatement(m_pWorld
.get(),
1240 i_xSubject
, i_xPredicate
, i_xObject
),
1241 librdf_free_statement
);
1242 OSL_ENSURE(pStatement
, "mkStatement failed");
1244 const boost::shared_ptr
<librdf_stream
> pStream(
1245 librdf_model_find_statements(m_pModel
.get(), pStatement
.get()),
1246 librdf_free_stream
);
1248 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1249 "librdf_Repository::getStatements: "
1250 "librdf_model_find_statements failed"), *this);
1253 return new librdf_GraphResult(this, m_aMutex
, pStream
);
1257 uno::Reference
< rdf::XQuerySelectResult
> SAL_CALL
1258 librdf_Repository::querySelect(const ::rtl::OUString
& i_rQuery
)
1259 throw (uno::RuntimeException
, rdf::QueryException
, rdf::RepositoryException
)
1261 ::osl::MutexGuard
g(m_aMutex
);
1262 const ::rtl::OString
query(
1263 ::rtl::OUStringToOString(i_rQuery
, RTL_TEXTENCODING_UTF8
) );
1264 const boost::shared_ptr
<librdf_query
> pQuery(
1265 librdf_new_query(m_pWorld
.get(), s_sparql
, NULL
,
1266 reinterpret_cast<const unsigned char*> (query
.getStr()), NULL
),
1269 throw rdf::QueryException(::rtl::OUString::createFromAscii(
1270 "librdf_Repository::querySelect: "
1271 "librdf_new_query failed"), *this);
1273 const boost::shared_ptr
<librdf_query_results
> pResults(
1274 librdf_model_query_execute(m_pModel
.get(), pQuery
.get()),
1275 librdf_free_query_results
);
1276 if (!pResults
|| !librdf_query_results_is_bindings(pResults
.get())) {
1277 throw rdf::QueryException(::rtl::OUString::createFromAscii(
1278 "librdf_Repository::querySelect: "
1279 "query result is null or not bindings"), *this);
1282 const int count( librdf_query_results_get_bindings_count(pResults
.get()) );
1284 uno::Sequence
< ::rtl::OUString
> names(count
);
1285 for (int i
= 0; i
< count
; ++i
) {
1286 const char* name( librdf_query_results_get_binding_name(
1287 pResults
.get(), i
) );
1289 throw rdf::QueryException(::rtl::OUString::createFromAscii(
1290 "librdf_Repository::querySelect: "
1291 "binding is null"), *this);
1294 names
[i
] = ::rtl::OUString::createFromAscii(name
);
1297 return new librdf_QuerySelectResult(this, m_aMutex
,
1298 pQuery
, pResults
, names
);
1301 throw rdf::QueryException(::rtl::OUString::createFromAscii(
1302 "librdf_Repository::querySelect: "
1303 "librdf_query_results_get_bindings_count failed"), *this);
1307 uno::Reference
< container::XEnumeration
> SAL_CALL
1308 librdf_Repository::queryConstruct(const ::rtl::OUString
& i_rQuery
)
1309 throw (uno::RuntimeException
, rdf::QueryException
, rdf::RepositoryException
)
1311 ::osl::MutexGuard
g(m_aMutex
);
1312 const ::rtl::OString
query(
1313 ::rtl::OUStringToOString(i_rQuery
, RTL_TEXTENCODING_UTF8
) );
1314 const boost::shared_ptr
<librdf_query
> pQuery(
1315 librdf_new_query(m_pWorld
.get(), s_sparql
, NULL
,
1316 reinterpret_cast<const unsigned char*> (query
.getStr()), NULL
),
1319 throw rdf::QueryException(::rtl::OUString::createFromAscii(
1320 "librdf_Repository::queryConstruct: "
1321 "librdf_new_query failed"), *this);
1323 const boost::shared_ptr
<librdf_query_results
> pResults(
1324 librdf_model_query_execute(m_pModel
.get(), pQuery
.get()),
1325 librdf_free_query_results
);
1326 if (!pResults
|| !librdf_query_results_is_graph(pResults
.get())) {
1327 throw rdf::QueryException(::rtl::OUString::createFromAscii(
1328 "librdf_Repository::queryConstruct: "
1329 "query result is null or not graph"), *this);
1331 const boost::shared_ptr
<librdf_stream
> pStream(
1332 librdf_query_results_as_stream(pResults
.get()),
1333 librdf_free_stream
);
1335 throw rdf::QueryException(::rtl::OUString::createFromAscii(
1336 "librdf_Repository::queryConstruct: "
1337 "librdf_query_results_as_stream failed"), *this);
1340 return new librdf_GraphResult(this, m_aMutex
, pStream
, pQuery
);
1344 librdf_Repository::queryAsk(const ::rtl::OUString
& i_rQuery
)
1345 throw (uno::RuntimeException
, rdf::QueryException
, rdf::RepositoryException
)
1347 ::osl::MutexGuard
g(m_aMutex
);
1349 const ::rtl::OString
query(
1350 ::rtl::OUStringToOString(i_rQuery
, RTL_TEXTENCODING_UTF8
) );
1351 const boost::shared_ptr
<librdf_query
> pQuery(
1352 librdf_new_query(m_pWorld
.get(), s_sparql
, NULL
,
1353 reinterpret_cast<const unsigned char*> (query
.getStr()), NULL
),
1356 throw rdf::QueryException(::rtl::OUString::createFromAscii(
1357 "librdf_Repository::queryAsk: "
1358 "librdf_new_query failed"), *this);
1360 const boost::shared_ptr
<librdf_query_results
> pResults(
1361 librdf_model_query_execute(m_pModel
.get(), pQuery
.get()),
1362 librdf_free_query_results
);
1363 if (!pResults
|| !librdf_query_results_is_boolean(pResults
.get())) {
1364 throw rdf::QueryException(::rtl::OUString::createFromAscii(
1365 "librdf_Repository::queryAsk: "
1366 "query result is null or not boolean"), *this);
1368 return librdf_query_results_get_boolean(pResults
.get())
1369 ? sal_True
: sal_False
;
1372 // ::com::sun::star::rdf::XDocumentRepository:
1373 void SAL_CALL
librdf_Repository::setStatementRDFa(
1374 const uno::Reference
< rdf::XResource
> & i_xSubject
,
1375 const uno::Sequence
< uno::Reference
< rdf::XURI
> > & i_rPredicates
,
1376 const uno::Reference
< rdf::XMetadatable
> & i_xObject
,
1377 const ::rtl::OUString
& i_rRDFaContent
,
1378 const uno::Reference
< rdf::XURI
> & i_xRDFaDatatype
)
1379 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
1380 rdf::RepositoryException
)
1382 static const ::rtl::OUString
s_cell(
1383 ::rtl::OUString::createFromAscii("com.sun.star.table.Cell"));
1384 static const ::rtl::OUString
s_cellprops( // for writer
1385 ::rtl::OUString::createFromAscii("com.sun.star.text.CellProperties"));
1386 static const ::rtl::OUString
s_paragraph(
1387 ::rtl::OUString::createFromAscii("com.sun.star.text.Paragraph"));
1388 static const ::rtl::OUString
s_bookmark(
1389 ::rtl::OUString::createFromAscii("com.sun.star.text.Bookmark"));
1390 static const ::rtl::OUString
s_meta( ::rtl::OUString::createFromAscii(
1391 "com.sun.star.text.InContentMetadata"));
1393 if (!i_xSubject
.is()) {
1394 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
1395 "librdf_Repository::setStatementRDFa: Subject is null"), *this, 0);
1397 if (!i_rPredicates
.getLength()) {
1398 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
1399 "librdf_Repository::setStatementRDFa: no Predicates"),
1402 for (sal_Int32 i
= 0; i
< i_rPredicates
.getLength(); ++i
) {
1403 if (!i_rPredicates
[i
].is()) {
1404 throw lang::IllegalArgumentException(
1405 ::rtl::OUString::createFromAscii(
1406 "librdf_Repository::setStatementRDFa: Predicate is null"),
1410 if (!i_xObject
.is()) {
1411 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
1412 "librdf_Repository::setStatementRDFa: Object is null"), *this, 2);
1414 const uno::Reference
<lang::XServiceInfo
> xService(i_xObject
,
1415 uno::UNO_QUERY_THROW
);
1416 uno::Reference
<text::XTextRange
> xTextRange
;
1417 if (xService
->supportsService(s_cell
) ||
1418 xService
->supportsService(s_cellprops
) ||
1419 xService
->supportsService(s_paragraph
))
1421 xTextRange
.set(i_xObject
, uno::UNO_QUERY_THROW
);
1423 else if (xService
->supportsService(s_bookmark
) ||
1424 xService
->supportsService(s_meta
))
1426 const uno::Reference
<text::XTextContent
> xTextContent(i_xObject
,
1427 uno::UNO_QUERY_THROW
);
1428 xTextRange
= xTextContent
->getAnchor();
1430 if (!xTextRange
.is()) {
1431 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
1432 "librdf_Repository::setStatementRDFa: "
1433 "Object does not support RDFa"), *this, 2);
1435 // ensure that the metadatable has an XML ID
1436 i_xObject
->ensureMetadataReference();
1437 const beans::StringPair
mdref( i_xObject
->getMetadataReference() );
1438 if (mdref
.First
.equalsAscii("") || mdref
.Second
.equalsAscii("")) {
1439 throw uno::RuntimeException( ::rtl::OUString::createFromAscii(
1440 "librdf_Repository::setStatementRDFa: "
1441 "ensureMetadataReference did not"), *this);
1443 uno::Reference
<rdf::XURI
> xXmlId
;
1445 xXmlId
.set( rdf::URI::create(m_xContext
,
1446 ::rtl::OUString::createFromAscii(s_nsOOo
)
1447 + mdref
.First
+ ::rtl::OUString::createFromAscii("#")
1449 uno::UNO_QUERY_THROW
);
1450 } catch (lang::IllegalArgumentException
& iae
) {
1451 throw lang::WrappedTargetRuntimeException(
1452 ::rtl::OUString::createFromAscii(
1453 "librdf_Repository::setStatementRDFa: "
1454 "cannot create URI for XML ID"), *this, uno::makeAny(iae
));
1457 ::osl::MutexGuard
g(m_aMutex
);
1458 uno::Reference
<rdf::XNode
> xText
;
1460 if (i_xRDFaDatatype
.is() && (i_rRDFaContent
.equalsAscii(""))) {
1461 xText
.set( rdf::Literal::createWithType(m_xContext
,
1462 xTextRange
->getString(), i_xRDFaDatatype
),
1463 uno::UNO_QUERY_THROW
);
1465 xText
.set( rdf::Literal::create(m_xContext
,
1466 xTextRange
->getString()), uno::UNO_QUERY_THROW
);
1468 } catch (lang::IllegalArgumentException
& iae
) {
1469 throw lang::WrappedTargetRuntimeException(
1470 ::rtl::OUString::createFromAscii(
1471 "librdf_Repository::setStatementRDFa: "
1472 "cannot create literal"), *this, uno::makeAny(iae
));
1474 if (i_rRDFaContent
.equalsAscii("")) {
1475 removeStatementRDFa(i_xObject
);
1476 ::std::for_each(::comphelper::stl_begin(i_rPredicates
),
1477 ::comphelper::stl_end(i_rPredicates
),
1478 ::boost::bind( &librdf_Repository::addStatementGraph
,
1479 this, i_xSubject
, _1
, xText
, xXmlId
, true));
1481 uno::Reference
<rdf::XURI
> xLabel( m_TypeConverter
.getRDFsLabel() );
1482 uno::Reference
<rdf::XNode
> xContent
;
1484 if (!i_xRDFaDatatype
.is()) {
1485 xContent
.set(rdf::Literal::create(m_xContext
, i_rRDFaContent
),
1486 uno::UNO_QUERY_THROW
);
1488 xContent
.set(rdf::Literal::createWithType(m_xContext
,
1489 i_rRDFaContent
, i_xRDFaDatatype
), uno::UNO_QUERY_THROW
);
1491 } catch (lang::IllegalArgumentException
& iae
) {
1492 throw lang::WrappedTargetRuntimeException(
1493 ::rtl::OUString::createFromAscii(
1494 "librdf_Repository::setStatementRDFa: "
1495 "cannot create literal"), *this, uno::makeAny(iae
));
1497 removeStatementRDFa(i_xObject
);
1498 ::std::for_each(::comphelper::stl_begin(i_rPredicates
),
1499 ::comphelper::stl_end(i_rPredicates
),
1500 ::boost::bind( &librdf_Repository::addStatementGraph
,
1501 this, i_xSubject
, _1
, xContent
, xXmlId
, true));
1502 addStatementGraph(i_xSubject
, xLabel
, xText
, xXmlId
, true);
1506 void SAL_CALL
librdf_Repository::removeStatementRDFa(
1507 const uno::Reference
< rdf::XMetadatable
> & i_xElement
)
1508 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
1509 rdf::RepositoryException
)
1511 if (!i_xElement
.is()) {
1512 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
1513 "librdf_Repository::removeStatementRDFa: Element is null"),
1517 const beans::StringPair
mdref( i_xElement
->getMetadataReference() );
1518 if (mdref
.First
.equalsAscii("") || mdref
.Second
.equalsAscii("")) {
1519 return; // nothing to do...
1521 uno::Reference
<rdf::XURI
> xXmlId
;
1523 xXmlId
.set( rdf::URI::create(m_xContext
,
1524 ::rtl::OUString::createFromAscii(s_nsOOo
)
1525 + mdref
.First
+ ::rtl::OUString::createFromAscii("#")
1527 uno::UNO_QUERY_THROW
);
1528 } catch (lang::IllegalArgumentException
& iae
) {
1529 throw lang::WrappedTargetRuntimeException(
1530 ::rtl::OUString::createFromAscii(
1531 "librdf_Repository::removeStatementRDFa: "
1532 "cannot create URI for XML ID"), *this, uno::makeAny(iae
));
1534 // clearGraph does locking, not needed here
1535 clearGraph(xXmlId
, true);
1538 uno::Sequence
<rdf::Statement
> SAL_CALL
1539 librdf_Repository::getStatementRDFa(
1540 const uno::Reference
< rdf::XMetadatable
> & i_xElement
)
1541 throw (uno::RuntimeException
, lang::IllegalArgumentException
,
1542 rdf::RepositoryException
)
1544 if (!i_xElement
.is()) {
1545 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
1546 "librdf_Repository::getStatementRDFa: Element is null"), *this, 0);
1548 const beans::StringPair
mdref( i_xElement
->getMetadataReference() );
1549 if (mdref
.First
.equalsAscii("") || mdref
.Second
.equalsAscii("")) {
1550 return uno::Sequence
<rdf::Statement
>();
1552 uno::Reference
<rdf::XURI
> xXmlId
;
1554 xXmlId
.set( rdf::URI::create(m_xContext
,
1555 ::rtl::OUString::createFromAscii(s_nsOOo
)
1556 + mdref
.First
+ ::rtl::OUString::createFromAscii("#")
1558 uno::UNO_QUERY_THROW
);
1559 } catch (lang::IllegalArgumentException
& iae
) {
1560 throw lang::WrappedTargetRuntimeException(
1561 ::rtl::OUString::createFromAscii(
1562 "librdf_Repository::getStatementRDFa: "
1563 "cannot create URI for XML ID"), *this, uno::makeAny(iae
));
1566 ::osl::MutexGuard
g(m_aMutex
);
1567 ::comphelper::SequenceAsVector
< rdf::Statement
> ret
;
1568 const uno::Reference
<container::XEnumeration
> xIter(
1569 getStatementsGraph(0, 0, 0, xXmlId
, true) );
1570 OSL_ENSURE(xIter
.is(), "getStatementRDFa: no result?");
1571 if (!xIter
.is()) throw uno::RuntimeException();
1572 const uno::Reference
<rdf::XURI
> xLabel( m_TypeConverter
.getRDFsLabel() );
1573 while (xIter
->hasMoreElements()) {
1574 rdf::Statement stmt
;
1575 if (!(xIter
->nextElement() >>= stmt
)) {
1576 OSL_ENSURE(false, "getStatementRDFa: result of wrong type?");
1578 OSL_ENSURE(stmt
.Predicate
.is(), "getStatementRDFa: no predicate?");
1579 if (stmt
.Predicate
->getStringValue() != xLabel
->getStringValue()) {
1580 ret
.push_back(stmt
);
1581 } else { // the RDFs:label comes first
1582 ret
.insert(ret
.begin(), stmt
);
1586 return ret
.getAsConstList();
1590 librdf_statement
*rdfa_context_stream_map_handler(
1591 librdf_stream
*i_pStream
, void *, librdf_statement
*i_pStatement
)
1593 OSL_ENSURE(i_pStream
, "rdfa_context_stream_map_handler: stream null");
1595 librdf_node
*pCtxt( static_cast<librdf_node
*>
1596 (librdf_stream_get_context(i_pStream
)) );
1597 OSL_ENSURE(pCtxt
, "rdfa_context_stream_map_handler: context null");
1598 if (pCtxt
&& isInternalContext(pCtxt
)) {
1599 return i_pStatement
;
1605 uno::Reference
< container::XEnumeration
> SAL_CALL
1606 librdf_Repository::getStatementsRDFa(
1607 const uno::Reference
< rdf::XResource
> & i_xSubject
,
1608 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
1609 const uno::Reference
< rdf::XNode
> & i_xObject
)
1610 throw (uno::RuntimeException
, rdf::RepositoryException
)
1612 if (isMetadatableWithoutMetadata(i_xSubject
) ||
1613 isMetadatableWithoutMetadata(i_xPredicate
) ||
1614 isMetadatableWithoutMetadata(i_xObject
))
1616 return new librdf_GraphResult(this, m_aMutex
,
1617 ::boost::shared_ptr
<librdf_stream
>());
1620 ::osl::MutexGuard
g(m_aMutex
);
1621 const boost::shared_ptr
<librdf_statement
> pStatement(
1622 m_TypeConverter
.mkStatement(m_pWorld
.get(),
1623 i_xSubject
, i_xPredicate
, i_xObject
),
1624 librdf_free_statement
);
1625 OSL_ENSURE(pStatement
, "mkStatement failed");
1627 const boost::shared_ptr
<librdf_stream
> pStream(
1628 librdf_model_find_statements(m_pModel
.get(), pStatement
.get()),
1629 librdf_free_stream
);
1631 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1632 "librdf_Repository::getStatementsRDFa: "
1633 "librdf_model_find_statements failed"), *this);
1636 if (librdf_stream_add_map(pStream
.get(), rdfa_context_stream_map_handler
,
1638 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1639 "librdf_Repository::getStatementsRDFa: "
1640 "librdf_stream_add_map failed"), *this);
1643 return new librdf_GraphResult(this, m_aMutex
, pStream
);
1646 // ::com::sun::star::lang::XInitialization:
1647 void SAL_CALL
librdf_Repository::initialize(
1648 const uno::Sequence
< ::com::sun::star::uno::Any
> & i_rArguments
)
1649 throw (uno::RuntimeException
, uno::Exception
)
1651 (void) i_rArguments
;
1653 ::osl::MutexGuard
g(m_aMutex
);
1655 // m_pWorld.reset(m_TypeConverter.createWorld(), librdf_free_world);
1656 m_pStorage
.reset(m_TypeConverter
.createStorage(m_pWorld
.get()),
1657 librdf_free_storage
);
1658 m_pModel
.reset(m_TypeConverter
.createModel(
1659 m_pWorld
.get(), m_pStorage
.get()), librdf_free_model
);
1662 const NamedGraphMap_t::iterator SAL_CALL
librdf_Repository::clearGraph(
1663 const uno::Reference
< rdf::XURI
> & i_xGraphName
, bool i_Internal
)
1664 // throw (uno::RuntimeException, container::NoSuchElementException,
1665 // rdf::RepositoryException)
1667 if (!i_xGraphName
.is()) {
1668 throw lang::IllegalArgumentException(
1669 ::rtl::OUString::createFromAscii("librdf_Repository::clearGraph: "
1670 "URI is null"), *this, 0);
1672 ::osl::MutexGuard
g(m_aMutex
);
1673 const ::rtl::OUString
contextU( i_xGraphName
->getStringValue() );
1674 const NamedGraphMap_t::iterator
iter( m_NamedGraphs
.find(contextU
) );
1675 if (!i_Internal
&& iter
== m_NamedGraphs
.end()) {
1676 throw container::NoSuchElementException(
1677 ::rtl::OUString::createFromAscii("librdf_Repository::clearGraph: "
1678 "no graph with given URI exists"), *this);
1680 const ::rtl::OString
context(
1681 ::rtl::OUStringToOString(contextU
, RTL_TEXTENCODING_UTF8
) );
1683 const boost::shared_ptr
<librdf_node
> pContext(
1684 librdf_new_node_from_uri_string(m_pWorld
.get(),
1685 reinterpret_cast<const unsigned char*> (context
.getStr())),
1688 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1689 "librdf_Repository::clearGraph: "
1690 "librdf_new_node_from_uri_string failed"), *this);
1692 if (librdf_model_context_remove_statements(m_pModel
.get(), pContext
.get()))
1694 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1695 "librdf_Repository::clearGraph: "
1696 "librdf_model_context_remove_statements failed"), *this);
1701 void SAL_CALL
librdf_Repository::addStatementGraph(
1702 const uno::Reference
< rdf::XResource
> & i_xSubject
,
1703 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
1704 const uno::Reference
< rdf::XNode
> & i_xObject
,
1705 const uno::Reference
< rdf::XURI
> & i_xGraphName
,
1707 //throw (uno::RuntimeException, lang::IllegalArgumentException,
1708 // container::NoSuchElementException, rdf::RepositoryException)
1710 if (!i_xSubject
.is()) {
1711 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
1712 "librdf_Repository::addStatement: Subject is null"), *this, 0);
1714 if (!i_xPredicate
.is()) {
1715 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
1716 "librdf_Repository::addStatement: Predicate is null"),
1719 if (!i_xObject
.is()) {
1720 throw lang::IllegalArgumentException(::rtl::OUString::createFromAscii(
1721 "librdf_Repository::addStatement: Object is null"), *this, 2);
1724 ::osl::MutexGuard
g(m_aMutex
);
1725 const ::rtl::OUString
contextU( i_xGraphName
->getStringValue() );
1726 if (!i_Internal
&& (m_NamedGraphs
.find(contextU
) == m_NamedGraphs
.end())) {
1727 throw container::NoSuchElementException(
1728 ::rtl::OUString::createFromAscii("librdf_Repository::addStatement: "
1729 "no graph with given URI exists"), *this);
1731 const ::rtl::OString
context(
1732 ::rtl::OUStringToOString(contextU
, RTL_TEXTENCODING_UTF8
) );
1734 const boost::shared_ptr
<librdf_node
> pContext(
1735 librdf_new_node_from_uri_string(m_pWorld
.get(),
1736 reinterpret_cast<const unsigned char*> (context
.getStr())),
1739 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1740 "librdf_Repository::addStatement: "
1741 "librdf_new_node_from_uri_string failed"), *this);
1743 const boost::shared_ptr
<librdf_statement
> pStatement(
1744 m_TypeConverter
.mkStatement(m_pWorld
.get(),
1745 i_xSubject
, i_xPredicate
, i_xObject
),
1746 librdf_free_statement
);
1747 OSL_ENSURE(pStatement
, "mkStatement failed");
1748 if (librdf_model_context_add_statement(m_pModel
.get(),
1749 pContext
.get(), pStatement
.get())) {
1750 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1751 "librdf_Repository::addStatement: "
1752 "librdf_model_context_add_statement failed"), *this);
1756 void SAL_CALL
librdf_Repository::removeStatementsGraph(
1757 const uno::Reference
< rdf::XResource
> & i_xSubject
,
1758 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
1759 const uno::Reference
< rdf::XNode
> & i_xObject
,
1760 const uno::Reference
< rdf::XURI
> & i_xGraphName
)
1761 //throw (uno::RuntimeException, lang::IllegalArgumentException,
1762 // container::NoSuchElementException, rdf::RepositoryException)
1764 if (isMetadatableWithoutMetadata(i_xSubject
) ||
1765 isMetadatableWithoutMetadata(i_xPredicate
) ||
1766 isMetadatableWithoutMetadata(i_xObject
))
1771 ::osl::MutexGuard
g(m_aMutex
);
1772 const ::rtl::OUString
contextU( i_xGraphName
->getStringValue() );
1773 if (m_NamedGraphs
.find(contextU
) == m_NamedGraphs
.end()) {
1774 throw container::NoSuchElementException(
1775 ::rtl::OUString::createFromAscii(
1776 "librdf_Repository::removeStatements: "
1777 "no graph with given URI exists"), *this);
1779 const ::rtl::OString
context(
1780 ::rtl::OUStringToOString(contextU
, RTL_TEXTENCODING_UTF8
) );
1782 const boost::shared_ptr
<librdf_node
> pContext(
1783 librdf_new_node_from_uri_string(m_pWorld
.get(),
1784 reinterpret_cast<const unsigned char*> (context
.getStr())),
1787 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1788 "librdf_Repository::removeStatements: "
1789 "librdf_new_node_from_uri_string failed"), *this);
1791 const boost::shared_ptr
<librdf_statement
> pStatement(
1792 m_TypeConverter
.mkStatement(m_pWorld
.get(),
1793 i_xSubject
, i_xPredicate
, i_xObject
),
1794 librdf_free_statement
);
1795 OSL_ENSURE(pStatement
, "mkStatement failed");
1797 const boost::shared_ptr
<librdf_stream
> pStream(
1798 librdf_model_find_statements_in_context(m_pModel
.get(),
1799 pStatement
.get(), pContext
.get()),
1800 librdf_free_stream
);
1802 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1803 "librdf_Repository::removeStatements: "
1804 "librdf_model_find_statements_in_context failed"), *this);
1807 if (!librdf_stream_end(pStream
.get())) {
1809 librdf_statement
*pStmt( librdf_stream_get_object(pStream
.get()) );
1811 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1812 "librdf_Repository::removeStatements: "
1813 "librdf_stream_get_object failed"), *this);
1815 if (librdf_model_context_remove_statement(m_pModel
.get(),
1816 pContext
.get(), pStmt
)) {
1817 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1818 "librdf_Repository::removeStatements: "
1819 "librdf_model_context_remove_statement failed"), *this);
1821 } while (!librdf_stream_next(pStream
.get()));
1825 uno::Reference
< container::XEnumeration
> SAL_CALL
1826 librdf_Repository::getStatementsGraph(
1827 const uno::Reference
< rdf::XResource
> & i_xSubject
,
1828 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
1829 const uno::Reference
< rdf::XNode
> & i_xObject
,
1830 const uno::Reference
< rdf::XURI
> & i_xGraphName
,
1832 //throw (uno::RuntimeException, lang::IllegalArgumentException,
1833 // container::NoSuchElementException, rdf::RepositoryException)
1835 // N.B.: if any of subject, predicate, object is an XMetadatable, and
1836 // has no metadata reference, then there cannot be any node in the graph
1837 // representing it; in order to prevent side effect
1838 // (ensureMetadataReference), check for this condition and return
1839 if (isMetadatableWithoutMetadata(i_xSubject
) ||
1840 isMetadatableWithoutMetadata(i_xPredicate
) ||
1841 isMetadatableWithoutMetadata(i_xObject
))
1843 return new librdf_GraphResult(this, m_aMutex
,
1844 ::boost::shared_ptr
<librdf_stream
>());
1847 ::osl::MutexGuard
g(m_aMutex
);
1848 const ::rtl::OUString
contextU( i_xGraphName
->getStringValue() );
1849 if (!i_Internal
&& (m_NamedGraphs
.find(contextU
) == m_NamedGraphs
.end())) {
1850 throw container::NoSuchElementException(
1851 ::rtl::OUString::createFromAscii(
1852 "librdf_Repository::getStatements: "
1853 "no graph with given URI exists"), *this);
1855 const ::rtl::OString
context(
1856 ::rtl::OUStringToOString(contextU
, RTL_TEXTENCODING_UTF8
) );
1858 const boost::shared_ptr
<librdf_node
> pContext(
1859 librdf_new_node_from_uri_string(m_pWorld
.get(),
1860 reinterpret_cast<const unsigned char*> (context
.getStr())),
1863 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1864 "librdf_Repository::getStatements: "
1865 "librdf_new_node_from_uri_string failed"), *this);
1867 const boost::shared_ptr
<librdf_statement
> pStatement(
1868 m_TypeConverter
.mkStatement(m_pWorld
.get(),
1869 i_xSubject
, i_xPredicate
, i_xObject
),
1870 librdf_free_statement
);
1871 OSL_ENSURE(pStatement
, "mkStatement failed");
1873 const boost::shared_ptr
<librdf_stream
> pStream(
1874 librdf_model_find_statements_in_context(m_pModel
.get(),
1875 pStatement
.get(), pContext
.get()),
1876 librdf_free_stream
);
1878 throw rdf::RepositoryException(::rtl::OUString::createFromAscii(
1879 "librdf_Repository::getStatements: "
1880 "librdf_model_find_statements_in_context failed"), *this);
1883 return new librdf_GraphResult(this, m_aMutex
, pStream
);
1886 librdf_world
*librdf_TypeConverter::createWorld() const
1888 // create and initialize world
1889 librdf_world
*pWorld( librdf_new_world() );
1891 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1892 "librdf_TypeConverter::createWorld: librdf_new_world failed"),
1895 //FIXME logger, digest, features?
1896 librdf_world_open(pWorld
);
1901 librdf_TypeConverter::createStorage(librdf_world
*i_pWorld
) const
1903 librdf_storage
*pStorage(
1904 // librdf_new_storage(i_pWorld, "memory", NULL, "contexts='yes'") );
1905 librdf_new_storage(i_pWorld
, "hashes", NULL
,
1906 "contexts='yes',hash-type='memory'") );
1908 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1909 "librdf_TypeConverter::createStorage: librdf_new_storage failed"),
1915 librdf_model
*librdf_TypeConverter::createModel(
1916 librdf_world
*i_pWorld
, librdf_storage
* i_pStorage
) const
1918 librdf_model
*pRepository( librdf_new_model(i_pWorld
, i_pStorage
, NULL
) );
1920 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1921 "librdf_TypeConverter::createModel: librdf_new_model failed"),
1927 librdf_uri
* ctxt
= librdf_new_uri(i_pWorld
, reinterpret_cast<const unsigned char *>(LIBRDF_MODEL_FEATURE_CONTEXTS
));
1928 librdf_node
* contexts
= librdf_model_get_feature(repository
, ctxt
);
1931 std::cout
<< "value of contexts feature: ";
1933 std::cout
<< std::endl
;
1934 // librdf_model_set_feature(repository, LIBRDF_FEATURE_CONTEXTS, ...);
1935 librdf_free_node(contexts
);
1936 librdf_free_uri(ctxt
);
1942 // this does NOT create a node, only URI
1943 librdf_uri
* librdf_TypeConverter::mkURI( librdf_world
* i_pWorld
,
1944 const uno::Reference
< rdf::XURI
> & i_xURI
) const
1946 const ::rtl::OString
uri(
1947 ::rtl::OUStringToOString(i_xURI
->getStringValue(),
1948 RTL_TEXTENCODING_UTF8
) );
1949 librdf_uri
*pURI( librdf_new_uri(i_pWorld
,
1950 reinterpret_cast<const unsigned char *>(uri
.getStr())));
1952 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1953 "librdf_TypeConverter::mkURI: librdf_new_uri failed"), 0);
1958 // create blank or URI node
1959 librdf_node
* librdf_TypeConverter::mkResource( librdf_world
* i_pWorld
,
1960 const uno::Reference
< rdf::XResource
> & i_xResource
) const
1962 if (!i_xResource
.is()) return 0;
1963 uno::Reference
< rdf::XBlankNode
> xBlankNode(i_xResource
, uno::UNO_QUERY
);
1964 if (xBlankNode
.is()) {
1965 const ::rtl::OString
label(
1966 ::rtl::OUStringToOString(xBlankNode
->getStringValue(),
1967 RTL_TEXTENCODING_UTF8
) );
1969 librdf_new_node_from_blank_identifier(i_pWorld
,
1970 reinterpret_cast<const unsigned char*> (label
.getStr())));
1972 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1973 "librdf_TypeConverter::mkResource: "
1974 "librdf_new_node_from_blank_identifier failed"), 0);
1977 } else { // assumption: everything else is URI
1978 const ::rtl::OString
uri(
1979 ::rtl::OUStringToOString(i_xResource
->getStringValue(),
1980 RTL_TEXTENCODING_UTF8
) );
1982 librdf_new_node_from_uri_string(i_pWorld
,
1983 reinterpret_cast<const unsigned char*> (uri
.getStr())));
1985 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
1986 "librdf_TypeConverter::mkResource: "
1987 "librdf_new_node_from_uri_string failed"), 0);
1993 // create blank or URI or literal node
1994 librdf_node
* librdf_TypeConverter::mkNode( librdf_world
* i_pWorld
,
1995 const uno::Reference
< rdf::XNode
> & i_xNode
) const
1997 if (!i_xNode
.is()) return 0;
1998 uno::Reference
< rdf::XResource
> xResource(i_xNode
, uno::UNO_QUERY
);
1999 if (xResource
.is()) {
2000 return mkResource(i_pWorld
, xResource
);
2002 uno::Reference
< rdf::XLiteral
> xLiteral(i_xNode
, uno::UNO_QUERY
);
2003 OSL_ENSURE(xLiteral
.is(),
2004 "mkNode: someone invented a new rdf.XNode and did not tell me");
2005 if (!xLiteral
.is()) return 0;
2006 const ::rtl::OString
val(
2007 ::rtl::OUStringToOString(xLiteral
->getValue(),
2008 RTL_TEXTENCODING_UTF8
) );
2009 const ::rtl::OString
lang(
2010 ::rtl::OUStringToOString(xLiteral
->getLanguage(),
2011 RTL_TEXTENCODING_UTF8
) );
2012 const uno::Reference
< rdf::XURI
> xType(xLiteral
->getDatatype());
2013 librdf_node
* ret(0);
2014 if (lang
.getLength() == 0) {
2016 ret
= librdf_new_node_from_literal(i_pWorld
,
2017 reinterpret_cast<const unsigned char*> (val
.getStr()),
2020 const boost::shared_ptr
<librdf_uri
> pDatatype(
2021 mkURI(i_pWorld
, xType
), librdf_free_uri
);
2022 ret
= librdf_new_node_from_typed_literal(i_pWorld
,
2023 reinterpret_cast<const unsigned char*> (val
.getStr()),
2024 NULL
, pDatatype
.get());
2028 ret
= librdf_new_node_from_literal(i_pWorld
,
2029 reinterpret_cast<const unsigned char*> (val
.getStr()),
2030 (lang
.getStr()), 0);
2033 OSL_ENSURE(false, "mkNode: invalid literal");
2038 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
2039 "librdf_TypeConverter::mkNode: "
2040 "librdf_new_node_from_literal failed"), 0);
2045 librdf_statement
* librdf_TypeConverter::mkStatement( librdf_world
* i_pWorld
,
2046 const uno::Reference
< rdf::XResource
> & i_xSubject
,
2047 const uno::Reference
< rdf::XURI
> & i_xPredicate
,
2048 const uno::Reference
< rdf::XNode
> & i_xObject
) const
2050 librdf_node
* pSubject( mkResource(i_pWorld
, i_xSubject
) );
2051 librdf_node
* pPredicate(0);
2052 librdf_node
* pObject(0);
2054 const uno::Reference
<rdf::XResource
> xPredicate(i_xPredicate
,
2056 pPredicate
= mkResource(i_pWorld
, xPredicate
);
2058 pObject
= mkNode(i_pWorld
, i_xObject
);
2060 librdf_free_node(pPredicate
);
2064 librdf_free_node(pSubject
);
2067 // NB: this takes ownership of the nodes! (which is really ugly)
2068 librdf_statement
* pStatement( librdf_new_statement_from_nodes(i_pWorld
,
2069 pSubject
, pPredicate
, pObject
) );
2071 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
2072 "librdf_TypeConverter::mkStatement: "
2073 "librdf_new_statement_from_nodes failed"), 0);
2078 uno::Reference
<rdf::XURI
>
2079 librdf_TypeConverter::convertToXURI(librdf_uri
* i_pURI
) const
2081 if (!i_pURI
) return 0;
2082 const unsigned char* uri( librdf_uri_as_string(i_pURI
) );
2084 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
2085 "librdf_TypeConverter::convertToXURI: "
2086 "librdf_uri_as_string failed"), m_rRep
);
2088 ::rtl::OUString
uriU( ::rtl::OStringToOUString(
2089 ::rtl::OString(reinterpret_cast<const sal_Char
*>(uri
)),
2090 RTL_TEXTENCODING_UTF8
) );
2092 return rdf::URI::create(m_xContext
, uriU
);
2093 } catch (lang::IllegalArgumentException
& iae
) {
2094 throw lang::WrappedTargetRuntimeException(
2095 ::rtl::OUString::createFromAscii(
2096 "librdf_TypeConverter::convertToXURI: "
2097 "illegal uri"), m_rRep
, uno::makeAny(iae
));
2101 uno::Reference
<rdf::XURI
>
2102 librdf_TypeConverter::convertToXURI(librdf_node
* i_pNode
) const
2104 if (!i_pNode
) return 0;
2105 if (librdf_node_is_resource(i_pNode
)) {
2106 librdf_uri
* pURI( librdf_node_get_uri(i_pNode
) );
2108 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
2109 "librdf_TypeConverter::convertToXURI: "
2110 "resource has no uri"), m_rRep
);
2112 return convertToXURI(pURI
);
2114 OSL_ENSURE(false, "convertToXURI: unknown librdf_node");
2119 uno::Reference
<rdf::XResource
>
2120 librdf_TypeConverter::convertToXResource(librdf_node
* i_pNode
) const
2122 if (!i_pNode
) return 0;
2123 if (librdf_node_is_blank(i_pNode
)) {
2124 const unsigned char* label( librdf_node_get_blank_identifier(i_pNode
) );
2126 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
2127 "librdf_TypeConverter::convertToXResource: "
2128 "blank node has no label"), m_rRep
);
2130 ::rtl::OUString
labelU( ::rtl::OStringToOUString(
2131 ::rtl::OString(reinterpret_cast<const sal_Char
*>(label
)),
2132 RTL_TEXTENCODING_UTF8
) );
2134 return uno::Reference
<rdf::XResource
>(
2135 rdf::BlankNode::create(m_xContext
, labelU
), uno::UNO_QUERY
);
2136 } catch (lang::IllegalArgumentException
& iae
) {
2137 throw lang::WrappedTargetRuntimeException(
2138 ::rtl::OUString::createFromAscii(
2139 "librdf_TypeConverter::convertToXResource: "
2140 "illegal blank node label"), m_rRep
, uno::makeAny(iae
));
2143 return uno::Reference
<rdf::XResource
>(convertToXURI(i_pNode
),
2148 uno::Reference
<rdf::XNode
>
2149 librdf_TypeConverter::convertToXNode(librdf_node
* i_pNode
) const
2151 if (!i_pNode
) return 0;
2152 if (!librdf_node_is_literal(i_pNode
)) {
2153 return uno::Reference
<rdf::XNode
>(convertToXResource(i_pNode
),
2156 const unsigned char* value( librdf_node_get_literal_value(i_pNode
) );
2158 throw uno::RuntimeException(::rtl::OUString::createFromAscii(
2159 "librdf_TypeConverter::convertToXNode: "
2160 "literal has no value"), m_rRep
);
2162 const char * lang( librdf_node_get_literal_value_language(i_pNode
) );
2164 librdf_node_get_literal_value_datatype_uri(i_pNode
) );
2165 OSL_ENSURE(!lang
|| !pType
, "convertToXNode: invalid literal");
2166 const ::rtl::OUString
valueU( ::rtl::OStringToOUString(
2167 ::rtl::OString(reinterpret_cast<const sal_Char
*>(value
)),
2168 RTL_TEXTENCODING_UTF8
) );
2170 const ::rtl::OUString
langU( ::rtl::OStringToOUString(
2171 ::rtl::OString(reinterpret_cast<const sal_Char
*>(lang
)),
2172 RTL_TEXTENCODING_UTF8
) );
2173 return uno::Reference
<rdf::XNode
>(
2174 rdf::Literal::createWithLanguage(m_xContext
, valueU
, langU
),
2177 uno::Reference
<rdf::XURI
> xType(convertToXURI(pType
));
2178 OSL_ENSURE(xType
.is(), "convertToXNode: null uri");
2179 return uno::Reference
<rdf::XNode
>(
2180 rdf::Literal::createWithType(m_xContext
, valueU
, xType
),
2183 return uno::Reference
<rdf::XNode
>(
2184 rdf::Literal::create(m_xContext
, valueU
),
2190 uno::Reference
<rdf::XStatement
>
2191 librdf_TypeConverter::convertToXStatement(librdf_statement
* i_pStmt
,
2192 librdf_node
* i_pContext
) const
2195 throw uno::RuntimeException();
2197 return new librdf_Statement(
2198 convertToXResource(librdf_statement_get_subject(i_pStmt
)),
2199 convertToXResource(librdf_statement_get_predicate(i_pStmt
)),
2200 convertToXNode(librdf_statement_get_object(i_pStmt
)),
2201 convertToXURI(i_pContext
));
2206 librdf_TypeConverter::convertToStatement(librdf_statement
* i_pStmt
,
2207 librdf_node
* i_pContext
) const
2210 throw uno::RuntimeException();
2212 return rdf::Statement(
2213 convertToXResource(librdf_statement_get_subject(i_pStmt
)),
2214 convertToXURI(librdf_statement_get_predicate(i_pStmt
)),
2215 convertToXNode(librdf_statement_get_object(i_pStmt
)),
2216 convertToXURI(i_pContext
));
2219 uno::Reference
<rdf::XURI
> librdf_TypeConverter::getRDFsLabel() const
2221 static uno::Reference
< rdf::XURI
> xLabel
;
2226 xLabel
.set(rdf::URI::createKnown(m_xContext
,
2227 rdf::URIs::RDFS_LABEL
),
2228 uno::UNO_QUERY_THROW
);
2229 } catch (lang::IllegalArgumentException
& iae
) {
2230 throw lang::WrappedTargetRuntimeException(
2231 ::rtl::OUString::createFromAscii(
2232 "librdf_TypeConverter::getRDFsLabel: "
2233 "cannot create rdfs:label"), m_rRep
, uno::makeAny(iae
));
2239 } // closing anonymous implementation namespace
2243 // component helper namespace
2244 namespace comp_librdf_Repository
{
2246 ::rtl::OUString SAL_CALL
_getImplementationName() {
2247 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
2248 "librdf_Repository"));
2251 uno::Sequence
< ::rtl::OUString
> SAL_CALL
_getSupportedServiceNames()
2253 uno::Sequence
< ::rtl::OUString
> s(1);
2254 s
[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
2255 "com.sun.star.rdf.Repository"));
2259 uno::Reference
< uno::XInterface
> SAL_CALL
_create(
2260 const uno::Reference
< uno::XComponentContext
> & context
)
2261 SAL_THROW((uno::Exception
))
2263 return static_cast< ::cppu::OWeakObject
* >(new librdf_Repository(context
));
2266 } // closing component helper namespace