From 94c78bed2887089fdfb0c36f5b68b9c98bfd5a72 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 10 Jul 2009 14:03:42 +0200 Subject: #i103452#: replace PRODUCT by !DBG_UTIL; replace assert by OSL_ASSERT where possible --- desktop/source/app/app.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 8675d22e0aae..6ea00ca50559 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1348,7 +1348,7 @@ void Desktop::Main() else aTitle = aTitleString; -#ifndef PRODUCT +#ifdef DBG_UTIL //include version ID in non product builds ::rtl::OUString aDefault; aTitle += DEFINE_CONST_UNICODE(" ["); -- cgit From 2484e4f7faa1f052ff48d2192ffb5931a71faa8f Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Thu, 30 Jul 2009 09:37:08 +0200 Subject: more dependencies fixed --- desktop/prj/build.lst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst index 4b6a5664e3d8..2154169314c9 100644 --- a/desktop/prj/build.lst +++ b/desktop/prj/build.lst @@ -1,4 +1,4 @@ -dt desktop : l10n sfx2 stoc uui BERKELEYDB:berkeleydb sysui SO:sysui_so BOOST:boost svx xmlhelp NULL +dt desktop : l10n sfx2 stoc BERKELEYDB:berkeleydb sysui SO:sysui_so BOOST:boost svx xmlhelp NULL dt desktop usr1 - all dt_mkout NULL dt desktop\inc nmake - all dt_inc NULL dt desktop\prj get - all dt_prj NULL -- cgit From b8a58871dcc7e2398e95d518dff2f739712515e3 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Mon, 14 Sep 2009 19:06:55 +0200 Subject: #i103496#: split cppunit in a pure external lib and a lib depending on sal -> testshl2 --- desktop/qa/deployment_misc/makefile.mk | 6 +++--- desktop/qa/deployment_misc/test_dp_version.cxx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'desktop') diff --git a/desktop/qa/deployment_misc/makefile.mk b/desktop/qa/deployment_misc/makefile.mk index 39e80ddb1c76..f673f27e49cb 100644 --- a/desktop/qa/deployment_misc/makefile.mk +++ b/desktop/qa/deployment_misc/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # 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 @@ -42,7 +42,7 @@ DLLPRE = # no leading "lib" on .so files SHL1TARGET = $(TARGET) SHL1OBJS = $(SLO)$/test_dp_version.obj -SHL1STDLIBS = $(CPPUNITLIB) $(DEPLOYMENTMISCLIB) $(SALLIB) +SHL1STDLIBS = $(CPPUNITLIB) $(DEPLOYMENTMISCLIB) $(SALLIB) $(TESTSHL2LIB) SHL1VERSIONMAP = version.map SHL1IMPLIB = i$(SHL1TARGET) DEF1NAME = $(SHL1TARGET) @@ -54,4 +54,4 @@ SLOFILES = $(SHL1OBJS) ALLTAR: test test .PHONY: $(SHL1TARGETN) - testshl2 $(SHL1TARGETN) + $(TESTSHL2) $(SHL1TARGETN) diff --git a/desktop/qa/deployment_misc/test_dp_version.cxx b/desktop/qa/deployment_misc/test_dp_version.cxx index b1de394e0cd6..728ed52c37b1 100644 --- a/desktop/qa/deployment_misc/test_dp_version.cxx +++ b/desktop/qa/deployment_misc/test_dp_version.cxx @@ -35,7 +35,7 @@ #include -#include "cppunit/simpleheader.hxx" +#include "testshl/simpleheader.hxx" #include "rtl/ustring.h" #include "rtl/ustring.hxx" -- cgit From bff284e216792b8d2a4e498beaba806eeddf844a Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Tue, 6 Oct 2009 07:38:24 +0200 Subject: #103496#: move VCL free ConfigItems to unotools --- desktop/source/app/app.cxx | 10 +++++----- desktop/source/app/appinit.cxx | 6 +++--- desktop/source/app/langselect.cxx | 2 +- desktop/source/app/officeipcthread.cxx | 2 +- desktop/source/migration/pages.cxx | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 01691bdfdd6b..ec4ffbe957c1 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -114,14 +114,14 @@ #include #include #include -#include +#include #include #include #include #include -#include +#include #include -#include +#include #include #include #include @@ -149,7 +149,7 @@ #include #include #include -#include +#include #include "langselect.hxx" @@ -1400,7 +1400,7 @@ void Desktop::Main() if (IsFirstStartWizardNeeded()) { - ::svt::RegOptions().removeReminder(); // remove patch registration reminder + ::utl::RegOptions().removeReminder(); // remove patch registration reminder Reference< XJob > xFirstStartJob( xSMgr->createInstance( DEFINE_CONST_UNICODE( "com.sun.star.comp.desktop.FirstStart" ) ), UNO_QUERY ); if (xFirstStartJob.is()) diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index e87701b4addf..b81923a48d9c 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -75,9 +75,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #define DEFINE_CONST_OUSTRING(CONSTASCII) OUString(RTL_CONSTASCII_USTRINGPARAM(CONSTASCII)) diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index e9a39207cb50..114997b5d1f7 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -39,7 +39,7 @@ #include #endif #ifndef _SVTOOLS_PATHOPTIONS_HXX -#include +#include #endif #include #include diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index cb2856fb897d..6777bbd52fe6 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/desktop/source/migration/pages.cxx b/desktop/source/migration/pages.cxx index 80c5849ee4d9..6f9308f7885d 100644 --- a/desktop/source/migration/pages.cxx +++ b/desktop/source/migration/pages.cxx @@ -43,8 +43,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -546,7 +546,7 @@ sal_Bool RegistrationPage::commitPage( CommitPageReason _eReason ) { if ( _eReason == eFinish ) { - ::svt::RegOptions aOptions; + ::utl::RegOptions aOptions; rtl::OUString aEvent; if ( m_rbNow.IsChecked()) @@ -603,7 +603,7 @@ void RegistrationPage::prepareSingleMode() bool RegistrationPage::hasReminderDateCome() { - return ::svt::RegOptions().hasReminderDateCome(); + return ::utl::RegOptions().hasReminderDateCome(); } void RegistrationPage::executeSingleMode() @@ -620,7 +620,7 @@ void RegistrationPage::executeSingleMode() if ( eMode == RegistrationPage::rmNow || eMode == RegistrationPage::rmLater ) pPage->commitPage( IWizardPage::eFinish ); if ( eMode != RegistrationPage::rmLater ) - ::svt::RegOptions().removeReminder(); + ::utl::RegOptions().removeReminder(); } // ----------------------------------------------------------------------- -- cgit From 0d72425b5d030c5764d9564ce89110a2acb9de95 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 9 Oct 2009 17:52:08 +0200 Subject: #i103496#: cleaned up invalid build --- desktop/source/app/langselect.hxx | 4 ---- desktop/source/app/makefile.mk | 9 ++++----- desktop/source/migration/makefile.mk | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/langselect.hxx b/desktop/source/app/langselect.hxx index d0867529ab1b..b13e2e01a55a 100644 --- a/desktop/source/app/langselect.hxx +++ b/desktop/source/app/langselect.hxx @@ -33,10 +33,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include diff --git a/desktop/source/app/makefile.mk b/desktop/source/app/makefile.mk index 238685649cf9..ffaf68c0fbad 100644 --- a/desktop/source/app/makefile.mk +++ b/desktop/source/app/makefile.mk @@ -50,7 +50,6 @@ SHL1OBJS = \ $(SLO)$/appfirststart.obj \ $(SLO)$/appinit.obj \ $(SLO)$/appsys.obj \ - $(SLO)$/cfgfilter.obj \ $(SLO)$/checkinstall.obj \ $(SLO)$/check_ext_deps.obj \ $(SLO)$/cmdlineargs.obj \ @@ -62,12 +61,12 @@ SHL1OBJS = \ $(SLO)$/langselect.obj \ $(SLO)$/lockfile.obj \ $(SLO)$/lockfile2.obj \ - $(SLO)$/migration.obj \ $(SLO)$/officeipcthread.obj \ - $(SLO)$/pages.obj \ $(SLO)$/sofficemain.obj \ - $(SLO)$/userinstall.obj \ - $(SLO)$/wizard.obj + $(SLO)$/userinstall.obj + +SHL1LIBS = $(SLB)$/mig.lib + SHL1STDLIBS = \ $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ diff --git a/desktop/source/migration/makefile.mk b/desktop/source/migration/makefile.mk index d5aaf884ac5e..31af71f83fee 100644 --- a/desktop/source/migration/makefile.mk +++ b/desktop/source/migration/makefile.mk @@ -33,7 +33,6 @@ PRJ=..$/.. PRJNAME=desktop TARGET=mig -LIBTARGET=NO AUTOSEG=true ENABLE_EXCEPTIONS=TRUE -- cgit From 9f2fde7ab5de20926bb25a6b298b4e5dffb66eb2 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Fri, 16 Oct 2009 00:05:16 +0200 Subject: #i103496#: split svtools; improve ConfitItems --- desktop/source/app/app.cxx | 15 ++++++--------- desktop/source/app/cmdlineargs.cxx | 2 +- desktop/source/app/desktop.hrc | 2 +- desktop/source/app/langselect.hxx | 2 +- desktop/source/app/userinstall.cxx | 4 ++-- desktop/source/deployment/gui/dp_gui_autoscrolledit.cxx | 2 +- desktop/source/deployment/gui/dp_gui_autoscrolledit.hxx | 2 +- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 2 +- desktop/source/deployment/gui/license_dialog.cxx | 2 +- desktop/source/deployment/manager/dp_manager.cxx | 2 +- .../source/deployment/registry/component/dp_component.cxx | 2 +- .../registry/configuration/dp_configuration.cxx | 2 +- .../deployment/registry/executable/dp_executable.cxx | 2 +- desktop/source/deployment/registry/help/dp_help.cxx | 2 +- desktop/source/deployment/registry/package/dp_package.cxx | 2 +- desktop/source/deployment/registry/script/dp_script.cxx | 2 +- desktop/source/deployment/registry/sfwk/dp_sfwk.cxx | 2 +- desktop/source/inc/helpid.hrc | 2 +- desktop/source/migration/pages.hxx | 2 +- 19 files changed, 25 insertions(+), 28 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index ec4ffbe957c1..cdfca115cd8b 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -120,12 +120,13 @@ #include #include #include -#include +#include #include #include #include -#include -#include +#include +#include +#include #include #include #include @@ -147,7 +148,7 @@ #include #include #include -#include +#include #include #include @@ -1329,7 +1330,7 @@ void Desktop::Main() //LanguageSelection langselect; OUString aUILocaleString = LanguageSelection::getLanguageString(); Locale aUILocale = LanguageSelection::IsoStringToLocale(aUILocaleString); - LanguageType eLanguage = SvtSysLocaleOptions().GetLocaleLanguageType(); + LanguageType eLanguage = SvtSysLocale().GetLanguage(); // #i39040#, do not call anything between GetSettings and SetSettings that might have // a side effect on the settings (like, eg, SvtSysLocaleOptions().GetLocaleLanguageType(), @@ -1820,10 +1821,6 @@ void Desktop::SystemSettingsChanging( AllSettings& rSettings, Window* ) hStyleSettings.SetDragFullOptions( nDragFullOptions ); rSettings.SetStyleSettings ( hStyleSettings ); - - MiscSettings aMiscSettings( rSettings.GetMiscSettings() ); - aMiscSettings.SetTwoDigitYearStart( (USHORT) SfxMiscCfg().GetYear2000() ); - rSettings.SetMiscSettings( aMiscSettings ); } // ======================================================================== diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 0f1b62d707f2..5220d60bc02c 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -41,7 +41,7 @@ #include #include "tools/getprocessworkingdir.hxx" -#include +#include using namespace rtl; using namespace com::sun::star::lang; diff --git a/desktop/source/app/desktop.hrc b/desktop/source/app/desktop.hrc index 1edb20e58dd2..81110d665868 100644 --- a/desktop/source/app/desktop.hrc +++ b/desktop/source/app/desktop.hrc @@ -32,7 +32,7 @@ #define _DESKTOP_HRC_ #ifndef _SOLAR_HRC -#include +#include #endif #define RID_DESKTOP_DIALOG_START 2000 diff --git a/desktop/source/app/langselect.hxx b/desktop/source/app/langselect.hxx index b13e2e01a55a..e9753ae4ab73 100644 --- a/desktop/source/app/langselect.hxx +++ b/desktop/source/app/langselect.hxx @@ -36,7 +36,7 @@ #include #include #include -#include +#include namespace desktop { diff --git a/desktop/source/app/userinstall.cxx b/desktop/source/app/userinstall.cxx index 920da5613382..ccdeadbd7c53 100644 --- a/desktop/source/app/userinstall.cxx +++ b/desktop/source/app/userinstall.cxx @@ -50,9 +50,9 @@ #include #endif #include -#include +#include #ifndef _SVTOOLS_SYSLOCALEOPTIONSOPTIONS_HXX -#include +#include #endif #include #include diff --git a/desktop/source/deployment/gui/dp_gui_autoscrolledit.cxx b/desktop/source/deployment/gui/dp_gui_autoscrolledit.cxx index 7338a377de5d..9a0b76773f27 100644 --- a/desktop/source/deployment/gui/dp_gui_autoscrolledit.cxx +++ b/desktop/source/deployment/gui/dp_gui_autoscrolledit.cxx @@ -33,7 +33,7 @@ #include "svtools/svmedit2.hxx" -#include "svtools/lstner.hxx" +#include "svl/lstner.hxx" #include "svtools/xtextedt.hxx" #include "vcl/scrbar.hxx" diff --git a/desktop/source/deployment/gui/dp_gui_autoscrolledit.hxx b/desktop/source/deployment/gui/dp_gui_autoscrolledit.hxx index 98fa0050584a..3353bd42f04d 100644 --- a/desktop/source/deployment/gui/dp_gui_autoscrolledit.hxx +++ b/desktop/source/deployment/gui/dp_gui_autoscrolledit.hxx @@ -31,7 +31,7 @@ #define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_AUTOSCROLLEDIT_HXX #include "svtools/svmedit2.hxx" -#include "svtools/lstner.hxx" +#include "svl/lstner.hxx" namespace dp_gui { diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index f09d906a840e..b2620703a44a 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -34,7 +34,7 @@ #include "dp_gui.hrc" #include "svtools/controldims.hrc" -#include "svtools/svtools.hrc" +#include "svl/svtools.hrc" #include "dp_gui.h" #include "dp_gui_dialog2.hxx" diff --git a/desktop/source/deployment/gui/license_dialog.cxx b/desktop/source/deployment/gui/license_dialog.cxx index bbc6a983c1fd..9044f82b506d 100644 --- a/desktop/source/deployment/gui/license_dialog.cxx +++ b/desktop/source/deployment/gui/license_dialog.cxx @@ -43,7 +43,7 @@ #include "com/sun/star/lang/XServiceInfo.hpp" #include "com/sun/star/task/XJobExecutor.hpp" #include "svtools/svmedit.hxx" -#include "svtools/lstner.hxx" +#include "svl/lstner.hxx" #include "svtools/xtextedt.hxx" #include #include "vcl/threadex.hxx" diff --git a/desktop/source/deployment/manager/dp_manager.cxx b/desktop/source/deployment/manager/dp_manager.cxx index d7177f90dc77..f0635eec3d72 100644 --- a/desktop/source/deployment/manager/dp_manager.cxx +++ b/desktop/source/deployment/manager/dp_manager.cxx @@ -49,7 +49,7 @@ #include "comphelper/servicedecl.hxx" #include "comphelper/sequence.hxx" #include "xmlscript/xml_helper.hxx" -#include "svtools/inettype.hxx" +#include "svl/inettype.hxx" #include "com/sun/star/lang/DisposedException.hpp" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" #include "com/sun/star/beans/UnknownPropertyException.hpp" diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index e9f8a07a96ae..361004b353a3 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -45,7 +45,7 @@ #include "comphelper/servicedecl.hxx" #include "comphelper/sequence.hxx" #include "xmlscript/xml_helper.hxx" -#include "svtools/inettype.hxx" +#include "svl/inettype.hxx" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" #include "com/sun/star/container/XNameContainer.hpp" #include "com/sun/star/container/XHierarchicalNameAccess.hpp" diff --git a/desktop/source/deployment/registry/configuration/dp_configuration.cxx b/desktop/source/deployment/registry/configuration/dp_configuration.cxx index b24000d43dbb..b1c67f642efb 100644 --- a/desktop/source/deployment/registry/configuration/dp_configuration.cxx +++ b/desktop/source/deployment/registry/configuration/dp_configuration.cxx @@ -45,7 +45,7 @@ #include "comphelper/anytostring.hxx" #include "comphelper/servicedecl.hxx" #include "xmlscript/xml_helper.hxx" -#include "svtools/inettype.hxx" +#include "svl/inettype.hxx" #include "com/sun/star/ucb/NameClash.hpp" #include "com/sun/star/io/XActiveDataSink.hpp" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" diff --git a/desktop/source/deployment/registry/executable/dp_executable.cxx b/desktop/source/deployment/registry/executable/dp_executable.cxx index 3afcb8d35636..690549db0119 100644 --- a/desktop/source/deployment/registry/executable/dp_executable.cxx +++ b/desktop/source/deployment/registry/executable/dp_executable.cxx @@ -38,7 +38,7 @@ #include "osl/file.hxx" #include "ucbhelper/content.hxx" #include "comphelper/servicedecl.hxx" -#include "svtools/inettype.hxx" +#include "svl/inettype.hxx" #include "cppuhelper/implbase1.hxx" using namespace ::com::sun::star; diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index dd9e009e90cc..83fcd09d8da8 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -38,7 +38,7 @@ #include "osl/file.hxx" #include "ucbhelper/content.hxx" #include "comphelper/servicedecl.hxx" -#include "svtools/inettype.hxx" +#include "svl/inettype.hxx" #include #include diff --git a/desktop/source/deployment/registry/package/dp_package.cxx b/desktop/source/deployment/registry/package/dp_package.cxx index 14075d0fca38..1771cc93ec07 100644 --- a/desktop/source/deployment/registry/package/dp_package.cxx +++ b/desktop/source/deployment/registry/package/dp_package.cxx @@ -44,7 +44,7 @@ #include "cppuhelper/exc_hlp.hxx" #include "cppuhelper/implbase1.hxx" #include "ucbhelper/content.hxx" -#include "svtools/inettype.hxx" +#include "svl/inettype.hxx" #include "comphelper/anytostring.hxx" #include "comphelper/makesequence.hxx" #include "comphelper/sequence.hxx" diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx index ba8a972d0624..dbc644e60f44 100644 --- a/desktop/source/deployment/registry/script/dp_script.cxx +++ b/desktop/source/deployment/registry/script/dp_script.cxx @@ -40,7 +40,7 @@ #include "cppuhelper/exc_hlp.hxx" #include "cppuhelper/implbase1.hxx" #include "comphelper/servicedecl.hxx" -#include "svtools/inettype.hxx" +#include "svl/inettype.hxx" #include "com/sun/star/util/XUpdatable.hpp" #include "com/sun/star/script/XLibraryContainer.hpp" #include diff --git a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx index ff17da268dff..de515dd78372 100644 --- a/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx +++ b/desktop/source/deployment/registry/sfwk/dp_sfwk.cxx @@ -38,7 +38,7 @@ #include "ucbhelper/content.hxx" #include "cppuhelper/exc_hlp.hxx" #include "comphelper/servicedecl.hxx" -#include "svtools/inettype.hxx" +#include "svl/inettype.hxx" #include #include #include diff --git a/desktop/source/inc/helpid.hrc b/desktop/source/inc/helpid.hrc index f2d096460bed..c6c18e4bfc01 100644 --- a/desktop/source/inc/helpid.hrc +++ b/desktop/source/inc/helpid.hrc @@ -31,7 +31,7 @@ #if ! defined INCLUDED_DESKTOP_HELPID_HRC #define INCLUDED_DESKTOP_HELPID_HRC -#include "svtools/solar.hrc" +#include "svl/solar.hrc" #define HID_GLOBAL_FALLBACK 0xFFFFFFFF diff --git a/desktop/source/migration/pages.hxx b/desktop/source/migration/pages.hxx index 97d4282d1d76..b5e89860792c 100644 --- a/desktop/source/migration/pages.hxx +++ b/desktop/source/migration/pages.hxx @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include namespace desktop -- cgit From a822b5571761174e94563f53c8e55abf79c9f0b2 Mon Sep 17 00:00:00 2001 From: Mathias Bauer Date: Mon, 26 Oct 2009 15:10:09 +0100 Subject: #i103496#: shorten timespan when locale settings are inconsistent as they are stored at three different locations --- desktop/source/app/app.cxx | 6 ++++-- desktop/source/app/langselect.cxx | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index cdfca115cd8b..ea39fbbbd2b6 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -1324,7 +1324,9 @@ void Desktop::Main() } String aTitle = pLabelResMgr ? String( ResId( RID_APPTITLE, *pLabelResMgr ) ) : String(); delete pLabelResMgr; - +/* + // locale and UI locale in AppSettings are now retrieved from configuration or system directly via SvtSysLocale + // no reason to set while starting // set UI language and locale RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ set locale settings" ); //LanguageSelection langselect; @@ -1340,7 +1342,7 @@ void Desktop::Main() aSettings.SetLanguage( eLanguage ); Application::SetSettings( aSettings ); RTL_LOGFILE_CONTEXT_TRACE( aLog, "} set locale settings" ); - +*/ // Check for StarOffice/Suite specific extensions runs also with OpenOffice installation sets OUString aTitleString( aTitle ); diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index 114997b5d1f7..e8b50cdd295e 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -143,6 +143,18 @@ bool LanguageSelection::prepareLanguage() xProp->setPropertyValue(OUString::createFromAscii("ooLocale"), makeAny(aLocaleString)); Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges(); + MsLangId::setConfiguredSystemUILanguage( MsLangId::convertLocaleToLanguage(loc) ); + + OUString sLocale; + xProp->getPropertyValue(OUString::createFromAscii("ooSetupSystemLocale")) >>= sLocale; + if ( sLocale.getLength() ) + { + loc = LanguageSelection::IsoStringToLocale(aLocaleString); + MsLangId::setConfiguredSystemLanguage( MsLangId::convertLocaleToLanguage(loc) ); + } + else + MsLangId::setConfiguredSystemLanguage( MsLangId::getSystemLanguage() ); + bSuccess = sal_True; } catch ( PropertyVetoException& ) -- cgit From bbc0c51356ee72bdfda91fd229d9da69b741db65 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Fri, 27 Nov 2009 09:59:04 +0000 Subject: #161124# Update service tag sources --- .../com/sun/star/servicetag/BrowserSupport.java | 5 +- .../com/sun/star/servicetag/Installer.java | 7 +- .../star/servicetag/LinuxSystemEnvironment.java | 142 ++++++++++- .../com/sun/star/servicetag/RegistrationData.java | 5 +- .../sun/star/servicetag/RegistrationDocument.java | 7 +- .../com/sun/star/servicetag/Registry.java | 5 +- .../com/sun/star/servicetag/ServiceTag.java | 5 +- .../com/sun/star/servicetag/SolarisServiceTag.java | 5 +- .../star/servicetag/SolarisSystemEnvironment.java | 279 ++++++++++++++++++++- .../com/sun/star/servicetag/SunConnection.java | 5 +- .../sun/star/servicetag/SysnetRegistryHelper.java | 5 +- .../com/sun/star/servicetag/SystemEnvironment.java | 89 ++++++- .../servicetag/UnauthorizedAccessException.java | 5 +- .../registration/com/sun/star/servicetag/Util.java | 7 +- .../star/servicetag/WindowsSystemEnvironment.java | 98 +++++++- 15 files changed, 614 insertions(+), 55 deletions(-) (limited to 'desktop') diff --git a/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java b/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java index c97d5f2cd4f0..060ef6cb7f6d 100644 --- a/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java +++ b/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java @@ -6,9 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: BrowserSupport.java,v $ - * - * $Revision: 1.2 $ + * $RCSfile: Registration.java,v $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * diff --git a/desktop/source/registration/com/sun/star/servicetag/Installer.java b/desktop/source/registration/com/sun/star/servicetag/Installer.java index 02825dfec69d..e4daf959c19d 100644 --- a/desktop/source/registration/com/sun/star/servicetag/Installer.java +++ b/desktop/source/registration/com/sun/star/servicetag/Installer.java @@ -6,9 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: Installer.java,v $ - * - * $Revision: 1.2 $ + * $RCSfile: Registration.java,v $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * @@ -794,7 +793,7 @@ public class Installer { reader.close(); } - String resourceFilename = "/com/sun/star/servicetag/resources/register"; + String resourceFilename = "/com/sun/servicetag/resources/register"; for (Locale locale : supportedLocales) { String name = REGISTRATION_HTML_NAME; String resource = resourceFilename; diff --git a/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java index 90e38021c103..4129e440099f 100644 --- a/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java +++ b/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java @@ -6,9 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: LinuxSystemEnvironment.java,v $ - * - * $Revision: 1.2 $ + * $RCSfile: Registration.java,v $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * @@ -29,6 +28,7 @@ * ************************************************************************/ + package com.sun.star.servicetag; // The Service Tags team maintains the latest version of the implementation @@ -40,6 +40,7 @@ package com.sun.star.servicetag; // (e.g. NetBeans and SunStudio) will use the version in JDK. import java.io.*; +import java.util.*; /** * Linux implementation of the SystemEnvironment class. @@ -47,16 +48,25 @@ import java.io.*; class LinuxSystemEnvironment extends SystemEnvironment { LinuxSystemEnvironment() { setHostId(getLinuxHostId()); - setSystemModel(getCommandOutput("/bin/uname", "-i")); + + setSystemModel(getLinuxModel()); setSystemManufacturer(getLinuxSystemManufacturer()); setCpuManufacturer(getLinuxCpuManufacturer()); setSerialNumber(getLinuxSN()); + setPhysMem(getLinuxPhysMem()); + setSockets(getLinuxSockets()); + setCores(getLinuxCores()); + setVirtCpus(getLinuxVirtCpus()); + setCpuName(getLinuxCpuName()); + setClockRate(getLinuxClockRate()); } private String dmiInfo = null; + private String kstatCpuInfo = null; private static final int SN = 1; private static final int SYS = 2; private static final int CPU = 3; + private static final int MODEL = 4; private String getLinuxHostId() { String output = getCommandOutput("/usr/bin/hostid"); @@ -91,6 +101,21 @@ class LinuxSystemEnvironment extends SystemEnvironment { return getLinuxDMIInfo("dmi type 4", "manufacturer"); } + private String getLinuxModel() { + String tmp = getLinuxPSNInfo(MODEL); + if (tmp.length() > 0) { + return tmp + "::" + getCommandOutput("/bin/uname","-v"); + } + + tmp = getLinuxDMIInfo("dmi type 1", "product name"); + if (tmp.length() > 0) { + return tmp + "::" + getCommandOutput("/bin/uname","-v"); + } + + return getCommandOutput("/bin/uname","-i") + + "::" + getCommandOutput("/bin/uname","-v"); + } + /** * Tries to obtain and return the system manufacturer. @@ -158,7 +183,7 @@ class LinuxSystemEnvironment extends SystemEnvironment { dmidecodeThread.start(); try { - dmidecodeThread.join(2000); + dmidecodeThread.join(3000); if (dmidecodeThread.isAlive()) { dmidecodeThread.interrupt(); dmiInfo = ""; @@ -191,4 +216,111 @@ class LinuxSystemEnvironment extends SystemEnvironment { return ""; } + private String getLinuxClockRate() { + String contents = getFileContent("/proc/cpuinfo"); + String token = "cpu MHz"; + for (String line : contents.split("\n")) { + if (line.contains(token)) { + String[] key = line.split(":", 2); + if (key.length > 1) { + return key[1].trim(); + } + } + } + return ""; + } + + private String getLinuxCpuName() { + String contents = getFileContent("/proc/cpuinfo"); + String token = "model name"; + for (String line : contents.split("\n")) { + if (line.contains(token)) { + String[] key = line.split(":", 2); + if (key.length > 1) { + return key[1].trim(); + } + } + } + return ""; + } + + private String getLinuxVirtCpus() { + Set set = new HashSet(); + String contents = getFileContent("/proc/cpuinfo"); + String token = "processor"; + for (String line : contents.split("\n")) { + if (line.contains(token)) { + String[] key = line.split(":", 2); + if (key.length > 1) { + set.add(key[1].trim()); + } + } + } + return "" + set.size(); + } + + private String getLinuxCores() { + Set set = new HashSet(); + String contents = getFileContent("/proc/cpuinfo"); + String token = "core id"; + for (String line : contents.split("\n")) { + if (line.contains(token)) { + String[] key = line.split(":", 2); + if (key.length > 1) { + set.add(key[1].trim()); + } + } + } + if (set.size() == 0) { + return "1"; + } + return "" + set.size(); + } + + private String getLinuxPhysMem() { + String contents = getFileContent("/proc/meminfo"); + for (String line : contents.split("\n")) { + if (line.contains("MemTotal")) { + String[] total = line.split(":", 2); + if (total.length > 1) { + String[] mem = total[1].trim().split(" "); + if (mem.length >= 1) { + return mem[0].trim(); + } else { + return total[1].trim(); + } + } + } + } + + return ""; + } + + private String getLinuxSockets() { + Set physIdSet = new HashSet(); + Set procSet = new HashSet(); + String contents = getFileContent("/proc/cpuinfo"); + String physIdToken = "physical id"; + String procToken = "processor"; + + for (String line : contents.split("\n")) { + if (line.contains(physIdToken)) { + String[] key = line.split(":", 2); + if (key.length > 1) { + physIdSet.add(key[1].trim()); + } + } + + if (line.contains(procToken)) { + String[] key = line.split(":", 2); + if (key.length > 1) { + procSet.add(key[1].trim()); + } + } + } + if (physIdSet.size() != 0) { + return "" + physIdSet.size(); + } + return "" + procSet.size(); + } } diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java index 57be724a78a3..d32d852c8eeb 100644 --- a/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java +++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java @@ -6,9 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: RegistrationData.java,v $ - * - * $Revision: 1.2 $ + * $RCSfile: Registration.java,v $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java index 240eebf4e65c..1b95824bb836 100644 --- a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java +++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java @@ -6,9 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: RegistrationDocument.java,v $ - * - * $Revision: 1.2 $ + * $RCSfile: Registration.java,v $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * @@ -68,7 +67,7 @@ import javax.xml.transform.stream.StreamResult; class RegistrationDocument { private static final String REGISTRATION_DATA_SCHEMA = - "/com/sun/star/servicetag/resources/product_registration.xsd"; + "/com/sun/servicetag/resources/product_registration.xsd"; private static final String REGISTRATION_DATA_VERSION = "1.0"; private static final String SERVICE_TAG_VERSION = "1.0"; final static String ST_NODE_REGISTRATION_DATA = "registration_data"; diff --git a/desktop/source/registration/com/sun/star/servicetag/Registry.java b/desktop/source/registration/com/sun/star/servicetag/Registry.java index c118dc2e2575..81e4ed41142d 100644 --- a/desktop/source/registration/com/sun/star/servicetag/Registry.java +++ b/desktop/source/registration/com/sun/star/servicetag/Registry.java @@ -6,9 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: Registry.java,v $ - * - * $Revision: 1.2 $ + * $RCSfile: Registration.java,v $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * diff --git a/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java b/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java index 4b2be9ff8cc2..73e83b172008 100644 --- a/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java +++ b/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java @@ -6,9 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: ServiceTag.java,v $ - * - * $Revision: 1.2 $ + * $RCSfile: Registration.java,v $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * diff --git a/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java b/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java index 245b993b086e..8d38e70f8b7e 100644 --- a/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java +++ b/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java @@ -6,9 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: SolarisServiceTag.java,v $ - * - * $Revision: 1.2 $ + * $RCSfile: Registration.java,v $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * diff --git a/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java index 1ce5f5697bcb..684b8224d2af 100644 --- a/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java +++ b/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java @@ -6,9 +6,8 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: SolarisSystemEnvironment.java,v $ - * - * $Revision: 1.2 $ + * $RCSfile: Registration.java,v $ + * $Revision: 1.3 $ * * This file is part of OpenOffice.org. * @@ -40,17 +39,180 @@ package com.sun.star.servicetag; // (e.g. NetBeans and SunStudio) will use the version in JDK. import java.io.*; +import java.util.Set; +import java.util.HashSet; /** * Solaris implementation of the SystemEnvironment class. */ class SolarisSystemEnvironment extends SystemEnvironment { + private static final int SN = 1; + private static final int SYS = 2; + private static final int CPU = 3; + private static final int MODEL = 4; + private String kstatCpuInfo = null; + SolarisSystemEnvironment() { setHostId(getCommandOutput("/usr/bin/hostid")); - setSystemModel(getCommandOutput("/usr/bin/uname", "-i")); + setSystemModel(getSolarisModel()); setSystemManufacturer(getSolarisSystemManufacturer()); setCpuManufacturer(getSolarisCpuManufacturer()); setSerialNumber(getSolarisSN()); + setPhysMem(getSolarisPhysMem()); + setSockets(getSolarisSockets()); + setCores(getSolarisCores()); + setVirtCpus(getSolarisVirtCpus()); + setCpuName(getSolarisCpuName()); + setClockRate(getSolarisClockRate()); + } + + private String getSolarisClockRate() { + String data = getSolarisKstatCpuInfo(); + + String lines[] = data.split("\n"); + String token = "clock_MHz"; + for (int i=0; i set = new HashSet(); + String lines[] = data.split("\n"); + String coreIdToken = "core_id"; + String coreId = ""; + String chipIdToken = "chip_id"; + String chipId = ""; + for (int i=0; i set = new HashSet(); + String lines[] = data.split("\n"); + String token = "chip_id"; + for (int i=0; i 0) { + String[] lines = tmp.split("\n"); + if (MODEL <= lines.length) { + return lines[MODEL-1] + "::" + + getCommandOutput("/usr/bin/uname", "-v"); + } + } + + if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) { + return getCommandOutput("/usr/bin/uname", "-i") + "::" + + getCommandOutput("/usr/bin/uname", "-v"); + } else { + String model = getSmbiosData("1", "Product: "); + if (model == null || model.trim().equals("")) { + model = getCommandOutput("/usr/bin/uname", "-i"); + } + if (model == null) { + model = ""; + } + return model.trim() + "::" + + getCommandOutput("/usr/bin/uname", "-v"); + } } /** @@ -58,13 +220,21 @@ class SolarisSystemEnvironment extends SystemEnvironment { * @return The cpu manufacturer (an empty string if not found or an error occurred) */ private String getSolarisCpuManufacturer() { + String tmp = getFileContent("/var/run/psn"); + if (tmp.length() > 0) { + String[] lines = tmp.split("\n"); + if (CPU <= lines.length) { + return lines[CPU-1]; + } + } + // not fully accurate, this could be another manufacturer (fujitsu for example) if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) { return "Sun Microsystems, Inc"; } - // if we're here, then we'll try smbios (type 3) - return getSmbiosData("3", "Manufacturer: "); + // if we're here, then we'll try smbios (type 4) + return getSmbiosData("4", "Manufacturer: "); } /** @@ -72,8 +242,19 @@ class SolarisSystemEnvironment extends SystemEnvironment { * @return The system manufacturer (an empty string if not found or an error occurred) */ private String getSolarisSystemManufacturer() { + String tmp = getFileContent("/var/run/psn"); + if (tmp.length() > 0) { + String[] lines = tmp.split("\n"); + if (SYS <= lines.length) { + return lines[SYS-1]; + } + } + // not fully accurate, this could be another manufacturer (fujitsu for example) if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) { + if (getCommandOutput("/usr/bin/uname", "-m").equals("sun4us")) { + return "Fujitsu"; + } return "Sun Microsystems, Inc"; } @@ -89,7 +270,10 @@ class SolarisSystemEnvironment extends SystemEnvironment { // try to read from the psn file if it exists String tmp = getFileContent("/var/run/psn"); if (tmp.length() > 0) { - return tmp.trim(); + String[] lines = tmp.split("\n"); + if (SN <= lines.length) { + return lines[SN-1]; + } } // if we're here, then we'll try sneep @@ -110,6 +294,17 @@ class SolarisSystemEnvironment extends SystemEnvironment { return tmpSN; } + if ("sparc".equalsIgnoreCase(System.getProperty("os.arch"))) { + tmpSN = getSNViaPrtfruX(); + if (tmpSN.length() > 0) { + return tmpSN; + } + tmpSN = getSNViaPrtfru(); + if (tmpSN.length() > 0) { + return tmpSN; + } + } + // give up and return return ""; } @@ -156,4 +351,74 @@ class SolarisSystemEnvironment extends SystemEnvironment { } } + private String getSNViaPrtfruX() { + String data = getCommandOutput("/usr/sbin/prtfru", "-x"); + + boolean FRUTREE_FLAG = false; + boolean FRUNAME_FLAG = false; + boolean MB_LABEL_FLAG = false; + boolean SYSTEM_BOARD_FLAG = false; + + String lines[] = data.split("\n"); + for (int i=0; i 0) { + return vals[0].trim(); + } + break; + } + } + + if (line.indexOf("") != -1) { + FRUTREE_FLAG = false; + FRUNAME_FLAG = false; + SYSTEM_BOARD_FLAG = false; + } + + if (FRUNAME_FLAG && line.indexOf("") != -1 ) { + SYSTEM_BOARD_FLAG = true; + } + + if (FRUTREE_FLAG && line.indexOf("") != -1 ) { + FRUNAME_FLAG = true; + } + + if (line.indexOf("") != -1) { + FRUTREE_FLAG = true; + } + } + + return ""; + } + + private String getSNViaPrtfru() { + String data = getCommandOutput("/usr/sbin/prtfru"); + boolean CHASSIS_FLAG = false; + + String lines[] = data.split("\n"); + for (int i=0; i set = new HashSet(); + for (String line : res.split("\n")) { + line = line.trim(); + if (line.equals("")) { + continue; + } + set.add(line); + } + if (set.size() == 0) { + return "1"; + } + return "" + set.size(); + } + + private String getWindowsPhysMem() { + String mem = getWmicResult("computersystem", "get", "TotalPhysicalMemory"); + long l = Long.parseLong(mem); + return "" + ((long) (l / (1024*1024))); + } + /** * This method invokes wmic outside of the normal environment @@ -142,4 +188,48 @@ class WindowsSystemEnvironment extends SystemEnvironment { } return res.trim(); } + + private String getFullWmicResult(String alias, String verb, String property) { + String res = ""; + BufferedReader in = null; + try { + ProcessBuilder pb = new ProcessBuilder("cmd", "/C", "WMIC", alias, verb, property); + Process p = pb.start(); + // need this for executing windows commands (at least + // needed for executing wmic command) + BufferedWriter bw = new BufferedWriter( + new OutputStreamWriter(p.getOutputStream())); + bw.write(13); + bw.flush(); + bw.close(); + + p.waitFor(); + if (p.exitValue() == 0) { + in = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line = null; + while ((line = in.readLine()) != null) { + line = line.trim(); + if (line.length() == 0) { + continue; + } + if (line.toLowerCase().indexOf(property.toLowerCase()) != -1) { + continue; + } + res += line + "\n"; + } + } + + } catch (Exception e) { + // ignore the exception + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + // ignore + } + } + } + return res; + } } -- cgit From 4068d2bc8d7acba8a45e33a54cf80e3c6ff9de81 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 3 Dec 2009 09:35:18 +0000 Subject: #161124# Update service tag implementation for additional fields --- .../com/sun/star/servicetag/RegistrationData.java | 1003 +++++++++++--------- .../sun/star/servicetag/RegistrationDocument.java | 783 +++++++-------- .../servicetag/resources/product_registration.xsd | 667 +++++++------ 3 files changed, 1307 insertions(+), 1146 deletions(-) (limited to 'desktop') diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java index d32d852c8eeb..c58d83a33dd8 100644 --- a/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java +++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java @@ -1,472 +1,531 @@ -/************************************************************************* - * - * 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: Registration.java,v $ - * $Revision: 1.3 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.servicetag; - -import java.io.*; -import java.net.UnknownHostException; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -import static com.sun.star.servicetag.RegistrationDocument.*; - -/** - * A {@code RegistrationData} object is a container of one or more - * {@link #getServiceTags service tags} that identify the - * components for product registration. - * Each {@code RegistrationData} object has a {@link #getRegistrationURN - * uniform resource name} (URN) as its identifier. - * - * It also has an environment map with - * the following elements: - *
- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
hostnameHostname of the systeme.g. woody
hostIdHost ID of the systeme.g. 83abc1ab
osNameOperating system name e.g. SunOS
osVersionOperating system version e.g. 5.10
osArchitectureOperating system architecture e.g. sparc
systemModelSystem model e.g. SUNW,Sun-Fire-V440
systemManufacturerSystem manufacturer e.g. Sun Microsystems
cpuManufacturerCPU manufacturer e.g. Sun Microsystems
serialNumberSystem serial number e.g. BEL078932
- *
- * The hostname and osName element must have a non-empty value. - * If an element is not available on a system and their value will be - * empty. - *

- * - * Registration XML Schema - *

- * A {@code RegistrationData} object can be {@link #loadFromXML loaded} from - * and {@link #storeToXML stored} into an XML file in the format described - * by the - * - * registration data schema. The registration data schema is defined by the - * Service Tags Technology. - *

- * Typically the registration data is constructed at installation time - * and stored in an XML file for later service tag lookup or registration. - * - *

- * Example Usage - *

- * The examples below show how the {@code RegistrationData} can be - * used for product registration. - * Exception handling is not shown in these examples for clarity. - *

    - *
  1. This example shows how the JDK creates a JDK service tag, installs it - * in the system service tag registry and adds it to the registration data. - *
    - *
    - *   // create a service tag object with an instance_urn
    - *   ServiceTag st = ServiceTag.newInstance(ServiceTag.generateInstanceURN(),
    - *                                          ....);
    - *   // Adds to the system service tag registry if supported
    - *   if (Registry.isSupported()) {
    - *       Registry.getSystemRegistry().addServiceTag(st);
    - *   }
    - *
    - *   // add to the registration data
    - *   RegistrationData registration  = new RegistrationData();
    - *   registration.addServiceTag(st);
    - * 
    - *
  2. - *
  3. At this point, the registration data is ready to - * send to Sun Connection for registration. This example shows how to register - * the JDK via the Registration Relay Service. - *

    - * There are several registration services for Sun Connection. For example, - * the - * Registration Relay Service is a web application interface that - * processes the registration data payload sent via HTTP post - * and hosts the registration user interface for a specified - * registration URL. Refer to the - * Registration Relay Service Specification for details. - *

    - *

    - *   // Open the connection to the URL of the registration service
    - *   HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
    - *   con.setDoInput(true);
    - *   con.setDoOutput(true);
    - *   con.setUseCaches(false);
    - *   con.setAllowUserInteraction(false);
    - *   con.setRequestMethod("POST");
    - *   con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\"");
    - *   con.connect();
    - *
    - *   // send the registration data to the registration service
    - *   OutputStream out = con.getOutputStream();
    - *   registration.storeToXML(out);
    - *   out.close();
    - * 
    - *
  4. - *
  5. This example shows how to store the registration data in an XML file. - * for later service tag lookup or registration. - *
    - *
    - *   BufferedOutputStream out = new BufferedOutputStream(
    - *       new FileOutputStream(""<JAVA_HOME>/lib/servicetag/registration.xml"));
    - *   registration.storeToXML(out);
    - *   out.close();
    - * 
    - *
  6. - *
  7. This example shows how to install service tags that are in the - * registration data in the system service tag registry when determined - * to be available. The system service tag registry might not have existed - * when the registration data was constructed. - *
    - *
    - *   if (Registry.isSupported()) {
    - *       Set<ServiceTag> svctags = registration.getServiceTags();
    - *       for (ServiceTag st : svctags) {
    - *           Registry.getSystemRegistry().addServiceTag(st);
    - *       }
    - *   }
    - * 
    - *
  8. - *
- * - * @see Sun Connection Inventory Channel - */ -public class RegistrationData { - private final Map environment; - private final Map svcTagMap; - private final String urn; - - /** - * Creates a {@code RegistrationData} object with a generated - * {@link #getRegistrationURN registration URN}. - * The following keys in the {@link #getEnvironmentMap environment map} - * will be initialized for the configuration of the - * running system: - *
- * hostname, osName, osVersion and - * osArchitecture - *
- * and the value of other keys may be empty. - */ - public RegistrationData() { - this(Util.generateURN()); - } - - // package private - RegistrationData(String urn) { - this.urn = urn; - this.environment = initEnvironment(); - this.svcTagMap = new LinkedHashMap(); - } - - private Map initEnvironment() { - Map map = new LinkedHashMap(); - SystemEnvironment sysEnv = SystemEnvironment.getSystemEnvironment(); - map.put(ST_NODE_HOSTNAME, sysEnv.getHostname()); - map.put(ST_NODE_HOST_ID, sysEnv.getHostId()); - map.put(ST_NODE_OS_NAME, sysEnv.getOsName()); - map.put(ST_NODE_OS_VERSION, sysEnv.getOsVersion()); - map.put(ST_NODE_OS_ARCH, sysEnv.getOsArchitecture()); - map.put(ST_NODE_SYSTEM_MODEL, sysEnv.getSystemModel()); - map.put(ST_NODE_SYSTEM_MANUFACTURER, sysEnv.getSystemManufacturer()); - map.put(ST_NODE_CPU_MANUFACTURER, sysEnv.getCpuManufacturer()); - map.put(ST_NODE_SERIAL_NUMBER, sysEnv.getSerialNumber()); - return map; - } - - /** - * Returns the uniform resource name of this registration data - * in this format: - * urn:st:<32-char {@link java.util.UUID uuid}> - * - * @return the URN of this registration data. - */ - public String getRegistrationURN() { - return urn; - } - - /** - * Returns a map containing the environment information for this - * registration data. See the set of keys - * in the environment map. Subsequent update to the environment - * map via the {@link #setEnvironment setEnvironment} method will not be reflected - * in the returned map. - * - * @return an environment map for this registration data. - */ - public Map getEnvironmentMap() { - return new LinkedHashMap(environment); - } - - /** - * Sets an element of the specified {@code name} in the environment map - * with the given {@code value}. - * - * @throws IllegalArgumentException if {@code name} is not a valid key - * in the environment map, or {@code value} is not valid. - */ - public void setEnvironment(String name, String value) { - if (name == null) { - throw new NullPointerException("name is null"); - } - if (value == null) { - throw new NullPointerException("value is null"); - } - if (environment.containsKey(name)) { - if (name.equals(ST_NODE_HOSTNAME) || name.equals(ST_NODE_OS_NAME)) { - if (value.length() == 0) { - throw new IllegalArgumentException("\"" + - name + "\" requires non-empty value."); - } - } - environment.put(name, value); - } else { - throw new IllegalArgumentException("\"" + - name + "\" is not an environment element."); - } - } - - /** - * Returns all service tags in this registration data. - * - * @return a {@link Set Set} of the service tags - * in this registration data. - */ - public Set getServiceTags() { - return new HashSet(svcTagMap.values()); - } - - /** - * Adds a service tag to this registration data. - * If the given service tag has an empty instance_urn, - * this method will generate a URN and place it in the copy - * of the service tag in this registration data. - * This method will return the {@code ServiceTag} object - * added to this registration data. - * - * @param st {@code ServiceTag} object to be added. - * @return a {@code ServiceTag} object added to this registration data. - * - * @throws IllegalArgumentException if - * a service tag of the same {@link ServiceTag#getInstanceURN - * instance_urn} already exists in the registry. - */ - public synchronized ServiceTag addServiceTag(ServiceTag st) { - ServiceTag svcTag = ServiceTag.newInstanceWithUrnTimestamp(st); - - String instanceURN = svcTag.getInstanceURN(); - if (svcTagMap.containsKey(instanceURN)) { - throw new IllegalArgumentException("Instance_urn = " + instanceURN + - " already exists in the registration data."); - } else { - svcTagMap.put(instanceURN, svcTag); - } - return svcTag; - } - - /** - * Returns a service tag of the given instance_urn in this registration - * data. - * - * @param instanceURN the instance_urn of the service tag - * @return the {@code ServiceTag} object of the given instance_urn - * if exists; otherwise return {@code null}. - */ - public synchronized ServiceTag getServiceTag(String instanceURN) { - if (instanceURN == null) { - throw new NullPointerException("instanceURN is null"); - } - return svcTagMap.get(instanceURN); - } - - /** - * Removes a service tag of the given instance_urn from this - * registration data. - * - * @param instanceURN the instance_urn of - * the service tag to be removed. - * - * @return the removed {@code ServiceTag} object; - * or {@code null} if the service tag does not exist in this - * registration data. - */ - public synchronized ServiceTag removeServiceTag(String instanceURN) { - if (instanceURN == null) { - throw new NullPointerException("instanceURN is null"); - } - - ServiceTag svcTag = null; - if (svcTagMap.containsKey(instanceURN)) { - svcTag = svcTagMap.remove(instanceURN); - } - return svcTag; - } - - /** - * Updates the product_defined_instance_id in the service tag - * of the given instance_urn in this registration data. - * - * @param instanceURN the instance_urn of the service tag to be updated. - * @param productDefinedInstanceID the value of the - * product_defined_instance_id to be set. - * - * @return the updated {@code ServiceTag} object; - * or {@code null} if the service tag does not exist in this - * registration data. - */ - public synchronized ServiceTag updateServiceTag(String instanceURN, - String productDefinedInstanceID) { - ServiceTag svcTag = getServiceTag(instanceURN); - if (svcTag == null) { - return null; - } - - svcTag = ServiceTag.newInstanceWithUrnTimestamp(svcTag); - // update the product defined instance ID field - svcTag.setProductDefinedInstanceID(productDefinedInstanceID); - svcTagMap.put(instanceURN, svcTag); - return svcTag; - } - - /** - * Reads the registration data from the XML document on the - * specified input stream. The XML document must be - * in the format described by the - * registration data schema. - * The specified stream is closed after this method returns. - * - * @param in the input stream from which to read the XML document. - * @return a {@code RegistrationData} object read from the input - * stream. - * - * @throws IllegalArgumentException if the input stream - * contains an invalid registration data. - * - * @throws IOException if an error occurred when reading from the input stream. - */ - public static RegistrationData loadFromXML(InputStream in) throws IOException { - try { - return RegistrationDocument.load(in); - } finally { - in.close(); - } - } - - /** - * Writes the registration data to the specified output stream - * in the format described by the - * registration data schema with "UTF-8" encoding. - * The specified stream remains open after this method returns. - * - * @param os the output stream on which to write the XML document. - * - * @throws IOException if an error occurred when writing to the output stream. - */ - public void storeToXML(OutputStream os) throws IOException { - RegistrationDocument.store(os, this); - os.flush(); - } - - /** - * Returns a newly allocated byte array containing the registration - * data in XML format. - * - * @return a newly allocated byte array containing the registration - * data in XML format. - */ - public byte[] toXML() { - try { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - storeToXML(out); - return out.toByteArray(); - } catch (IOException e) { - // should not reach here - return new byte[0]; - } - } - - /** - * Returns a string representation of this registration data in XML - * format. - * - * @return a string representation of this registration data in XML - * format. - */ - @Override - public String toString() { - try { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - storeToXML(out); - return out.toString("UTF-8"); - } catch (IOException e) { - // should not reach here - return "Error creating the return string."; - } - } -} + +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can obtain + * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html + * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt. + * Sun designates this particular file as subject to the "Classpath" exception + * as provided by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the License + * Header, with the fields enclosed by brackets [] replaced by your own + * identifying information: "Portions Copyrighted [year] + * [name of copyright owner]" + * + * Contributor(s): + * + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +package com.sun.star.servicetag; + +import java.io.*; +import java.net.UnknownHostException; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import static com.sun.star.servicetag.RegistrationDocument.*; + +/** + * A {@code RegistrationData} object is a container of one or more + * {@link #getServiceTags service tags} that identify the + * components for product registration. + * Each {@code RegistrationData} object has a {@link #getRegistrationURN + * uniform resource name} (URN) as its identifier. + * + * It also has an environment map with + * the following elements: + *
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
hostnameHostname of the systeme.g. woody
hostIdHost ID of the systeme.g. 83abc1ab
osNameOperating system name e.g. SunOS
osVersionOperating system version e.g. 5.10
osArchitectureOperating system architecture e.g. sparc
systemModelSystem model e.g. SUNW,Sun-Fire-V440
systemManufacturerSystem manufacturer e.g. Sun Microsystems
cpuManufacturerCPU manufacturer e.g. Sun Microsystems
serialNumberSystem serial number e.g. BEL078932
physmemPhysical memory for the system (in MB) e.g. 4096
+ *
+ * The hostname and osName element must have a non-empty value. + * If an element is not available on a system and their value will be + * empty. + *

+ * + * Registration XML Schema + *

+ * A {@code RegistrationData} object can be {@link #loadFromXML loaded} from + * and {@link #storeToXML stored} into an XML file in the format described + * by the + * + * registration data schema. The registration data schema is defined by the + * Service Tags Technology. + *

+ * Typically the registration data is constructed at installation time + * and stored in an XML file for later service tag lookup or registration. + * + *

+ * Example Usage + *

+ * The examples below show how the {@code RegistrationData} can be + * used for product registration. + * Exception handling is not shown in these examples for clarity. + *

    + *
  1. This example shows how the JDK creates a JDK service tag, installs it + * in the system service tag registry and adds it to the registration data. + *
    + *
    + *   // create a service tag object with an instance_urn
    + *   ServiceTag st = ServiceTag.newInstance(ServiceTag.generateInstanceURN(),
    + *                                          ....);
    + *   // Adds to the system service tag registry if supported
    + *   if (Registry.isSupported()) {
    + *       Registry.getSystemRegistry().addServiceTag(st);
    + *   }
    + * 
    + *   // add to the registration data
    + *   RegistrationData registration  = new RegistrationData();
    + *   registration.addServiceTag(st); 
    + * 
    + *
  2. + *
  3. At this point, the registration data is ready to + * send to Sun Connection for registration. This example shows how to register + * the JDK via the Registration Relay Service. + *

    + * There are several registration services for Sun Connection. For example, + * the + * Registration Relay Service is a web application interface that + * processes the registration data payload sent via HTTP post + * and hosts the registration user interface for a specified + * registration URL. Refer to the + * Registration Relay Service Specification for details. + *

    + *

    + *   // Open the connection to the URL of the registration service
    + *   HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
    + *   con.setDoInput(true);
    + *   con.setDoOutput(true);
    + *   con.setUseCaches(false);
    + *   con.setAllowUserInteraction(false);
    + *   con.setRequestMethod("POST");
    + *   con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\"");
    + *   con.connect();
    + *
    + *   // send the registration data to the registration service
    + *   OutputStream out = con.getOutputStream();
    + *   registration.storeToXML(out);
    + *   out.close();
    + * 
    + *
  4. + *
  5. This example shows how to store the registration data in an XML file. + * for later service tag lookup or registration. + *
    + *
    + *   BufferedOutputStream out = new BufferedOutputStream(
    + *       new FileOutputStream(""<JAVA_HOME>/lib/servicetag/registration.xml"));
    + *   registration.storeToXML(out);
    + *   out.close();
    + * 
    + *
  6. + *
  7. This example shows how to install service tags that are in the + * registration data in the system service tag registry when determined + * to be available. The system service tag registry might not have existed + * when the registration data was constructed. + *
    + *
    + *   if (Registry.isSupported()) {
    + *       Set<ServiceTag> svctags = registration.getServiceTags();
    + *       for (ServiceTag st : svctags) {
    + *           Registry.getSystemRegistry().addServiceTag(st);
    + *       }
    + *   }
    + * 
    + *
  8. + *
+ * + * @see Sun Connection Inventory Channel + */ +public class RegistrationData { + private final Map environment; + private final Map cpuInfo; + private final Map svcTagMap; + private final String urn; + + /** + * Creates a {@code RegistrationData} object with a generated + * {@link #getRegistrationURN registration URN}. + * The following keys in the {@link #getEnvironmentMap environment map} + * will be initialized for the configuration of the + * running system: + *
+ * hostname, osName, osVersion and + * osArchitecture + *
+ * and the value of other keys may be empty. + */ + public RegistrationData() { + this(Util.generateURN()); + } + + // package private + RegistrationData(String urn) { + this.urn = urn; + SystemEnvironment sysEnv = SystemEnvironment.getSystemEnvironment(); + this.environment = initEnvironment(sysEnv); + this.cpuInfo = initCpuInfo(sysEnv); + this.svcTagMap = new LinkedHashMap(); + } + + private Map initEnvironment(SystemEnvironment sysEnv) { + Map map = new LinkedHashMap(); + map.put(ST_NODE_HOSTNAME, sysEnv.getHostname()); + map.put(ST_NODE_HOST_ID, sysEnv.getHostId()); + map.put(ST_NODE_OS_NAME, sysEnv.getOsName()); + map.put(ST_NODE_OS_VERSION, sysEnv.getOsVersion()); + map.put(ST_NODE_OS_ARCH, sysEnv.getOsArchitecture()); + map.put(ST_NODE_SYSTEM_MODEL, sysEnv.getSystemModel()); + map.put(ST_NODE_SYSTEM_MANUFACTURER, sysEnv.getSystemManufacturer()); + map.put(ST_NODE_CPU_MANUFACTURER, sysEnv.getCpuManufacturer()); + map.put(ST_NODE_SERIAL_NUMBER, sysEnv.getSerialNumber()); + map.put(ST_NODE_PHYS_MEM, sysEnv.getPhysMem()); + return map; + } + + private Map initCpuInfo(SystemEnvironment sysEnv) { + Map map = new LinkedHashMap(); + map.put(ST_NODE_SOCKETS, sysEnv.getSockets()); + map.put(ST_NODE_CORES, sysEnv.getCores()); + map.put(ST_NODE_VIRT_CPUS, sysEnv.getVirtCpus()); + map.put(ST_NODE_CPU_NAME, sysEnv.getCpuName()); + map.put(ST_NODE_CLOCK_RATE, sysEnv.getClockRate()); + return map; + } + + /** + * Returns the uniform resource name of this registration data + * in this format: + * urn:st:<32-char {@link java.util.UUID uuid}> + * + * @return the URN of this registration data. + */ + public String getRegistrationURN() { + return urn; + } + + /** + * Returns a map containing the environment information for this + * registration data. See the set of keys + * in the environment map. Subsequent update to the environment + * map via the {@link #setEnvironment setEnvironment} method will not be reflected + * in the returned map. + * + * @return an environment map for this registration data. + */ + public Map getEnvironmentMap() { + return new LinkedHashMap(environment); + } + + /** + * Returns a map containing the cpu information for this + * registration data. Subsequent update to the cpu info + * map via the {@link #setCpuInfo setCpuInfo} method will not be reflected + * in the returned map. + * + * @return a cpu info map for this registration data. + */ + public Map getCpuInfoMap() { + return new LinkedHashMap(cpuInfo); + } + + /** + * Sets an element of the specified {@code name} in the environment map + * with the given {@code value}. + * + * @throws IllegalArgumentException if {@code name} is not a valid key + * in the environment map, or {@code value} is not valid. + */ + public void setEnvironment(String name, String value) { + if (name == null) { + throw new NullPointerException("name is null"); + } + if (value == null) { + throw new NullPointerException("value is null"); + } + if (environment.containsKey(name)) { + if (name.equals(ST_NODE_HOSTNAME) || name.equals(ST_NODE_OS_NAME)) { + if (value.length() == 0) { + throw new IllegalArgumentException("\"" + + name + "\" requires non-empty value."); + } + } + environment.put(name, value); + } else { + throw new IllegalArgumentException("\"" + + name + "\" is not an environment element."); + } + } + + /** + * Sets an element of the specified {@code name} in the cpu info map + * with the given {@code value}. + * + * @throws IllegalArgumentException if {@code name} is not a valid key + * in the cpu info map, or {@code value} is not valid. + */ + public void setCpuInfo(String name, String value) { + if (name == null) { + throw new NullPointerException("name is null"); + } + if (value == null) { + throw new NullPointerException("value is null"); + } + if (cpuInfo.containsKey(name)) { + cpuInfo.put(name, value); + } else { + throw new IllegalArgumentException("\"" + + name + "\" is not an cpuinfo element."); + } + } + + /** + * Returns all service tags in this registration data. + * + * @return a {@link Set Set} of the service tags + * in this registration data. + */ + public Set getServiceTags() { + return new HashSet(svcTagMap.values()); + } + + /** + * Adds a service tag to this registration data. + * If the given service tag has an empty instance_urn, + * this method will generate a URN and place it in the copy + * of the service tag in this registration data. + * This method will return the {@code ServiceTag} object + * added to this registration data. + * + * @param st {@code ServiceTag} object to be added. + * @return a {@code ServiceTag} object added to this registration data. + * + * @throws IllegalArgumentException if + * a service tag of the same {@link ServiceTag#getInstanceURN + * instance_urn} already exists in the registry. + */ + public synchronized ServiceTag addServiceTag(ServiceTag st) { + ServiceTag svcTag = ServiceTag.newInstanceWithUrnTimestamp(st); + + String instanceURN = svcTag.getInstanceURN(); + if (svcTagMap.containsKey(instanceURN)) { + throw new IllegalArgumentException("Instance_urn = " + instanceURN + + " already exists in the registration data."); + } else { + svcTagMap.put(instanceURN, svcTag); + } + return svcTag; + } + + /** + * Returns a service tag of the given instance_urn in this registration + * data. + * + * @param instanceURN the instance_urn of the service tag + * @return the {@code ServiceTag} object of the given instance_urn + * if exists; otherwise return {@code null}. + */ + public synchronized ServiceTag getServiceTag(String instanceURN) { + if (instanceURN == null) { + throw new NullPointerException("instanceURN is null"); + } + return svcTagMap.get(instanceURN); + } + + /** + * Removes a service tag of the given instance_urn from this + * registration data. + * + * @param instanceURN the instance_urn of + * the service tag to be removed. + * + * @return the removed {@code ServiceTag} object; + * or {@code null} if the service tag does not exist in this + * registration data. + */ + public synchronized ServiceTag removeServiceTag(String instanceURN) { + if (instanceURN == null) { + throw new NullPointerException("instanceURN is null"); + } + + ServiceTag svcTag = null; + if (svcTagMap.containsKey(instanceURN)) { + svcTag = svcTagMap.remove(instanceURN); + } + return svcTag; + } + + /** + * Updates the product_defined_instance_id in the service tag + * of the given instance_urn in this registration data. + * + * @param instanceURN the instance_urn of the service tag to be updated. + * @param productDefinedInstanceID the value of the + * product_defined_instance_id to be set. + * + * @return the updated {@code ServiceTag} object; + * or {@code null} if the service tag does not exist in this + * registration data. + */ + public synchronized ServiceTag updateServiceTag(String instanceURN, + String productDefinedInstanceID) { + ServiceTag svcTag = getServiceTag(instanceURN); + if (svcTag == null) { + return null; + } + + svcTag = ServiceTag.newInstanceWithUrnTimestamp(svcTag); + // update the product defined instance ID field + svcTag.setProductDefinedInstanceID(productDefinedInstanceID); + svcTagMap.put(instanceURN, svcTag); + return svcTag; + } + + /** + * Reads the registration data from the XML document on the + * specified input stream. The XML document must be + * in the format described by the + * registration data schema. + * The specified stream is closed after this method returns. + * + * @param in the input stream from which to read the XML document. + * @return a {@code RegistrationData} object read from the input + * stream. + * + * @throws IllegalArgumentException if the input stream + * contains an invalid registration data. + * + * @throws IOException if an error occurred when reading from the input stream. + */ + public static RegistrationData loadFromXML(InputStream in) throws IOException { + try { + return RegistrationDocument.load(in); + } finally { + in.close(); + } + } + + /** + * Writes the registration data to the specified output stream + * in the format described by the + * registration data schema with "UTF-8" encoding. + * The specified stream remains open after this method returns. + * + * @param os the output stream on which to write the XML document. + * + * @throws IOException if an error occurred when writing to the output stream. + */ + public void storeToXML(OutputStream os) throws IOException { + RegistrationDocument.store(os, this); + os.flush(); + } + + /** + * Returns a newly allocated byte array containing the registration + * data in XML format. + * + * @return a newly allocated byte array containing the registration + * data in XML format. + */ + public byte[] toXML() { + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + storeToXML(out); + return out.toByteArray(); + } catch (IOException e) { + // should not reach here + return new byte[0]; + } + } + + /** + * Returns a string representation of this registration data in XML + * format. + * + * @return a string representation of this registration data in XML + * format. + */ + @Override + public String toString() { + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + storeToXML(out); + return out.toString("UTF-8"); + } catch (IOException e) { + // should not reach here + return "Error creating the return string."; + } + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java index 1b95824bb836..9e9a9b65bd93 100644 --- a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java +++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java @@ -1,373 +1,410 @@ -/************************************************************************* - * - * 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: Registration.java,v $ - * $Revision: 1.3 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -package com.sun.star.servicetag; - -import java.io.*; -import java.net.URL; -import java.util.Collection; -import java.util.Map; -import java.util.Set; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; -import org.xml.sax.InputSource; - -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import javax.xml.validation.Validator; - -// For write operation -import javax.xml.transform.OutputKeys; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -/** - * XML Support Class for Product Registration. - */ -class RegistrationDocument { - - private static final String REGISTRATION_DATA_SCHEMA = - "/com/sun/servicetag/resources/product_registration.xsd"; - private static final String REGISTRATION_DATA_VERSION = "1.0"; - private static final String SERVICE_TAG_VERSION = "1.0"; - final static String ST_NODE_REGISTRATION_DATA = "registration_data"; - final static String ST_ATTR_REGISTRATION_VERSION = "version"; - final static String ST_NODE_ENVIRONMENT = "environment"; - final static String ST_NODE_HOSTNAME = "hostname"; - final static String ST_NODE_HOST_ID = "hostId"; - final static String ST_NODE_OS_NAME = "osName"; - final static String ST_NODE_OS_VERSION = "osVersion"; - final static String ST_NODE_OS_ARCH = "osArchitecture"; - final static String ST_NODE_SYSTEM_MODEL = "systemModel"; - final static String ST_NODE_SYSTEM_MANUFACTURER = "systemManufacturer"; - final static String ST_NODE_CPU_MANUFACTURER = "cpuManufacturer"; - final static String ST_NODE_SERIAL_NUMBER = "serialNumber"; - final static String ST_NODE_REGISTRY = "registry"; - final static String ST_ATTR_REGISTRY_URN = "urn"; - final static String ST_ATTR_REGISTRY_VERSION = "version"; - final static String ST_NODE_SERVICE_TAG = "service_tag"; - final static String ST_NODE_INSTANCE_URN = "instance_urn"; - final static String ST_NODE_PRODUCT_NAME = "product_name"; - final static String ST_NODE_PRODUCT_VERSION = "product_version"; - final static String ST_NODE_PRODUCT_URN = "product_urn"; - final static String ST_NODE_PRODUCT_PARENT_URN = "product_parent_urn"; - final static String ST_NODE_PRODUCT_PARENT = "product_parent"; - final static String ST_NODE_PRODUCT_DEFINED_INST_ID = "product_defined_inst_id"; - final static String ST_NODE_PRODUCT_VENDOR = "product_vendor"; - final static String ST_NODE_PLATFORM_ARCH = "platform_arch"; - final static String ST_NODE_TIMESTAMP = "timestamp"; - final static String ST_NODE_CONTAINER = "container"; - final static String ST_NODE_SOURCE = "source"; - final static String ST_NODE_INSTALLER_UID = "installer_uid"; - - static RegistrationData load(InputStream in) throws IOException { - Document document = initializeDocument(in); - - // Gets the registration URN - Element root = getRegistrationDataRoot(document); - Element registryRoot = - getSingletonElementFromRoot(root, ST_NODE_REGISTRY); - String urn = registryRoot.getAttribute(ST_ATTR_REGISTRY_URN); - - // Construct a new RegistrationData object from the DOM tree - // Initialize the environment map and service tags - RegistrationData regData = new RegistrationData(urn); - addServiceTags(registryRoot, regData); - - Element envRoot = getSingletonElementFromRoot(root, ST_NODE_ENVIRONMENT); - buildEnvironmentMap(envRoot, regData); - return regData; - } - - static void store(OutputStream os, RegistrationData registration) - throws IOException { - // create a new document with the root node - Document document = initializeDocument(); - - // create the nodes for the environment map and the service tags - // in the registration data - addEnvironmentNodes(document, - registration.getEnvironmentMap()); - addServiceTagRegistry(document, - registration.getRegistrationURN(), - registration.getServiceTags()); - transform(document, os); - } - - // initialize a document from an input stream - private static Document initializeDocument(InputStream in) throws IOException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - try { - // XML schema for validation - SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA); - Schema schema = sf.newSchema(xsdUrl); - Validator validator = schema.newValidator(); - - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.parse(new InputSource(in)); - validator.validate(new DOMSource(doc)); - return doc; - } catch (SAXException sxe) { - IllegalArgumentException e = new IllegalArgumentException("Error generated in parsing"); - e.initCause(sxe); - throw e; - } catch (ParserConfigurationException pce) { - // Parser with specific options can't be built - // should not reach here - InternalError x = new InternalError("Error in creating the new document"); - x.initCause(pce); - throw x; - } - } - - // initialize a new document for the registration data - private static Document initializeDocument() throws IOException { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - try { - DocumentBuilder builder = factory.newDocumentBuilder(); - Document doc = builder.newDocument(); - - // initialize the document with the registration_data root - Element root = doc.createElement(ST_NODE_REGISTRATION_DATA); - doc.appendChild(root); - root.setAttribute(ST_ATTR_REGISTRATION_VERSION, REGISTRATION_DATA_VERSION); - - return doc; - } catch (ParserConfigurationException pce) { - // Parser with specified options can't be built - // should not reach here - InternalError x = new InternalError("Error in creating the new document"); - x.initCause(pce); - throw x; - } - } - - // Transform the current DOM tree with the given output stream. - private static void transform(Document document, OutputStream os) { - try { - // Use a Transformer for output - TransformerFactory tFactory = TransformerFactory.newInstance(); - tFactory.setAttribute("indent-number", new Integer(3)); - - Transformer transformer = tFactory.newTransformer(); - - transformer.setOutputProperty(OutputKeys.INDENT, "yes"); - transformer.setOutputProperty(OutputKeys.METHOD, "xml"); - transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); - transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); - transformer.transform(new DOMSource(document), - new StreamResult(new BufferedWriter(new OutputStreamWriter(os, "UTF-8")))); - } catch (UnsupportedEncodingException ue) { - // Should not reach here - InternalError x = new InternalError("Error generated during transformation"); - x.initCause(ue); - throw x; - } catch (TransformerConfigurationException tce) { - // Error generated by the parser - // Should not reach here - InternalError x = new InternalError("Error in creating the new document"); - x.initCause(tce); - throw x; - } catch (TransformerException te) { - // Error generated by the transformer - InternalError x = new InternalError("Error generated during transformation"); - x.initCause(te); - throw x; - } - } - - private static void addServiceTagRegistry(Document document, - String registryURN, - Set svcTags) { - // add service tag registry node and its attributes - Element reg = document.createElement(ST_NODE_REGISTRY); - reg.setAttribute(ST_ATTR_REGISTRY_URN, registryURN); - reg.setAttribute(ST_ATTR_REGISTRY_VERSION, SERVICE_TAG_VERSION); - - Element root = getRegistrationDataRoot(document); - root.appendChild(reg); - - // adds the elements for the service tags - for (ServiceTag st : svcTags) { - addServiceTagElement(document, reg, st); - } - } - - private static void addServiceTagElement(Document document, - Element registryRoot, - ServiceTag st) { - Element svcTag = document.createElement(ST_NODE_SERVICE_TAG); - registryRoot.appendChild(svcTag); - addChildElement(document, svcTag, - ST_NODE_INSTANCE_URN, st.getInstanceURN()); - addChildElement(document, svcTag, - ST_NODE_PRODUCT_NAME, st.getProductName()); - addChildElement(document, svcTag, - ST_NODE_PRODUCT_VERSION, st.getProductVersion()); - addChildElement(document, svcTag, - ST_NODE_PRODUCT_URN, st.getProductURN()); - addChildElement(document, svcTag, - ST_NODE_PRODUCT_PARENT_URN, st.getProductParentURN()); - addChildElement(document, svcTag, - ST_NODE_PRODUCT_PARENT, st.getProductParent()); - addChildElement(document, svcTag, - ST_NODE_PRODUCT_DEFINED_INST_ID, - st.getProductDefinedInstanceID()); - addChildElement(document, svcTag, - ST_NODE_PRODUCT_VENDOR, st.getProductVendor()); - addChildElement(document, svcTag, - ST_NODE_PLATFORM_ARCH, st.getPlatformArch()); - addChildElement(document, svcTag, - ST_NODE_TIMESTAMP, Util.formatTimestamp(st.getTimestamp())); - addChildElement(document, svcTag, - ST_NODE_CONTAINER, st.getContainer()); - addChildElement(document, svcTag, - ST_NODE_SOURCE, st.getSource()); - addChildElement(document, svcTag, - ST_NODE_INSTALLER_UID, - String.valueOf(st.getInstallerUID())); - } - - private static void addChildElement(Document document, Element root, - String element, String text) { - Element node = document.createElement(element); - node.appendChild(document.createTextNode(text)); - root.appendChild(node); - } - - // Constructs service tags from the document - private static void addServiceTags(Element registryRoot, - RegistrationData registration) { - NodeList children = registryRoot.getElementsByTagName(ST_NODE_SERVICE_TAG); - int length = (children == null ? 0 : children.getLength()); - for (int i = 0; i < length; i++) { - Element svcTagElement = (Element) children.item(i); - ServiceTag st = getServiceTag(svcTagElement); - registration.addServiceTag(st); - } - } - - // build environment map from the document - private static void buildEnvironmentMap(Element envRoot, - RegistrationData registration) { - registration.setEnvironment(ST_NODE_HOSTNAME, getTextValue(envRoot, ST_NODE_HOSTNAME)); - registration.setEnvironment(ST_NODE_HOST_ID, getTextValue(envRoot, ST_NODE_HOST_ID)); - registration.setEnvironment(ST_NODE_OS_NAME, getTextValue(envRoot, ST_NODE_OS_NAME)); - registration.setEnvironment(ST_NODE_OS_VERSION, getTextValue(envRoot, ST_NODE_OS_VERSION)); - registration.setEnvironment(ST_NODE_OS_ARCH, getTextValue(envRoot, ST_NODE_OS_ARCH)); - registration.setEnvironment(ST_NODE_SYSTEM_MODEL, getTextValue(envRoot, ST_NODE_SYSTEM_MODEL)); - registration.setEnvironment(ST_NODE_SYSTEM_MANUFACTURER, getTextValue(envRoot, ST_NODE_SYSTEM_MANUFACTURER)); - registration.setEnvironment(ST_NODE_CPU_MANUFACTURER, getTextValue(envRoot, ST_NODE_CPU_MANUFACTURER)); - registration.setEnvironment(ST_NODE_SERIAL_NUMBER, getTextValue(envRoot, ST_NODE_SERIAL_NUMBER)); - } - - // add the nodes representing the environment map in the document - private static void addEnvironmentNodes(Document document, - Map envMap) { - Element root = getRegistrationDataRoot(document); - Element env = document.createElement(ST_NODE_ENVIRONMENT); - root.appendChild(env); - Set> keys = envMap.entrySet(); - for (Map.Entry entry : keys) { - addChildElement(document, env, entry.getKey(), entry.getValue()); - } - } - - private static Element getRegistrationDataRoot(Document doc) { - Element root = doc.getDocumentElement(); - if (!root.getNodeName().equals(ST_NODE_REGISTRATION_DATA)) { - throw new IllegalArgumentException("Not a " + - ST_NODE_REGISTRATION_DATA + - " node \"" + root.getNodeName() + "\""); - } - return root; - } - - private static Element getSingletonElementFromRoot(Element root, String name) { - NodeList children = root.getElementsByTagName(name); - int length = (children == null ? 0 : children.getLength()); - if (length != 1) { - throw new IllegalArgumentException("Invalid number of " + name + - " nodes = " + length); - } - Element e = (Element) children.item(0); - if (!e.getNodeName().equals(name)) { - throw new IllegalArgumentException("Not a " + name + - " node \"" + e.getNodeName() + "\""); - } - return e; - } - - // Constructs one ServiceTag instance from a service tag element root - private static ServiceTag getServiceTag(Element svcTagElement) { - return new ServiceTag( - getTextValue(svcTagElement, ST_NODE_INSTANCE_URN), - getTextValue(svcTagElement, ST_NODE_PRODUCT_NAME), - getTextValue(svcTagElement, ST_NODE_PRODUCT_VERSION), - getTextValue(svcTagElement, ST_NODE_PRODUCT_URN), - getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT), - getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT_URN), - getTextValue(svcTagElement, ST_NODE_PRODUCT_DEFINED_INST_ID), - getTextValue(svcTagElement, ST_NODE_PRODUCT_VENDOR), - getTextValue(svcTagElement, ST_NODE_PLATFORM_ARCH), - getTextValue(svcTagElement, ST_NODE_CONTAINER), - getTextValue(svcTagElement, ST_NODE_SOURCE), - Util.getIntValue(getTextValue(svcTagElement, ST_NODE_INSTALLER_UID)), - Util.parseTimestamp(getTextValue(svcTagElement, ST_NODE_TIMESTAMP)) - ); - } - - private static String getTextValue(Element e, String tagName) { - String value = ""; - NodeList nl = e.getElementsByTagName(tagName); - if (nl != null && nl.getLength() > 0) { - Element el = (Element) nl.item(0); - Node node = el.getFirstChild(); - if (node != null) { - value = node.getNodeValue(); - } - } - return value; - } -} + +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2008 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can obtain + * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html + * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt. + * Sun designates this particular file as subject to the "Classpath" exception + * as provided by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the License + * Header, with the fields enclosed by brackets [] replaced by your own + * identifying information: "Portions Copyrighted [year] + * [name of copyright owner]" + * + * Contributor(s): + * + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +package com.sun.star.servicetag; + +import java.io.*; +import java.net.URL; +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; +import org.xml.sax.InputSource; + +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +// For write operation +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +/** + * XML Support Class for Product Registration. + */ +class RegistrationDocument { + + private static final String REGISTRATION_DATA_SCHEMA = + "/com/sun/servicetag/resources/product_registration.xsd"; + private static final String REGISTRATION_DATA_VERSION = "1.0"; + private static final String SERVICE_TAG_VERSION = "1.0"; + final static String ST_NODE_REGISTRATION_DATA = "registration_data"; + final static String ST_ATTR_REGISTRATION_VERSION = "version"; + final static String ST_NODE_ENVIRONMENT = "environment"; + final static String ST_NODE_HOSTNAME = "hostname"; + final static String ST_NODE_HOST_ID = "hostId"; + final static String ST_NODE_OS_NAME = "osName"; + final static String ST_NODE_OS_VERSION = "osVersion"; + final static String ST_NODE_OS_ARCH = "osArchitecture"; + final static String ST_NODE_SYSTEM_MODEL = "systemModel"; + final static String ST_NODE_SYSTEM_MANUFACTURER = "systemManufacturer"; + final static String ST_NODE_CPU_MANUFACTURER = "cpuManufacturer"; + final static String ST_NODE_SERIAL_NUMBER = "serialNumber"; + final static String ST_NODE_PHYS_MEM = "physmem"; + final static String ST_NODE_CPU_INFO = "cpuinfo"; + final static String ST_NODE_SOCKETS = "sockets"; + final static String ST_NODE_CORES = "cores"; + final static String ST_NODE_VIRT_CPUS = "virtcpus"; + final static String ST_NODE_CPU_NAME = "name"; + final static String ST_NODE_CLOCK_RATE = "clockrate"; + final static String ST_NODE_REGISTRY = "registry"; + final static String ST_ATTR_REGISTRY_URN = "urn"; + final static String ST_ATTR_REGISTRY_VERSION = "version"; + final static String ST_NODE_SERVICE_TAG = "service_tag"; + final static String ST_NODE_INSTANCE_URN = "instance_urn"; + final static String ST_NODE_PRODUCT_NAME = "product_name"; + final static String ST_NODE_PRODUCT_VERSION = "product_version"; + final static String ST_NODE_PRODUCT_URN = "product_urn"; + final static String ST_NODE_PRODUCT_PARENT_URN = "product_parent_urn"; + final static String ST_NODE_PRODUCT_PARENT = "product_parent"; + final static String ST_NODE_PRODUCT_DEFINED_INST_ID = "product_defined_inst_id"; + final static String ST_NODE_PRODUCT_VENDOR = "product_vendor"; + final static String ST_NODE_PLATFORM_ARCH = "platform_arch"; + final static String ST_NODE_TIMESTAMP = "timestamp"; + final static String ST_NODE_CONTAINER = "container"; + final static String ST_NODE_SOURCE = "source"; + final static String ST_NODE_INSTALLER_UID = "installer_uid"; + + static RegistrationData load(InputStream in) throws IOException { + Document document = initializeDocument(in); + + // Gets the registration URN + Element root = getRegistrationDataRoot(document); + Element registryRoot = + getSingletonElementFromRoot(root, ST_NODE_REGISTRY); + String urn = registryRoot.getAttribute(ST_ATTR_REGISTRY_URN); + + // Construct a new RegistrationData object from the DOM tree + // Initialize the environment map and service tags + RegistrationData regData = new RegistrationData(urn); + addServiceTags(registryRoot, regData); + + Element envRoot = getSingletonElementFromRoot(root, ST_NODE_ENVIRONMENT); + buildEnvironmentMap(envRoot, regData); + + Element cpuInfo = getSingletonElementFromRoot(envRoot, ST_NODE_CPU_INFO); + buildCpuInfoMap(cpuInfo, regData); + return regData; + } + + static void store(OutputStream os, RegistrationData registration) + throws IOException { + // create a new document with the root node + Document document = initializeDocument(); + + // create the nodes for the environment map and the service tags + // in the registration data + addEnvironmentNodes(document, + registration.getEnvironmentMap(), + registration.getCpuInfoMap()); + addServiceTagRegistry(document, + registration.getRegistrationURN(), + registration.getServiceTags()); + transform(document, os); + } + + // initialize a document from an input stream + private static Document initializeDocument(InputStream in) throws IOException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + try { + // XML schema for validation + SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA); + Schema schema = sf.newSchema(xsdUrl); + Validator validator = schema.newValidator(); + + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.parse(new InputSource(in)); + validator.validate(new DOMSource(doc)); + return doc; + } catch (SAXException sxe) { + IllegalArgumentException e = new IllegalArgumentException("Error generated in parsing"); + e.initCause(sxe); + throw e; + } catch (ParserConfigurationException pce) { + // Parser with specific options can't be built + // should not reach here + InternalError x = new InternalError("Error in creating the new document"); + x.initCause(pce); + throw x; + } + } + + // initialize a new document for the registration data + private static Document initializeDocument() throws IOException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + try { + DocumentBuilder builder = factory.newDocumentBuilder(); + Document doc = builder.newDocument(); + + // initialize the document with the registration_data root + Element root = doc.createElement(ST_NODE_REGISTRATION_DATA); + doc.appendChild(root); + root.setAttribute(ST_ATTR_REGISTRATION_VERSION, REGISTRATION_DATA_VERSION); + + return doc; + } catch (ParserConfigurationException pce) { + // Parser with specified options can't be built + // should not reach here + InternalError x = new InternalError("Error in creating the new document"); + x.initCause(pce); + throw x; + } + } + + // Transform the current DOM tree with the given output stream. + private static void transform(Document document, OutputStream os) { + try { + // Use a Transformer for output + TransformerFactory tFactory = TransformerFactory.newInstance(); + tFactory.setAttribute("indent-number", new Integer(3)); + + Transformer transformer = tFactory.newTransformer(); + + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.setOutputProperty(OutputKeys.STANDALONE, "yes"); + transformer.transform(new DOMSource(document), + new StreamResult(new BufferedWriter(new OutputStreamWriter(os, "UTF-8")))); + } catch (UnsupportedEncodingException ue) { + // Should not reach here + InternalError x = new InternalError("Error generated during transformation"); + x.initCause(ue); + throw x; + } catch (TransformerConfigurationException tce) { + // Error generated by the parser + // Should not reach here + InternalError x = new InternalError("Error in creating the new document"); + x.initCause(tce); + throw x; + } catch (TransformerException te) { + // Error generated by the transformer + InternalError x = new InternalError("Error generated during transformation"); + x.initCause(te); + throw x; + } + } + + private static void addServiceTagRegistry(Document document, + String registryURN, + Set svcTags) { + // add service tag registry node and its attributes + Element reg = document.createElement(ST_NODE_REGISTRY); + reg.setAttribute(ST_ATTR_REGISTRY_URN, registryURN); + reg.setAttribute(ST_ATTR_REGISTRY_VERSION, SERVICE_TAG_VERSION); + + Element root = getRegistrationDataRoot(document); + root.appendChild(reg); + + // adds the elements for the service tags + for (ServiceTag st : svcTags) { + addServiceTagElement(document, reg, st); + } + } + + private static void addServiceTagElement(Document document, + Element registryRoot, + ServiceTag st) { + Element svcTag = document.createElement(ST_NODE_SERVICE_TAG); + registryRoot.appendChild(svcTag); + addChildElement(document, svcTag, + ST_NODE_INSTANCE_URN, st.getInstanceURN()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_NAME, st.getProductName()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_VERSION, st.getProductVersion()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_URN, st.getProductURN()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_PARENT_URN, st.getProductParentURN()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_PARENT, st.getProductParent()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_DEFINED_INST_ID, + st.getProductDefinedInstanceID()); + addChildElement(document, svcTag, + ST_NODE_PRODUCT_VENDOR, st.getProductVendor()); + addChildElement(document, svcTag, + ST_NODE_PLATFORM_ARCH, st.getPlatformArch()); + addChildElement(document, svcTag, + ST_NODE_TIMESTAMP, Util.formatTimestamp(st.getTimestamp())); + addChildElement(document, svcTag, + ST_NODE_CONTAINER, st.getContainer()); + addChildElement(document, svcTag, + ST_NODE_SOURCE, st.getSource()); + addChildElement(document, svcTag, + ST_NODE_INSTALLER_UID, + String.valueOf(st.getInstallerUID())); + } + + private static void addChildElement(Document document, Element root, + String element, String text) { + Element node = document.createElement(element); + node.appendChild(document.createTextNode(text)); + root.appendChild(node); + } + + // Constructs service tags from the document + private static void addServiceTags(Element registryRoot, + RegistrationData registration) { + NodeList children = registryRoot.getElementsByTagName(ST_NODE_SERVICE_TAG); + int length = (children == null ? 0 : children.getLength()); + for (int i = 0; i < length; i++) { + Element svcTagElement = (Element) children.item(i); + ServiceTag st = getServiceTag(svcTagElement); + registration.addServiceTag(st); + } + } + + // build environment map from the document + private static void buildEnvironmentMap(Element envRoot, + RegistrationData registration) { + registration.setEnvironment(ST_NODE_HOSTNAME, getTextValue(envRoot, ST_NODE_HOSTNAME)); + registration.setEnvironment(ST_NODE_HOST_ID, getTextValue(envRoot, ST_NODE_HOST_ID)); + registration.setEnvironment(ST_NODE_OS_NAME, getTextValue(envRoot, ST_NODE_OS_NAME)); + registration.setEnvironment(ST_NODE_OS_VERSION, getTextValue(envRoot, ST_NODE_OS_VERSION)); + registration.setEnvironment(ST_NODE_OS_ARCH, getTextValue(envRoot, ST_NODE_OS_ARCH)); + registration.setEnvironment(ST_NODE_SYSTEM_MODEL, getTextValue(envRoot, ST_NODE_SYSTEM_MODEL)); + registration.setEnvironment(ST_NODE_SYSTEM_MANUFACTURER, getTextValue(envRoot, ST_NODE_SYSTEM_MANUFACTURER)); + registration.setEnvironment(ST_NODE_CPU_MANUFACTURER, getTextValue(envRoot, ST_NODE_CPU_MANUFACTURER)); + registration.setEnvironment(ST_NODE_SERIAL_NUMBER, getTextValue(envRoot, ST_NODE_SERIAL_NUMBER)); + registration.setEnvironment(ST_NODE_PHYS_MEM, getTextValue(envRoot, ST_NODE_PHYS_MEM)); + } + + private static void buildCpuInfoMap(Element cpuInfoRoot, + RegistrationData registration) { + registration.setCpuInfo(ST_NODE_SOCKETS, getTextValue(cpuInfoRoot, ST_NODE_SOCKETS)); + registration.setCpuInfo(ST_NODE_CORES, getTextValue(cpuInfoRoot, ST_NODE_CORES)); + registration.setCpuInfo(ST_NODE_VIRT_CPUS, getTextValue(cpuInfoRoot, ST_NODE_VIRT_CPUS)); + registration.setCpuInfo(ST_NODE_CPU_NAME, getTextValue(cpuInfoRoot, ST_NODE_CPU_NAME)); + registration.setCpuInfo(ST_NODE_CLOCK_RATE, getTextValue(cpuInfoRoot, ST_NODE_CLOCK_RATE)); + } + + // add the nodes representing the environment map in the document + private static void addEnvironmentNodes(Document document, + Map envMap, + Map cpuInfoMap) { + Element root = getRegistrationDataRoot(document); + + Element env = document.createElement(ST_NODE_ENVIRONMENT); + root.appendChild(env); + Set> keys = envMap.entrySet(); + for (Map.Entry entry : keys) { + addChildElement(document, env, entry.getKey(), entry.getValue()); + } + + Element cpuInfo = document.createElement(ST_NODE_CPU_INFO); + env.appendChild(cpuInfo); + keys = cpuInfoMap.entrySet(); + for (Map.Entry entry : keys) { + addChildElement(document, cpuInfo, entry.getKey(), entry.getValue()); + } + } + + private static Element getRegistrationDataRoot(Document doc) { + Element root = doc.getDocumentElement(); + if (!root.getNodeName().equals(ST_NODE_REGISTRATION_DATA)) { + throw new IllegalArgumentException("Not a " + + ST_NODE_REGISTRATION_DATA + + " node \"" + root.getNodeName() + "\""); + } + return root; + } + + private static Element getSingletonElementFromRoot(Element root, String name) { + NodeList children = root.getElementsByTagName(name); + int length = (children == null ? 0 : children.getLength()); + if (length != 1) { + throw new IllegalArgumentException("Invalid number of " + name + + " nodes = " + length); + } + Element e = (Element) children.item(0); + if (!e.getNodeName().equals(name)) { + throw new IllegalArgumentException("Not a " + name + + " node \"" + e.getNodeName() + "\""); + } + return e; + } + + // Constructs one ServiceTag instance from a service tag element root + private static ServiceTag getServiceTag(Element svcTagElement) { + return new ServiceTag( + getTextValue(svcTagElement, ST_NODE_INSTANCE_URN), + getTextValue(svcTagElement, ST_NODE_PRODUCT_NAME), + getTextValue(svcTagElement, ST_NODE_PRODUCT_VERSION), + getTextValue(svcTagElement, ST_NODE_PRODUCT_URN), + getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT), + getTextValue(svcTagElement, ST_NODE_PRODUCT_PARENT_URN), + getTextValue(svcTagElement, ST_NODE_PRODUCT_DEFINED_INST_ID), + getTextValue(svcTagElement, ST_NODE_PRODUCT_VENDOR), + getTextValue(svcTagElement, ST_NODE_PLATFORM_ARCH), + getTextValue(svcTagElement, ST_NODE_CONTAINER), + getTextValue(svcTagElement, ST_NODE_SOURCE), + Util.getIntValue(getTextValue(svcTagElement, ST_NODE_INSTALLER_UID)), + Util.parseTimestamp(getTextValue(svcTagElement, ST_NODE_TIMESTAMP)) + ); + } + + private static String getTextValue(Element e, String tagName) { + String value = ""; + NodeList nl = e.getElementsByTagName(tagName); + if (nl != null && nl.getLength() > 0) { + Element el = (Element) nl.item(0); + Node node = el.getFirstChild(); + if (node != null) { + value = node.getNodeValue(); + } + } + return value; + } +} diff --git a/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd b/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd index e9b34417d9ae..bb48ba90844d 100644 --- a/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd +++ b/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd @@ -1,301 +1,366 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit From 83551c86578375623fa8e670bbfe1c976b3bd665 Mon Sep 17 00:00:00 2001 From: Mikhail Voitenko Date: Thu, 3 Dec 2009 10:37:54 +0000 Subject: #i105172# allow to request storing of documents from the user on session shutdown --- desktop/inc/app.hxx | 1 + desktop/source/app/app.cxx | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 995c7e65e999..353a3e045719 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -186,6 +186,7 @@ class Desktop : public Application static sal_Bool _bTasksSaved; static void retrieveCrashReporterState(); + static sal_Bool isUIOnSessionShutdownAllowed(); // on-demand acceptors static void createAcceptor(const OUString& aDescription); diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index ede5fdf7511a..7d9123620e24 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -937,6 +937,29 @@ void Desktop::retrieveCrashReporterState() _bCrashReporterEnabled = bEnabled; } +sal_Bool Desktop::isUIOnSessionShutdownAllowed() +{ + static const ::rtl::OUString CFG_PACKAGE_RECOVERY = ::rtl::OUString::createFromAscii("org.openoffice.Office.Recovery/"); + static const ::rtl::OUString CFG_PATH_SESSION = ::rtl::OUString::createFromAscii("SessionShutdown" ); + static const ::rtl::OUString CFG_ENTRY_UIENABLED = ::rtl::OUString::createFromAscii("DocumentStoreUIEnabled" ); + + css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); + + sal_Bool bResult = sal_False; + if ( xSMGR.is() ) + { + css::uno::Any aVal = ::comphelper::ConfigurationHelper::readDirectKey( + xSMGR, + CFG_PACKAGE_RECOVERY, + CFG_PATH_SESSION, + CFG_ENTRY_UIENABLED, + ::comphelper::ConfigurationHelper::E_READONLY); + aVal >>= bResult; + } + + return bResult; +} + //----------------------------------------------- /** @short check if crash reporter feature is enabled or disabled. @@ -2458,7 +2481,15 @@ void Desktop::OpenClients() { xSessionListener = Reference< XInitialization >(::comphelper::getProcessServiceFactory()->createInstance( OUString::createFromAscii("com.sun.star.frame.SessionListener")), UNO_QUERY_THROW); - xSessionListener->initialize(Sequence< Any >(0)); + + // specifies whether the UI-interaction on Session shutdown is allowed + sal_Bool bAllowUI = isUIOnSessionShutdownAllowed(); + css::beans::NamedValue aProperty( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AllowUserInteractionOnQuit" ) ), + css::uno::makeAny( bAllowUI ) ); + css::uno::Sequence< css::uno::Any > aArgs( 1 ); + aArgs[0] <<= aProperty; + + xSessionListener->initialize( aArgs ); } catch(const com::sun::star::uno::Exception& e) { -- cgit From b5b0a616cc603435f8c8d4e3b348baa4fb24e740 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Thu, 3 Dec 2009 17:22:08 +0000 Subject: #i107283# Pass config help path as argument to compileExtensionHelp() --- desktop/source/deployment/registry/help/dp_help.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index dd9e009e90cc..3bc1e1458670 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -39,6 +39,7 @@ #include "ucbhelper/content.hxx" #include "comphelper/servicedecl.hxx" #include "svtools/inettype.hxx" +#include "svtools/pathoptions.hxx" #include #include @@ -350,8 +351,12 @@ void BackendImpl::implProcessHelp pXhpFiles[iXhp] = aXhpRelFile; } + rtl::OUString aOfficeHelpPath( SvtPathOptions().GetHelpPath() ); + rtl::OUString aOfficeHelpPathFileURL; + ::osl::File::getFileURLFromSystemPath( aOfficeHelpPath, aOfficeHelpPathFileURL ); + HelpProcessingErrorInfo aErrorInfo; - bool bSuccess = compileExtensionHelp( aHelpStr, aLangURL, + bool bSuccess = compileExtensionHelp( aOfficeHelpPathFileURL, aHelpStr, aLangURL, nXhpFileCount, pXhpFiles, aErrorInfo ); if( bSuccess && xInvocation.is() ) -- cgit From b3bfaa49dbfe2c7e6c9861766c6dbcb338a1cbfd Mon Sep 17 00:00:00 2001 From: Joachim Lingner Date: Tue, 8 Dec 2009 14:11:19 +0000 Subject: #i107528# incorrect string conversion of the path of the berkeley db causes the Extension Manager to abort --- desktop/source/deployment/dp_persmap.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/source/deployment/dp_persmap.cxx b/desktop/source/deployment/dp_persmap.cxx index 39ea6f016dbf..75005b728465 100644 --- a/desktop/source/deployment/dp_persmap.cxx +++ b/desktop/source/deployment/dp_persmap.cxx @@ -104,7 +104,7 @@ PersistentMap::PersistentMap( OUString const & url_, bool readOnly ) OSL_ASSERT( false ); } OString cstr_sysPath( - OUStringToOString( m_sysPath, osl_getThreadTextEncoding() ) ); + OUStringToOString( m_sysPath, RTL_TEXTENCODING_UTF8 ) ); char const * pcstr_sysPath = cstr_sysPath.getStr(); u_int32_t flags = DB_CREATE; -- cgit From 6a9b5c605f4b808673d1e96d72e1c8562ecb42c6 Mon Sep 17 00:00:00 2001 From: Martin Hollmichel Date: Tue, 8 Dec 2009 15:54:11 +0000 Subject: update: year of copyright --- desktop/source/app/copyright_ascii_ooo.c | 4 ++-- desktop/source/app/copyright_ascii_sun.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'desktop') diff --git a/desktop/source/app/copyright_ascii_ooo.c b/desktop/source/app/copyright_ascii_ooo.c index 6c49ba9d9f86..7b58f1a60f7e 100644 --- a/desktop/source/app/copyright_ascii_ooo.c +++ b/desktop/source/app/copyright_ascii_ooo.c @@ -9,8 +9,8 @@ extern const char copyright_text_2[]; extern const char copyright_text_21[]; extern const char copyright_text_22[]; -const char copyright_text_1[] = "Copyright © 2008 Sun Microsystems, Inc., All rights reserved."; +const char copyright_text_1[] = "Copyright © 2010 Sun Microsystems, Inc., All rights reserved."; const char copyright_text_2[] = "Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries."; -const char copyright_text_21[] = "Copyright © 2008 Sun Microsystems, Tous droits réservés."; +const char copyright_text_21[] = "Copyright © 2010 Sun Microsystems, Tous droits réservés."; const char copyright_text_22[] = "Sun Microsystems, Inc. a les droits de propriété intellectuels relatants à la technologie incorporée dans ce produit. En particulier, et sans la limitation, ces droits de propriété intellectuels peuvent inclure un ou plus des brevets américains énumérés à http://www.sun.com/patents et un ou les brevets plus supplémentaires ou les applications de brevet en attente dans les États - Unis et les autres pays."; diff --git a/desktop/source/app/copyright_ascii_sun.c b/desktop/source/app/copyright_ascii_sun.c index 70d7d53f4b9c..6284744db94f 100644 --- a/desktop/source/app/copyright_ascii_sun.c +++ b/desktop/source/app/copyright_ascii_sun.c @@ -4,12 +4,12 @@ * */ -const char copyright_text_1[] = "Copyright © 2008 Sun Microsystems, Inc., All rights reserved."; +const char copyright_text_1[] = "Copyright © 2010 Sun Microsystems, Inc., All rights reserved."; const char copyright_text_2[] = "Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more of the U.S. patents listed at http://www.sun.com/patents and one or more additional patents or pending patent applications in the U.S. and in other countries."; const char copyright_text_3[] = "U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Use is subject to license terms."; const char copyright_text_4[] = "This distribution may include materials developed by third parties.Sun, Sun Microsystems, the Sun logo, Java, Solaris and StarOffice are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries."; const char copyright_text_5[] = "UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd."; -const char copyright_text_21[] = "Copyright © 2008 Sun Microsystems, Tous droits réservés."; +const char copyright_text_21[] = "Copyright © 2010 Sun Microsystems, Tous droits réservés."; const char copyright_text_22[] = "Sun Microsystems, Inc. a les droits de propriété intellectuels relatants à la technologie incorporée dans ce produit. En particulier, et sans la limitation, ces droits de propriété intellectuels peuvent inclure un ou plus des brevets américains énumérés à http://www.sun.com/patents et un ou les brevets plus supplémentaires ou les applications de brevet en attente dans les États - Unis et les autres pays."; const char copyright_text_23[] = "Ce produit ou document est protégé par un copyright et distribué avec des licences qui en restreignent l'utilisation, la copie, la distribution, et la décompilation. Aucune partie de ce produit ou document ne peut être reproduite sous aucune forme, par quelque moyen que ce soit, sans l'autorisation préalable et écrite de Sun et de ses bailleurs de licence, s'il y ena."; const char copyright_text_24[] = "L'utilisation est soumise aux termes du contrat de licence."; -- cgit From 724842d9b72155dac4f2ade8ed5385da302a15bf Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 9 Dec 2009 13:31:58 +0000 Subject: #161124# Fix problem with cpu frequency as float. Added context class loader code to fix problems with certain Java versions. --- .../sun/star/servicetag/RegistrationDocument.java | 44 ++++++++++++++++++---- .../com/sun/star/servicetag/SystemEnvironment.java | 4 +- 2 files changed, 40 insertions(+), 8 deletions(-) (limited to 'desktop') diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java index 9e9a9b65bd93..93a1f25a6c2f 100644 --- a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java +++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java @@ -74,7 +74,7 @@ import javax.xml.transform.stream.StreamResult; class RegistrationDocument { private static final String REGISTRATION_DATA_SCHEMA = - "/com/sun/servicetag/resources/product_registration.xsd"; + "/com/sun/star/servicetag/resources/product_registration.xsd"; private static final String REGISTRATION_DATA_VERSION = "1.0"; private static final String SERVICE_TAG_VERSION = "1.0"; final static String ST_NODE_REGISTRATION_DATA = "registration_data"; @@ -155,16 +155,46 @@ class RegistrationDocument { // initialize a document from an input stream private static Document initializeDocument(InputStream in) throws IOException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + SchemaFactory sf = null; try { - // XML schema for validation - SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA); - Schema schema = sf.newSchema(xsdUrl); - Validator validator = schema.newValidator(); + // Some Java versions (e.g., 1.5.0_06-b05) fail with a + // NullPointerException if SchemaFactory.newInstance is called with + // a null context class loader, so work around that here (and the + // class loader of this class hopefully is not the null bootstrap + // class loader): + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + if (cl == null) { + Thread.currentThread().setContextClassLoader( + RegistrationDocument.class.getClassLoader()); + } + try { + sf = SchemaFactory.newInstance( + XMLConstants.W3C_XML_SCHEMA_NS_URI); + } finally { + Thread.currentThread().setContextClassLoader(cl); + } + + Schema schema = null; + try { + // Even using the workaround above is not enough on some + // Java versions. Therefore try to workaround the validation + // completely! + URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA); + schema = sf.newSchema(xsdUrl); + } + catch (NullPointerException nex) { + } + + Validator validator = null; + if (schema != null) + validator = schema.newValidator(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new InputSource(in)); - validator.validate(new DOMSource(doc)); + + if (validator != null) + validator.validate(new DOMSource(doc)); + return doc; } catch (SAXException sxe) { IllegalArgumentException e = new IllegalArgumentException("Error generated in parsing"); diff --git a/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java index b433600f7995..4628034723e1 100644 --- a/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java +++ b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java @@ -213,7 +213,9 @@ public class SystemEnvironment { * @param clockrate The clockrate to set. */ public void setClockRate(String clockrate) { - this.clockrate = clockrate; + Float f = Float.parseFloat(clockrate); + Integer nClockrate = f.intValue(); + this.clockrate = nClockrate.toString(); } /** -- cgit From fdc6366a584f72684e027fa829759ba95994bf81 Mon Sep 17 00:00:00 2001 From: Vladimir Glazunov Date: Thu, 17 Dec 2009 12:08:31 +0100 Subject: #i100000# add link library --- desktop/source/deployment/makefile.mk | 1 + 1 file changed, 1 insertion(+) (limited to 'desktop') diff --git a/desktop/source/deployment/makefile.mk b/desktop/source/deployment/makefile.mk index 8ee3efd34f63..f63661df4cd5 100644 --- a/desktop/source/deployment/makefile.mk +++ b/desktop/source/deployment/makefile.mk @@ -82,6 +82,7 @@ SHL1STDLIBS = \ $(TOOLSLIB) \ $(XMLSCRIPTLIB) \ $(SVLLIB) \ + $(UNOTOOLSLIB) \ $(DEPLOYMENTMISCLIB) \ $(HELPLINKERLIB) -- cgit From 0648323dac86161361ef0aa76d1d90e4d1075472 Mon Sep 17 00:00:00 2001 From: Vladimir Glazunov Date: Thu, 17 Dec 2009 12:09:46 +0100 Subject: #i100000# corrected includes --- desktop/source/deployment/registry/help/dp_help.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'desktop') diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx index 3bc1e1458670..7daa9adb277e 100644 --- a/desktop/source/deployment/registry/help/dp_help.cxx +++ b/desktop/source/deployment/registry/help/dp_help.cxx @@ -38,8 +38,8 @@ #include "osl/file.hxx" #include "ucbhelper/content.hxx" #include "comphelper/servicedecl.hxx" -#include "svtools/inettype.hxx" -#include "svtools/pathoptions.hxx" +#include "svl/inettype.hxx" +#include "unotools/pathoptions.hxx" #include #include -- cgit