Kaydet (Commit) 2953e898 authored tarafından Ocke Janssen's avatar Ocke Janssen

#81131# check installed adabas dbs

üst a154ca89
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: adminpages.cxx,v $ * $RCSfile: adminpages.cxx,v $
* *
* $Revision: 1.19 $ * $Revision: 1.20 $
* *
* last change: $Author: kso $ $Date: 2000-12-01 08:06:01 $ * last change: $Author: oj $ $Date: 2000-12-07 14:15:42 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -128,9 +128,6 @@ ...@@ -128,9 +128,6 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#ifndef _UCBHELPER_CONTENT_HXX
#include <ucbhelper/content.hxx>
#endif
#ifndef _OSL_FILE_HXX_ #ifndef _OSL_FILE_HXX_
#include <osl/file.hxx> #include <osl/file.hxx>
#endif #endif
...@@ -488,36 +485,56 @@ IMPL_LINK(OGeneralPage, OnBrowseConnections, PushButton*, _pButton) ...@@ -488,36 +485,56 @@ IMPL_LINK(OGeneralPage, OnBrowseConnections, PushButton*, _pButton)
break; break;
case DST_ADABAS: case DST_ADABAS:
{ {
String sAdabasConfigDir; // collect all names from the config dir
const char* pAdabas = getenv("DBCONFIG"); // and all dir's of the DBWORK/wrk or DBROOT/wrk dir
if (pAdabas) // compare the names
sAdabasConfigDir.AssignAscii(pAdabas);
// collect the names of the installed databases
StringBag aInstalledDBs;
String sAdabasConfigDir,sAdabasWorkDir;
const char* pAdabasCfg = getenv("DBCONFIG");
const char* pAdabasWrk = getenv("DBWORK");
sal_Bool bOldFashion = sal_False;
if (pAdabasCfg && pAdabasWrk) // for our type of adabas this must apply
{
sAdabasConfigDir.AssignAscii(pAdabasCfg);
sAdabasWorkDir.AssignAscii(pAdabasWrk);
bOldFashion = sal_True;
}
else // we have a normal adabas installation else // we have a normal adabas installation
{ // so we check the local database names in $DBROOT/config { // so we check the local database names in $DBROOT/config
const char* pAdabasRoot = getenv("DBROOT"); const char* pAdabasRoot = getenv("DBROOT");
if (pAdabasRoot) if (pAdabasRoot)
{
sAdabasConfigDir.AssignAscii(pAdabasRoot); sAdabasConfigDir.AssignAscii(pAdabasRoot);
sAdabasWorkDir.AssignAscii(pAdabasRoot);
}
} }
if(sAdabasConfigDir.Len()) if(sAdabasConfigDir.Len() && sAdabasWorkDir.Len())
{ {
// collect the names of the installed databases
StringBag aInstalledDBs; aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir);
aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir);
if(!aInstalledDBs.size()) if(!aInstalledDBs.size() && bOldFashion)
{ {
const char* pAdabasRoot = getenv("DBROOT"); const char* pAdabasRoot = getenv("DBROOT");
if (pAdabasRoot) if (pAdabasRoot)
{ {
sAdabasConfigDir.AssignAscii(pAdabasRoot); sAdabasConfigDir.AssignAscii(pAdabasRoot);
aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir); sAdabasWorkDir.AssignAscii(pAdabasRoot);
aInstalledDBs = getInstalledAdabasDBs(sAdabasConfigDir,sAdabasWorkDir);
} }
} }
ODatasourceSelectDialog aSelector(GetParent(), aInstalledDBs, GetSelectedType()); ODatasourceSelectDialog aSelector(GetParent(), aInstalledDBs, GetSelectedType());
if (RET_OK == aSelector.Execute()) if (RET_OK == aSelector.Execute())
{ {
m_aConnection.SetTextNoPrefix(aSelector.GetSelected()); String aSelected;
aSelected.AssignAscii(":");
aSelected += aSelector.GetSelected();
m_aConnection.SetTextNoPrefix(aSelected);
callModifiedHdl(); callModifiedHdl();
} }
} }
...@@ -562,18 +579,48 @@ IMPL_LINK(OGeneralPage, OnBrowseConnections, PushButton*, _pButton) ...@@ -562,18 +579,48 @@ IMPL_LINK(OGeneralPage, OnBrowseConnections, PushButton*, _pButton)
return 0L; return 0L;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
StringBag OGeneralPage::getInstalledAdabasDBs(const String &_rPath) StringBag OGeneralPage::getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir)
{ {
INetURLObject aNormalizer; String sAdabasConfigDir(_rConfigDir),sAdabasWorkDir(_rWorkDir);
aNormalizer.SetSmartProtocol(INET_PROT_FILE);
aNormalizer.SetSmartURL(_rPath);
String sAdabasConfigDir = aNormalizer.GetMainURL();
if (sAdabasConfigDir.Len() && ('/' == sAdabasConfigDir.GetBuffer()[sAdabasConfigDir.Len() - 1])) if (sAdabasConfigDir.Len() && ('/' == sAdabasConfigDir.GetBuffer()[sAdabasConfigDir.Len() - 1]))
sAdabasConfigDir.AppendAscii("config"); sAdabasConfigDir.AppendAscii("config");
else else
sAdabasConfigDir.AppendAscii("/config"); sAdabasConfigDir.AppendAscii("/config");
if (sAdabasWorkDir.Len() && ('/' == sAdabasWorkDir.GetBuffer()[sAdabasWorkDir.Len() - 1]))
sAdabasWorkDir.AppendAscii("wrk");
else
sAdabasWorkDir.AppendAscii("/wrk");
// collect the names of the installed databases
StringBag aInstalledDBs;
// collect the names of the installed databases
StringBag aConfigDBs,aWrkDBs;
aConfigDBs = getInstalledAdabasDBDirs(sAdabasConfigDir,::ucb::INCLUDE_DOCUMENTS_ONLY);
aWrkDBs = getInstalledAdabasDBDirs(sAdabasWorkDir,::ucb::INCLUDE_FOLDERS_ONLY);
StringBag::const_iterator aOuter = aConfigDBs.begin();
for(;aOuter != aConfigDBs.end();++aOuter)
{
StringBag::const_iterator aInner = aWrkDBs.begin();
for(;aInner != aWrkDBs.end();++aInner)
{
if(*aInner == *aOuter)
{
aInstalledDBs.insert(*aOuter);
break;
}
}
}
return aInstalledDBs;
}
// -----------------------------------------------------------------------------
StringBag OGeneralPage::getInstalledAdabasDBDirs(const String &_rPath,const ::ucb::ResultSetInclude& _reResultSetInclude)
{
INetURLObject aNormalizer;
aNormalizer.SetSmartProtocol(INET_PROT_FILE);
aNormalizer.SetSmartURL(_rPath);
String sAdabasConfigDir = aNormalizer.GetMainURL();
::ucb::Content aAdabasConfigDir; ::ucb::Content aAdabasConfigDir;
try try
{ {
...@@ -581,7 +628,7 @@ StringBag OGeneralPage::getInstalledAdabasDBs(const String &_rPath) ...@@ -581,7 +628,7 @@ StringBag OGeneralPage::getInstalledAdabasDBs(const String &_rPath)
} }
catch(::com::sun::star::ucb::ContentCreationException&) catch(::com::sun::star::ucb::ContentCreationException&)
{ {
DBG_ERROR("OGeneralPage::OnBrowseConnections: could not create the UCB content for the adabas config directory!"); return StringBag();
} }
StringBag aInstalledDBs; StringBag aInstalledDBs;
...@@ -600,7 +647,7 @@ StringBag OGeneralPage::getInstalledAdabasDBs(const String &_rPath) ...@@ -600,7 +647,7 @@ StringBag OGeneralPage::getInstalledAdabasDBs(const String &_rPath)
try try
{ {
Reference< XResultSet > xFiles = aAdabasConfigDir.createCursor(aProperties, ::ucb::INCLUDE_DOCUMENTS_ONLY); Reference< XResultSet > xFiles = aAdabasConfigDir.createCursor(aProperties, _reResultSetInclude);
Reference< XRow > xRow(xFiles, UNO_QUERY); Reference< XRow > xRow(xFiles, UNO_QUERY);
xFiles->beforeFirst(); xFiles->beforeFirst();
while (xFiles->next()) while (xFiles->next())
...@@ -1776,6 +1823,9 @@ IMPL_LINK( OTableSubscriptionPage, OnRadioButtonClicked, Button*, pButton ) ...@@ -1776,6 +1823,9 @@ IMPL_LINK( OTableSubscriptionPage, OnRadioButtonClicked, Button*, pButton )
/************************************************************************* /*************************************************************************
* history: * history:
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.19 2000/12/01 08:06:01 kso
* #80644# - ::ucb::ContentCreationException -> ::com::sun::star::ucb::ContentCreationException
*
* Revision 1.18 2000/11/30 08:32:30 fs * Revision 1.18 2000/11/30 08:32:30 fs
* #80003# changed some sal_uInt16 to sal_Int32 (need some -1's) * #80003# changed some sal_uInt16 to sal_Int32 (need some -1's)
* *
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: adminpages.hxx,v $ * $RCSfile: adminpages.hxx,v $
* *
* $Revision: 1.15 $ * $Revision: 1.16 $
* *
* last change: $Author: fs $ $Date: 2000-11-30 08:32:30 $ * last change: $Author: oj $ $Date: 2000-12-07 14:15:42 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -98,6 +98,10 @@ ...@@ -98,6 +98,10 @@
#ifndef _DBAUI_COMMON_TYPES_HXX_ #ifndef _DBAUI_COMMON_TYPES_HXX_
#include "commontypes.hxx" #include "commontypes.hxx"
#endif #endif
#ifndef _UCBHELPER_CONTENT_HXX
#include <ucbhelper/content.hxx>
#endif
//......................................................................... //.........................................................................
namespace dbaui namespace dbaui
{ {
...@@ -212,7 +216,8 @@ protected: ...@@ -212,7 +216,8 @@ protected:
void initializeHistory(); void initializeHistory();
sal_Bool isBrowseable(DATASOURCE_TYPE _eType) const; sal_Bool isBrowseable(DATASOURCE_TYPE _eType) const;
StringBag getInstalledAdabasDBs(const String &_rPath); StringBag getInstalledAdabasDBDirs(const String &_rPath,const ::ucb::ResultSetInclude& _reResultSetInclude);
StringBag getInstalledAdabasDBs(const String &_rConfigDir,const String &_rWorkDir);
DECL_LINK(OnDatasourceTypeSelected, ListBox*); DECL_LINK(OnDatasourceTypeSelected, ListBox*);
DECL_LINK(OnBrowseConnections, PushButton*); DECL_LINK(OnBrowseConnections, PushButton*);
...@@ -460,6 +465,9 @@ private: ...@@ -460,6 +465,9 @@ private:
/************************************************************************* /*************************************************************************
* history: * history:
* $Log: not supported by cvs2svn $ * $Log: not supported by cvs2svn $
* Revision 1.15 2000/11/30 08:32:30 fs
* #80003# changed some sal_uInt16 to sal_Int32 (need some -1's)
*
* Revision 1.14 2000/11/29 22:29:40 fs * Revision 1.14 2000/11/29 22:29:40 fs
* #80003# implementation of the character set map changed * #80003# implementation of the character set map changed
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment