LCOV - code coverage report
Current view: top level - desktop/source/deployment/registry/component - dp_compbackenddb.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 30 38 78.9 %
Date: 2015-06-13 12:38:46 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include <rtl/string.h>
      22             : #include <rtl/bootstrap.hxx>
      23             : #include <cppuhelper/exc_hlp.hxx>
      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"
      28             : 
      29             : #include "dp_compbackenddb.hxx"
      30             : 
      31             : 
      32             : using namespace ::com::sun::star::uno;
      33             : 
      34             : #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010"
      35             : #define NS_PREFIX "comp"
      36             : #define ROOT_ELEMENT_NAME "component-backend-db"
      37             : #define KEY_ELEMENT_NAME "component"
      38             : 
      39             : namespace dp_registry {
      40             : namespace backend {
      41             : namespace component {
      42             : 
      43         392 : ComponentBackendDb::ComponentBackendDb(
      44             :     Reference<XComponentContext> const &  xContext,
      45         392 :     OUString const & url):BackendDb(xContext, url)
      46             : {
      47             : 
      48         392 : }
      49             : 
      50           5 : OUString ComponentBackendDb::getDbNSName()
      51             : {
      52           5 :     return OUString(EXTENSION_REG_NS);
      53             : }
      54             : 
      55          12 : OUString ComponentBackendDb::getNSPrefix()
      56             : {
      57          12 :     return OUString(NS_PREFIX);
      58             : }
      59             : 
      60           1 : OUString ComponentBackendDb::getRootElementName()
      61             : {
      62           1 :     return OUString(ROOT_ELEMENT_NAME);
      63             : }
      64             : 
      65           5 : OUString ComponentBackendDb::getKeyElementName()
      66             : {
      67           5 :     return OUString(KEY_ELEMENT_NAME);
      68             : }
      69             : 
      70           1 : void ComponentBackendDb::addEntry(OUString const & url, Data const & data)
      71             : {
      72             :     try{
      73           1 :         if (!activateEntry(url))
      74             :         {
      75           1 :             Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url);
      76             :             writeSimpleElement("java-type-library",
      77             :                                OUString::boolean(data.javaTypeLibrary),
      78           1 :                                componentNode);
      79             : 
      80             :             writeSimpleList(
      81             :                 data.implementationNames,
      82             :                 "implementation-names",
      83             :                 "name",
      84           1 :                 componentNode);
      85             : 
      86             :             writeVectorOfPair(
      87             :                 data.singletons,
      88             :                 "singletons",
      89             :                 "item",
      90             :                 "key",
      91             :                 "value",
      92           1 :                 componentNode);
      93             : 
      94           1 :             save();
      95             :         }
      96             :     }
      97           0 :     catch(const css::uno::Exception &)
      98             :     {
      99           0 :         Any exc( ::cppu::getCaughtException() );
     100             :         throw css::deployment::DeploymentException(
     101           0 :             "Extension Manager: failed to write data entry in backend db: " +
     102           0 :             m_urlDb, 0, exc);
     103             :     }
     104           1 : }
     105             : 
     106           1 : ComponentBackendDb::Data ComponentBackendDb::getEntry(OUString const & url)
     107             : {
     108             :     try
     109             :     {
     110           1 :         ComponentBackendDb::Data retData;
     111           2 :         Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
     112           1 :         if (aNode.is())
     113             :         {
     114           1 :             bool bJava = readSimpleElement("java-type-library", aNode) == "true";
     115           1 :             retData.javaTypeLibrary = bJava;
     116             : 
     117           2 :             retData.implementationNames =
     118           1 :                 readList( aNode, "implementation-names", "name");
     119             : 
     120           2 :             retData.singletons =
     121           1 :                 readVectorOfPair( aNode, "singletons", "item", "key", "value");
     122             :         }
     123           2 :         return retData;
     124             :     }
     125           0 :     catch(const css::uno::Exception &)
     126             :     {
     127           0 :         Any exc( ::cppu::getCaughtException() );
     128             :         throw css::deployment::DeploymentException(
     129           0 :             "Extension Manager: failed to read data entry in backend db: " +
     130           0 :             m_urlDb, 0, exc);
     131             :     }
     132             : }
     133             : 
     134             : 
     135             : } // namespace bundle
     136             : } // namespace backend
     137             : } // namespace dp_registry
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11