summaryrefslogtreecommitdiff
path: root/configmgr/source/localbe
diff options
context:
space:
mode:
Diffstat (limited to 'configmgr/source/localbe')
-rw-r--r--configmgr/source/localbe/localdataimportsvc.cxx360
-rw-r--r--configmgr/source/localbe/localdataimportsvc.hxx101
-rw-r--r--configmgr/source/localbe/localfilehelper.cxx245
-rw-r--r--configmgr/source/localbe/localfilehelper.hxx124
-rw-r--r--configmgr/source/localbe/localfilelayer.cxx611
-rw-r--r--configmgr/source/localbe/localfilelayer.hxx495
-rw-r--r--configmgr/source/localbe/localhierarchybrowsersvc.cxx536
-rw-r--r--configmgr/source/localbe/localhierarchybrowsersvc.hxx103
-rw-r--r--configmgr/source/localbe/localmultistratum.cxx250
-rw-r--r--configmgr/source/localbe/localmultistratum.hxx100
-rw-r--r--configmgr/source/localbe/localoutputstream.cxx199
-rw-r--r--configmgr/source/localbe/localoutputstream.hxx106
-rw-r--r--configmgr/source/localbe/localschemasupplier.cxx291
-rw-r--r--configmgr/source/localbe/localschemasupplier.hxx118
-rw-r--r--configmgr/source/localbe/localsinglebackend.cxx801
-rw-r--r--configmgr/source/localbe/localsinglebackend.hxx248
-rw-r--r--configmgr/source/localbe/localsinglestratum.cxx233
-rw-r--r--configmgr/source/localbe/localsinglestratum.hxx150
-rw-r--r--configmgr/source/localbe/localstratumbase.cxx256
-rw-r--r--configmgr/source/localbe/localstratumbase.hxx202
-rw-r--r--configmgr/source/localbe/makefile.mk61
21 files changed, 0 insertions, 5590 deletions
diff --git a/configmgr/source/localbe/localdataimportsvc.cxx b/configmgr/source/localbe/localdataimportsvc.cxx
deleted file mode 100644
index 2c207b11fc1a..000000000000
--- a/configmgr/source/localbe/localdataimportsvc.cxx
+++ /dev/null
@@ -1,360 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localdataimportsvc.cxx,v $
- * $Revision: 1.9 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "localdataimportsvc.hxx"
-#include "localsinglebackend.hxx"
-
-#ifndef CONFIGMGR_API_FACTORY_HXX_
-#include "confapifactory.hxx"
-#endif
-#include <rtl/ustrbuf.hxx>
-#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
-#include <com/sun/star/configuration/backend/XLayerImporter.hpp>
-
-// -----------------------------------------------------------------------------
-#define OUSTRING( constascii ) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(constascii))
-// -----------------------------------------------------------------------------
-namespace configmgr
-{
-// -----------------------------------------------------------------------------
- namespace localbe
- {
-// -----------------------------------------------------------------------------
- namespace backend = ::com::sun::star::configuration::backend;
-// -----------------------------------------------------------------------------
-
-sal_Char const * const aLocalDataImportServices[] =
-{
- "com.sun.star.configuration.backend.LocalDataImporter",
- 0,
- "com.sun.star.configuration.backend.DataImporter",
- 0
-};
-const ServiceImplementationInfo aLocalDataImportSI =
-{
- "com.sun.star.comp.configuration.backend.LocalDataImporter",
- aLocalDataImportServices,
- aLocalDataImportServices + 3
-};
-// -----------------------------------------------------------------------------
-
-const ServiceRegistrationInfo* getLocalDataImportServiceInfo()
-{ return getRegistrationInfo(& aLocalDataImportSI); }
-// -----------------------------------------------------------------------------
-
-inline
-ServiceInfoHelper LocalDataImportService::getServiceInfo()
-{
- return & aLocalDataImportSI;
-}
-// -----------------------------------------------------------------------------
-
-uno::Reference< uno::XInterface > SAL_CALL instantiateLocalDataImporter
-( uno::Reference< uno::XComponentContext > const& xContext )
-{
- return * new LocalDataImportService( xContext );
-}
-// -----------------------------------------------------------------------------
-
-LocalDataImportService::LocalDataImportService(uno::Reference< uno::XComponentContext > const & _xContext)
-: m_xServiceFactory(_xContext->getServiceManager(), uno::UNO_QUERY)
-{
- if (!m_xServiceFactory.is())
- {
- rtl::OUString sMessage = OUSTRING("Configuration Importer: Context has no service manager (or interface is missing)");
- throw lang::NullPointerException(sMessage,NULL);
- }
-}
-// -----------------------------------------------------------------------------
-
-LocalDataImportService::~LocalDataImportService()
-{}
-// -----------------------------------------------------------------------------
-
-namespace
-{
-// -----------------------------------------------------------------------------
- struct JobDesc
- {
- explicit JobDesc(task::XJob * pJob, const uno::Sequence< beans::NamedValue >& aArguments);
-
- rtl::OUString aLayerDataUrl;
- rtl::OUString aImporterService;
-
- rtl::OUString aComponent;
- rtl::OUString aEntity;
-
- uno::Reference< backend::XLayer > xLayerFilter;
-
- sal_Bool overwrite;
- sal_Bool truncate;
-
- sal_Bool use_component;
- sal_Bool use_entity;
- sal_Bool use_overwrite;
- sal_Bool use_truncate;
- };
- // -----------------------------------------------------------------------------
-
- JobDesc::JobDesc(task::XJob * pJob, const uno::Sequence< beans::NamedValue >& aArguments)
- : aLayerDataUrl()
- , aImporterService()
- , aComponent()
- , aEntity()
- , xLayerFilter()
- , overwrite(true)
- , truncate(false)
- , use_component(false)
- , use_entity(false)
- , use_overwrite(false)
- , use_truncate(false)
- {
- sal_Int16 const nCount = static_cast<sal_Int16>(aArguments.getLength());
-
- if (sal_Int32(nCount) != aArguments.getLength())
- {
- rtl::OUString sMessage = OUSTRING("Too many arguments for LocalDataImporter Job");
- throw lang::IllegalArgumentException(sMessage,pJob,0);
- }
-
- for (sal_Int16 i=0; i < nCount; ++i)
- {
- sal_Bool bKnown = false;
- sal_Bool bGood = false;
-
- if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("LayerDataUrl")))
- {
- bKnown = true;
- bGood = (aArguments[i].Value >>= aLayerDataUrl);
- }
- else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ImporterService")))
- {
- bKnown = true;
- bGood = (aArguments[i].Value >>= aImporterService);
- }
- else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Component")))
- {
- bKnown = true;
- bGood = (aArguments[i].Value >>= aComponent);
- use_component = bGood && (aComponent.getLength() != 0);
- }
- else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Entity")))
- {
- bKnown = true;
- bGood = (aArguments[i].Value >>= aEntity);
- use_entity = bGood && (aEntity.getLength() != 0);
- }
- else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("LayerFilter")))
- {
- bKnown = true;
- bGood = (aArguments[i].Value >>= xLayerFilter);
- if (xLayerFilter.is() && !uno::Reference<lang::XInitialization>::query(xLayerFilter).is())
- bGood = false;
- }
- else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("OverwriteExisting")))
- {
- bKnown = true;
- bGood = (aArguments[i].Value >>= overwrite);
- use_overwrite = bGood;
- }
- else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("TruncateExisting")))
- {
- bKnown = true;
- bGood = (aArguments[i].Value >>= truncate);
- use_truncate = bGood;
- }
-
- if (!bGood)
- {
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii("LocalDataImportService - Illegal argument: ");
- if (bKnown)
- sMsg.appendAscii("Wrong value type for argument '");
- else
- sMsg.appendAscii("Unknown argument '");
-
- sMsg.append(aArguments[i].Name).appendAscii("'.");
-
- throw lang::IllegalArgumentException(sMsg.makeStringAndClear(),pJob,i+1);
- }
- }
- if (aLayerDataUrl.getLength() == 0)
- {
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii("LocalDataImportService - Missing argument: ");
- sMsg.appendAscii("No data URL available");
- throw lang::IllegalArgumentException(sMsg.makeStringAndClear(),pJob,0);
- }
- if (aImporterService.getLength() == 0)
- {
- if ( (use_truncate && truncate) || (use_overwrite && !overwrite) )
- aImporterService = OUSTRING("com.sun.star.configuration.backend.CopyImporter");
- else
- aImporterService = OUSTRING("com.sun.star.configuration.backend.MergeImporter");
- }
- }
- // -----------------------------------------------------------------------------
-
- static
- inline
- uno::Type getOverwriteFailedExceptionType()
- {
- lang::IllegalAccessException const * const selected = 0;
- return ::getCppuType(selected);
- }
-// -----------------------------------------------------------------------------
-}
-// -----------------------------------------------------------------------------
-// XJob
-
-uno::Any SAL_CALL
- LocalDataImportService::execute( const uno::Sequence< beans::NamedValue >& Arguments )
- throw (lang::IllegalArgumentException, uno::Exception, uno::RuntimeException)
-{
- JobDesc const aJob(this,Arguments);
-
- uno::Reference< lang::XMultiServiceFactory > aFactory = this->getServiceFactory();
-
- uno::Reference< backend::XLayer > xLayer = aJob.use_component ?
- LocalSingleBackend::createSimpleLayer(aFactory,aJob.aLayerDataUrl, aJob.aComponent ):
- LocalSingleBackend::createSimpleLayer(aFactory,aJob.aLayerDataUrl) ;
-
- if (!xLayer.is())
- {
- rtl::OUString sMessage = OUSTRING("LocalDataImportService - Cannot create layer to import from");
- throw lang::NullPointerException(sMessage,*this);
- }
-
- uno::Reference< lang::XInitialization > xFilterInit(aJob.xLayerFilter,uno::UNO_QUERY);
- if (xFilterInit.is())
- {
- beans::NamedValue argvalue(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Source") ),
- uno::makeAny( xLayer) );
-
- uno::Sequence< uno::Any > args(1);
- args[0] <<= argvalue;
-
- xFilterInit->initialize(args);
-
- xLayer = aJob.xLayerFilter;
- }
-
- uno::Reference< backend::XLayerImporter > xImporter;
-
- int nArgCount = 0;
- if (aJob.use_overwrite) ++nArgCount;
- if (aJob.use_truncate) ++nArgCount;
-
- if (nArgCount)
- {
- uno::Sequence< uno::Any > aArgs(nArgCount);
-
- int n = 0;
- if (aJob.use_overwrite)
- aArgs[n++] <<= beans::NamedValue(OUSTRING("Overwrite"), uno::makeAny(aJob.overwrite));
-
- if (aJob.use_truncate)
- aArgs[n++] <<= beans::NamedValue(OUSTRING("Truncate"), uno::makeAny(aJob.truncate));
-
- OSL_ASSERT(n == nArgCount);
-
- xImporter.set( aFactory->createInstanceWithArguments(aJob.aImporterService,aArgs), uno::UNO_QUERY);
- }
- else
- xImporter.set( aFactory->createInstance(aJob.aImporterService), uno::UNO_QUERY);
-
- if (!xImporter.is())
- {
- rtl::OUString sMessage = OUSTRING("LocalDataImportService - Cannot create importer service: ") + aJob.aImporterService;
- throw lang::NullPointerException(sMessage,*this);
- }
-
- try
- {
- if (aJob.use_entity)
- xImporter->importLayerForEntity(xLayer,aJob.aEntity);
-
- else
- xImporter->importLayer(xLayer);
- }
- catch (lang::WrappedTargetException & e)
- {
- if (aJob.overwrite || !e.TargetException.isExtractableTo(getOverwriteFailedExceptionType())) throw;
- return e.TargetException;
- }
- catch (lang::WrappedTargetRuntimeException & e)
- {
- if (aJob.overwrite || !e.TargetException.isExtractableTo(getOverwriteFailedExceptionType())) throw;
- return e.TargetException;
- }
-
- return uno::Any();
-}
-// -----------------------------------------------------------------------------
-
-// XServiceInfo
-
-rtl::OUString SAL_CALL
- LocalDataImportService::getImplementationName( )
- throw (uno::RuntimeException)
-{
- return getServiceInfo().getImplementationName( );
-}
-// -----------------------------------------------------------------------------
-
-
-sal_Bool SAL_CALL
- LocalDataImportService::supportsService( const rtl::OUString& ServiceName )
- throw (uno::RuntimeException)
-{
- return getServiceInfo().supportsService( ServiceName );
-}
-// -----------------------------------------------------------------------------
-
-
-uno::Sequence< ::rtl::OUString > SAL_CALL
- LocalDataImportService::getSupportedServiceNames( )
- throw (uno::RuntimeException)
-{
- return getServiceInfo().getSupportedServiceNames( );
-}
-// -----------------------------------------------------------------------------
-
-// -----------------------------------------------------------------------------
-// -----------------------------------------------------------------------------
- } // namespace
-
-// -----------------------------------------------------------------------------
-} // namespace
-
diff --git a/configmgr/source/localbe/localdataimportsvc.hxx b/configmgr/source/localbe/localdataimportsvc.hxx
deleted file mode 100644
index e1ede1d60071..000000000000
--- a/configmgr/source/localbe/localdataimportsvc.hxx
+++ /dev/null
@@ -1,101 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localdataimportsvc.hxx,v $
- * $Revision: 1.4 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_LOCALBE_IMPORTSVC_HXX
-#define CONFIGMGR_LOCALBE_IMPORTSVC_HXX
-
-#include "serviceinfohelper.hxx"
-#include <cppuhelper/implbase2.hxx>
-#include <osl/mutex.hxx>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/task/XJob.hpp>
-
-// -----------------------------------------------------------------------------
-
-namespace configmgr
-{
-// -----------------------------------------------------------------------------
- namespace localbe
- {
-// -----------------------------------------------------------------------------
- namespace uno = ::com::sun::star::uno;
- namespace lang = ::com::sun::star::lang;
- namespace task = ::com::sun::star::task;
- namespace beans = ::com::sun::star::beans;
-// -----------------------------------------------------------------------------
-
- class LocalDataImportService : public ::cppu::WeakImplHelper2<
- task::XJob,
- lang::XServiceInfo
- >
- {
- public:
- explicit
- LocalDataImportService(uno::Reference< uno::XComponentContext > const & _xContext);
- ~LocalDataImportService();
-
- // XServiceInfo
- virtual rtl::OUString SAL_CALL
- getImplementationName( )
- throw (uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL
- supportsService( const rtl::OUString& ServiceName )
- throw (uno::RuntimeException);
-
- virtual uno::Sequence< rtl::OUString > SAL_CALL
- getSupportedServiceNames( )
- throw (uno::RuntimeException);
-
- // XJob
- virtual uno::Any SAL_CALL
- execute( const uno::Sequence< beans::NamedValue >& Arguments )
- throw (lang::IllegalArgumentException, uno::Exception, uno::RuntimeException);
-
- protected:
- uno::Reference< lang::XMultiServiceFactory > getServiceFactory() const
- { return m_xServiceFactory; }
-
- private:
- uno::Reference< lang::XMultiServiceFactory > m_xServiceFactory;
-
- static ServiceInfoHelper getServiceInfo();
- };
-// -----------------------------------------------------------------------------
- } // namespace xml
-// -----------------------------------------------------------------------------
-
-} // namespace configmgr
-#endif
-
-
-
-
diff --git a/configmgr/source/localbe/localfilehelper.cxx b/configmgr/source/localbe/localfilehelper.cxx
deleted file mode 100644
index 8b9ecc41198c..000000000000
--- a/configmgr/source/localbe/localfilehelper.cxx
+++ /dev/null
@@ -1,245 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localfilehelper.cxx,v $
- * $Revision: 1.6 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-#include "localfilehelper.hxx"
-#include "filehelper.hxx"
-#include <rtl/ustrbuf.hxx>
-#include "tools/getprocessworkingdir.hxx"
-#include <vector>
-
-namespace configmgr
-{
- namespace localbe
- {
- //------------------------------------------------------------------------------
- bool isValidFileURL (rtl::OUString const& _sFileURL)
- {
- rtl::OUString sSystemPath;
- return _sFileURL.getLength() && (osl::File::E_None == osl::File::getSystemPathFromFileURL(_sFileURL, sSystemPath));
- }
- //------------------------------------------------------------------------------
- void validateFileURL(const rtl::OUString& _sFileURL, const uno::Reference<uno::XInterface>& pContext)
- throw(css::configuration::InvalidBootstrapFileException)
- {
- if (!isValidFileURL( _sFileURL))
- {
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii(" Not a Valid File URL: \"");
- sMsg.append(_sFileURL);
- sMsg.appendAscii("\"");
- throw com::sun::star::configuration::InvalidBootstrapFileException(
- sMsg.makeStringAndClear(),pContext, rtl::OUString() ) ;
- }
- }
- //------------------------------------------------------------------------------
- void checkFileExists(const rtl::OUString& _sFileURL,const uno::Reference<uno::XInterface>& pContext)
- throw (backend::CannotConnectException)
- {
- if (!FileHelper::fileExists(_sFileURL))
- {
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii(" No Such File or Directory: \"");
- sMsg.append(_sFileURL);
- sMsg.appendAscii("\"");
-
- throw backend::CannotConnectException(sMsg.makeStringAndClear(), pContext, uno::Any()) ;
- }
- }
- //------------------------------------------------------------------------------
- void checkIfDirectory(const rtl::OUString& _sFileURL, const uno::Reference<uno::XInterface>& pContext)
- throw (backend::BackendSetupException)
- {
- if (!FileHelper::dirExists(_sFileURL))
- {
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii(" File:\"");
- sMsg.append(_sFileURL);
- sMsg.appendAscii("\" Must be a Directory\"");
-
- throw backend::BackendSetupException(sMsg.makeStringAndClear(),pContext, uno::Any()) ;
- }
- }
-
- // ---------------------------------------------------------------------------------------
- bool implEnsureAbsoluteURL(rtl::OUString & _rsURL) // also strips embedded dots etc.
- {
- rtl::OUString sBasePath;
- OSL_VERIFY(tools::getProcessWorkingDir(&sBasePath));
-
- rtl::OUString sAbsolute;
- if ( osl::File::E_None == osl::File::getAbsoluteFileURL(sBasePath, _rsURL, sAbsolute))
- {
- _rsURL = sAbsolute;
- return true;
- }
- else
- {
- OSL_ENSURE(false, "Could not get absolute file URL for valid URL");
- return false;
- }
- }
- // ---------------------------------------------------------------------------------------
- osl::DirectoryItem::RC implNormalizeURL(rtl::OUString & _sURL, osl::DirectoryItem& aDirItem)
- {
- OSL_PRECOND(aDirItem.is(), "Opened DirItem required");
-
- static const sal_uInt32 cFileStatusMask = FileStatusMask_FileURL;
-
- osl::FileStatus aFileStatus(cFileStatusMask);
-
- osl::DirectoryItem::RC rc = aDirItem.getFileStatus(aFileStatus);
-
- if (rc == osl::DirectoryItem::E_None)
- {
- rtl::OUString aNormalizedURL = aFileStatus.getFileURL();
-
- if (aNormalizedURL.getLength() != 0)
- _sURL = aNormalizedURL;
- else
- rc = osl::DirectoryItem::E_INVAL;
- }
- return rc;
- }
-
- // ---------------------------------------------------------------------------------------
-
- bool normalizeURL(rtl::OUString & _sURL, const uno::Reference<uno::XInterface>& pContext, bool bNothrow )
- throw (backend::InsufficientAccessRightsException, backend::BackendAccessException)
- {
- if (_sURL.getLength() == 0)
- return false;
-
- osl::DirectoryItem aDirItem;
-
- osl::DirectoryItem::RC rc = osl::DirectoryItem::get(_sURL, aDirItem);
-
- if (rc == osl::DirectoryItem::E_None)
- rc = implNormalizeURL(_sURL,aDirItem);
-
- switch (rc)
- {
- case osl::DirectoryItem::E_None: return true;
-
- case osl::DirectoryItem::E_NOENT: return true;
-
- case osl::DirectoryItem::E_ACCES:
- if (!bNothrow)
- {
- rtl::OUStringBuffer msg;
- msg.appendAscii("LocalBackend: Cannot normalize URL \"" );
- msg.append(_sURL);
- msg.appendAscii("\" - InsufficientAccess");
- throw backend::InsufficientAccessRightsException(msg.makeStringAndClear(),pContext,uno::Any());
- }
- return false;
-
- default:
- if (!bNothrow)
- {
- rtl::OUStringBuffer msg;
- msg.appendAscii("LocalBackend: Cannot normalize URL \"" );
- msg.append(_sURL);
- msg.appendAscii("\" - ").append(FileHelper::createOSLErrorString(rc));
- throw backend::BackendAccessException(msg.makeStringAndClear(),pContext,uno::Any());
- }
- return false;
-
- }
- }
-
- // ---------------------------------------------------------------------------------------
- static const sal_Unicode kComponentSeparator = '.' ;
- static const sal_Unicode kPathSeparator = '/' ;
-
- rtl::OUString componentToPath(const rtl::OUString& aComponent)
- {
- rtl::OUStringBuffer retCode ;
-
- retCode.append(kPathSeparator) ;
- retCode.append(aComponent.replace(kComponentSeparator, kPathSeparator)) ;
- return retCode.makeStringAndClear() ;
- }
- //------------------------------------------------------------------------------
- rtl::OUString layeridToPath(const rtl::OUString& aLayerId)
- {
- sal_Int32 const nSplit = aLayerId.indexOf(k_cLayerIdSeparator);
- if (nSplit < 0)
- return componentToPath(aLayerId);
-
- rtl::OUString const aComponent= aLayerId.copy(0,nSplit);
- rtl::OUString const aSubid = aLayerId.copy(nSplit+1);
-
- rtl::OUStringBuffer retCode ;
-
- retCode.append(kPathSeparator) ;
- retCode.append(aComponent.replace(kComponentSeparator, kPathSeparator)) ;
- retCode.append(kPathSeparator) ;
- retCode.append(aSubid) ;
- return retCode.makeStringAndClear() ;
- }
- //------------------------------------------------------------------------------
- bool checkOptionalArg(rtl::OUString& aArg)
- {
- if (aArg.getLength() && aArg[0] == sal_Unicode('?'))
- {
- aArg = aArg.copy(1);
- return true;
- }
- else
- {
- return false;
- }
- }
- //------------------------------------------------------------------------------
- void fillFromBlankSeparated(const rtl::OUString& aList,
- uno::Sequence<rtl::OUString>& aTarget)
- {
- std::vector<rtl::OUString> tokens ;
- sal_Int32 nextToken = 0 ;
-
- do {
- tokens.push_back(aList.getToken(0, ' ', nextToken)) ;
- } while (nextToken >= 0) ;
- if (tokens.size() > 0) {
- aTarget.realloc(tokens.size()) ;
- std::vector<rtl::OUString>::const_iterator token ;
- sal_Int32 i = 0 ;
-
- for (token = tokens.begin() ; token != tokens.end() ; ++ token) {
- aTarget [i ++] = *token ;
- }
- }
- }
- //------------------------------------------------------------------------------
- }
-} // namespace configmgr
diff --git a/configmgr/source/localbe/localfilehelper.hxx b/configmgr/source/localbe/localfilehelper.hxx
deleted file mode 100644
index 56610a9e73e6..000000000000
--- a/configmgr/source/localbe/localfilehelper.hxx
+++ /dev/null
@@ -1,124 +0,0 @@
-#ifndef CONFIGMGR_LOCALBE_LOCALFILEHELPER_HXX_
-#define CONFIGMGR_LOCALBE_LOCALFILEHELPER_HXX_
-
-#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
-#include <com/sun/star/configuration/backend/CannotConnectException.hpp>
-#include <com/sun/star/configuration/backend/BackendAccessException.hpp>
-#include <com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <osl/file.hxx>
-
-
-namespace configmgr
-{
-
- namespace localbe
- {
- namespace css = com::sun::star ;
- namespace uno = css::uno ;
- namespace backend = css::configuration::backend ;
-
- /**
- Validates a file URL
-
- @param _sFileURL URL of the file to validate
- @return bool true if URL valid, false if URL invalid
- */
-
- bool isValidFileURL (rtl::OUString const& _sFileURL);
- /**
- Ensures Absolute URL
- @param _sFileURL URL of the file to validate
- @return bool true if URL is absolute URL,
- false if URL is not absolute URL
- */
-
- bool implEnsureAbsoluteURL(rtl::OUString & _sFileURL);
- /**
- Normalize URL
- @param _sFileURL URL of the file to validate
- @param aDirItem Directory Item
- @return RC error code
- */
-
- osl::DirectoryItem::RC implNormalizeURL(rtl::OUString & _sFileURL, osl::DirectoryItem& aDirItem);
- /**
- Normalize URL
- @param _sFileURL URL of the file to validate
- @param pContext pointer to context class
- @param bNothrow param indicating that exception should not be thrown
- @return bool true if URL is normalized URL
- false if URL is not normalized URL
- */
-
-
- bool normalizeURL(rtl::OUString & _sFileURL,
- const uno::Reference<uno::XInterface>& pContext,
- bool bNothrow = false )
- throw (backend::InsufficientAccessRightsException,
- backend::BackendAccessException);
-
- /**
- Validates a file URL
-
- @param _sFileURL URL of the file to validate
- @param pContext pointer to context class
- @throws css::configuration::InvalidBootstrapFileException
- */
- void validateFileURL(const rtl::OUString& _sFileURL,
- const uno::Reference<uno::XInterface>& pContext)
- throw(css::configuration::InvalidBootstrapFileException);
- /**
- Checks if a Directory exist for a given file URL
-
- @param _sFileURL URL of the file to validate
- @param pContext pointer to context class
- @throws backend::BackendSetupException
- */
- void checkIfDirectory(const rtl::OUString& _sFileURL,
- const uno::Reference<uno::XInterface>& pContext )
- throw (backend::BackendSetupException);
- /**
- Checks if a File exist for a given file URL
- @param pContext pointer to context class
- @param _sFileURL URL of the file to validate
- @throws backend::CannotConnectException
- */
- void checkFileExists(const rtl::OUString& _sFileURL,
- const uno::Reference<uno::XInterface>& pContext)
- throw (backend::CannotConnectException);
-
- /**
- Convert Component name to Path name
- @param aComponent Component name
- */
- rtl::OUString componentToPath(const rtl::OUString& aComponent);
-
- /// character that can be used to delimit a sub-id within a layerid
- const sal_Unicode k_cLayerIdSeparator = ':';
- /**
- Convert layer id to Path name
- Format of layer id is <component> [:<sub-id>]
- @param aLayerId layer id
- */
- rtl::OUString layeridToPath(const rtl::OUString& aLayerId);
-
-
- /**
- Checks if Arguement is Optional
- @param aArg Argument
- @return bool returns true is Argument is Optional, false otherwise
- */
- bool checkOptionalArg(rtl::OUString& aArg);
-
- /*
- parses sequence of strings from blank separated list
- @param aList blank separated list
- @param aTarget sequence of parsed strings
- */
- void fillFromBlankSeparated(const rtl::OUString& aList,
- uno::Sequence<rtl::OUString>& aTarget);
-
- }
-}
-#endif
diff --git a/configmgr/source/localbe/localfilelayer.cxx b/configmgr/source/localbe/localfilelayer.cxx
deleted file mode 100644
index b4f1e5b4611b..000000000000
--- a/configmgr/source/localbe/localfilelayer.cxx
+++ /dev/null
@@ -1,611 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localfilelayer.cxx,v $
- * $Revision: 1.15 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-#include "localfilelayer.hxx"
-#include "localoutputstream.hxx"
-#include "oslstream.hxx"
-#include <rtl/ustrbuf.hxx>
-#include <com/sun/star/io/XActiveDataSource.hpp>
-#include <com/sun/star/io/XActiveDataSink.hpp>
-#include <com/sun/star/configuration/backend/BackendAccessException.hpp>
-#include <com/sun/star/beans/PropertyAttribute.hpp>
-
-namespace configmgr { namespace localbe {
-
-//==============================================================================
-
-//------------------------------------------------------------------------------
-
-BasicLocalFileLayer::BasicLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aComponentFile)
-: mFactory(xFactory)
-, mFileUrl(aComponentFile)
-{
- static const rtl::OUString kXMLLayerParser(RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.configuration.backend.xml.LayerParser")) ;
-
- mLayerReader = uno::Reference<backend::XLayer>::query(
- mFactory->createInstance(kXMLLayerParser)) ;
-
-}
-//------------------------------------------------------------------------------
-
-SimpleLocalFileLayer::SimpleLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aComponentFile)
-: BasicLocalFileLayer(xFactory,aComponentFile)
-{
-}
-//------------------------------------------------------------------------------
-
-SimpleLocalFileLayer::SimpleLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent)
-: BasicLocalFileLayer(xFactory,aBaseDir + aComponent)
-{
-}
-//------------------------------------------------------------------------------
-
-FlatLocalFileLayer::FlatLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent)
-: BasicLocalFileLayer(xFactory,aBaseDir + aComponent)
-, mLayerWriter( createLayerWriter() )
-{
-}
-//------------------------------------------------------------------------------
-
-BasicCompositeLocalFileLayer::BasicCompositeLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aComponentFile)
-: BasicLocalFileLayer(xFactory,aComponentFile)
-{
-}
-//------------------------------------------------------------------------------
-
-CompositeLocalFileLayer::CompositeLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aComponent,
- const std::vector<rtl::OUString>& aSublayerDirectories)
-: BasicCompositeLocalFileLayer(xFactory,rtl::OUString())
-{
- fillSubLayerLists(aSublayerDirectories, aComponent) ;
-}
-//------------------------------------------------------------------------------
-
-FullCompositeLocalFileLayer::FullCompositeLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent,
- const std::vector<rtl::OUString>& aSublayerDirectories)
-: BasicCompositeLocalFileLayer(xFactory,aBaseDir + aComponent)
-, mLayerWriter( createLayerWriter() )
-{
- fillSubLayerLists(aSublayerDirectories, aComponent) ;
-}
-//------------------------------------------------------------------------------
-
-BasicLocalFileLayer::~BasicLocalFileLayer() {}
-//------------------------------------------------------------------------------
-
-SimpleLocalFileLayer::~SimpleLocalFileLayer() {}
-//------------------------------------------------------------------------------
-
-FlatLocalFileLayer::~FlatLocalFileLayer() {}
-//------------------------------------------------------------------------------
-
-CompositeLocalFileLayer::~CompositeLocalFileLayer() {}
-//------------------------------------------------------------------------------
-
-FullCompositeLocalFileLayer::~FullCompositeLocalFileLayer() {}
-//------------------------------------------------------------------------------
-
-uno::Reference<backend::XLayerHandler> BasicLocalFileLayer::createLayerWriter()
-{
- static const rtl::OUString kXMLLayerWriter(RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.configuration.backend.xml.LayerWriter")) ;
-
- uno::Reference< uno::XInterface > xWriter = mFactory->createInstance(kXMLLayerWriter);
-
- return uno::Reference<backend::XLayerHandler>(xWriter,uno::UNO_REF_QUERY_THROW) ;
-}
-//------------------------------------------------------------------------------
-
-static inline void readEmptyLayer(const uno::Reference<backend::XLayerHandler>& xHandler)
-{
- OSL_ASSERT(xHandler.is());
- xHandler->startLayer();
- xHandler->endLayer();
-}
-//------------------------------------------------------------------------------
-
-void BasicLocalFileLayer::readData(
- backend::XLayer * pContext,
- const uno::Reference<backend::XLayerHandler>& xHandler,
- const rtl::OUString& aFileUrl)
- throw ( backend::MalformedDataException,
- lang::NullPointerException,
- lang::WrappedTargetException,
- uno::RuntimeException)
-{
- if (!xHandler.is())
- {
- rtl::OUString const sMessage(RTL_CONSTASCII_USTRINGPARAM(
- "LocalFileLayer - Cannot readData: Handler is NULL."));
-
- throw lang::NullPointerException(sMessage,pContext);
- }
-
- osl::File blobFile(aFileUrl) ;
- osl::File::RC errorCode = blobFile.open(OpenFlag_Read) ;
-
- switch (errorCode)
- {
- case osl::File::E_None: // got it
- {
- uno::Reference<io::XActiveDataSink> xAS(mLayerReader, uno::UNO_QUERY_THROW);
-
- uno::Reference<io::XInputStream> xStream( new OSLInputStreamWrapper(blobFile) );
-
- xAS->setInputStream(xStream);
-
- mLayerReader->readData(xHandler) ;
- }
- break;
-
- case osl::File::E_NOENT: // no layer => empty layer
- readEmptyLayer(xHandler);
- break;
-
- default:
- {
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii("LocalFile Layer: Cannot open input file \"");
- sMsg.append(aFileUrl);
- sMsg.appendAscii("\" : ");
- sMsg.append(FileHelper::createOSLErrorString(errorCode));
-
- io::IOException ioe(sMsg.makeStringAndClear(),pContext);
-
- sMsg.appendAscii("LocalFileLayer - Cannot readData: ").append(ioe.Message);
- throw backend::BackendAccessException(sMsg.makeStringAndClear(),pContext,uno::makeAny(ioe));
- }
- }
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL SimpleLocalFileLayer::readData(
- const uno::Reference<backend::XLayerHandler>& xHandler)
- throw ( backend::MalformedDataException,
- lang::NullPointerException,
- lang::WrappedTargetException,
- uno::RuntimeException)
-{
- BasicLocalFileLayer::readData(this,xHandler, getFileUrl()) ;
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL FlatLocalFileLayer::readData(
- const uno::Reference<backend::XLayerHandler>& xHandler)
- throw ( backend::MalformedDataException,
- lang::NullPointerException,
- lang::WrappedTargetException,
- uno::RuntimeException)
-{
- BasicLocalFileLayer::readData(this,xHandler, getFileUrl() ) ;
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL CompositeLocalFileLayer::readData(
- const uno::Reference<backend::XLayerHandler>& xHandler)
- throw ( backend::MalformedDataException,
- lang::NullPointerException,
- lang::WrappedTargetException,
- uno::RuntimeException)
-{
- if (!xHandler.is())
- {
- rtl::OUString const sMessage(RTL_CONSTASCII_USTRINGPARAM(
- "LocalFileLayer - Cannot readData: Handler is NULL."));
-
- throw lang::NullPointerException(sMessage,*this);
- }
-
- readEmptyLayer(xHandler) ;
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL FullCompositeLocalFileLayer::readData(
- const uno::Reference<backend::XLayerHandler>& xHandler)
- throw ( backend::MalformedDataException,
- lang::NullPointerException,
- lang::WrappedTargetException,
- uno::RuntimeException)
-{
- BasicLocalFileLayer::readData(static_cast<backend::XCompositeLayer*>(this),xHandler, getFileUrl() ) ;
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL BasicCompositeLocalFileLayer::readSubLayerData(
- backend::XCompositeLayer * pContext,
- const uno::Reference<backend::XLayerHandler>& xHandler,
- const rtl::OUString& aSubLayerId)
- throw ( backend::MalformedDataException,
- lang::IllegalArgumentException,
- lang::NullPointerException,
- lang::WrappedTargetException,
- uno::RuntimeException)
-{
- if (!xHandler.is())
- {
- rtl::OUString const sMessage(RTL_CONSTASCII_USTRINGPARAM(
- "CompositeLocalFileLayer - Cannot readSubLayerData: Handler is NULL."));
-
- throw lang::NullPointerException(sMessage,pContext);
- }
-
- sal_Int32 i ;
-
- for (i = 0 ; i < mSubLayers.getLength() ; ++ i) {
- if (mSubLayers [i].equals(aSubLayerId)) { break ; }
- }
- if (i == mSubLayers.getLength())
- {
- rtl::OUStringBuffer message ;
-
- message.appendAscii("Sublayer Id '").append(aSubLayerId) ;
- message.appendAscii("' is unknown") ;
- throw lang::IllegalArgumentException(message.makeStringAndClear(),
- pContext, 2) ;
- }
- if (mSubLayerFiles[i].getLength() != 0)
- BasicLocalFileLayer::readData(pContext,xHandler, mSubLayerFiles [i]) ;
- else
- readEmptyLayer(xHandler);
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL CompositeLocalFileLayer::readSubLayerData(
- const uno::Reference<backend::XLayerHandler>& xHandler,
- const rtl::OUString& aSubLayerId)
- throw ( backend::MalformedDataException,
- lang::IllegalArgumentException,
- lang::NullPointerException,
- lang::WrappedTargetException,
- uno::RuntimeException)
-{
- return BasicCompositeLocalFileLayer::readSubLayerData(this,xHandler,aSubLayerId);
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL FullCompositeLocalFileLayer::readSubLayerData(
- const uno::Reference<backend::XLayerHandler>& xHandler,
- const rtl::OUString& aSubLayerId)
- throw ( backend::MalformedDataException,
- lang::IllegalArgumentException,
- lang::NullPointerException,
- lang::WrappedTargetException,
- uno::RuntimeException)
-{
- return BasicCompositeLocalFileLayer::readSubLayerData(this,xHandler,aSubLayerId);
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL FlatLocalFileLayer::replaceWith(
- const uno::Reference<backend::XLayer>& aNewLayer)
- throw ( backend::MalformedDataException,
- lang::NullPointerException,
- lang::WrappedTargetException,
- uno::RuntimeException)
-{
- if (!aNewLayer.is())
- {
- rtl::OUString const sMessage(RTL_CONSTASCII_USTRINGPARAM(
- "LocalFileLayer - Cannot replaceWith: Replacement layer is NULL."));
-
- throw lang::NullPointerException(sMessage,*this);
- }
- OSL_ENSURE( !uno::Reference<backend::XCompositeLayer>::query(aNewLayer).is(),
- "Warning: correct updates with composite layers are not implemented");
-
- uno::Reference<io::XActiveDataSource> xAS(mLayerWriter, uno::UNO_QUERY_THROW);
-
- LocalOutputStream * pStream = new LocalOutputStream(getFileUrl());
- uno::Reference<io::XOutputStream> xStream( pStream );
-
- xAS->setOutputStream(xStream);
-
- aNewLayer->readData(mLayerWriter) ;
-
- pStream->finishOutput();
-
- // clear the output stream
- xStream.clear();
- xAS->setOutputStream(xStream);
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL FullCompositeLocalFileLayer::replaceWith(
- const uno::Reference<backend::XLayer>& aNewLayer)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, uno::RuntimeException)
-{
- if (!aNewLayer.is())
- {
- rtl::OUString const sMessage(RTL_CONSTASCII_USTRINGPARAM(
- "LocalFileLayer - Cannot replaceWith: Replacement layer is NULL."));
-
- throw lang::NullPointerException(sMessage,*this);
- }
- OSL_ENSURE( !uno::Reference<backend::XCompositeLayer>::query(aNewLayer).is(),
- "Warning: correct updates with composite layers are not implemented");
-
- uno::Reference<io::XActiveDataSource> xAS(mLayerWriter, uno::UNO_QUERY_THROW);
-
- LocalOutputStream * pStream = new LocalOutputStream(getFileUrl());
- uno::Reference<io::XOutputStream> xStream( pStream );
-
- xAS->setOutputStream(xStream);
-
- aNewLayer->readData(mLayerWriter) ;
-
- pStream->finishOutput();
-
- // clear the output stream
- xStream.clear();
- xAS->setOutputStream(xStream);
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString BasicLocalFileLayer::getTimestamp(const rtl::OUString& aFileUrl)
-{
- TimeValue timevalue = {0,0};
- sal_uInt64 aSize = FileHelper::getModifyStatus(aFileUrl,timevalue) ;
- oslDateTime fileStamp ;
- rtl::OUString retCode ;
-
- if (osl_getDateTimeFromTimeValue(&timevalue, &fileStamp))
- {
- // truncate to 32 bits
- unsigned long aLongSize = static_cast<sal_Int32>(aSize);
-
- sal_Char asciiStamp [50] ;
-
- sprintf(asciiStamp, "%04u%02u%02u%02u%02u%02uZ%010lu",
- unsigned(fileStamp.Year), unsigned(fileStamp.Month), unsigned(fileStamp.Day),
- unsigned(fileStamp.Hours), unsigned(fileStamp.Minutes), unsigned(fileStamp.Seconds),
- aLongSize) ;
- retCode = rtl::OUString::createFromAscii(asciiStamp) ;
- }
- return retCode ;
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString SimpleLocalFileLayer::getTimestamp()
- throw (uno::RuntimeException)
-{
- rtl::OUString sStamp = BasicLocalFileLayer::getTimestamp(getFileUrl());
-
- return sStamp;
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString FlatLocalFileLayer::getTimestamp()
- throw (uno::RuntimeException)
-{
- rtl::OUString sStamp = BasicLocalFileLayer::getTimestamp(getFileUrl());
-
- return sStamp;
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString FullCompositeLocalFileLayer::getTimestamp()
- throw (uno::RuntimeException)
-{
- rtl::OUString sStamp = BasicLocalFileLayer::getTimestamp(getFileUrl());
-#if 0 // thus far composite layers are only manipulated via the main layer
- for (std::vector<rtl::OUString>::const_iterator it = mSubLayerFiles.begin();
- it != mSubLayerFiles.end();
- ++it)
- {
- rtl::OUString sSublayerTime = BasicLocalFileLayer::getTimestamp(*it);
- if (sStamp < sSublayerTime)
- sStamp = sSublayerTime;
- }
-#endif
- return sStamp;
-}
-//------------------------------------------------------------------------------
-
-void BasicCompositeLocalFileLayer::fillSubLayerLists( const std::vector<rtl::OUString>& aSublayerDirectories,
- const rtl::OUString& aComponent)
-{
- std::vector<rtl::OUString>::size_type const nSublayerCount = aSublayerDirectories.size();
- mSubLayers.realloc(nSublayerCount);
- mSubLayerFiles.resize(nSublayerCount);
-
- for (std::vector<rtl::OUString>::size_type i = 0; i < nSublayerCount; ++i)
- {
- mSubLayers[i] = FileHelper::getFileName(aSublayerDirectories[i]);
-
- // Let's check whether the sublayer exists for the
- // particular component.
- rtl::OUString subLayerFile(aSublayerDirectories[i] + aComponent) ;
- if (FileHelper::fileExists(subLayerFile))
- {
- mSubLayerFiles[i] = subLayerFile;
- }
- else
- OSL_ASSERT(mSubLayerFiles[i].getLength() == 0);
- }
-}
-//------------------------------------------------------------------------------
-
-static bool findSubLayers(const rtl::OUString& aResDir,
- std::vector<rtl::OUString>& aSublayerDirectories)
-{
- if (aResDir.getLength() == 0) return false;
-
- // Extract the directory where the file is located
- osl::Directory directory(aResDir) ;
- if (directory.open() != osl::Directory::E_None) return false;
-
- osl::DirectoryItem item ;
- osl::FileStatus status(osl_FileStatus_Mask_Type |
- osl_FileStatus_Mask_FileURL) ;
-
- while (directory.getNextItem(item) == osl::Directory::E_None)
- {
- if (item.getFileStatus(status) == osl::Directory::E_None)
- {
- if (status.getFileType() == osl::FileStatus::Directory)
- {
- aSublayerDirectories.push_back(status.getFileURL()) ;
- }
- }
- }
- return !aSublayerDirectories.empty();
-}
-//------------------------------------------------------------------------------
-
-uno::Reference<backend::XLayer> createReadonlyLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent,
- const rtl::OUString& aResDir)
-{
- uno::Reference<backend::XLayer> xResult;
-
- std::vector<rtl::OUString> aSublayers;
- if (aBaseDir.getLength() == 0)
- {
- findSubLayers(aResDir,aSublayers);
- xResult.set( new CompositeLocalFileLayer(xFactory,aComponent,aSublayers) );
- }
- else if (findSubLayers(aResDir,aSublayers))
- {
- // there is no readonly full composite layer - take the updatable one
- backend::XCompositeLayer * pNewLayer =
- new FullCompositeLocalFileLayer(xFactory,aBaseDir,aComponent,aSublayers);
- xResult.set( pNewLayer );
- }
- else
- {
- xResult.set( new SimpleLocalFileLayer(xFactory,aBaseDir,aComponent) );
- }
- return xResult;
-}
-//------------------------------------------------------------------------------
-
-uno::Reference<backend::XUpdatableLayer> createUpdatableLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent,
- const rtl::OUString& aResDir)
-{
- uno::Reference<backend::XUpdatableLayer> xResult;
-
- std::vector<rtl::OUString> aSublayers;
- if (findSubLayers(aResDir,aSublayers))
- {
- xResult.set( new FullCompositeLocalFileLayer(xFactory,aBaseDir,aComponent,aSublayers) );
- }
- else if (aBaseDir.getLength() != 0)
- {
- xResult.set( new FlatLocalFileLayer(xFactory,aBaseDir,aComponent) );
- }
- else
- OSL_ENSURE(false,"WARNING: Trying to create an updatable ressource-only layer");
-
- return xResult;
-}
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-enum
-{
- LAYER_PROPERTY_URL = 1
-};
-
-#define PROPNAME( name ) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( name ) )
-#define PROPTYPE( type ) getCppuType( static_cast< type const *>( 0 ) )
-
-// cppu::OPropertySetHelper
-cppu::IPropertyArrayHelper * SAL_CALL LayerPropertyHelper::newInfoHelper()
-{
- com::sun::star::beans::Property properties[] =
- {
- com::sun::star::beans::Property(PROPNAME("URL"), LAYER_PROPERTY_URL, PROPTYPE(rtl::OUString), com::sun::star::beans::PropertyAttribute::READONLY)
- };
-
- return new cppu::OPropertyArrayHelper(properties, sizeof(properties)/sizeof(properties[0]));
-}
-
-#define MESSAGE( text ) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ERROR: Layer Properties: " text ) )
-
-void SAL_CALL LayerPropertyHelper::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& /*rValue*/ )
- throw (uno::Exception)
-{
- namespace beans = com::sun::star::beans;
-
- switch (nHandle)
- {
- case LAYER_PROPERTY_URL:
- OSL_ENSURE(false, "Error: trying to set a READONLY property");
- throw beans::PropertyVetoException(MESSAGE("Property 'URL' is read-only"),*this);
-
- default:
- OSL_ENSURE(false, "Error: trying to set an UNKNOWN property");
- throw beans::UnknownPropertyException(MESSAGE("Trying to set an unknown property"),*this);
- }
-}
-
-void SAL_CALL LayerPropertyHelper::getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const
-{
- switch (nHandle)
- {
- case LAYER_PROPERTY_URL:
- rValue = uno::makeAny( this->getLayerUrl() );
- break;
-
- default:
- OSL_ENSURE(false, "Error: trying to get an UNKNOWN property");
- break;
- }
-}
-
-//------------------------------------------------------------------------------
-} } // configmgr.localbe
-
diff --git a/configmgr/source/localbe/localfilelayer.hxx b/configmgr/source/localbe/localfilelayer.hxx
deleted file mode 100644
index 796582d314e5..000000000000
--- a/configmgr/source/localbe/localfilelayer.hxx
+++ /dev/null
@@ -1,495 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localfilelayer.hxx,v $
- * $Revision: 1.13 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_LOCALBE_LOCALFILELAYER_HXX_
-#define CONFIGMGR_LOCALBE_LOCALFILELAYER_HXX_
-
-#include "propertysethelper.hxx"
-#include <com/sun/star/configuration/backend/XUpdatableLayer.hpp>
-#include <com/sun/star/configuration/backend/XCompositeLayer.hpp>
-#include <com/sun/star/util/XTimeStamped.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <cppuhelper/implbase3.hxx>
-#include <cppuhelper/implbase2.hxx>
-#include <cppuhelper/implbase1.hxx>
-
-#ifndef VECTOR_INCLUDED_
-#define VECTOR_INCLUDED_
-#include <vector>
-#endif // VECTOR_INCLUDED_
-
-namespace configmgr { namespace localbe {
-
-namespace css = com::sun::star ;
-namespace uno = css::uno ;
-namespace lang = css::lang ;
-namespace util = css::util ;
-namespace backend = css::configuration::backend ;
-
-/**
- Basic Implementation of the readonly XLayer interfaces for a local file access.
- The read data is accessible through a canned implementation of an XML parser.
- The layer is defined by the URL of the file containing its contents.
- */
-class BasicLocalFileLayer
-{
-protected :
- /**
- Constructor providing the base directory and the
- file subpath describing the file to access.
- An optional resource directory provides the location
- of sublayers of the component.
-
- @param xFactory service factory used to access canned services
- @param aComponentFile path describing the component file
- */
- BasicLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aComponentFile) ;
- /** Destructor */
- ~BasicLocalFileLayer() ;
-
-protected :
- /**
- Describes the contents of a particular file to a handler.
-
- @param xHandler handler to describe the data to
- @param aFileUrl URL of the file
- @throws com::sun::star::configuration::backend::MalformedDataException
- if the file contains invalid data.
- @throws com::sun::star::lang::NullPointerException
- if pContext is NULL.
- @throws com::sun::star::lang::WrappedTargetException
- if an error occurs while accessing the data.
- */
- void readData(backend::XLayer * pContext,
- const uno::Reference<backend::XLayerHandler>& xHandler,
- const rtl::OUString& aFileUrl)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, uno::RuntimeException);
-
- /**
- Returns an object that can be used to write a layer.
- */
- uno::Reference<backend::XLayerHandler> createLayerWriter();
-
-public:
- /**
- Returns a timestamp associated to a file defined by its URL.
-
- @param aFileUrl URL of the file
- @return timestamp
- */
- static rtl::OUString getTimestamp(const rtl::OUString& aFileUrl) ;
-
- rtl::OUString const & getFileUrl() const { return mFileUrl; };
-
-private :
- /** Service factory */
- uno::Reference<lang::XMultiServiceFactory> const mFactory ;
- /** URL of the file being accessed */
- rtl::OUString const mFileUrl ;
- /** XLayer implementation used for readData */
- uno::Reference<backend::XLayer> mLayerReader ;
-
-} ;
-
-// provides properties for file layers
-class LayerPropertyHelper : public apihelper::PropertySetHelper
-{
-protected:
- LayerPropertyHelper(){};
- virtual ~LayerPropertyHelper(){};
-
-protected:
- virtual rtl::OUString const & getLayerUrl() const = 0;
-
-protected:
- // cppu::OPropertySetHelper
- virtual cppu::IPropertyArrayHelper * SAL_CALL newInfoHelper();
-
- virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue )
- throw (uno::Exception);
-
- using PropertySetHelper::getFastPropertyValue;
- virtual void SAL_CALL getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const;
-
-};
-
-/**
- Implementation of the readonly XLayer interfaces for a local file access.
- The read data is accessible through a canned implementation of
- an XML parser.
- The layer is defined by the URL of the file containing its
- contents.
- */
-class SimpleLocalFileLayer : public BasicLocalFileLayer
- , public cppu::ImplInheritanceHelper2< LayerPropertyHelper,
- backend::XLayer,
- util::XTimeStamped>
-{
-public :
- /**
- Constructor providing the base directory and the
- file subpath describing the file to access.
- An optional resource directory provides the location
- of sublayers of the component.
-
- @param xFactory service factory used to access canned services
- @param aComponentFile URL describing the component file
- */
- SimpleLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aComponentFile) ;
- /**
- Constructor providing the base directory and the
- file subpath describing the file to access.
- An optional resource directory provides the location
- of sublayers of the component.
-
- @param xFactory service factory used to access canned services
- @param aBaseDir base directory
- @param aComponent subpath describing the component file
- */
- SimpleLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent) ;
-
- /** Destructor */
- ~SimpleLocalFileLayer() ;
-
- // XLayer
- using BasicLocalFileLayer::readData;
- virtual void SAL_CALL readData(
- const uno::Reference<backend::XLayerHandler>& xHandler)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, uno::RuntimeException);
-
- // XTimeStamped
- virtual rtl::OUString SAL_CALL getTimestamp()
- throw (uno::RuntimeException);
-
-protected:
- virtual rtl::OUString const & getLayerUrl() const
- { return getFileUrl(); }
-} ;
-
-/**
- Implementation of the XUpdatableLayer
- interface for a local file access.
- The read data is accessible through a canned implementation of
- an XML parser, and the write data is defined through a canned
- implementation of an XML writer.
- The layer is defined by the URL of the file containing its
- contents, and that file will be either read or updated by
- the access to the handlers.
- The timestamp is refreshed on each read operation only.
- */
-class FlatLocalFileLayer : public BasicLocalFileLayer
- , public cppu::ImplInheritanceHelper2< LayerPropertyHelper,
- backend::XUpdatableLayer,
- util::XTimeStamped>
-{
-public :
- /**
- Constructor providing the base directory and the
- file subpath describing the file to access.
-
- @param xFactory service factory used to access canned services
- @param aBaseDir base directory
- @param aComponent subpath describing the component file
- */
- FlatLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent) ;
- /** Destructor */
- ~FlatLocalFileLayer(void) ;
-
- // XLayer
- using BasicLocalFileLayer::readData;
- virtual void SAL_CALL readData(
- const uno::Reference<backend::XLayerHandler>& xHandler)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, uno::RuntimeException);
-
- // XUpdatableLayer
- virtual void SAL_CALL replaceWith(
- const uno::Reference<backend::XLayer>& aNewLayer)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, uno::RuntimeException);
-
- // XTimeStamped
- virtual rtl::OUString SAL_CALL getTimestamp()
- throw (uno::RuntimeException);
-
-protected:
- virtual rtl::OUString const & getLayerUrl() const
- { return getFileUrl(); }
-
-private :
- /** XLayerHandler implementation for getWriteHandler */
- uno::Reference<backend::XLayerHandler> mLayerWriter ;
-
-} ;
-
-/**
- Implementation of the XCompositeLayer
- interface for a local file access.
- The read data is accessible through a canned implementation of
- an XML parser.
- The layer is defined by the URL of the file containing its
- contents, and that file will be either read or updated by
- the access to the handlers.
- The timestamp is refreshed on each read operation only.
- */
-class BasicCompositeLocalFileLayer : public BasicLocalFileLayer
-{
-protected:
- /**
- Constructor providing the base directory and the
- file subpath describing the file to access.
- An resource directory provides the location
- of sublayers of the component.
-
- @param xFactory service factory used to access canned services
- @param aComponent path describing the component file
- */
- BasicCompositeLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aComponent) ;
-
- // XCompositeLayer helpers
- uno::Sequence<rtl::OUString> SAL_CALL listSubLayerIds()
- throw (lang::WrappedTargetException, uno::RuntimeException)
- { return mSubLayers ; }
-
- void SAL_CALL readSubLayerData(
- backend::XCompositeLayer * context,
- const uno::Reference<backend::XLayerHandler>& xHandler,
- const rtl::OUString& aSubLayerId)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, lang::IllegalArgumentException,
- uno::RuntimeException);
-
- /**
- Fills the list of available sublayers.
-
- @param aResDir resource directory containing potential sublayers
- @param aComponent component subpath
- */
- void fillSubLayerLists(const std::vector<rtl::OUString>& aSublayerDirectories,
- const rtl::OUString& aComponent) ;
-private :
- /** List of available sublayers... */
- uno::Sequence<rtl::OUString> mSubLayers ;
- /** .. and the corresponding file URLs. */
- std::vector<rtl::OUString> mSubLayerFiles ;
-
-};
-
-/**
- Implementation of the XCompositeLayer
- interface for a local file access.
- The read data is accessible through a canned implementation of
- an XML parser.
- The layer is defined by the URL of the file containing its
- contents, and that file will be either read or updated by
- the access to the handlers.
- The timestamp is refreshed on each read operation only.
- */
-class CompositeLocalFileLayer : public BasicCompositeLocalFileLayer
- , public cppu::WeakImplHelper1< backend::XCompositeLayer>
-{
-public :
- /**
- Constructor providing the base directory and the
- file subpath describing the file to access.
- An resource directory provides the location
- of sublayers of the component.
-
- @param xFactory service factory used to access canned services
- @param aBaseDir base directory
- @param aComponent subpath describing the component file
- @param aResDir resource directory, if empty it is
- assumed the layer does not have sublayers.
- */
- CompositeLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aComponent,
- const std::vector<rtl::OUString>& aSublayerDirectories) ;
- /** Destructor */
- ~CompositeLocalFileLayer(void) ;
- // XLayer
- using BasicCompositeLocalFileLayer::readData;
- virtual void SAL_CALL readData(
- const uno::Reference<backend::XLayerHandler>& xHandler)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, uno::RuntimeException);
-
- // XCompositeLayer
- virtual uno::Sequence<rtl::OUString> SAL_CALL listSubLayerIds()
- throw (lang::WrappedTargetException, uno::RuntimeException)
- { return BasicCompositeLocalFileLayer::listSubLayerIds() ; }
-
- using BasicCompositeLocalFileLayer::readSubLayerData;
- virtual void SAL_CALL readSubLayerData(
- const uno::Reference<backend::XLayerHandler>& xHandler,
- const rtl::OUString& aSubLayerId)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, lang::IllegalArgumentException,
- uno::RuntimeException);
-
-private :
- // not implemented: warn of attempts to use this here
- void getFileUrl() const;
-} ;
-/**
- Implementation of the XUpdatableLayer and XCompositeLayer
- interfaces for a local file access.
- The read data is accessible through a canned implementation of
- an XML parser, and the write data is defined through a canned
- implementation of an XML writer.
- The layer is defined by the URL of the file containing its
- contents, and that file will be either read or updated by
- the access to the handlers.
- The timestamp is refreshed on each read operation only.
- */
-class FullCompositeLocalFileLayer : public BasicCompositeLocalFileLayer
- , public cppu::ImplInheritanceHelper3<
- LayerPropertyHelper,
- backend::XUpdatableLayer,
- backend::XCompositeLayer,
- util::XTimeStamped>
-{
-public :
- /**
- Constructor providing the base directory and the
- file subpath describing the file to access.
- An resource directory provides the location
- of sublayers of the component.
-
- @param xFactory service factory used to access canned services
- @param aBaseDir base directory
- @param aComponent subpath describing the component file
- @param aResDir resource directory, if empty it is
- assumed the layer does not have sublayers.
- */
- FullCompositeLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent,
- const std::vector<rtl::OUString>& aSublayerDirectories) ;
- /** Destructor */
- ~FullCompositeLocalFileLayer(void) ;
- // XLayer
- using BasicCompositeLocalFileLayer::readData;
- virtual void SAL_CALL readData(
- const uno::Reference<backend::XLayerHandler>& xHandler)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, uno::RuntimeException);
-
- // XUpdatableLayer
- virtual void SAL_CALL replaceWith(
- const uno::Reference<backend::XLayer>& aNewLayer)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, uno::RuntimeException);
-
- // XCompositeLayer
- virtual uno::Sequence<rtl::OUString> SAL_CALL listSubLayerIds()
- throw (lang::WrappedTargetException, uno::RuntimeException)
- { return BasicCompositeLocalFileLayer::listSubLayerIds() ; }
-
- using BasicCompositeLocalFileLayer::readSubLayerData;
- virtual void SAL_CALL readSubLayerData(
- const uno::Reference<backend::XLayerHandler>& xHandler,
- const rtl::OUString& aSubLayerId)
- throw (backend::MalformedDataException, lang::NullPointerException,
- lang::WrappedTargetException, lang::IllegalArgumentException,
- uno::RuntimeException);
-
- // XTimeStamped
- virtual rtl::OUString SAL_CALL getTimestamp()
- throw (uno::RuntimeException);
-
-protected:
- virtual rtl::OUString const & getLayerUrl() const
- { return getFileUrl(); }
-
-private :
- /** XLayerHandler implementation for getWriteHandler */
- uno::Reference<backend::XLayerHandler> mLayerWriter ;
-} ;
-/**
- Factory function to create the appropriate Flat- or Composite-
- LocalFileLayer for a set of parameters.
-
- Arguments provide the base directory and the
- file subpath describing the file to access.
- An optional resource directory provides the location
- of sublayers of the component.
-
- @param xFactory service factory used to access canned services
- @param aBaseDir base directory
- @param aComponent subpath describing the component file
- @param aResDir resource directory, if empty it is
- assumed the layer does not have sublayers.
- */
-uno::Reference<backend::XLayer> createReadonlyLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent,
- const rtl::OUString& aResDir) ;
-
-/**
- Factory function to create the appropriate Flat- or Composite-
- LocalFileLayer for a set of parameters.
-
- Arguments provide the base directory and the
- file subpath describing the file to access.
- An optional resource directory provides the location
- of sublayers of the component.
-
- @param xFactory service factory used to access canned services
- @param aBaseDir base directory
- @param aComponent subpath describing the component file
- @param aResDir resource directory, if empty it is
- assumed the layer does not have sublayers.
- */
-uno::Reference<backend::XUpdatableLayer> createUpdatableLocalFileLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- const rtl::OUString& aBaseDir,
- const rtl::OUString& aComponent,
- const rtl::OUString& aResDir) ;
-
-} } // configmgr.localbe
-
-#endif // CONFIGMGR_LOCALBE_LOCALFILELAYER_HXX_
diff --git a/configmgr/source/localbe/localhierarchybrowsersvc.cxx b/configmgr/source/localbe/localhierarchybrowsersvc.cxx
deleted file mode 100644
index 2a6196e87fd5..000000000000
--- a/configmgr/source/localbe/localhierarchybrowsersvc.cxx
+++ /dev/null
@@ -1,536 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localhierarchybrowsersvc.cxx,v $
- * $Revision: 1.12 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "localhierarchybrowsersvc.hxx"
-#include "localsinglebackend.hxx"
-
-#ifndef CONFIGMGR_API_FACTORY_HXX_
-#include "confapifactory.hxx"
-#endif
-#include <com/sun/star/lang/NullPointerException.hpp>
-#include <rtl/ustrbuf.hxx>
-
-#include <algorithm>
-// -----------------------------------------------------------------------------
-
-#define OUSTRING( constascii ) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(constascii))
-// -----------------------------------------------------------------------------
-
-namespace configmgr
-{
-// -----------------------------------------------------------------------------
- namespace localbe
- {
-// -----------------------------------------------------------------------------
-
-sal_Char const * const aLocalHierarchyBrowserServices[] =
-{
- "com.sun.star.configuration.backend.LocalHierarchyBrowser",
- 0,
- "com.sun.star.configuration.backend.HierarchyBrowser",
- 0
-};
-const ServiceImplementationInfo aLocalHierarchyBrowserSI =
-{
- "com.sun.star.comp.configuration.backend.LocalHierarchyBrowser",
- aLocalHierarchyBrowserServices,
- aLocalHierarchyBrowserServices + 3
-};
-// -----------------------------------------------------------------------------
-
-const ServiceRegistrationInfo* getLocalHierarchyBrowserServiceInfo()
-{ return getRegistrationInfo(& aLocalHierarchyBrowserSI); }
-// -----------------------------------------------------------------------------
-
-inline
-ServiceInfoHelper LocalHierarchyBrowserService::getServiceInfo()
-{
- return & aLocalHierarchyBrowserSI;
-}
-// -----------------------------------------------------------------------------
-
-uno::Reference< uno::XInterface > SAL_CALL instantiateLocalHierarchyBrowser
-( uno::Reference< uno::XComponentContext > const& rServiceManager )
-{
- return * new LocalHierarchyBrowserService( rServiceManager );
-}
-// -----------------------------------------------------------------------------
-
-LocalHierarchyBrowserService::LocalHierarchyBrowserService(uno::Reference< uno::XComponentContext > const & _xContext)
-: m_xServiceFactory(_xContext->getServiceManager(), uno::UNO_QUERY)
-{
- if (!m_xServiceFactory.is())
- {
- rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM("Configuration Importer: Unexpected NULL context"));
- throw lang::NullPointerException(sMessage,NULL);
- }
-}
-// -----------------------------------------------------------------------------
-
-LocalHierarchyBrowserService::~LocalHierarchyBrowserService()
-{}
-// -----------------------------------------------------------------------------
-
-namespace
-{
- struct JobDesc
- {
- explicit JobDesc(task::XJob * pJob, const uno::Sequence< beans::NamedValue >& aArguments);
-
- enum Mode { findNone, findSchemas, findLayers };
- enum Result { getDefault,getUrls, getNames };
-
- rtl::OUString aBaseDataUrl;
- uno::Sequence< rtl::OUString > aExcludeList;
- Mode mode;
- Result result_type;
- };
-
- JobDesc::JobDesc(task::XJob * pJob, const uno::Sequence< beans::NamedValue >& aArguments)
- : aBaseDataUrl()
- , aExcludeList()
- , mode(findNone)
- , result_type(getDefault)
- {
- sal_Int16 const nCount = static_cast<sal_Int16>(aArguments.getLength());
-
- if (sal_Int32(nCount) != aArguments.getLength())
- {
- rtl::OUString sMessage = OUSTRING("Too many arguments for LocalHierarchyBrowser Job");
- throw lang::IllegalArgumentException(sMessage,pJob,0);
- }
-
- for (sal_Int16 i=0; i < nCount; ++i)
- {
- sal_Bool bKnown = false;
- sal_Bool bGood = false;
-
- if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("SchemaDataUrl")))
- {
- bKnown = true;
- bGood = (aArguments[i].Value >>= aBaseDataUrl);
- mode = (bGood && aBaseDataUrl.getLength()) ? findSchemas : findNone;
- }
- else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("LayerDataUrl")))
- {
- bKnown = true;
-
- rtl::OUString aLayerBaseUrl;
- bGood = (aArguments[i].Value >>= aLayerBaseUrl);
-
- if (aLayerBaseUrl.getLength())
- {
- rtl::OUString aLocalizedSubDir;
- LocalSingleBackend::getLayerSubDirectories(aLayerBaseUrl,this->aBaseDataUrl,aLocalizedSubDir);
-
- mode = findLayers;
- }
- else
- {
- mode = findNone;
- }
- }
- else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ExcludeComponents")))
- {
- bKnown = true;
-
- sal_Int32 const nNextIndex = aExcludeList.getLength();
-
- switch (aArguments[i].Value.getValueTypeClass())
- {
- case uno::TypeClass_STRING:
- {
- rtl::OUString aComponent;
- bGood = (aArguments[i].Value >>= aComponent);
-
- OSL_ASSERT(bGood);
-
- aExcludeList.realloc(nNextIndex + 1);
- aExcludeList[nNextIndex] = aComponent;
- }
- break;
-
- case uno::TypeClass_SEQUENCE:
- {
- uno::Sequence<rtl::OUString> aComponentList;
- bGood = (aArguments[i].Value >>= aComponentList);
-
- if (bGood)
- {
- sal_Int32 const nCompListCount = aComponentList.getLength();
- aExcludeList.realloc(nNextIndex + nCompListCount);
-
- rtl::OUString const * pSrc = aComponentList.getConstArray();
- std::copy(pSrc,pSrc+nCompListCount,aExcludeList.getArray());
- }
- }
- break;
-
- default:
- OSL_ASSERT(!bGood);
- break;
- }
- }
- else if (aArguments[i].Name.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("FetchComponentNames")))
- {
- sal_Bool bComponents = sal_False;
-
- bKnown = true;
- if (aArguments[i].Value.hasValue())
- {
- bGood = (aArguments[i].Value >>= bComponents);
- if (bGood) result_type = bComponents ? getNames : getUrls;
- }
- else
- {
- bGood = true;
- result_type = getDefault;
- }
- }
-
- if (!bGood)
- {
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii("LocalHierarchyBrowser - Illegal argument: ");
- if (bKnown)
- sMsg.appendAscii("Wrong value type for argument '");
- else
- sMsg.appendAscii("Unknown argument '");
-
- sMsg.append(aArguments[i].Name).appendAscii("'.");
-
- throw lang::IllegalArgumentException(sMsg.makeStringAndClear(),pJob,i+1);
- }
- }
- if (findNone == mode)
- {
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii("LocalHierarchyBrowser - Missing argument: ");
- sMsg.appendAscii("No data URL available");
- throw lang::IllegalArgumentException(sMsg.makeStringAndClear(),pJob,0);
- }
- if (getDefault == result_type)
- result_type = (mode == findSchemas) ? getNames : getUrls;
-
- }
-
- static
- inline
- rtl::OUString getDataFileExtension(JobDesc::Mode mode)
- {
- switch (mode)
- {
- case JobDesc::findSchemas: return OUSTRING(".xcs");
- case JobDesc::findLayers: return OUSTRING(".xcu");
- default: OSL_ASSERT(false); return rtl::OUString();
- }
- }
-}
-// -----------------------------------------------------------------------------
-
-// XJob
-
-uno::Any SAL_CALL
- LocalHierarchyBrowserService::execute( const uno::Sequence< beans::NamedValue >& Arguments )
- throw (lang::IllegalArgumentException, uno::Exception, uno::RuntimeException)
-{
- JobDesc const aJob(this,Arguments);
-
- OSL_ASSERT(JobDesc::getUrls == aJob.result_type || JobDesc::getNames == aJob.result_type);
-
- uno::Sequence< rtl::OUString > (LocalHierarchyBrowserService::* const find)( rtl::OUString const & _aBaseDirectory, rtl::OUString const & _aComponentFileExtension, uno::Sequence< rtl::OUString > const & aExcludeList) = (JobDesc::getUrls == aJob.result_type) ?
- &LocalHierarchyBrowserService::findLocalComponentUrls :
- &LocalHierarchyBrowserService::findLocalComponentNames;
-
- uno::Sequence< rtl::OUString > aComponents = (this->*find)(aJob.aBaseDataUrl,getDataFileExtension(aJob.mode), aJob.aExcludeList);
-
- return uno::makeAny(aComponents);
-}
-// -----------------------------------------------------------------------------
-
-// XServiceInfo
-
-rtl::OUString SAL_CALL
- LocalHierarchyBrowserService::getImplementationName( )
- throw (uno::RuntimeException)
-{
- return getServiceInfo().getImplementationName( );
-}
-// -----------------------------------------------------------------------------
-
-sal_Bool SAL_CALL
- LocalHierarchyBrowserService::supportsService( const rtl::OUString& ServiceName )
- throw (uno::RuntimeException)
-{
- return getServiceInfo().supportsService( ServiceName );
-}
-// -----------------------------------------------------------------------------
-
-
-uno::Sequence< ::rtl::OUString > SAL_CALL
- LocalHierarchyBrowserService::getSupportedServiceNames( )
- throw (uno::RuntimeException)
-{
- return getServiceInfo().getSupportedServiceNames( );
-}
-// -----------------------------------------------------------------------------
-// -----------------------------------------------------------------------------
- } // namespace
-
-// -----------------------------------------------------------------------------
-} // namespace
-
-// -----------------------------------------------------------------------------
-// -----------------------------------------------------------------------------
-
-#include "filehelper.hxx"
-#include <osl/file.hxx>
-#include "tools/getprocessworkingdir.hxx"
-#include <vector>
-// -----------------------------------------------------------------------------
-
- namespace uno = com::sun::star::uno;
- // -----------------------------------------------------------------------------
-
- #define OSL_VERIFY_RC( expr ) OSL_VERIFY( (expr) == osl::FileBase::E_None )
- //------------------------------------------------------------------------------
- static
- inline
- bool matchesExtension( rtl::OUString const & aFileName, rtl::OUString const & aExt )
- {
- sal_Int32 const nExtStart = aFileName.getLength() - aExt.getLength();
- return nExtStart > 0 && !!aFileName.copy(nExtStart).equalsIgnoreAsciiCase(aExt);
- }
- //------------------------------------------------------------------------------
- static
- inline
- rtl::OUString stripExtension( rtl::OUString const & aFileName, rtl::OUString const & aExt )
- {
- OSL_PRECOND( matchesExtension(aFileName,aExt), "File name doesn't have expected extension");
-
- sal_Int32 const nExtStart = aFileName.getLength() - aExt.getLength();
- return aFileName.copy(0,nExtStart);
- }
-//------------------------------------------------------------------------------
- static
- inline
- bool matchesExtension( osl::FileStatus const & aFileDescriptor, rtl::OUString const & aExt )
- {
- OSL_PRECOND( aFileDescriptor.isValid(FileStatusMask_Type | FileStatusMask_FileName),
- "Not all required file-status fields available for filter" );
-
- if (aFileDescriptor.getFileType() != osl::FileStatus::Regular)
- return false;
-
- return matchesExtension(aFileDescriptor.getFileName(),aExt);
- }
-//------------------------------------------------------------------------------
-
- static
- bool makeAbsoluteURL(rtl::OUString & rURL )
- {
- rtl::OUString aBaseDir; tools::getProcessWorkingDir(&aBaseDir);
-
- osl::File::RC errcode = osl::File::getAbsoluteFileURL(aBaseDir,rURL,rURL);
-
- return osl::File::E_None == errcode;
- }
-//------------------------------------------------------------------------------
- static
- inline
- bool getNextDirectoryItem(osl::Directory & aDirectory, osl::DirectoryItem & aItem, osl::Directory::RC & errcode)
- {
- switch (errcode = aDirectory.getNextItem(aItem))
- {
- case osl::Directory::E_None:
- return true;
-
- case osl::Directory::E_NOENT:
- errcode = osl::Directory::E_None;
- return false;
-
- default:
- return false;
- }
- }
-//------------------------------------------------------------------------------
- static inline bool isExcluded(rtl::OUString const & aName, uno::Sequence< rtl::OUString > const & aExcludeList)
- {
- for (sal_Int32 i = 0; i<aExcludeList.getLength(); ++i)
- {
- if (aExcludeList[i].equals(aName)) return true;
- }
- return false;
- }
-//------------------------------------------------------------------------------
- static
- osl::FileBase::RC findComponents( std::vector<rtl::OUString> * componentNames, std::vector<rtl::OUString> * componentUrls,
- rtl::OUString const& aDirectoryPath, rtl::OUString const& aComponentExtension,
- rtl::OUString const& aPackagePrefix, rtl::OUString const & aComponentSeparator,
- uno::Sequence< rtl::OUString > const & aExcludeList)
- {
- static sal_Unicode const chDirSep = '/';
- static rtl::OUString const sDirectorySeparator(&chDirSep,1);
-
- osl::Directory aDirectory(aDirectoryPath);
-
- osl::Directory::RC errcode = aDirectory.open();
-
- if (errcode == osl::Directory::E_None)
- {
- sal_uInt32 n_STATUS_FIELDS = FileStatusMask_Type | FileStatusMask_FileName;
- if (componentUrls) n_STATUS_FIELDS |= FileStatusMask_FileURL;
-
- osl::DirectoryItem aItem;
- while( getNextDirectoryItem(aDirectory,aItem,errcode) )
- {
-
- osl::FileStatus aItemDescriptor( n_STATUS_FIELDS );
- errcode = aItem.getFileStatus(aItemDescriptor);
-
- if ( errcode != osl::DirectoryItem::E_None )
- {
- OSL_TRACE("Locating Configuration Components - Error (%u) getting status of directory item - skipping\n", unsigned(errcode));
- continue;
- }
-
- OSL_ENSURE( aItemDescriptor.isValid(FileStatusMask_Type), "Could not get type of directory item");
-
- if (aItemDescriptor.getFileType() == osl::FileStatus::Directory)
- {
- OSL_ENSURE( aItemDescriptor.isValid(FileStatusMask_FileName), "Could not get name of subdirectory");
-
- rtl::OUString const aSubdirName = aItemDescriptor.getFileName();
- rtl::OUString const aSubdirPath = aDirectoryPath + sDirectorySeparator + aSubdirName;
- rtl::OUString const aSubpackagePrefix = aPackagePrefix + aSubdirName + aComponentSeparator;
- // recurse
- if (!isExcluded(aSubpackagePrefix,aExcludeList))
- OSL_VERIFY_RC( findComponents( componentNames, componentUrls,
- aSubdirPath, aComponentExtension,
- aSubpackagePrefix, aComponentSeparator,
- aExcludeList) );
- }
- else if (matchesExtension(aItemDescriptor,aComponentExtension))
- {
- OSL_ENSURE( aItemDescriptor.isValid(FileStatusMask_FileName), "Could not get name of component found");
-
- rtl::OUString const aComponentName = stripExtension( aItemDescriptor.getFileName(), aComponentExtension );
- rtl::OUString const aFullComponentName = aPackagePrefix + aComponentName;
-
- if (!isExcluded(aFullComponentName,aExcludeList))
- {
- if (componentNames)
- {
- componentNames->push_back(aFullComponentName);
- }
-
- if (componentUrls)
- {
- OSL_ENSURE( aItemDescriptor.isValid(FileStatusMask_FileURL), "Could not get URL of component found");
-
- componentUrls->push_back(aItemDescriptor.getFileURL());
- }
- }
- }
- }
- aDirectory.close();
- }
- return errcode;
- }
-// -----------------------------------------------------------------------------
-
- uno::Sequence< rtl::OUString > configmgr::localbe::LocalHierarchyBrowserService::findLocalComponentNames( rtl::OUString const & _aBaseDirectory, rtl::OUString const & _aComponentFileExtension, uno::Sequence< rtl::OUString > const & aExcludeList)
- {
- rtl::OUString aBaseDirectory(_aBaseDirectory);
- OSL_VERIFY( makeAbsoluteURL(aBaseDirectory) );
-
- static const sal_Unicode chPkgSep = '.';
-
- std::vector< rtl::OUString > components;
-
- osl::Directory::RC errcode = findComponents(&components, NULL,
- aBaseDirectory, _aComponentFileExtension,
- rtl::OUString(), rtl::OUString(&chPkgSep,1),
- aExcludeList );
-
- if (errcode != osl::Directory::E_None)
- {
- OSL_TRACE("Locating Configuration Components failed - Error (%u) trying to locate files\n", unsigned(errcode));
-
- if (errcode != osl::Directory::E_NOENT)
- {
- rtl::OUString sMsg = OUSTRING("LocalHierarchyBrowser - IO Error while scanning for components: ") +
- FileHelper::createOSLErrorString(errcode);
-
- throw com::sun::star::io::IOException(sMsg,*this);
- }
- }
-
- return uno::Sequence< rtl::OUString >(&components.front(),components.size());
- }
-// -----------------------------------------------------------------------------
-
- uno::Sequence< rtl::OUString > configmgr::localbe::LocalHierarchyBrowserService::findLocalComponentUrls( rtl::OUString const & _aBaseDirectory, rtl::OUString const & _aComponentFileExtension, uno::Sequence< rtl::OUString > const & aExcludeList)
- {
- rtl::OUString aBaseDirectory(_aBaseDirectory);
- OSL_VERIFY( makeAbsoluteURL(aBaseDirectory) );
-
- static const sal_Unicode chPkgSep = '.';
-
- std::vector< rtl::OUString > components;
-
- osl::Directory::RC errcode = findComponents(NULL, &components,
- aBaseDirectory, _aComponentFileExtension,
- rtl::OUString(), rtl::OUString(&chPkgSep,1),
- aExcludeList );
-
- if (errcode != osl::Directory::E_None)
- {
- OSL_TRACE("Locating Configuration Components failed - Error (%u) trying to locate files\n", unsigned(errcode));
-
- if (errcode != osl::Directory::E_NOENT)
- {
- rtl::OUString sMsg = OUSTRING("LocalHierarchyBrowser - IO Error while scanning for component files: ") +
- FileHelper::createOSLErrorString(errcode);
-
- throw com::sun::star::io::IOException(sMsg,*this);
- }
- }
-
- return uno::Sequence< rtl::OUString >(&components.front(),components.size());
- }
-//------------------------------------------------------------------------------
-
-// -----------------------------------------------------------------------------
-// -----------------------------------------------------------------------------
-
diff --git a/configmgr/source/localbe/localhierarchybrowsersvc.hxx b/configmgr/source/localbe/localhierarchybrowsersvc.hxx
deleted file mode 100644
index 11c486f0aca1..000000000000
--- a/configmgr/source/localbe/localhierarchybrowsersvc.hxx
+++ /dev/null
@@ -1,103 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localhierarchybrowsersvc.hxx,v $
- * $Revision: 1.4 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_LOCALBE_BROWSERSVC_HXX
-#define CONFIGMGR_LOCALBE_BROWSERSVC_HXX
-
-#include "serviceinfohelper.hxx"
-#include <cppuhelper/implbase2.hxx>
-#include <osl/mutex.hxx>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/task/XJob.hpp>
-
-// -----------------------------------------------------------------------------
-
-namespace configmgr
-{
-// -----------------------------------------------------------------------------
- namespace localbe
- {
-// -----------------------------------------------------------------------------
- namespace uno = ::com::sun::star::uno;
- namespace lang = ::com::sun::star::lang;
- namespace task = ::com::sun::star::task;
- namespace beans = ::com::sun::star::beans;
-// -----------------------------------------------------------------------------
-
- class LocalHierarchyBrowserService : public ::cppu::WeakImplHelper2<
- task::XJob,
- lang::XServiceInfo
- >
- {
- public:
- explicit
- LocalHierarchyBrowserService(uno::Reference< uno::XComponentContext > const & _xContext);
- ~LocalHierarchyBrowserService();
-
- // XServiceInfo
- virtual rtl::OUString SAL_CALL
- getImplementationName( )
- throw (uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL
- supportsService( const rtl::OUString& ServiceName )
- throw (uno::RuntimeException);
-
- virtual uno::Sequence< rtl::OUString > SAL_CALL
- getSupportedServiceNames( )
- throw (uno::RuntimeException);
-
- // XJob
- virtual uno::Any SAL_CALL
- execute( const uno::Sequence< beans::NamedValue >& Arguments )
- throw (lang::IllegalArgumentException, uno::Exception, uno::RuntimeException);
-
- private:
- uno::Reference< lang::XMultiServiceFactory > getServiceFactory() const
- { return m_xServiceFactory; }
-
- uno::Sequence< rtl::OUString > findLocalComponentNames( rtl::OUString const & _aBaseDirectory, rtl::OUString const & _aComponentFileExtension, uno::Sequence< rtl::OUString > const & aExcludeList);
- uno::Sequence< rtl::OUString > findLocalComponentUrls( rtl::OUString const & _aBaseDirectory, rtl::OUString const & _aComponentFileExtension, uno::Sequence< rtl::OUString > const & aExcludeList);
- private:
- uno::Reference< lang::XMultiServiceFactory > m_xServiceFactory;
-
- static ServiceInfoHelper getServiceInfo();
- };
-// -----------------------------------------------------------------------------
- } // namespace localbe
-// -----------------------------------------------------------------------------
-
-} // namespace configmgr
-#endif
-
-
-
-
diff --git a/configmgr/source/localbe/localmultistratum.cxx b/configmgr/source/localbe/localmultistratum.cxx
deleted file mode 100644
index 65c71a727391..000000000000
--- a/configmgr/source/localbe/localmultistratum.cxx
+++ /dev/null
@@ -1,250 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localmultistratum.cxx,v $
- * $Revision: 1.9 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "localmultistratum.hxx"
-#include "localfilehelper.hxx"
-#include "filehelper.hxx"
-
-#ifndef CONFIGMGR_API_FACTORY_HXX_
-#include "confapifactory.hxx"
-#endif // CONFIGMGR_API_FACTORY_HXX_
-#include "serviceinfohelper.hxx"
-#include <rtl/ustrbuf.hxx>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp>
-#include <osl/file.hxx>
-
-namespace configmgr { namespace localbe {
-
-//==============================================================================
-
-static inline
-rtl::OUString const & impl_getLayerDataDirectory(rtl::OUString const & aLayerBaseUrl)
-{ return aLayerBaseUrl; }
-//------------------------------------------------------------------------------
-static //inline
-rtl::OUString makeLayerId(rtl::OUString const & aComponent,rtl::OUString const & aParticleFile)
-{
- OSL_ASSERT(aParticleFile.endsWithIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM(kLocalDataSuffix)));
- const sal_Int32 kExtLength = RTL_CONSTASCII_LENGTH(kLocalDataSuffix);
- rtl::OUString const aParticleName = aParticleFile.copy(0,aParticleFile.getLength() - kExtLength);
-
- rtl::OUStringBuffer aLayerId(aComponent);
- aLayerId.append(k_cLayerIdSeparator);
- aLayerId.append(aParticleName);
-
- return aLayerId.makeStringAndClear();
-}
-
-LocalMultiStratum::LocalMultiStratum(const uno::Reference<uno::XComponentContext>& xContext)
-: cppu::ImplInheritanceHelper1< LocalStratumBase, backend::XMultiLayerStratum >(xContext)
-{
-}
-//------------------------------------------------------------------------------
-
-LocalMultiStratum::~LocalMultiStratum() {}
-
-//------------------------------------------------------------------------------
-uno::Sequence< rtl::OUString > SAL_CALL
- LocalMultiStratum::listLayerIds( const rtl::OUString& aComponent,
- const rtl::OUString& /*aEntity*/ )
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException)
-{
- rtl::OUString const aLayerUrl = impl_getLayerDataDirectory(getBaseUrl());
- rtl::OUString const aComponentUrl = aLayerUrl + componentToPath(aComponent);
-
- const sal_uInt32 k_STATUS_FIELDS = FileStatusMask_Type | FileStatusMask_FileName;
- osl::Directory aComponentDirectory(aComponentUrl);
- osl::DirectoryItem aItem;
- std::vector< rtl::OUString > aResult;
-
- osl::Directory::RC errcode = aComponentDirectory.open();
- switch (errcode)
- {
- case osl::Directory::E_NOENT:
- return uno::Sequence< rtl::OUString >();
-
- case osl::Directory::E_None:
- while (osl::Directory::E_None == (errcode=aComponentDirectory.getNextItem(aItem)))
- {
- osl::FileStatus aItemDescriptor( k_STATUS_FIELDS );
- errcode = aItem.getFileStatus(aItemDescriptor);
-
- if ( errcode != osl::DirectoryItem::E_None )
- {
- OSL_ASSERT(errcode != osl::Directory::E_NOENT); // unexpected failure for getFileStatus for existing file
- if (errcode == osl::Directory::E_NOENT) continue;
-
- OSL_TRACE("Reading Component Directory - Error (%u) getting status of directory item.\n", unsigned(errcode));
- break;
- }
-
- OSL_ENSURE( aItemDescriptor.isValid(FileStatusMask_Type), "Could not get type of directory item");
- if (aItemDescriptor.getFileType() != osl::FileStatus::Regular)
- continue;
-
- OSL_ENSURE( aItemDescriptor.isValid(FileStatusMask_FileName), "Could not get name of component found");
- rtl::OUString const aFileName = aItemDescriptor.getFileName();
- if (!aFileName.endsWithIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM(kLocalDataSuffix)))
- continue;
-
- aResult.push_back( makeLayerId(aComponent,aFileName) );
- }
- OSL_ASSERT(errcode != osl::Directory::E_None); // Loop postcond
-
- // joint error handling with open failure
- if (errcode != osl::Directory::E_NOENT) // normal loop termination
- {
- default: // if open() truly failed we also go here
- rtl::OUStringBuffer errbuf;
- errbuf.appendAscii("LocalMultiStratum::listLayerIds: ");
- errbuf.appendAscii("Error scanning directory ").append(aComponentUrl)
- .appendAscii(" for particle files. ");
- errbuf.appendAscii("Error: ").append(FileHelper::createOSLErrorString(errcode));
- rtl::OUString const errmsg = errbuf.makeStringAndClear();
- throw backend::BackendAccessException(errmsg,*this,uno::Any());
- }
-
- return aResult.empty()
- ? uno::Sequence< rtl::OUString >()
- : uno::Sequence< rtl::OUString >(
- &aResult.front(), static_cast<sal_Int32>(aResult.size()));
- }
-}
-
-//------------------------------------------------------------------------------
-rtl::OUString SAL_CALL
- LocalMultiStratum::getUpdateLayerId( const rtl::OUString& aComponent,
- const rtl::OUString& /*aEntity*/ )
- throw (backend::BackendAccessException, lang::NoSupportException,
- lang::IllegalArgumentException, uno::RuntimeException)
-{
- failReadonly();
- return aComponent;
-}
-
-//------------------------------------------------------------------------------
-uno::Reference< backend::XLayer > SAL_CALL
- LocalMultiStratum::getLayer( const rtl::OUString& aLayerId,
- const rtl::OUString& aTimestamp )
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- return LocalStratumBase::getLayer(aLayerId,aTimestamp);
-}
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Reference< backend::XLayer > > SAL_CALL
- LocalMultiStratum::getLayers( const uno::Sequence< rtl::OUString >& aLayerIds,
- const rtl::OUString& aTimestamp )
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- sal_Int32 const nLayers = aLayerIds.getLength();
- uno::Sequence< uno::Reference< backend::XLayer > > aResult(nLayers);
- for (sal_Int32 ix=0; ix<nLayers; ++ix)
- {
- aResult[ix] = LocalStratumBase::getLayer(aLayerIds[ix],aTimestamp);
- }
- return aResult;
-}
-
-//------------------------------------------------------------------------------
-uno::Sequence< uno::Reference< backend::XLayer > > SAL_CALL
- LocalMultiStratum::getMultipleLayers( const uno::Sequence< rtl::OUString >& aLayerIds,
- const uno::Sequence< rtl::OUString >& aTimestamps )
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- if (aLayerIds.getLength() != aTimestamps.getLength()) {
- throw lang::IllegalArgumentException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "LocalStratum::getMultipleLayers(): Timestamp count does not match layer count")),
- *this, 0) ;
- }
- sal_Int32 const nLayers = aLayerIds.getLength();
- uno::Sequence< uno::Reference< backend::XLayer > > aResult(nLayers);
- for (sal_Int32 ix=0; ix<nLayers; ++ix)
- {
- aResult[ix] = LocalStratumBase::getLayer(aLayerIds[ix],aTimestamps[ix]);
- }
- return aResult;
-}
-
-//------------------------------------------------------------------------------
-uno::Reference< backend::XUpdatableLayer > SAL_CALL
- LocalMultiStratum::getUpdatableLayer( const rtl::OUString& /*aLayerId*/ )
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- lang::NoSupportException, uno::RuntimeException)
-{
- failReadonly();
- return 0;
-}
-//------------------------------------------------------------------------------
-
-void LocalMultiStratum::getLayerDirectories(rtl::OUString& aLayerUrl,
- rtl::OUString& aSubLayerUrl) const
-{
- aLayerUrl = impl_getLayerDataDirectory(getBaseUrl());
- aSubLayerUrl = rtl::OUString();
-}
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-static const sal_Char * const kMultiStratumImplementation =
- "com.sun.star.comp.configuration.backend.LocalMultiStratum" ;
-static const sal_Char * const kBackendService =
- "com.sun.star.configuration.backend.MultiStratum" ;
-static const sal_Char * const kLocalService =
- "com.sun.star.configuration.backend.LocalMultiStratum" ;
-
-static sal_Char const * kServiceNames [] = { kLocalService, 0, kBackendService, 0 } ;
-static const ServiceImplementationInfo kMultiStratumServiceInfo = { kMultiStratumImplementation , kServiceNames, kServiceNames + 2 } ;
-
-const ServiceRegistrationInfo *getLocalMultiStratumServiceInfo()
-{ return getRegistrationInfo(&kMultiStratumServiceInfo) ; }
-
-uno::Reference<uno::XInterface> SAL_CALL
-instantiateLocalMultiStratum(const uno::Reference< uno::XComponentContext >& xContext) {
- return *new LocalMultiStratum(xContext) ;
-}
-
-//------------------------------------------------------------------------------
-
-const ServiceImplementationInfo * LocalMultiStratum::getServiceInfoData() const
-{
- return &kMultiStratumServiceInfo;
-}
-//------------------------------------------------------------------------------
-// ---------------------------------------------------------------------------------------
-
-} } // configmgr.localsinglestratum
diff --git a/configmgr/source/localbe/localmultistratum.hxx b/configmgr/source/localbe/localmultistratum.hxx
deleted file mode 100644
index 6bb7f623d4d9..000000000000
--- a/configmgr/source/localbe/localmultistratum.hxx
+++ /dev/null
@@ -1,100 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localmultistratum.hxx,v $
- * $Revision: 1.4 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_LOCALBE_LOCALMULTISTRATUM_HXX_
-#define CONFIGMGR_LOCALBE_LOCALMULTISTRATUM_HXX_
-
-#include "localstratumbase.hxx"
-#include <com/sun/star/configuration/backend/XMultiLayerStratum.hpp>
-#include <cppuhelper/implbase1.hxx>
-
-namespace configmgr
-{
- namespace localbe
- {
-
-namespace css = com::sun::star ;
-namespace uno = css::uno ;
-namespace lang = css::lang ;
-namespace backend = css::configuration::backend ;
-
-/**
- Implements the MultiLayerStratum service for local file access.
- */
-class LocalMultiStratum : public cppu::ImplInheritanceHelper1< LocalStratumBase, backend::XMultiLayerStratum >
-{
-public :
- /**
- Service constructor from a service factory.
-
- @param xContext component context
- */
- LocalMultiStratum(const uno::Reference<uno::XComponentContext>& xContext) ;
-
- /** Destructor */
- ~LocalMultiStratum() ;
-
-
- // XMultiLayerStratum
- virtual uno::Sequence< rtl::OUString > SAL_CALL
- listLayerIds( const rtl::OUString& aComponent, const rtl::OUString& aEntity )
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException);
-
- virtual rtl::OUString SAL_CALL
- getUpdateLayerId( const rtl::OUString& aComponent, const rtl::OUString& aEntity )
- throw (backend::BackendAccessException, lang::NoSupportException,
- lang::IllegalArgumentException, uno::RuntimeException);
-
- virtual uno::Reference< backend::XLayer > SAL_CALL
- getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp )
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException);
-
- virtual uno::Sequence< uno::Reference< backend::XLayer > > SAL_CALL
- getLayers( const uno::Sequence< rtl::OUString >& aLayerIds, const rtl::OUString& aTimestamp )
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException);
-
- virtual uno::Sequence< uno::Reference< backend::XLayer > > SAL_CALL
- getMultipleLayers( const uno::Sequence< rtl::OUString >& aLayerIds, const uno::Sequence< rtl::OUString >& aTimestamps )
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException);
-
- virtual uno::Reference< backend::XUpdatableLayer > SAL_CALL
- getUpdatableLayer( const rtl::OUString& aLayerId )
- throw (backend::BackendAccessException, lang::NoSupportException,
- lang::IllegalArgumentException, uno::RuntimeException);
-
-private:
- virtual void getLayerDirectories(rtl::OUString& aLayerUrl, rtl::OUString& aSubLayerUrl) const;
- virtual const ServiceImplementationInfo * getServiceInfoData() const;
-} ;
-
-
-} } // configmgr.localbe
-
-#endif
diff --git a/configmgr/source/localbe/localoutputstream.cxx b/configmgr/source/localbe/localoutputstream.cxx
deleted file mode 100644
index f4b538f63c65..000000000000
--- a/configmgr/source/localbe/localoutputstream.cxx
+++ /dev/null
@@ -1,199 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localoutputstream.cxx,v $
- * $Revision: 1.8 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-#include "localoutputstream.hxx"
-#include <rtl/ustrbuf.hxx>
-#include <com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp>
-
-namespace configmgr { namespace localbe {
-
-//==============================================================================
-
-//------------------------------------------------------------------------------
-
-LocalOutputStream::LocalOutputStream(const rtl::OUString& aFileUrl)
- throw (backend::BackendAccessException, uno::RuntimeException)
-: mFileUrl(aFileUrl)
-, mTemporaryFileUrl(mFileUrl)
-, mWriteFile(NULL)
-{
- // First, ensure the directory where the file is supposed to be
- // put exists.
- mTemporaryFileUrl += rtl::OUString::createFromAscii("_tmp") ;
- rtl::OUString parentDirectory = FileHelper::getParentDir(aFileUrl) ;
-
- if (osl::File::RC errorCode = FileHelper::mkdirs(parentDirectory))
- {
- rtl::OUStringBuffer message ;
- message.appendAscii("Cannot create directory \"") ;
- message.append(parentDirectory).appendAscii("\". Error is ") ;
- message.append(FileHelper::createOSLErrorString(errorCode));
- message.appendAscii(" [").append(sal_Int32(errorCode)).appendAscii("].") ;
-
- rtl::OUString const sIOMsg = message.makeStringAndClear();
- uno::Any ioe = uno::makeAny(io::IOException(sIOMsg,0));
-
- switch (errorCode)
- {
- case osl::File::E_ACCES:
- case osl::File::E_ROFS:
- message.appendAscii("Configuration LocalOutputStream - No Write Access: ");
- message.append(sIOMsg);
- throw backend::InsufficientAccessRightsException(message.makeStringAndClear(), NULL, ioe) ;
-
- case osl::File::E_None: OSL_ASSERT(!"can't happen");
- default:
- message.appendAscii("Configuration LocalOutputStream - IO Error: ");
- message.append(sIOMsg);
- throw backend::BackendAccessException(message.makeStringAndClear(), NULL, ioe) ;
- }
- }
-
- osl::File::remove(mTemporaryFileUrl) ;
- mWriteFile = new osl::File(mTemporaryFileUrl) ;
-
- if (osl::File::RC errorCode = mWriteFile->open(OpenFlag_Write | OpenFlag_Create) )
- {
- delete mWriteFile, mWriteFile = NULL;
-
- rtl::OUStringBuffer message ;
- message.appendAscii("Cannot open file \"") ;
- message.append(mTemporaryFileUrl).appendAscii("\" for writing. ");
- message.appendAscii("Error is ").append(FileHelper::createOSLErrorString(errorCode));
- message.appendAscii(" [").append(sal_Int32(errorCode)).appendAscii("].") ;
-
- rtl::OUString const sIOMsg = message.makeStringAndClear();
- uno::Any ioe = uno::makeAny(io::IOException(sIOMsg,0));
-
- switch (errorCode)
- {
- case osl::File::E_EXIST: // take inability to remove as indicator of missing rights
- case osl::File::E_ACCES:
- case osl::File::E_ROFS:
- message.appendAscii("Configuration LocalOutputStream - No Write Access: ");
- message.append(sIOMsg);
- throw backend::InsufficientAccessRightsException(message.makeStringAndClear(), NULL, ioe) ;
-
- case osl::File::E_None: OSL_ASSERT(!"can't happen");
- default:
- message.appendAscii("Configuration LocalOutputStream - IO Error: ");
- message.append(sIOMsg);
- throw backend::BackendAccessException(message.makeStringAndClear(), NULL, ioe) ;
- }
- }
- mTemporaryFile = new OSLOutputStreamWrapper(*mWriteFile) ;
-}
-//------------------------------------------------------------------------------
-
-LocalOutputStream::~LocalOutputStream()
-{
- try
- {
- this->closeOutput();
- }
- catch (uno::Exception&)
- {
- OSL_ENSURE(false,"Exception from closing LocalOutputStream ignored.");
- }
-
- delete mWriteFile;
-}
-//------------------------------------------------------------------------------
-
-void LocalOutputStream::finishOutput()
- throw (backend::BackendAccessException, uno::RuntimeException)
-{
- if (mWriteFile)
- try
- {
- this->closeOutput();
- delete mWriteFile, mWriteFile = NULL;
-
- FileHelper::replaceFile(mFileUrl, mTemporaryFileUrl) ;
- }
- catch (io::IOException& ioe)
- {
- rtl::OUStringBuffer message ;
- message.appendAscii("Configuration LocalOutputStream - IO Error: ");
- message.appendAscii("Cannot finish output to \"").append(mTemporaryFileUrl) ;
- message.appendAscii("\" or copy the result to \"").append(mFileUrl).appendAscii("\". ");
- message.appendAscii("Error is \"").append(ioe.Message).appendAscii("\". ");
- throw backend::BackendAccessException(message.makeStringAndClear(), *this, uno::makeAny(ioe));
- }
-}
-//------------------------------------------------------------------------------
-
-inline
-uno::Reference<io::XOutputStream> LocalOutputStream::getOutputFile()
-{
- if (!mTemporaryFile.is())
- {
- throw io::NotConnectedException(
- rtl::OUString::createFromAscii("LocalOutputStream: no output file."),
- *this);
- }
- return mTemporaryFile;
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL LocalOutputStream::writeBytes(const uno::Sequence<sal_Int8>& aData)
- throw (io::NotConnectedException,
- io::BufferSizeExceededException,
- io::IOException, uno::RuntimeException)
-{
- getOutputFile()->writeBytes(aData) ;
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL LocalOutputStream::flush()
- throw (io::NotConnectedException,
- io::BufferSizeExceededException,
- io::IOException, uno::RuntimeException)
-{
- getOutputFile()->flush() ;
-}
-//------------------------------------------------------------------------------
-
-void SAL_CALL LocalOutputStream::closeOutput()
- throw (io::NotConnectedException, io::BufferSizeExceededException,
- io::IOException, uno::RuntimeException)
-{
- if (mTemporaryFile.is())
- {
- mTemporaryFile->closeOutput() ;
-
- mTemporaryFile.clear();
- }
-}
-//------------------------------------------------------------------------------
-
-} } // configmgr.localbe
diff --git a/configmgr/source/localbe/localoutputstream.hxx b/configmgr/source/localbe/localoutputstream.hxx
deleted file mode 100644
index fa86c0e73b1e..000000000000
--- a/configmgr/source/localbe/localoutputstream.hxx
+++ /dev/null
@@ -1,106 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localoutputstream.hxx,v $
- * $Revision: 1.7 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_LOCALBE_LOCALOUTPUTSTREAM_HXX_
-#define CONFIGMGR_LOCALBE_LOCALOUTPUTSTREAM_HXX_
-
-#include "oslstream.hxx"
-#include "filehelper.hxx"
-#include <com/sun/star/configuration/backend/BackendAccessException.hpp>
-
-namespace configmgr { namespace localbe {
-
-namespace css = com::sun::star ;
-namespace uno = css::uno ;
-namespace io = css::io ;
-namespace backend = css::configuration::backend ;
-
-/**
- Class wrapping the use of the XOutputStream implementation on a file
- to make it handle a temporary file and synch the contents to the
- actual file being accessed only on successful completion of the output
- process.
- */
-class LocalOutputStream : public cppu::WeakImplHelper1<io::XOutputStream>
-{
- public :
- /**
- Constructor using the URL of the file to access.
- The actual writing will occur in a temporary file
- whose name is derived from the URL, and the file
- specified by the parameter will be overwritten
- on closing the stream.
-
- @param aFileUrl URL of the file to write
- @throws com::sun::star::io::IOException
- if access to the temporary file fails.
- */
- LocalOutputStream(const rtl::OUString& aFileUrl)
- throw (backend::BackendAccessException, uno::RuntimeException) ;
- /** Destructor */
- ~LocalOutputStream(void) ;
-
- // closeOutput and mark as successful
- void finishOutput()
- throw (backend::BackendAccessException, uno::RuntimeException) ;
- protected :
- // XOutputStream
- virtual void SAL_CALL writeBytes(const uno::Sequence<sal_Int8>& aData)
- throw (io::NotConnectedException,
- io::BufferSizeExceededException,
- io::IOException, uno::RuntimeException);
-
- virtual void SAL_CALL flush(void)
- throw (io::NotConnectedException,
- io::BufferSizeExceededException,
- io::IOException, uno::RuntimeException);
-
- virtual void SAL_CALL closeOutput(void)
- throw (io::NotConnectedException,
- io::BufferSizeExceededException,
- io::IOException, uno::RuntimeException) ;
-
-
- private :
- uno::Reference<io::XOutputStream> getOutputFile() ;
-
- /** Temporary file used during access */
- uno::Reference<io::XOutputStream> mTemporaryFile ;
- /** URL of the target file */
- rtl::OUString mFileUrl ;
- /** URL of the temporary file */
- rtl::OUString mTemporaryFileUrl ;
- /** File being written */
- osl::File *mWriteFile ;
-} ;
-
-} } // configmgr.localbe
-
-#endif // CONFIGMGR_LOCALBE_LOCALOUTPUTSTREAM_HXX_
diff --git a/configmgr/source/localbe/localschemasupplier.cxx b/configmgr/source/localbe/localschemasupplier.cxx
deleted file mode 100644
index c85b985976e1..000000000000
--- a/configmgr/source/localbe/localschemasupplier.cxx
+++ /dev/null
@@ -1,291 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localschemasupplier.cxx,v $
- * $Revision: 1.7 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "localschemasupplier.hxx"
-#include "localfilehelper.hxx"
-#include "oslstream.hxx"
-
-#ifndef CONFIGMGR_API_FACTORY_HXX_
-#include "confapifactory.hxx"
-#endif // CONFIGMGR_API_FACTORY_HXX_
-#include "serviceinfohelper.hxx"
-#include "bootstrap.hxx"
-#include "filehelper.hxx"
-#include <rtl/ustrbuf.hxx>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp>
-#include <osl/file.hxx>
-#include <osl/process.h>
-#include <memory>
-
-namespace configmgr { namespace localbe {
-
-//==============================================================================
-
-//------------------------------------------------------------------------------
-
-LocalSchemaSupplier::LocalSchemaSupplier(
- const uno::Reference<uno::XComponentContext>& xContext)
- : cppu::WeakComponentImplHelper3<backend::XVersionedSchemaSupplier, lang::XInitialization, lang::XServiceInfo>(mMutex), mFactory(xContext->getServiceManager(),uno::UNO_QUERY) {
-}
-//------------------------------------------------------------------------------
-
-LocalSchemaSupplier::~LocalSchemaSupplier(void) {}
-//------------------------------------------------------------------------------
-static const rtl::OUString kSchemaDataUrl(
- RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"SchemaDataUrl")) ;
-
-static const rtl::OUString kSchemaVersion(
- RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"SchemaVersion")) ;
-
-void SAL_CALL LocalSchemaSupplier::initialize(
- const uno::Sequence<uno::Any>& aParameters)
- throw (uno::RuntimeException, uno::Exception,
- css::configuration::InvalidBootstrapFileException,
- backend::CannotConnectException,
- backend::BackendSetupException)
-{
- if (aParameters.getLength() == 0) {
- throw lang::IllegalArgumentException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "No parameters provided to LocalSchemaSupplier")),
- *this, 0) ;
- }
- uno::Reference<uno::XComponentContext> context ;
-
- for (sal_Int32 i = 0 ; i < aParameters.getLength() ; ++ i) {
- if (aParameters [i] >>= context) { break ; }
- }
-
- // Setting: schema version
- // TODO: Add support for repository-specific versions
- uno::Any const aSchemaVersionSetting = context->getValueByName(kSchemaVersion);
- aSchemaVersionSetting >>= mSchemaVersion;
-
- // Setting: schema diretory(ies)
- uno::Any const aSchemaDataSetting = context->getValueByName(kSchemaDataUrl);
- uno::Sequence< rtl::OUString > aSchemas;
- rtl::OUString schemas;
-
- if (aSchemaDataSetting >>= schemas)
- {
- fillFromBlankSeparated(schemas, aSchemas) ;
- }
- else
- {
- aSchemaDataSetting >>= aSchemas;
- }
- //validate SchemaDataUrls
- mSchemaDataUrls.realloc(aSchemas.getLength());
-
- sal_Int32 nSchemaLocations =0;
- sal_Int32 nExistingSchemaLocations = 0;
- for (sal_Int32 j = 0; j < aSchemas.getLength(); ++j)
- {
- bool bOptional = checkOptionalArg(aSchemas[j]);
-
- if(!bOptional)
- validateFileURL(aSchemas[j],*this);
- else if (!isValidFileURL(aSchemas[j]))
- continue;
-
- OSL_ASSERT(isValidFileURL(aSchemas[j]));
-
- //NormalizeURL
- implEnsureAbsoluteURL(aSchemas[j]);
- if(!normalizeURL(aSchemas[j],*this,bOptional))
- continue;
-
- //now we have a correct file URL, which we will use
- mSchemaDataUrls[nSchemaLocations++]= aSchemas[j];
- if (!bOptional)
- checkFileExists(aSchemas[j],*this);
-
- else if(!FileHelper::fileExists(aSchemas[j]))
- continue; // skip the directory check
-
- checkIfDirectory(aSchemas[j],*this);
- ++nExistingSchemaLocations;
- }
- if (0 == nExistingSchemaLocations)
- {
- rtl::OUString sMsg = rtl::OUString::createFromAscii("LocalBackend: No schema directories found");
- throw backend::BackendSetupException(sMsg,*this, uno::Any()) ;
- }
- mSchemaDataUrls.realloc(nSchemaLocations);
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString SAL_CALL
- LocalSchemaSupplier::getSchemaVersion(const rtl::OUString& /*aComponent*/)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- // TODO: Add support for repository-specific versions
- return mSchemaVersion;
-}
-//------------------------------------------------------------------------------
-static const rtl::OUString kSchemaSuffix(RTL_CONSTASCII_USTRINGPARAM(".xcs")) ;
-static const rtl::OUString kXMLSchemaParser(RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.configuration.backend.xml.SchemaParser")) ;
-
-uno::Reference<backend::XSchema> SAL_CALL
- LocalSchemaSupplier::getComponentSchema(const rtl::OUString& aComponent)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- rtl::OUString subPath = componentToPath(aComponent) ;
-
- osl::File * schemaFile = NULL;
- rtl::OUString errorMessage;
- bool bInsufficientAccess = false;
- for (sal_Int32 ix = 0; ix < mSchemaDataUrls.getLength(); ++ix)
- {
- rtl::OUStringBuffer schemaUrl(mSchemaDataUrls[ix]) ;
-
- schemaUrl.append(subPath).append(kSchemaSuffix) ;
-
- rtl::OUString const aFileUrl = schemaUrl.makeStringAndClear();
-
- std::auto_ptr<osl::File> checkFile( new osl::File(aFileUrl) );
- osl::File::RC rc = checkFile->open(OpenFlag_Read) ;
-
- if (rc == osl::File::E_None)
- {
- schemaFile = checkFile.release();
- break;
- }
- else if (rc != osl::File::E_NOENT)
- {
- if (rc == osl::File::E_ACCES)
- bInsufficientAccess =true;
-
- // accumulate error messages
- rtl::OUStringBuffer sMsg(errorMessage);
- if (errorMessage.getLength())
- sMsg.appendAscii("LocalFile SchemaSupplier - Error accessing schema: ");
-
- sMsg.appendAscii("\n- Cannot open input file \"");
- sMsg.append(aFileUrl);
- sMsg.appendAscii("\" : ");
- sMsg.append(FileHelper::createOSLErrorString(rc));
-
- errorMessage = sMsg.makeStringAndClear();
- }
- }
-
- if (NULL == schemaFile)
- {
- if (errorMessage.getLength() != 0)
- {
- // a real error occured
- io::IOException ioe(errorMessage,*this);
-
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii("LocalFileLayer - Cannot readData: ").append(errorMessage);
-
- if (bInsufficientAccess)
- throw backend::InsufficientAccessRightsException(sMsg.makeStringAndClear(),*this,uno::makeAny(ioe));
- else
- throw backend::BackendAccessException(sMsg.makeStringAndClear(),*this,uno::makeAny(ioe));
- }
- // simply not found
- return NULL;
- }
-
- uno::Sequence<uno::Any> arguments(1) ;
- uno::Reference<io::XInputStream> stream( new OSLInputStreamWrapper(schemaFile, true) );
-
- arguments [0] <<= stream ;
- uno::Reference<backend::XSchema> schema(
- mFactory->createInstanceWithArguments(kXMLSchemaParser, arguments),
- uno::UNO_QUERY) ;
-
- if (!schema.is())
- {
- throw uno::RuntimeException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "Cannot instantiate Schema Parser for ")) + aComponent,
- *this) ;
- }
- return schema ;
-}
-//------------------------------------------------------------------------------
-
-
-//------------------------------------------------------------------------------
-
-static const sal_Char * const kImplementation =
- "com.sun.star.comp.configuration.backend.LocalSchemaSupplier" ;
-static const sal_Char * const kSchemaService =
- "com.sun.star.configuration.backend.SchemaSupplier" ;
-static const sal_Char * const kLocalService =
- "com.sun.star.configuration.backend.LocalSchemaSupplier" ;
-
-static sal_Char const * kServiceNames [] = {kLocalService, 0, kSchemaService, 0 } ;
-static const ServiceImplementationInfo kServiceInfo = { kImplementation, kServiceNames,kServiceNames+2 } ;
-
-const ServiceRegistrationInfo *getLocalSchemaSupplierServiceInfo()
-{ return getRegistrationInfo(&kServiceInfo) ; }
-
-uno::Reference<uno::XInterface> SAL_CALL
-instantiateLocalSchemaSupplier(const uno::Reference< uno::XComponentContext >& xContext) {
- return *new LocalSchemaSupplier(xContext) ;
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString SAL_CALL LocalSchemaSupplier::getImplementationName(void)
- throw (uno::RuntimeException)
-{
- return ServiceInfoHelper(&kServiceInfo).getImplementationName() ;
-}
-//------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL LocalSchemaSupplier::supportsService(
- const rtl::OUString& aServiceName)
- throw (uno::RuntimeException)
-{
- return ServiceInfoHelper(&kServiceInfo).supportsService(aServiceName);
-}
-//------------------------------------------------------------------------------
-
-uno::Sequence<rtl::OUString>
-SAL_CALL LocalSchemaSupplier::getSupportedServiceNames(void)
- throw (uno::RuntimeException)
-{
- return ServiceInfoHelper(&kServiceInfo).getSupportedServiceNames() ;
-}
-
-// ---------------------------------------------------------------------------------------
-
-} } // configmgr.localbe
diff --git a/configmgr/source/localbe/localschemasupplier.hxx b/configmgr/source/localbe/localschemasupplier.hxx
deleted file mode 100644
index 4447c98f984b..000000000000
--- a/configmgr/source/localbe/localschemasupplier.hxx
+++ /dev/null
@@ -1,118 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localschemasupplier.hxx,v $
- * $Revision: 1.6 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_LOCALBE_LOCALSCHEMASUPPLIER_HXX_
-#define CONFIGMGR_LOCALBE_LOCALSCHEMASUPPLIER_HXX_
-
-#include <com/sun/star/configuration/backend/XVersionedSchemaSupplier.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
-#include <com/sun/star/configuration/backend/CannotConnectException.hpp>
-#include <cppuhelper/compbase3.hxx>
-
-namespace configmgr { namespace localbe {
-
-namespace css = com::sun::star ;
-namespace uno = css::uno ;
-namespace lang = css::lang ;
-namespace backend = css::configuration::backend ;
-
-/**
- Implements the SchemaSupplier service for local schema file access.
- */
-class LocalSchemaSupplier : public cppu::WeakComponentImplHelper3<backend::XVersionedSchemaSupplier, lang::XInitialization, lang::XServiceInfo> {
- public :
- /**
- Service constructor from a service factory.
-
- @param xConxtext Component Context
- */
- LocalSchemaSupplier(const uno::Reference<uno::XComponentContext>& xContext) ;
-
- /** Destructor */
- ~LocalSchemaSupplier(void) ;
-
-
- // XInitialize
- virtual void SAL_CALL
- initialize( const uno::Sequence<uno::Any>& aParameters)
- throw (uno::RuntimeException, uno::Exception,
- css::configuration::InvalidBootstrapFileException,
- backend::CannotConnectException,
- backend::BackendSetupException);
-
- // XVersionedSchemaSupplier
- virtual rtl::OUString SAL_CALL
- getSchemaVersion( const rtl::OUString& aComponent )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- // XSchemaSupplier
- virtual uno::Reference<backend::XSchema> SAL_CALL
- getComponentSchema( const rtl::OUString& aComponent )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- // XServiceInfo
- virtual rtl::OUString SAL_CALL
- getImplementationName( )
- throw (uno::RuntimeException) ;
-
- virtual sal_Bool SAL_CALL
- supportsService( const rtl::OUString& aServiceName )
- throw (uno::RuntimeException) ;
-
- virtual uno::Sequence<rtl::OUString> SAL_CALL
- getSupportedServiceNames( )
- throw (uno::RuntimeException) ;
-
- private :
- /** Service factory */
- uno::Reference<lang::XMultiServiceFactory> mFactory ;
- /** Mutex for resources protection */
- osl::Mutex mMutex ;
- /**
- Base of the schema data. Is a list to allow
- for multiple schema directories.
- */
- uno::Sequence<rtl::OUString> mSchemaDataUrls ;
- /** Version of the schema repository */
- // TODO: Add support for repository-specific versions
- rtl::OUString mSchemaVersion;
-} ;
-
-} } // configmgr.localschemasupplirt
-
-#endif // CONFIGMGR_LOCALBE_LOCALSCHEMASUPPLIER_HXX_
diff --git a/configmgr/source/localbe/localsinglebackend.cxx b/configmgr/source/localbe/localsinglebackend.cxx
deleted file mode 100644
index ef41babb04c2..000000000000
--- a/configmgr/source/localbe/localsinglebackend.cxx
+++ /dev/null
@@ -1,801 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localsinglebackend.cxx,v $
- * $Revision: 1.23 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "localsinglebackend.hxx"
-#include "localfilehelper.hxx"
-#include "localfilelayer.hxx"
-#include "oslstream.hxx"
-
-#ifndef CONFIGMGR_API_FACTORY_HXX_
-#include "confapifactory.hxx"
-#endif // CONFIGMGR_API_FACTORY_HXX_
-#include "serviceinfohelper.hxx"
-#include "bootstrap.hxx"
-#include "filehelper.hxx"
-#include <rtl/ustrbuf.hxx>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp>
-#include <osl/file.hxx>
-#include <osl/process.h>
-#include <memory>
-
-namespace configmgr { namespace localbe {
-
-//==============================================================================
-
-//------------------------------------------------------------------------------
-
-LocalSingleBackend::LocalSingleBackend(
- const uno::Reference<uno::XComponentContext>& xContext)
- : cppu::WeakComponentImplHelper5<backend::XSchemaSupplier, backend::XMultiLayerStratum, backend::XBackendEntities, lang::XInitialization, lang::XServiceInfo>(mMutex), mFactory(xContext->getServiceManager(),uno::UNO_QUERY) {
-}
-//------------------------------------------------------------------------------
-
-LocalSingleBackend::~LocalSingleBackend(void) {}
-//------------------------------------------------------------------------------
-static const rtl::OUString kSchemaDataUrl(
- RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"SchemaDataUrl")) ;
-static const rtl::OUString kDefaultDataUrl(
- RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"DefaultLayerUrls")) ;
-static const rtl::OUString kUserDataUrl(
- RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"UserLayerUrl")) ;
-static const rtl::OUString kEntity(
- RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_PREFIX_"EntityLayer")) ;
-
-static const rtl::OUString kAdminModeFlag(
- RTL_CONSTASCII_USTRINGPARAM(CONTEXT_ITEM_ADMINFLAG)) ;
-
-void SAL_CALL LocalSingleBackend::initialize(
- const uno::Sequence<uno::Any>& aParameters)
- throw (uno::RuntimeException, uno::Exception,
- css::configuration::InvalidBootstrapFileException,
- backend::CannotConnectException,
- backend::BackendSetupException)
-{
- if (aParameters.getLength() == 0) {
- throw lang::IllegalArgumentException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "No parameters provided to SingleBackend")),
- *this, 0) ;
- }
- uno::Reference<uno::XComponentContext> context ;
-
- for (sal_Int32 i = 0 ; i < aParameters.getLength() ; ++ i) {
- if (aParameters [i] >>= context) { break ; }
- }
-
- // Setting: schema diretory(ies)
- uno::Any const aSchemaDataSetting = context->getValueByName(kSchemaDataUrl);
- uno::Sequence< rtl::OUString > aSchemas;
- rtl::OUString schemas;
-
- if (aSchemaDataSetting >>= schemas)
- {
- fillFromBlankSeparated(schemas, aSchemas) ;
- }
- else
- {
- aSchemaDataSetting >>= aSchemas;
- }
- //validate SchemaDataUrls
- mSchemaDataUrls.realloc(aSchemas.getLength());
-
- sal_Int32 nSchemaLocations = 0;
- sal_Int32 nExistingSchemaLocations = 0;
- for (sal_Int32 j = 0; j < aSchemas.getLength(); ++j)
- {
- bool bOptional = checkOptionalArg(aSchemas[j]);
-
- if (!bOptional)
- validateFileURL(aSchemas[j],*this);
-
- else if (!isValidFileURL(aSchemas[j]))
- continue;
-
- OSL_ASSERT(isValidFileURL(aSchemas[j]));
-
- //NormalizeURL
- implEnsureAbsoluteURL(aSchemas[j]);
- if (!normalizeURL(aSchemas[j],*this,bOptional))
- continue;
-
- // now we have a correct file URL, which we will use
- mSchemaDataUrls[nSchemaLocations++] = aSchemas[j];
-
- // check existence
- if (!bOptional)
- checkFileExists(aSchemas[j], *this);
-
- else if(!FileHelper::fileExists(aSchemas[j]))
- continue; // skip the directory check
-
-
- checkIfDirectory(aSchemas[j],*this);
-
- ++nExistingSchemaLocations;
- }
- mSchemaDataUrls.realloc(nSchemaLocations);
-
- if (0 == nExistingSchemaLocations)
- {
- rtl::OUString sMsg = rtl::OUString::createFromAscii("LocalBackend: No schema directories found");
- throw backend::BackendSetupException(sMsg,*this, uno::Any()) ;
- }
-
- // Setting: default layer(s)
- uno::Any const aDefaultDataSetting = context->getValueByName(kDefaultDataUrl);
- uno::Sequence< rtl::OUString > aDefaults;
- rtl::OUString defaults;
-
- if (aDefaultDataSetting >>= defaults)
- {
- fillFromBlankSeparated(defaults, aDefaults) ;
- }
- else
- {
- aDefaultDataSetting >>= aDefaults ;
- }
-
- //validate DefaultDataUrls
- mDefaultDataUrls.realloc(aDefaults.getLength());
- sal_Int32 nDefaultLayers = 0;
-
- for (sal_Int32 ix = 0; ix < aDefaults.getLength(); ++ix)
- {
- // skip invalid URLs
- if (!isValidFileURL(aDefaults[ix]))
- continue;
-
- //NormalizeURL
- implEnsureAbsoluteURL(aDefaults[ix]);
- if (!normalizeURL(aDefaults[ix],*this,true))
- continue;
-
- if(FileHelper::fileExists(aDefaults[ix]))
- {
- checkIfDirectory(aDefaults[ix],*this);
- }
-
- // good URL -> use it
- mDefaultDataUrls[nDefaultLayers++] = aDefaults[ix];
- }
- mDefaultDataUrls.realloc(nDefaultLayers);
-
- // Setting: admin mode tag
- sal_Bool bAdminMode = false;
- context->getValueByName(kAdminModeFlag) >>= bAdminMode;
-
- if (bAdminMode)
- {
- // find given entity
- if ( (context->getValueByName(kEntity) >>= mUserDataUrl) && mUserDataUrl.getLength() )
- {
- //Validate UserDataUrl
- validateFileURL(mUserDataUrl,*this);
- //NormalizeURL
- implEnsureAbsoluteURL(mUserDataUrl);
- normalizeURL(mUserDataUrl,*this);
- if(FileHelper::fileExists(mUserDataUrl))
- {
- checkIfDirectory(mUserDataUrl,*this);
- }
-
- for (sal_Int32 ix = 0; ix < mDefaultDataUrls.getLength(); ++ix)
- {
- if (mDefaultDataUrls.getConstArray()[ix].equals(mUserDataUrl))
- {
- mDefaultDataUrls.realloc(ix);
- // this is the last round through the loop
- }
- }
- }
- else if (aDefaults.getLength()) // administrate first default layer
- {
- mUserDataUrl = aDefaults[0];
- mDefaultDataUrls.realloc(0);
- }
- else
- {
- OSL_ENSURE(false, "Cannot find target entity for admin mode - fallback to local mode");
- bAdminMode = false;
- }
- }
-
- if (!bAdminMode)
- {
- context->getValueByName(kUserDataUrl) >>= mUserDataUrl ;
- //Validate UserDataUrl
- if (isValidFileURL(mUserDataUrl))
- {
- implEnsureAbsoluteURL(mUserDataUrl);
- normalizeURL(mUserDataUrl,*this);
- if(FileHelper::fileExists(mUserDataUrl))
- {
- checkIfDirectory(mUserDataUrl,*this);
- }
- }
- }
-
- if (mUserDataUrl.getLength() == 0)
- {
- mUserDataUrl = rtl::OUString::createFromAscii("*");
- OSL_ASSERT(!isValidFileURL(mUserDataUrl));
- }
-}
-//------------------------------------------------------------------------------
-const sal_Int32 k_UserLayerEntity = 0;
-const sal_Int32 k_InvalidEntity = k_UserLayerEntity - 1;
-const sal_Int32 k_DefaultEntityOffset = k_UserLayerEntity + 1;
-//------------------------------------------------------------------------------
-static inline bool isValidEntity(sal_Int32 ent)
-{
- return ent > k_InvalidEntity;
-}
-//------------------------------------------------------------------------------
-static inline sal_Int32 indexToEntity(sal_Int32 ix)
-{
- OSL_ASSERT(0 <= ix);
- return ix + k_DefaultEntityOffset;
-}
-static inline sal_Int32 entityToIndex(sal_Int32 ent)
-{
- OSL_ASSERT(k_DefaultEntityOffset <= ent);
- return ent - k_DefaultEntityOffset;
-}
-//------------------------------------------------------------------------------
-
-
-/**
- Transforms a file url into a layer id. The layer id will
- contain the URL passed plus an integer indicating which
- layer the URL points to. If the integer is 0, the URL
- is a user layer, otherwise it is one of the default layers.
-
- @param aFileUrl URL to encode
- @param aIndex index of the layer concerned (0 = user, other = default)
- @return layer id
- */
-static
-rtl::OUString urlToLayerId(const rtl::OUString& aFileUrl,sal_Int32 aIndex)
-{
- rtl::OUStringBuffer id ;
-
- OSL_ASSERT(isValidEntity(aIndex));
- if (aIndex)
- id.append(aIndex).appendAscii(" ",1); // non-user layers
- else
- id.appendAscii("U ",2); // user layer
-
- id.append(aFileUrl) ;
- return id.makeStringAndClear() ;
-}
-
-static
-inline
-bool layerIdToUrl( const rtl::OUString& aLayerId,
- rtl::OUString& aFileUrl,
- sal_Int32& aIndex)
-{
- sal_Int32 const sep = aLayerId.indexOf(sal_Unicode(' ')) ;
-
- if (sep < 0) return false;
-
- // detect user layer id
- if (aLayerId[0] == sal_Unicode('U'))
- {
- if (sep != 1) return false;
- aIndex = 0;
- }
- else
- {
- aIndex = aLayerId.copy(0, sep).toInt32() ;
- if (0 == aIndex || !isValidEntity(aIndex)) return false;
-
- OSL_ENSURE( aLayerId.copy(0, sep).equals(rtl::OUString::valueOf(aIndex)),
- "Invalid layer id was not detected");
- }
- aFileUrl = aLayerId.copy(sep + 1);
-
- return true;
-}
-//------------------------------------------------------------------------------
-sal_Int32 LocalSingleBackend::resolveLayerId(const rtl::OUString& aLayerId,
- rtl::OUString& aFileUrl)
-{
- sal_Int32 nIndex = k_InvalidEntity;
- if (!layerIdToUrl(aLayerId,aFileUrl,nIndex))
- {
- rtl::OUString const sMsg(RTL_CONSTASCII_USTRINGPARAM(
- "LocalSingleBackend - Invalid layer id: "));
-
- // layer id is always the second parameter
- throw lang::IllegalArgumentException(sMsg.concat(aLayerId), *this, 2);
- }
- OSL_ASSERT(isValidEntity(nIndex));
- return nIndex;
-}
-//------------------------------------------------------------------------------
-
-sal_Int32 LocalSingleBackend::findEntity(const rtl::OUString& aEntity)
-{
- if (aEntity.getLength() == 0)
- {
- return k_InvalidEntity;
- }
-
- // quick check for OwnerEntity first
- if (aEntity.equals(mUserDataUrl))
- {
- return k_UserLayerEntity;
- }
-
- rtl::OUString sNormalizedEntityUrl(aEntity);
- normalizeURL(sNormalizedEntityUrl,*this);
-
- for (sal_Int32 ix = 0; ix < mDefaultDataUrls.getLength(); ++ix)
- {
- rtl::OUString sNormalizedDefaultUrl(mDefaultDataUrls[ix]);
- OSL_VERIFY(normalizeURL(sNormalizedDefaultUrl,*this,true));
-
- if (sNormalizedEntityUrl.equals(sNormalizedDefaultUrl))
- {
- // found it
- return indexToEntity(ix);
- }
- }
-
- //Try normalized version of mUserDataUrl
- rtl::OUString sNormalizedUserUrl(mUserDataUrl);
-
- if (normalizeURL(sNormalizedUserUrl,*this,true))
- {
- if (sNormalizedEntityUrl.equals(sNormalizedUserUrl))
- {
- return k_UserLayerEntity;
- }
- }
-
- // not found
- return k_InvalidEntity;
-}
-//------------------------------------------------------------------------------
-
-static const rtl::OUString kDataSuffix(RTL_CONSTASCII_USTRINGPARAM(".xcu")) ;
-
-uno::Sequence<rtl::OUString> SAL_CALL LocalSingleBackend::listLayerIds(
- const rtl::OUString& aComponent, const rtl::OUString& aEntity)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- sal_Int32 nEntity = findEntity(aEntity);
- if ( !isValidEntity(nEntity) )
- {
- rtl::OUString const sMsg(RTL_CONSTASCII_USTRINGPARAM(
- "LocalSingleBackend - Unknown entity: "));
-
- throw lang::IllegalArgumentException(sMsg.concat(aEntity), *this, 2);
- }
-
- sal_Int32 nDefLayers = (k_UserLayerEntity == nEntity)
- ? mDefaultDataUrls.getLength()
- : entityToIndex(nEntity);
-
- OSL_ASSERT(0 <= nDefLayers && nDefLayers <= mDefaultDataUrls.getLength());
-
- rtl::OUString const componentSubPath = componentToPath(aComponent) + kDataSuffix ;
-
- uno::Sequence<rtl::OUString> aLayerIds(nDefLayers + 1) ;
- OSL_ASSERT(0 < aLayerIds.getLength());
-
- // First, the defaults...
- for (sal_Int32 ix = 0; ix < nDefLayers ; ++ ix)
- {
- aLayerIds[ix] = urlToLayerId(componentSubPath, indexToEntity(ix)) ;
- }
- // Then the entity data.
- aLayerIds [nDefLayers] = urlToLayerId(componentSubPath, nEntity) ;
-
- return aLayerIds;
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString SAL_CALL LocalSingleBackend::getUpdateLayerId(
- const rtl::OUString& aComponent, const rtl::OUString& aEntity)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- sal_Int32 nEntity = findEntity(aEntity);
- if ( !isValidEntity(nEntity) )
- {
- rtl::OUString const sMsg(RTL_CONSTASCII_USTRINGPARAM(
- "LocalSingleBackend - Unknown entity for update: "));
-
- throw lang::IllegalArgumentException(sMsg.concat(aEntity), *this, 2);
- }
-
- return urlToLayerId(componentToPath(aComponent) + kDataSuffix, nEntity) ;
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString SAL_CALL LocalSingleBackend::getOwnerEntity()
- throw (uno::RuntimeException)
-{
- return mUserDataUrl ;
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString SAL_CALL LocalSingleBackend::getAdminEntity()
- throw (uno::RuntimeException)
-{
- return mDefaultDataUrls.getLength() > 0 ? mDefaultDataUrls[0] : mUserDataUrl;
-}
-//------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL LocalSingleBackend::supportsEntity( const rtl::OUString& aEntity )
- throw (backend::BackendAccessException, uno::RuntimeException)
-{
- return isValidEntity(findEntity(aEntity)) ;
-}
-//------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL LocalSingleBackend::isEqualEntity(const rtl::OUString& aEntity, const rtl::OUString& aOtherEntity)
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException)
-{
- if (aEntity.getLength() == 0)
- {
- rtl::OUString const sMsg(RTL_CONSTASCII_USTRINGPARAM(
- "LocalSingleBackend - Invalid empty entity."));
-
- throw lang::IllegalArgumentException(sMsg, *this, 1);
- }
- if (aOtherEntity.getLength() == 0)
- {
- rtl::OUString const sMsg(RTL_CONSTASCII_USTRINGPARAM(
- "LocalSingleBackend - Invalid empty entity."));
-
- throw lang::IllegalArgumentException(sMsg, *this, 2);
- }
- rtl::OUString aNormalizedEntity(aEntity);
- normalizeURL(aNormalizedEntity,*this);
-
- rtl::OUString aNormalizedOther(aOtherEntity);
- normalizeURL(aNormalizedOther,*this);
-
- return aNormalizedEntity == aNormalizedOther;
-}
-//------------------------------------------------------------------------------
-
-sal_Bool LocalSingleBackend::isMoreRecent(const rtl::OUString& aFileUrl,
- sal_Int32 aLayerIndex,
- const rtl::OUString& aTimestamp) {
- rtl::OUString layerUrl ;
- rtl::OUString subLayerUrl ;
-
- // if we don't find a layer, but have a non-empty timestamp -> modified
- if (!getLayerDirectories(aLayerIndex,layerUrl, subLayerUrl))
- return aTimestamp.getLength() != 0;
-
- return layerUrl.getLength() == 0 ||
- BasicLocalFileLayer::getTimestamp(layerUrl + aFileUrl).compareTo( aTimestamp) != 0;
-}
-//------------------------------------------------------------------------------
-
-static const rtl::OUString kDataSubPath(
- RTL_CONSTASCII_USTRINGPARAM("/data")) ;
-static const rtl::OUString kLocalisedDataSubPath(
- RTL_CONSTASCII_USTRINGPARAM("/res")) ;
-
-uno::Reference<backend::XLayer> SAL_CALL LocalSingleBackend::getLayer(
- const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- rtl::OUString fileUrl ;
-
- sal_Int32 defaultIndex = resolveLayerId(aLayerId, fileUrl) ;
-
- if (!isMoreRecent(fileUrl, defaultIndex, aTimestamp)) { return NULL ; }
-
- uno::Reference<backend::XUpdatableLayer> xLayer = getFileLayer(fileUrl,defaultIndex);
- uno::Reference<backend::XLayer> xResult = xLayer.get();
- return xResult;
-}
-//------------------------------------------------------------------------------
-
-uno::Sequence<uno::Reference<backend::XLayer> > SAL_CALL
-LocalSingleBackend::getLayers(const uno::Sequence<rtl::OUString>& aLayerIds,
- const rtl::OUString& aTimestamp)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- uno::Sequence<uno::Reference<backend::XLayer> >
- retCode(aLayerIds.getLength()) ;
-
- for (sal_Int32 i = 0 ; i < aLayerIds.getLength() ; ++ i) {
- retCode [i] = getLayer(aLayerIds [i], aTimestamp) ;
- }
- return retCode ;
-}
-//------------------------------------------------------------------------------
-
-uno::Sequence<uno::Reference<backend::XLayer> > SAL_CALL
-LocalSingleBackend::getMultipleLayers(
- const uno::Sequence<rtl::OUString>& aLayerIds,
- const uno::Sequence<rtl::OUString>& aTimestamps)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- if (aLayerIds.getLength() != aTimestamps.getLength()) {
- throw lang::IllegalArgumentException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "Not enough or too many timestamps")),
- *this, 0) ;
- }
- uno::Sequence<uno::Reference<backend::XLayer> >
- retCode(aLayerIds.getLength()) ;
-
- for (sal_Int32 i = 0 ; i < aLayerIds.getLength() ; ++ i) {
- retCode [i] = getLayer(aLayerIds [i], aTimestamps [i]) ;
- }
- return retCode ;
-}
-//------------------------------------------------------------------------------
-
-uno::Reference<backend::XUpdatableLayer> SAL_CALL
-LocalSingleBackend::getUpdatableLayer(const rtl::OUString& aLayerId)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- return getFileLayer(aLayerId) ;
-}
-//------------------------------------------------------------------------------
-
-static const rtl::OUString kSchemaSuffix(RTL_CONSTASCII_USTRINGPARAM(".xcs")) ;
-static const rtl::OUString kXMLSchemaParser(RTL_CONSTASCII_USTRINGPARAM(
- "com.sun.star.configuration.backend.xml.SchemaParser")) ;
-
-uno::Reference<backend::XSchema> SAL_CALL
- LocalSingleBackend::getComponentSchema(const rtl::OUString& aComponent)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- rtl::OUString subPath = componentToPath(aComponent) ;
-
- osl::File * schemaFile = NULL;
- rtl::OUString errorMessage;
- bool bInsufficientAccess = false;
- for (sal_Int32 ix = 0; ix < mSchemaDataUrls.getLength(); ++ix)
- {
- rtl::OUStringBuffer schemaUrl(mSchemaDataUrls[ix]) ;
-
- schemaUrl.append(subPath).append(kSchemaSuffix) ;
-
- rtl::OUString const aFileUrl = schemaUrl.makeStringAndClear();
-
- std::auto_ptr<osl::File> checkFile( new osl::File(aFileUrl) );
- osl::File::RC rc = checkFile->open(OpenFlag_Read) ;
-
- if (rc == osl::File::E_None)
- {
- schemaFile = checkFile.release();
- break;
- }
- else if (rc != osl::File::E_NOENT)
- {
- if (rc == osl::File::E_ACCES)
- bInsufficientAccess =true;
-
- // accumulate error messages
- rtl::OUStringBuffer sMsg(errorMessage);
- if (errorMessage.getLength())
- sMsg.appendAscii("LocalFile SchemaSupplier - Error accessing schema: ");
-
- sMsg.appendAscii("\n- Cannot open input file \"");
- sMsg.append(aFileUrl);
- sMsg.appendAscii("\" : ");
- sMsg.append(FileHelper::createOSLErrorString(rc));
-
- errorMessage = sMsg.makeStringAndClear();
- }
- }
-
- if (NULL == schemaFile)
- {
- if (errorMessage.getLength() != 0)
- {
- // a real error occured
- io::IOException ioe(errorMessage,*this);
-
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii("LocalFileLayer - Cannot readData: ").append(errorMessage);
-
- if (bInsufficientAccess)
- throw backend::InsufficientAccessRightsException(sMsg.makeStringAndClear(),*this,uno::makeAny(ioe));
- else
- throw backend::BackendAccessException(sMsg.makeStringAndClear(),*this,uno::makeAny(ioe));
- }
- // simply not found
- return NULL;
- }
-
- uno::Sequence<uno::Any> arguments(1) ;
- uno::Reference<io::XInputStream> stream( new OSLInputStreamWrapper(schemaFile, true) );
-
- arguments [0] <<= stream ;
- uno::Reference<backend::XSchema> schema(
- mFactory->createInstanceWithArguments(kXMLSchemaParser, arguments),
- uno::UNO_QUERY) ;
-
- if (!schema.is())
- {
- throw uno::RuntimeException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "Cannot instantiate Schema Parser for ")) + aComponent,
- *this) ;
- }
- return schema ;
-}
-//------------------------------------------------------------------------------
-
-static
-inline
-bool impl_getLayerSubDirectories(rtl::OUString const & aLayerBaseUrl,
- rtl::OUString& aMainLayerUrl,
- rtl::OUString& aSubLayerUrl)
-{
- if (!isValidFileURL(aLayerBaseUrl)) return false;
-
- aMainLayerUrl = aLayerBaseUrl + kDataSubPath ;
- aSubLayerUrl = aLayerBaseUrl + kLocalisedDataSubPath ;
- return true;
-}
-//------------------------------------------------------------------------------
-
-bool LocalSingleBackend::getLayerSubDirectories(rtl::OUString const & aLayerBaseUrl,
- rtl::OUString& aMainLayerUrl,
- rtl::OUString& aSubLayerUrl)
-{
- return impl_getLayerSubDirectories(aLayerBaseUrl,aMainLayerUrl,aSubLayerUrl);
-}
-//------------------------------------------------------------------------------
-
-bool LocalSingleBackend::getLayerDirectories(sal_Int32 aLayerIndex,
- rtl::OUString& aLayerUrl,
- rtl::OUString& aSubLayerUrl)
-{
- OSL_ASSERT(isValidEntity(aLayerIndex));
- rtl::OUString aLayerBaseUrl = (aLayerIndex == k_UserLayerEntity) ? mUserDataUrl : mDefaultDataUrls [entityToIndex(aLayerIndex)] ;
-
- return impl_getLayerSubDirectories(aLayerBaseUrl,aLayerUrl,aSubLayerUrl);
-}
-//------------------------------------------------------------------------------
-
-uno::Reference<backend::XLayer> LocalSingleBackend::createSimpleLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- rtl::OUString const & aComponentUrl)
-{
- SimpleLocalFileLayer * pLayer = new SimpleLocalFileLayer(xFactory, aComponentUrl);
- return pLayer;
-}
-//------------------------------------------------------------------------------
-
-uno::Reference<backend::XLayer> LocalSingleBackend::createSimpleLayer(
- const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- rtl::OUString const & aLayerBaseUrl,
- rtl::OUString const & aComponent)
-{
- rtl::OUString aLayerUrl, aSubLayerUrl;
- if (!impl_getLayerSubDirectories(aLayerBaseUrl,aLayerUrl,aSubLayerUrl))
- return NULL;
-
- SimpleLocalFileLayer * pLayer = new SimpleLocalFileLayer(xFactory, aLayerUrl, componentToPath(aComponent) + kDataSuffix);
- return pLayer;
-}
-//------------------------------------------------------------------------------
-
-
-uno::Reference<backend::XUpdatableLayer> LocalSingleBackend::getFileLayer(const rtl::OUString& aLayerId)
- throw (lang::IllegalArgumentException)
-{
- rtl::OUString fileUrl ;
- sal_Int32 defaultIndex = resolveLayerId(aLayerId, fileUrl) ;
-
- return getFileLayer(fileUrl, defaultIndex) ;
-}
-//------------------------------------------------------------------------------
-
-uno::Reference<backend::XUpdatableLayer> LocalSingleBackend::getFileLayer(
- const rtl::OUString& aComponent, sal_Int32 aLayerIndex) {
- rtl::OUString layerPath ;
- rtl::OUString subLayerPath ;
-
- if (!getLayerDirectories(aLayerIndex, layerPath, subLayerPath))
- {
- OSL_ENSURE(aLayerIndex == k_UserLayerEntity, "Unexpected: Invalid non-user layer url");
-
- rtl::OUStringBuffer sMsg;
- sMsg.appendAscii("LocalSingleBackend: Cannot create file layer - Layer URL '");
- sMsg.append(mUserDataUrl).appendAscii("' is invalid.");
-
- throw lang::IllegalArgumentException(sMsg.makeStringAndClear(),*this,1);
- }
-
- return createUpdatableLocalFileLayer(mFactory, layerPath, aComponent, subLayerPath) ;
-}
-//------------------------------------------------------------------------------
-
-static const sal_Char * const kImplementation =
- "com.sun.star.comp.configuration.backend.LocalSingleBackend" ;
-static const sal_Char * const kBackendService =
- "com.sun.star.configuration.backend.SingleBackend" ;
-static const sal_Char * const kLocalService =
- "com.sun.star.configuration.backend.LocalSingleBackend" ;
-
-static sal_Char const * kServiceNames [] = { kLocalService, 0, kBackendService, 0 } ;
-static const ServiceImplementationInfo kServiceInfo = { kImplementation, kServiceNames, kServiceNames + 2 } ;
-
-const ServiceRegistrationInfo *getLocalBackendServiceInfo()
-{ return getRegistrationInfo(&kServiceInfo) ; }
-
-uno::Reference<uno::XInterface> SAL_CALL
-instantiateLocalBackend(const uno::Reference< uno::XComponentContext >& xContext) {
- return *new LocalSingleBackend(xContext) ;
-}
-
-//------------------------------------------------------------------------------
-
-rtl::OUString SAL_CALL LocalSingleBackend::getImplementationName(void)
- throw (uno::RuntimeException)
-{
- return ServiceInfoHelper(&kServiceInfo).getImplementationName() ;
-}
-//------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL LocalSingleBackend::supportsService(
- const rtl::OUString& aServiceName)
- throw (uno::RuntimeException)
-{
- return ServiceInfoHelper(&kServiceInfo).supportsService(aServiceName);
-}
-//------------------------------------------------------------------------------
-
-uno::Sequence<rtl::OUString>
-SAL_CALL LocalSingleBackend::getSupportedServiceNames(void)
- throw (uno::RuntimeException)
-{
- return ServiceInfoHelper(&kServiceInfo).getSupportedServiceNames() ;
-}
-
-// ---------------------------------------------------------------------------------------
-
-} } // configmgr.localbe
diff --git a/configmgr/source/localbe/localsinglebackend.hxx b/configmgr/source/localbe/localsinglebackend.hxx
deleted file mode 100644
index 3a2968f0fcc2..000000000000
--- a/configmgr/source/localbe/localsinglebackend.hxx
+++ /dev/null
@@ -1,248 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localsinglebackend.hxx,v $
- * $Revision: 1.12 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_LOCALBE_LOCALSINGLEBACKEND_HXX_
-#define CONFIGMGR_LOCALBE_LOCALSINGLEBACKEND_HXX_
-
-#include <com/sun/star/configuration/backend/XSchemaSupplier.hpp>
-#include <com/sun/star/configuration/backend/XMultiLayerStratum.hpp>
-#include <com/sun/star/configuration/backend/XBackendEntities.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
-#include <com/sun/star/configuration/backend/CannotConnectException.hpp>
-#include <cppuhelper/compbase5.hxx>
-
-namespace configmgr { namespace localbe {
-
-namespace css = com::sun::star ;
-namespace uno = css::uno ;
-namespace lang = css::lang ;
-namespace backend = css::configuration::backend ;
-
-/**
- Implements the SingleBackend service for local file access.
- Layer identifiers in that backend are file URLs.
- */
-class LocalSingleBackend : public cppu::WeakComponentImplHelper5<backend::XSchemaSupplier, backend::XMultiLayerStratum, backend::XBackendEntities, lang::XInitialization, lang::XServiceInfo> {
- public :
- /**
- Service constructor from a service factory.
-
- @param xFactory service factory
- */
- LocalSingleBackend(const uno::Reference<uno::XComponentContext>& xContext) ;
-
- /** Destructor */
- ~LocalSingleBackend(void) ;
-
-
- // XInitialize
- virtual void SAL_CALL
- initialize( const uno::Sequence<uno::Any>& aParameters)
- throw (uno::RuntimeException, uno::Exception,
- css::configuration::InvalidBootstrapFileException,
- backend::CannotConnectException,
- backend::BackendSetupException);
-
- // XSchemaSupplier
- virtual uno::Reference<backend::XSchema> SAL_CALL
- getComponentSchema( const rtl::OUString& aComponent )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- // XMultiLayerStratum
- virtual uno::Sequence<rtl::OUString> SAL_CALL
- listLayerIds( const rtl::OUString& aComponent, const rtl::OUString& aEntity )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- virtual rtl::OUString SAL_CALL
- getUpdateLayerId( const rtl::OUString& aComponent, const rtl::OUString& aEntity )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- virtual uno::Reference<backend::XLayer> SAL_CALL
- getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- virtual uno::Sequence<uno::Reference<backend::XLayer> > SAL_CALL
- getLayers(const uno::Sequence<rtl::OUString>& aLayerIds,
- const rtl::OUString& aTimestamp)
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- virtual uno::Sequence<uno::Reference<backend::XLayer> > SAL_CALL
- getMultipleLayers(const uno::Sequence<rtl::OUString>& aLayerIds,
- const uno::Sequence<rtl::OUString>& aTimestamps)
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- virtual uno::Reference<backend::XUpdatableLayer> SAL_CALL
- getUpdatableLayer( const rtl::OUString& aLayerId )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- // XBackendEntities
- virtual rtl::OUString SAL_CALL
- getOwnerEntity( )
- throw (uno::RuntimeException);
-
- virtual rtl::OUString SAL_CALL
- getAdminEntity( )
- throw (uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL
- supportsEntity( const rtl::OUString& aEntity )
- throw (backend::BackendAccessException, uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL
- isEqualEntity( const rtl::OUString& aEntity, const rtl::OUString& aOtherEntity )
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException);
-
- // XServiceInfo
- virtual rtl::OUString SAL_CALL
- getImplementationName( )
- throw (uno::RuntimeException) ;
-
- virtual sal_Bool SAL_CALL
- supportsService( const rtl::OUString& aServiceName )
- throw (uno::RuntimeException) ;
-
- virtual uno::Sequence<rtl::OUString> SAL_CALL
- getSupportedServiceNames( )
- throw (uno::RuntimeException) ;
-
- public: // helpers for other implementation that need to use the same data
- /**
- Locates the main layer data and localized data directories in a layer directory hierarchy
- */
- static bool getLayerSubDirectories( rtl::OUString const & aLayerBaseUrl,
- rtl::OUString& aMainLayerUrl,
- rtl::OUString& aSubLayerUrl);
- /**
- Creates a simple readonly non-composite layer for a component in a base directory
- */
- static uno::Reference<backend::XLayer>
- createSimpleLayer(const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- rtl::OUString const & aLayerBaseUrl,
- rtl::OUString const & aComponent);
-
- /**
- Creates a simple readonly non-composite layer for a component in a given file
- */
- static uno::Reference<backend::XLayer>
- createSimpleLayer(const uno::Reference<lang::XMultiServiceFactory>& xFactory,
- rtl::OUString const & aComponentUrl);
- private :
- /** Service factory */
- uno::Reference<lang::XMultiServiceFactory> mFactory ;
- /** Mutex for resources protection */
- osl::Mutex mMutex ;
- /**
- Base of the schema data. Is a list to allow
- for multiple schema directories.
- */
- uno::Sequence<rtl::OUString> mSchemaDataUrls ;
- /**
- Base of the default data. Is a list to allow
- for multiple layers of default data.
- */
- uno::Sequence<rtl::OUString> mDefaultDataUrls ;
- /** Base of the user data */
- rtl::OUString mUserDataUrl ;
-
- /** special index for entity */
- sal_Int32 findEntity(rtl::OUString const & _aEntity);
- /** parse and translate layer-id */
- sal_Int32 resolveLayerId(rtl::OUString const & _aLayerId, rtl::OUString & _aFile);
-
- /**
- Builds a LocalFileLayer object given a layer id.
- Since the LocalFileLayer implements the various
- interfaces a layer can be accessed as, a few methods
- need one. This method handles the layer id mapping
- and the existence or not of sublayers.
-
- @param aLayerId layer id
- @return local file layer
- @throws com::sun::star::lang::IllegalArgumentException
- if the layer id is invalid.
- */
- uno::Reference<backend::XUpdatableLayer> getFileLayer(const rtl::OUString& aLayerId)
- throw (lang::IllegalArgumentException) ;
- /**
- Same as above, but using a component URL and layer index
- combination instead of a layer id (which encodes both).
-
- @param aComponent component URL
- @param aLayerIndex layer index
- @return local file layer
- */
- uno::Reference<backend::XUpdatableLayer> getFileLayer(const rtl::OUString& aComponent,
- sal_Int32 aLayerIndex) ;
- /**
- Maps a layer index (-1 for user layer, 0-x for defaults)
- to the appropriate layer and sublayers base directories.
-
- @param aLayerIndex layer index
- @param aLayerUrl layer base URL, filled on return
- @param aSubLayerUrl sublayer base URL, filled on return
- */
- bool getLayerDirectories(sal_Int32 aLayerIndex,
- rtl::OUString& aLayerUrl,
- rtl::OUString& aSubLayerUrl) ;
- /**
- Tells if a file is more recent than a given date.
- The date is formatted YYYYMMDDhhmmssZ.
-
- @param aComponent URL of the component to check
- @param aLayerIndex index of the layer involved (-1 = user)
- @param aTimestamp timestamp to check against
- @return sal_True if the file is more recent, sal_False otherwise
- */
- sal_Bool isMoreRecent(const rtl::OUString& aComponent,
- sal_Int32 aLayerId,
- const rtl::OUString& aTimestamp) ;
- } ;
-
-} } // configmgr.localbe
-
-#endif // CONFIGMGR_LOCALBE_LOCALSINGLEBACKEND_HXX_
diff --git a/configmgr/source/localbe/localsinglestratum.cxx b/configmgr/source/localbe/localsinglestratum.cxx
deleted file mode 100644
index 3cab41f6344b..000000000000
--- a/configmgr/source/localbe/localsinglestratum.cxx
+++ /dev/null
@@ -1,233 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localsinglestratum.cxx,v $
- * $Revision: 1.9 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "localsinglestratum.hxx"
-#include "localfilehelper.hxx"
-
-#ifndef CONFIGMGR_API_FACTORY_HXX_
-#include "confapifactory.hxx"
-#endif // CONFIGMGR_API_FACTORY_HXX_
-#include "serviceinfohelper.hxx"
-#include <rtl/ustrbuf.hxx>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp>
-
-namespace configmgr { namespace localbe {
-
-//==============================================================================
-
-static inline rtl::OUString getDataSubPath()
-{ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/data")); }
-
-static inline rtl::OUString getLocalisedDataSubPath()
-{ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/res")); }
-//------------------------------------------------------------------------------
-
-LocalSingleStratumBase::LocalSingleStratumBase(const uno::Reference<uno::XComponentContext>& xContext)
-: cppu::ImplInheritanceHelper1< LocalStratumBase, backend::XSingleLayerStratum >(xContext)
-{
-}
-//------------------------------------------------------------------------------
-
-LocalSingleStratumBase::~LocalSingleStratumBase() {}
-
-//------------------------------------------------------------------------------
-uno::Reference<backend::XLayer> SAL_CALL
- LocalSingleStratumBase::getLayer( const rtl::OUString& aComponent, const rtl::OUString& aTimestamp )
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
- return LocalStratumBase::getLayer(aComponent,aTimestamp);
-}
-//------------------------------------------------------------------------------
-uno::Reference<backend::XUpdatableLayer> SAL_CALL
- LocalSingleStratumBase::getUpdatableLayer(const rtl::OUString& aComponent)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- lang::NoSupportException, uno::RuntimeException)
-{
- if (aComponent.getLength() == 0){
- throw lang::IllegalArgumentException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "LocalSingleStratum:getLayer - no component specified")),
- *this, 0) ;
- }
- rtl::OUString const componentSubPath = componentToPath(aComponent) + getDataSuffix();
- return createUpdatableFileLayer( componentSubPath) ;
-}
-//------------------------------------------------------------------------------
-uno::Reference<backend::XUpdatableLayer> SAL_CALL
- LocalReadonlyStratum::getUpdatableLayer(const rtl::OUString& /*aComponent*/)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- lang::NoSupportException, uno::RuntimeException)
-{
- failReadonly();
- return 0;
-}
-uno::Reference<backend::XUpdatableLayer> SAL_CALL
- LocalResourceStratum::getUpdatableLayer(const rtl::OUString& /*aComponent*/)
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- lang::NoSupportException, uno::RuntimeException)
-{
- failReadonly();
- return 0;
-}
-//------------------------------------------------------------------------------
-static
-inline
-void impl_getLayerDataDirectory(rtl::OUString const & aLayerBaseUrl,
- rtl::OUString& aMainLayerUrl)
-{
- aMainLayerUrl = aLayerBaseUrl + getDataSubPath() ;
-}
-//------------------------------------------------------------------------------
-static
-inline
-void impl_getLayerResDirectory(rtl::OUString const & aLayerBaseUrl,
- rtl::OUString& aSubLayerUrl)
-{
- aSubLayerUrl = aLayerBaseUrl + getLocalisedDataSubPath() ;
-}
-//------------------------------------------------------------------------------
-
-void LocalSingleStratum::getLayerDirectories(rtl::OUString& aLayerUrl,
- rtl::OUString& aSubLayerUrl) const
-{
- impl_getLayerDataDirectory(getBaseUrl(),aLayerUrl);
- impl_getLayerResDirectory(getBaseUrl(),aSubLayerUrl);
-}
-//------------------------------------------------------------------------------
-
-void LocalDataStratum::getLayerDirectories(rtl::OUString& aLayerUrl,
- rtl::OUString& aSubLayerUrl) const
-{
- impl_getLayerDataDirectory(getBaseUrl(),aLayerUrl);
- aSubLayerUrl = rtl::OUString();
-}
-//------------------------------------------------------------------------------
-
-void LocalReadonlyStratum::getLayerDirectories(rtl::OUString& aLayerUrl,
- rtl::OUString& aSubLayerUrl) const
-{
- impl_getLayerDataDirectory(getBaseUrl(),aLayerUrl);
- aSubLayerUrl = rtl::OUString();
-}
-//------------------------------------------------------------------------------
-
-void LocalResourceStratum::adjustBaseURL(rtl::OUString& aBaseUrl)
-{
- impl_getLayerResDirectory(aBaseUrl,aBaseUrl);
-}
-//------------------------------------------------------------------------------
-
-void LocalResourceStratum::getLayerDirectories(rtl::OUString& aLayerUrl,
- rtl::OUString& aSubLayerUrl) const
-{
- aLayerUrl = rtl::OUString();
- aSubLayerUrl = getBaseUrl();
- // impl_getLayerResDirectory(getBaseUrl(),aSubLayerUrl);
-}
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-static const sal_Char * const kLegacyStratumImplementation =
- "com.sun.star.comp.configuration.backend.LocalSingleStratum" ;
-static const sal_Char * const kDataStratumImplementation =
- "com.sun.star.comp.configuration.backend.LocalStratum" ;
-static const sal_Char * const kReadonlyStratumImplementation =
- "com.sun.star.comp.configuration.backend.LocalReadonlyStratum" ;
-static const sal_Char * const kResourceStratumImplementation =
- "com.sun.star.comp.configuration.backend.LocalResourceStratum" ;
-static const sal_Char * const kBackendService =
- "com.sun.star.configuration.backend.SingleStratum" ;
-static const sal_Char * const kLocalService =
- "com.sun.star.configuration.backend.LocalSingleStratum" ;
-
-static sal_Char const * kServiceNames [] = { kLocalService, 0, kBackendService, 0 } ;
-static const ServiceImplementationInfo kLegacyStratumServiceInfo = { kLegacyStratumImplementation , kServiceNames, kServiceNames + 2 } ;
-static const ServiceImplementationInfo kDataStratumServiceInfo = { kDataStratumImplementation , kServiceNames, kServiceNames + 2 } ;
-static const ServiceImplementationInfo kReadonlyStratumServiceInfo = { kReadonlyStratumImplementation, kServiceNames, kServiceNames + 2 } ;
-static const ServiceImplementationInfo kResourceStratumServiceInfo = { kResourceStratumImplementation, kServiceNames, kServiceNames + 2 } ;
-
-const ServiceRegistrationInfo *getLocalLegacyStratumServiceInfo()
-{ return getRegistrationInfo(&kLegacyStratumServiceInfo) ; }
-
-const ServiceRegistrationInfo *getLocalDataStratumServiceInfo()
-{ return getRegistrationInfo(&kDataStratumServiceInfo) ; }
-
-const ServiceRegistrationInfo *getLocalReadonlyStratumServiceInfo()
-{ return getRegistrationInfo(&kReadonlyStratumServiceInfo) ; }
-
-const ServiceRegistrationInfo *getLocalResourceStratumServiceInfo()
-{ return getRegistrationInfo(&kResourceStratumServiceInfo) ; }
-
-uno::Reference<uno::XInterface> SAL_CALL
-instantiateLocalLegacyStratum(const uno::Reference< uno::XComponentContext >& xContext) {
- return *new LocalSingleStratum(xContext) ;
-}
-
-uno::Reference<uno::XInterface> SAL_CALL
-instantiateLocalDataStratum(const uno::Reference< uno::XComponentContext >& xContext) {
- return *new LocalDataStratum(xContext) ;
-}
-
-uno::Reference<uno::XInterface> SAL_CALL
-instantiateLocalReadonlyStratum(const uno::Reference< uno::XComponentContext >& xContext) {
- return *new LocalReadonlyStratum(xContext) ;
-}
-
-uno::Reference<uno::XInterface> SAL_CALL
-instantiateLocalResourceStratum(const uno::Reference< uno::XComponentContext >& xContext) {
- return *new LocalResourceStratum(xContext) ;
-}
-//------------------------------------------------------------------------------
-
-const ServiceImplementationInfo * LocalSingleStratum::getServiceInfoData() const
-{
- return &kLegacyStratumServiceInfo;
-}
-const ServiceImplementationInfo * LocalDataStratum::getServiceInfoData() const
-{
- return &kDataStratumServiceInfo;
-}
-const ServiceImplementationInfo * LocalReadonlyStratum::getServiceInfoData() const
-{
- return &kReadonlyStratumServiceInfo;
-}
-const ServiceImplementationInfo * LocalResourceStratum::getServiceInfoData() const
-{
- return &kResourceStratumServiceInfo;
-}
-//------------------------------------------------------------------------------
-// ---------------------------------------------------------------------------------------
-
-} } // configmgr.localsinglestratum
diff --git a/configmgr/source/localbe/localsinglestratum.hxx b/configmgr/source/localbe/localsinglestratum.hxx
deleted file mode 100644
index 5b2b81465c51..000000000000
--- a/configmgr/source/localbe/localsinglestratum.hxx
+++ /dev/null
@@ -1,150 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localsinglestratum.hxx,v $
- * $Revision: 1.7 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_LOCALBE_LOCALSINGLESTRATUM_HXX_
-#define CONFIGMGR_LOCALBE_LOCALSINGLESTRATUM_HXX_
-
-#include "localstratumbase.hxx"
-#include <com/sun/star/configuration/backend/XSingleLayerStratum.hpp>
-#include <cppuhelper/implbase1.hxx>
-
-namespace configmgr
-{
- namespace localbe
- {
-
-namespace css = com::sun::star ;
-namespace uno = css::uno ;
-namespace lang = css::lang ;
-namespace backend = css::configuration::backend ;
-
-/**
- Implements the SingleLayerStratum service for local file access.
- */
-class LocalSingleStratumBase : public cppu::ImplInheritanceHelper1< LocalStratumBase, backend::XSingleLayerStratum >
-{
-public :
- /**
- Service constructor from a service factory.
-
- @param xContext component context
- */
- LocalSingleStratumBase(const uno::Reference<uno::XComponentContext>& xContext) ;
-
- /** Destructor */
- ~LocalSingleStratumBase() ;
-
-
- // XSingleLayerStratum
- virtual uno::Reference<backend::XLayer> SAL_CALL
- getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- uno::RuntimeException) ;
-
- virtual uno::Reference<backend::XUpdatableLayer> SAL_CALL
- getUpdatableLayer( const rtl::OUString& aLayerId )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- lang::NoSupportException,
- uno::RuntimeException) ;
-
-} ;
-
-class LocalSingleStratum : public LocalSingleStratumBase
-{
-public:
- LocalSingleStratum(const uno::Reference<uno::XComponentContext>& xContext)
- : LocalSingleStratumBase(xContext)
- {};
-
-private:
- virtual void getLayerDirectories(rtl::OUString& aLayerUrl, rtl::OUString& aSubLayerUrl) const;
- virtual const ServiceImplementationInfo * getServiceInfoData() const;
-};
-
-class LocalDataStratum : public LocalSingleStratumBase
-{
-public:
- LocalDataStratum(const uno::Reference<uno::XComponentContext>& xContext)
- : LocalSingleStratumBase(xContext)
- {};
-
-private:
- virtual void getLayerDirectories(rtl::OUString& aLayerUrl, rtl::OUString& aSubLayerUrl) const;
- virtual const ServiceImplementationInfo * getServiceInfoData() const;
-};
-
-class LocalReadonlyStratum : public LocalSingleStratumBase
-{
-public:
- LocalReadonlyStratum(const uno::Reference<uno::XComponentContext>& xContext)
- : LocalSingleStratumBase(xContext)
- {};
-
- // XSingleLayerStratum - readonly implementation
- virtual uno::Reference<backend::XUpdatableLayer> SAL_CALL
- getUpdatableLayer( const rtl::OUString& aLayerId )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- lang::NoSupportException,
- uno::RuntimeException) ;
-
-private:
- virtual void getLayerDirectories(rtl::OUString& aLayerUrl, rtl::OUString& aSubLayerUrl) const;
- virtual const ServiceImplementationInfo * getServiceInfoData() const;
-};
-
-class LocalResourceStratum : public LocalSingleStratumBase
-{
-public:
- LocalResourceStratum(const uno::Reference<uno::XComponentContext>& xContext)
- : LocalSingleStratumBase(xContext)
- {};
-
- // XSingleLayerStratum - readonly implementation
- virtual uno::Reference<backend::XUpdatableLayer> SAL_CALL
- getUpdatableLayer( const rtl::OUString& aLayerId )
- throw (backend::BackendAccessException,
- lang::IllegalArgumentException,
- lang::NoSupportException,
- uno::RuntimeException) ;
-
-private:
- virtual void adjustBaseURL(rtl::OUString& aBaseURL);
- virtual void getLayerDirectories(rtl::OUString& aLayerUrl, rtl::OUString& aSubLayerUrl) const;
- virtual const ServiceImplementationInfo * getServiceInfoData() const;
-};
-
-
-
-} } // configmgr.localbe
-
-#endif
diff --git a/configmgr/source/localbe/localstratumbase.cxx b/configmgr/source/localbe/localstratumbase.cxx
deleted file mode 100644
index bbfb0384e134..000000000000
--- a/configmgr/source/localbe/localstratumbase.cxx
+++ /dev/null
@@ -1,256 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localstratumbase.cxx,v $
- * $Revision: 1.8 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_configmgr.hxx"
-
-#include "localstratumbase.hxx"
-#include "localfilehelper.hxx"
-#include "localfilelayer.hxx"
-#include "oslstream.hxx"
-#include "serviceinfohelper.hxx"
-#include "bootstrap.hxx"
-#include "filehelper.hxx"
-#include <rtl/ustrbuf.hxx>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/NoSupportException.hpp>
-#include <com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp>
-#include <osl/file.hxx>
-#include <osl/process.h>
-#include <memory>
-
-namespace configmgr { namespace localbe {
-
-//==============================================================================
-
-//------------------------------------------------------------------------------
-
-LocalStratumBase::LocalStratumBase(const uno::Reference<uno::XComponentContext>& xContext)
-: cppu::WeakComponentImplHelper3<lang::XInitialization, backend::XBackendEntities, lang::XServiceInfo>(mMutex)
-, mFactory(xContext->getServiceManager(),uno::UNO_QUERY)
-{
-}
-//------------------------------------------------------------------------------
-
-LocalStratumBase::~LocalStratumBase()
-{}
-
-//------------------------------------------------------------------------------
-void SAL_CALL LocalStratumBase::initialize(const uno::Sequence<uno::Any>& aParameters)
- throw (uno::RuntimeException, uno::Exception,
- css::configuration::InvalidBootstrapFileException,
- backend::CannotConnectException,
- backend::BackendSetupException)
-{
-
-
-
- if (aParameters.getLength() == 0)
- {
- throw lang::IllegalArgumentException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "No parameters provided to local Stratum")),
- *this, 0) ;
- }
-
-
- for (sal_Int32 i = 0 ; i < aParameters.getLength() ; ++ i)
- {
- if (aParameters [i] >>= mStrataDataUrl )
- { break ; }
-
- }
-
- // get modified base for special layer implementations (e.g. resources)
- this->adjustBaseURL(mStrataDataUrl);
-
- validateFileURL(mStrataDataUrl, *this);
- implEnsureAbsoluteURL(mStrataDataUrl);
- normalizeURL(mStrataDataUrl,*this, true);
-
- if(FileHelper::fileExists(mStrataDataUrl))
- {
- checkIfDirectory(mStrataDataUrl, *this);
- }
-}
-
-//------------------------------------------------------------------------------
-
-void LocalStratumBase::adjustBaseURL(rtl::OUString& )
-{
-}
-//------------------------------------------------------------------------------
-
-sal_Bool LocalStratumBase::isMoreRecent(const rtl::OUString& aFileUrl,
- const rtl::OUString& aTimestamp) {
- rtl::OUString layerUrl ;
- rtl::OUString subLayerUrl ;
-
- getLayerDirectories(layerUrl, subLayerUrl) ;
-
- return layerUrl.getLength() == 0 ||
- !BasicLocalFileLayer::getTimestamp(layerUrl + aFileUrl).equals( aTimestamp);
-}
-//------------------------------------------------------------------------------
-
-uno::Reference<backend::XLayer> SAL_CALL
- LocalStratumBase::getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp )
- throw (backend::BackendAccessException, lang::IllegalArgumentException,
- uno::RuntimeException)
-{
-
- if (aLayerId.getLength() == 0){
- throw lang::IllegalArgumentException(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "LocalStratum:getLayer - no LayerId specified")),
- *this, 0) ;
- }
- rtl::OUString const componentSubPath = layeridToPath(aLayerId) + getDataSuffix();
- if (!isMoreRecent(componentSubPath, aTimestamp)) { return NULL ; }
-
- return createReadonlyFileLayer(componentSubPath);
-}
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-rtl::OUString SAL_CALL LocalStratumBase::getOwnerEntity()
- throw (uno::RuntimeException)
-{
- return mStrataDataUrl ;
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString SAL_CALL LocalStratumBase::getAdminEntity()
- throw (uno::RuntimeException)
-{
- return rtl::OUString();
-}
-//------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL LocalStratumBase::supportsEntity( const rtl::OUString& aEntity )
- throw (backend::BackendAccessException, uno::RuntimeException)
-{
- if(mStrataDataUrl.getLength() == 0)
- {
- return false;
- }
- if (aEntity.getLength() == 0)
- {
- return false;
- }
- return isEqualEntity(mStrataDataUrl,aEntity);
-}
-//------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL LocalStratumBase::isEqualEntity(const rtl::OUString& aEntity, const rtl::OUString& aOtherEntity)
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException)
-{
- if (aEntity.getLength() == 0)
- {
- rtl::OUString const sMsg(RTL_CONSTASCII_USTRINGPARAM(
- "LocalSingleBackend - Invalid empty entity."));
-
- throw lang::IllegalArgumentException(sMsg, *this, 1);
- }
- if (aOtherEntity.getLength() == 0)
- {
- rtl::OUString const sMsg(RTL_CONSTASCII_USTRINGPARAM(
- "LocalSingleBackend - Invalid empty entity."));
-
- throw lang::IllegalArgumentException(sMsg, *this, 2);
- }
- rtl::OUString aNormalizedEntity(aEntity);
- normalizeURL(aNormalizedEntity,*this);
-
- rtl::OUString aNormalizedOther(aOtherEntity);
- normalizeURL(aNormalizedOther,*this);
-
- return aNormalizedEntity == aNormalizedOther;
-}
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-uno::Reference<backend::XLayer>
- LocalStratumBase::createReadonlyFileLayer(const rtl::OUString& aSubpath)
- throw (lang::IllegalArgumentException)
-{
- rtl::OUString layerPath ;
- rtl::OUString subLayerPath ;
-
- getLayerDirectories(layerPath, subLayerPath) ;
- return createReadonlyLocalFileLayer(mFactory, layerPath, aSubpath, subLayerPath) ;
-}
-//------------------------------------------------------------------------------
-uno::Reference<backend::XUpdatableLayer>
- LocalStratumBase::createUpdatableFileLayer(const rtl::OUString& aSubpath)
- throw (lang::IllegalArgumentException)
-{
- rtl::OUString layerPath ;
- rtl::OUString subLayerPath ;
-
- getLayerDirectories(layerPath, subLayerPath) ;
- return createUpdatableLocalFileLayer(mFactory, layerPath, aSubpath, subLayerPath) ;
-}
-//------------------------------------------------------------------------------
-
-rtl::OUString SAL_CALL LocalStratumBase::getImplementationName()
- throw (uno::RuntimeException)
-{
- return ServiceInfoHelper(getServiceInfoData()).getImplementationName() ;
-}
-//------------------------------------------------------------------------------
-
-sal_Bool SAL_CALL LocalStratumBase::supportsService(const rtl::OUString& aServiceName)
- throw (uno::RuntimeException)
-{
- return ServiceInfoHelper(getServiceInfoData()).supportsService(aServiceName);
-}
-//------------------------------------------------------------------------------
-
-uno::Sequence<rtl::OUString> SAL_CALL LocalStratumBase::getSupportedServiceNames()
- throw (uno::RuntimeException)
-{
- return ServiceInfoHelper(getServiceInfoData()).getSupportedServiceNames() ;
-}
-
-// ---------------------------------------------------------------------------------------
-
-void LocalStratumBase::failReadonly()
-{
- rtl::OUStringBuffer aMessage;
- aMessage.appendAscii("Configurations - ")
- .appendAscii("Cannot get update access to layer: ")
- .appendAscii("Local file-based stratum at ")
- .append(this->getBaseUrl())
- .appendAscii(" is readonly.");
- throw lang::NoSupportException(aMessage.makeStringAndClear(),*this);
-}
-//------------------------------------------------------------------------------
-
-} } // configmgr.localsinglestratum
diff --git a/configmgr/source/localbe/localstratumbase.hxx b/configmgr/source/localbe/localstratumbase.hxx
deleted file mode 100644
index 292f04be4937..000000000000
--- a/configmgr/source/localbe/localstratumbase.hxx
+++ /dev/null
@@ -1,202 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: localstratumbase.hxx,v $
- * $Revision: 1.4 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef CONFIGMGR_LOCALBE_LOCALSTRATUMBASE_HXX_
-#define CONFIGMGR_LOCALBE_LOCALSTRATUMBASE_HXX_
-
-#include <com/sun/star/configuration/backend/XBackendEntities.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/configuration/backend/XUpdatableLayer.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
-#include <com/sun/star/configuration/backend/CannotConnectException.hpp>
-#include <cppuhelper/compbase3.hxx>
-
-namespace configmgr
-{
- struct ServiceImplementationInfo;
-
- namespace localbe
- {
-//------------------------------------------------------------------------------
-
-namespace css = com::sun::star ;
-namespace uno = css::uno ;
-namespace lang = css::lang ;
-namespace backend = css::configuration::backend ;
-//------------------------------------------------------------------------------
-
-struct LocalStratumMutexHolder { osl::Mutex mMutex; };
-//------------------------------------------------------------------------------
-static const char kLocalDataSuffix[] = ".xcu";
-//------------------------------------------------------------------------------
-
-/**
- Helper for implementing the [Single|Multi]LayerStratum service for local file access.
- */
-class LocalStratumBase : protected LocalStratumMutexHolder, public cppu::WeakComponentImplHelper3<lang::XInitialization, backend::XBackendEntities, lang::XServiceInfo>
-{
-protected :
- /**
- Service constructor from a service factory.
-
- @param xContext component context
- */
- LocalStratumBase(const uno::Reference<uno::XComponentContext>& xContext) ;
-
- /** Destructor */
- ~LocalStratumBase() ;
-
-
-public:
- // XInitialize
- virtual void SAL_CALL
- initialize( const uno::Sequence<uno::Any>& aParameters)
- throw (uno::RuntimeException, uno::Exception,
- css::configuration::InvalidBootstrapFileException,
- backend::CannotConnectException,
- backend::BackendSetupException);
-
-
- // XBackendEntities
- virtual rtl::OUString SAL_CALL
- getOwnerEntity( )
- throw (uno::RuntimeException);
-
- virtual rtl::OUString SAL_CALL
- getAdminEntity( )
- throw (uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL
- supportsEntity( const rtl::OUString& aEntity )
- throw (backend::BackendAccessException, uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL
- isEqualEntity( const rtl::OUString& aEntity, const rtl::OUString& aOtherEntity )
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException);
-
- // XServiceInfo
- virtual rtl::OUString SAL_CALL
- getImplementationName( )
- throw (uno::RuntimeException);
-
- virtual sal_Bool SAL_CALL
- supportsService( const rtl::OUString& aServiceName )
- throw (uno::RuntimeException) ;
-
- virtual uno::Sequence<rtl::OUString> SAL_CALL
- getSupportedServiceNames( )
- throw (uno::RuntimeException) ;
-
-protected:
- rtl::OUString const & getBaseUrl() const
- { return mStrataDataUrl; }
-
- static rtl::OUString getDataSuffix()
- { return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(kLocalDataSuffix)); }
-//------------------------------------------------------------------------------
- /// raise a NoSupportException for an attempt to update this layer
- void failReadonly();
-
- // helper for implementing the stratum getLayer[s] function[s]
- uno::Reference<backend::XLayer> SAL_CALL
- getLayer( const rtl::OUString& aLayerId, const rtl::OUString& aTimestamp )
- throw (backend::BackendAccessException, lang::IllegalArgumentException, uno::RuntimeException);
-
- /**
- Builds a LocalFileLayer object given a subpath
- Since the LocalFileLayer implements the various
- interfaces a layer can be accessed as, a few methods
- need one.
-
- @param aSubpath Subpath
- @return local file layer
- @throws com::sun::star::lang::IllegalArgumentException
- if the subpath is invalid.
- */
- uno::Reference<backend::XLayer> createReadonlyFileLayer(const rtl::OUString& aSubpath)
- throw (lang::IllegalArgumentException) ;
-
- /**
- Builds a LocalFileLayer object given a subpath.
- Since the LocalFileLayer implements the various
- interfaces a layer can be accessed as, a few methods
- need one.
-
- @param aSubpath subpath
- @return local file layer
- @throws com::sun::star::lang::IllegalArgumentException
- if the subpath is invalid.
- */
- uno::Reference<backend::XUpdatableLayer> createUpdatableFileLayer(const rtl::OUString& aSubpath)
- throw (lang::IllegalArgumentException) ;
-
- /**
- Tells if a file is more recent than a given date.
- The date is formatted YYYYMMDDhhmmssZ.
-
- @param aSubpath relative URL of the component to check
- @param aTimestamp timestamp to check against
- @return sal_True if the file is more recent, sal_False otherwise
- */
- sal_Bool isMoreRecent(const rtl::OUString& aSubpath,
- const rtl::OUString& aTimestamp) ;
-
-protected:
- /// Parses and adjusts the passed base URL
- virtual void adjustBaseURL(rtl::OUString& aBaseURL);
-
-private:
- /**
- Retrieves the appropriate layer and sublayers base directories.
-
- @param aLayerUrl layer base URL, filled on return
- @param aSubLayerUrl sublayer base URL, filled on return
- */
- virtual void getLayerDirectories(rtl::OUString& aLayerUrl,
- rtl::OUString& aSubLayerUrl) const = 0;
- virtual const ServiceImplementationInfo * getServiceInfoData() const = 0;
-
-private :
- /** Service factory */
- uno::Reference<lang::XMultiServiceFactory> mFactory ;
- /**
- Base of the strata data.
- */
- rtl::OUString mStrataDataUrl ;
-
-} ;
-
-
-} } // configmgr.localbe
-
-#endif
diff --git a/configmgr/source/localbe/makefile.mk b/configmgr/source/localbe/makefile.mk
deleted file mode 100644
index 5462836be4d7..000000000000
--- a/configmgr/source/localbe/makefile.mk
+++ /dev/null
@@ -1,61 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2008 by Sun Microsystems, Inc.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# $RCSfile: makefile.mk,v $
-#
-# $Revision: 1.6 $
-#
-# This file is part of OpenOffice.org.
-#
-# OpenOffice.org is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License version 3
-# only, as published by the Free Software Foundation.
-#
-# OpenOffice.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License version 3 for more details
-# (a copy is included in the LICENSE file that accompanied this code).
-#
-# You should have received a copy of the GNU Lesser General Public License
-# version 3 along with OpenOffice.org. If not, see
-# <http://www.openoffice.org/license.html>
-# for a copy of the LGPLv3 License.
-#
-#*************************************************************************
-
-PRJ=..$/..
-PRJINC=$(PRJ)$/source$/inc
-PRJNAME=configmgr
-TARGET=localbe
-
-ENABLE_EXCEPTIONS=TRUE
-
-# --- Settings ----------------------------------
-
-.INCLUDE : settings.mk
-.INCLUDE : $(PRJ)$/makefile.pmk
-
-# --- Files -------------------------------------
-
-SLOFILES=\
- $(SLO)$/localsinglebackend.obj \
- $(SLO)$/localfilelayer.obj \
- $(SLO)$/localoutputstream.obj \
- $(SLO)$/localdataimportsvc.obj \
- $(SLO)$/localhierarchybrowsersvc.obj \
- $(SLO)$/localschemasupplier.obj \
- $(SLO)$/localstratumbase.obj \
- $(SLO)$/localsinglestratum.obj \
- $(SLO)$/localmultistratum.obj \
- $(SLO)$/localfilehelper.obj
-
-# --- Targets ----------------------------------
-
-.INCLUDE : target.mk
-