update dev300-m58
[ooovba.git] / configmgr / source / localbe / localstratumbase.hxx
blob8c5fb02fad08d8833d6b5ddfbb9c1f0f9e340a6a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: localstratumbase.hxx,v $
10 * $Revision: 1.4 $
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 #ifndef CONFIGMGR_LOCALBE_LOCALSTRATUMBASE_HXX_
32 #define CONFIGMGR_LOCALBE_LOCALSTRATUMBASE_HXX_
34 #include <com/sun/star/configuration/backend/XBackendEntities.hpp>
35 #include <com/sun/star/lang/XInitialization.hpp>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/configuration/backend/XUpdatableLayer.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
41 #include <com/sun/star/configuration/backend/CannotConnectException.hpp>
42 #include <cppuhelper/compbase3.hxx>
44 namespace configmgr
46 struct ServiceImplementationInfo;
48 namespace localbe
50 //------------------------------------------------------------------------------
52 namespace css = com::sun::star ;
53 namespace uno = css::uno ;
54 namespace lang = css::lang ;
55 namespace backend = css::configuration::backend ;
56 //------------------------------------------------------------------------------
58 struct LocalStratumMutexHolder { osl::Mutex mMutex; };
59 //------------------------------------------------------------------------------
60 static const char kLocalDataSuffix[] = ".xcu";
61 //------------------------------------------------------------------------------
63 /**
64 Helper for implementing the [Single|Multi]LayerStratum service for local file access.
66 class LocalStratumBase : protected LocalStratumMutexHolder, public cppu::WeakComponentImplHelper3<lang::XInitialization, backend::XBackendEntities, lang::XServiceInfo>
68 protected :
69 /**
70 Service constructor from a service factory.
72 @param xContext component context
74 LocalStratumBase(const uno::Reference<uno::XComponentContext>& xContext) ;
76 /** Destructor */
77 ~LocalStratumBase() ;
80 public:
81 // XInitialize
82 virtual void SAL_CALL
83 initialize( const uno::Sequence<uno::Any>& aParameters)
84 throw (uno::RuntimeException, uno::Exception,
85 css::configuration::InvalidBootstrapFileException,
86 backend::CannotConnectException,
87 backend::BackendSetupException);
90 // XBackendEntities
91 virtual rtl::OUString SAL_CALL
92 getOwnerEntity( )
93 throw (uno::RuntimeException);
95 virtual rtl::OUString SAL_CALL
96 getAdminEntity( )
97 throw (uno::RuntimeException);
99 virtual sal_Bool SAL_CALL
100 supportsEntity( const rtl::OUString& aEntity )
101 throw (backend::BackendAccessException, uno::RuntimeException);
103 virtual sal_Bool SAL_CALL
104 isEqualEntity( const rtl::OUString& aEntity, const rtl::OUString& aOtherEntity )
105 throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException);
107 // XServiceInfo
108 virtual rtl::OUString SAL_CALL
109 getImplementationName( )
110 throw (uno::RuntimeException);
112 virtual sal_Bool SAL_CALL
113 supportsService( const rtl::OUString& aServiceName )
114 throw (uno::RuntimeException) ;
116 virtual uno::Sequence<rtl::OUString> SAL_CALL
117 getSupportedServiceNames( )
118 throw (uno::RuntimeException) ;
120 protected:
121 rtl::OUString const & getBaseUrl() const
122 { return mStrataDataUrl; }
124 static rtl::OUString getDataSuffix()
125 { return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(kLocalDataSuffix)); }
126 //------------------------------------------------------------------------------
127 /// raise a NoSupportException for an attempt to update this layer
128 void failReadonly();
130 // helper for implementing the stratum getLayer[s] function[s]
131 uno::Reference<backend::XLayer> SAL_CALL
132 getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp )
133 throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException);
136 Builds a LocalFileLayer object given a subpath
137 Since the LocalFileLayer implements the various
138 interfaces a layer can be accessed as, a few methods
139 need one.
141 @param aSubpath Subpath
142 @return local file layer
143 @throws com::sun::star::lang::IllegalArgumentException
144 if the subpath is invalid.
146 uno::Reference<backend::XLayer> createReadonlyFileLayer(const rtl::OUString& aSubpath)
147 throw (lang::IllegalArgumentException) ;
150 Builds a LocalFileLayer object given a subpath.
151 Since the LocalFileLayer implements the various
152 interfaces a layer can be accessed as, a few methods
153 need one.
155 @param aSubpath subpath
156 @return local file layer
157 @throws com::sun::star::lang::IllegalArgumentException
158 if the subpath is invalid.
160 uno::Reference<backend::XUpdatableLayer> createUpdatableFileLayer(const rtl::OUString& aSubpath)
161 throw (lang::IllegalArgumentException) ;
164 Tells if a file is more recent than a given date.
165 The date is formatted YYYYMMDDhhmmssZ.
167 @param aSubpath relative URL of the component to check
168 @param aTimestamp timestamp to check against
169 @return sal_True if the file is more recent, sal_False otherwise
171 sal_Bool isMoreRecent(const rtl::OUString& aSubpath,
172 const rtl::OUString& aTimestamp) ;
174 protected:
175 /// Parses and adjusts the passed base URL
176 virtual void adjustBaseURL(rtl::OUString& aBaseURL);
178 private:
180 Retrieves the appropriate layer and sublayers base directories.
182 @param aLayerUrl layer base URL, filled on return
183 @param aSubLayerUrl sublayer base URL, filled on return
185 virtual void getLayerDirectories(rtl::OUString& aLayerUrl,
186 rtl::OUString& aSubLayerUrl) const = 0;
187 virtual const ServiceImplementationInfo * getServiceInfoData() const = 0;
189 private :
190 /** Service factory */
191 uno::Reference<lang::XMultiServiceFactory> mFactory ;
192 /**
193 Base of the strata data.
195 rtl::OUString mStrataDataUrl ;
200 } } // configmgr.localbe
202 #endif