LCOV - code coverage report
Current view: top level - desktop/source/deployment/registry/package - dp_extbackenddb.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 29 79.3 %
Date: 2012-08-25 Functions: 7 7 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 18 54 33.3 %

           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/bootstrap.hxx"
      31                 :            : #include "cppuhelper/exc_hlp.hxx"
      32                 :            : #include "com/sun/star/uno/XComponentContext.hpp"
      33                 :            : #include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
      34                 :            : #include "com/sun/star/xml/xpath/XXPathAPI.hpp"
      35                 :            : #include "dp_misc.h"
      36                 :            : 
      37                 :            : #include "dp_extbackenddb.hxx"
      38                 :            : 
      39                 :            : 
      40                 :            : namespace css = ::com::sun::star;
      41                 :            : using namespace ::com::sun::star::uno;
      42                 :            : using ::rtl::OUString;
      43                 :            : 
      44                 :            : #define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010"
      45                 :            : #define NS_PREFIX "ext"
      46                 :            : #define ROOT_ELEMENT_NAME "extension-backend-db"
      47                 :            : #define KEY_ELEMENT_NAME "extension"
      48                 :            : 
      49                 :            : namespace dp_registry {
      50                 :            : namespace backend {
      51                 :            : namespace bundle {
      52                 :            : 
      53                 :        380 : ExtensionBackendDb::ExtensionBackendDb(
      54                 :            :     Reference<XComponentContext> const &  xContext,
      55                 :        380 :     ::rtl::OUString const & url):BackendDb(xContext, url)
      56                 :            : {
      57                 :            : 
      58                 :        380 : }
      59                 :            : 
      60                 :       1130 : OUString ExtensionBackendDb::getDbNSName()
      61                 :            : {
      62                 :       1130 :     return OUSTR(EXTENSION_REG_NS);
      63                 :            : }
      64                 :            : 
      65                 :       1644 : OUString ExtensionBackendDb::getNSPrefix()
      66                 :            : {
      67                 :       1644 :     return OUSTR(NS_PREFIX);
      68                 :            : }
      69                 :            : 
      70                 :         66 : OUString ExtensionBackendDb::getRootElementName()
      71                 :            : {
      72                 :         66 :     return OUSTR(ROOT_ELEMENT_NAME);
      73                 :            : }
      74                 :            : 
      75                 :       1010 : OUString ExtensionBackendDb::getKeyElementName()
      76                 :            : {
      77                 :       1010 :     return OUSTR(KEY_ELEMENT_NAME);
      78                 :            : }
      79                 :            : 
      80                 :        498 : void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
      81                 :            : {
      82                 :            :     try{
      83                 :            :         //reactive revoked entry if possible.
      84 [ +  - ][ +  - ]:        498 :         if (!activateEntry(url))
      85                 :            :         {
      86         [ +  - ]:        498 :             Reference<css::xml::dom::XNode> extensionNodeNode = writeKeyElement(url);
      87                 :            :             writeVectorOfPair(
      88                 :            :                 data.items,
      89                 :            :                 OUSTR("extension-items"),
      90                 :            :                 OUSTR("item"),
      91                 :            :                 OUSTR("url"),
      92                 :            :                 OUSTR("media-type"),
      93 [ +  - ][ +  - ]:        498 :                 extensionNodeNode);
         [ +  - ][ +  - ]
                 [ +  - ]
      94         [ +  - ]:        498 :             save();
      95                 :            :         }
      96                 :            :     }
      97         [ #  # ]:          0 :     catch(const css::uno::Exception &)
      98                 :            :     {
      99         [ #  # ]:          0 :         Any exc( ::cppu::getCaughtException() );
     100                 :            :         throw css::deployment::DeploymentException(
     101                 :            :             OUSTR("Extension Manager: failed to write data entry in backend db: ") +
     102   [ #  #  #  #  :          0 :             m_urlDb, 0, exc);
                   #  # ]
     103                 :            :     }
     104                 :        498 : }
     105                 :            : 
     106                 :          6 : ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & url)
     107                 :            : {
     108                 :            :     try
     109                 :            :     {
     110         [ +  - ]:          6 :         ExtensionBackendDb::Data retData;
     111         [ +  - ]:          6 :         Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
     112                 :            : 
     113         [ +  + ]:          6 :         if (aNode.is())
     114                 :            :         {
     115                 :            :             retData.items =
     116                 :            :                 readVectorOfPair(
     117                 :            :                     aNode,
     118                 :            :                     OUSTR("extension-items"),
     119                 :            :                     OUSTR("item"),
     120                 :            :                     OUSTR("url"),
     121 [ +  - ][ +  - ]:          2 :                     OUSTR("media-type"));
         [ +  - ][ +  - ]
                 [ +  - ]
     122                 :            :         }
     123                 :          6 :         return retData;
     124                 :            :     }
     125         [ #  # ]:          0 :     catch(const css::uno::Exception &)
     126                 :            :     {
     127         [ #  # ]:          0 :         Any exc( ::cppu::getCaughtException() );
     128                 :            :         throw css::deployment::DeploymentException(
     129                 :            :             OUSTR("Extension Manager: failed to read data entry in backend db: ") +
     130   [ #  #  #  #  :          0 :             m_urlDb, 0, exc);
                   #  # ]
     131                 :            :     }
     132                 :            : }
     133                 :            : 
     134                 :            : } // namespace bundle
     135                 :            : } // namespace backend
     136                 :            : } // namespace dp_registry
     137                 :            : 
     138                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10