Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "rtl/string.h"
31 : : #include "rtl/bootstrap.hxx"
32 : : #include "cppuhelper/exc_hlp.hxx"
33 : : #include "com/sun/star/uno/XComponentContext.hpp"
34 : : #include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
35 : : #include "com/sun/star/xml/xpath/XXPathAPI.hpp"
36 : : #include "dp_misc.h"
37 : :
38 : : #include "dp_compbackenddb.hxx"
39 : :
40 : :
41 : : namespace css = ::com::sun::star;
42 : : using namespace ::com::sun::star::uno;
43 : : using ::rtl::OUString;
44 : :
45 : : #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010"
46 : : #define NS_PREFIX "comp"
47 : : #define ROOT_ELEMENT_NAME "component-backend-db"
48 : : #define KEY_ELEMENT_NAME "component"
49 : :
50 : : namespace dp_registry {
51 : : namespace backend {
52 : : namespace component {
53 : :
54 : 380 : ComponentBackendDb::ComponentBackendDb(
55 : : Reference<XComponentContext> const & xContext,
56 : 380 : ::rtl::OUString const & url):BackendDb(xContext, url)
57 : : {
58 : :
59 : 380 : }
60 : :
61 : 320 : OUString ComponentBackendDb::getDbNSName()
62 : : {
63 : 320 : return OUSTR(EXTENSION_REG_NS);
64 : : }
65 : :
66 : 396 : OUString ComponentBackendDb::getNSPrefix()
67 : : {
68 : 396 : return OUSTR(NS_PREFIX);
69 : : }
70 : :
71 : 64 : OUString ComponentBackendDb::getRootElementName()
72 : : {
73 : 64 : return OUSTR(ROOT_ELEMENT_NAME);
74 : : }
75 : :
76 : 134 : OUString ComponentBackendDb::getKeyElementName()
77 : : {
78 : 134 : return OUSTR(KEY_ELEMENT_NAME);
79 : : }
80 : :
81 : 64 : void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
82 : : {
83 : : try{
84 [ + - ][ + - ]: 64 : if (!activateEntry(url))
85 : : {
86 [ + - ]: 64 : Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url);
87 : : writeSimpleElement(OUSTR("java-type-library"),
88 : : OUString::valueOf((sal_Bool) data.javaTypeLibrary),
89 [ + - ][ + - ]: 64 : componentNode);
90 : :
91 : : writeSimpleList(
92 : : data.implementationNames,
93 : : OUSTR("implementation-names"),
94 : : OUSTR("name"),
95 [ + - ][ + - ]: 64 : componentNode);
[ + - ]
96 : :
97 : : writeVectorOfPair(
98 : : data.singletons,
99 : : OUSTR("singletons"),
100 : : OUSTR("item"),
101 : : OUSTR("key"),
102 : : OUSTR("value"),
103 [ + - ][ + - ]: 64 : componentNode);
[ + - ][ + - ]
[ + - ]
104 : :
105 [ + - ]: 64 : save();
106 : : }
107 : : }
108 [ # # ]: 0 : catch(const css::uno::Exception &)
109 : : {
110 [ # # ]: 0 : Any exc( ::cppu::getCaughtException() );
111 : : throw css::deployment::DeploymentException(
112 : : OUSTR("Extension Manager: failed to write data entry in backend db: ") +
113 [ # # # # : 0 : m_urlDb, 0, exc);
# # ]
114 : : }
115 : 64 : }
116 : :
117 : 2 : ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & url)
118 : : {
119 : : try
120 : : {
121 [ + - ]: 2 : ComponentBackendDb::Data retData;
122 [ + - ]: 2 : Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
123 [ + - ]: 2 : if (aNode.is())
124 : : {
125 : : bool bJava = readSimpleElement(OUSTR("java-type-library"), aNode)
126 [ + - ][ + - ]: 2 : .equals(OUSTR("true")) ? true : false;
[ + - ]
127 : 2 : retData.javaTypeLibrary = bJava;
128 : :
129 : : retData.implementationNames =
130 : : readList(
131 : : aNode,
132 : : OUSTR("implementation-names"),
133 [ + - ][ + - ]: 2 : OUSTR("name"));
[ + - ][ + - ]
134 : :
135 : : retData.singletons =
136 : : readVectorOfPair(
137 : : aNode,
138 : : OUSTR("singletons"),
139 : : OUSTR("item"),
140 : : OUSTR("key"),
141 [ + - ][ + - ]: 2 : OUSTR("value"));
[ + - ][ + - ]
[ + - ]
142 : : }
143 : 2 : return retData;
144 : : }
145 [ # # ]: 0 : catch(const css::uno::Exception &)
146 : : {
147 [ # # ]: 0 : Any exc( ::cppu::getCaughtException() );
148 : : throw css::deployment::DeploymentException(
149 : : OUSTR("Extension Manager: failed to read data entry in backend db: ") +
150 [ # # # # : 0 : m_urlDb, 0, exc);
# # ]
151 : : }
152 : : }
153 : :
154 : :
155 : : } // namespace bundle
156 : : } // namespace backend
157 : : } // namespace dp_registry
158 : :
159 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|