Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / desktop / source / deployment / registry / package / dp_extbackenddb.cxx
blobe47138d6598a56e18a919a752eb846705020cea6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <rtl/bootstrap.hxx>
22 #include <cppuhelper/exc_hlp.hxx>
23 #include <com/sun/star/deployment/DeploymentException.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
26 #include <com/sun/star/xml/xpath/XXPathAPI.hpp>
27 #include <dp_misc.h>
29 #include "dp_extbackenddb.hxx"
32 using namespace ::com::sun::star::uno;
34 #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010"
35 #define NS_PREFIX "ext"
36 #define ROOT_ELEMENT_NAME "extension-backend-db"
37 #define KEY_ELEMENT_NAME "extension"
39 namespace dp_registry {
40 namespace backend {
41 namespace bundle {
43 ExtensionBackendDb::ExtensionBackendDb(
44 Reference<XComponentContext> const & xContext,
45 OUString const & url):BackendDb(xContext, url)
50 OUString ExtensionBackendDb::getDbNSName()
52 return EXTENSION_REG_NS;
55 OUString ExtensionBackendDb::getNSPrefix()
57 return NS_PREFIX;
60 OUString ExtensionBackendDb::getRootElementName()
62 return ROOT_ELEMENT_NAME;
65 OUString ExtensionBackendDb::getKeyElementName()
67 return KEY_ELEMENT_NAME;
70 void ExtensionBackendDb::addEntry(OUString const & url, Data const & data)
72 try{
73 //reactive revoked entry if possible.
74 if (!activateEntry(url))
76 Reference<css::xml::dom::XNode> extensionNodeNode = writeKeyElement(url);
77 writeVectorOfPair( data.items, "extension-items", "item",
78 "url", "media-type", extensionNodeNode);
79 save();
82 catch(const css::uno::Exception &)
84 Any exc( ::cppu::getCaughtException() );
85 throw css::deployment::DeploymentException(
86 "Extension Manager: failed to write data entry in backend db: " +
87 m_urlDb, nullptr, exc);
91 ExtensionBackendDb::Data ExtensionBackendDb::getEntry(OUString const & url)
93 try
95 ExtensionBackendDb::Data retData;
96 Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
98 if (aNode.is())
100 retData.items =
101 readVectorOfPair( aNode, "extension-items", "item",
102 "url", "media-type");
104 return retData;
106 catch(const css::uno::Exception &)
108 Any exc( ::cppu::getCaughtException() );
109 throw css::deployment::DeploymentException(
110 "Extension Manager: failed to read data entry in backend db: " +
111 m_urlDb, nullptr, exc);
115 } // namespace bundle
116 } // namespace backend
117 } // namespace dp_registry
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */