summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2009-09-16 11:45:54 +0000
committerIvo Hinkelmann <ihi@openoffice.org>2009-09-16 11:45:54 +0000
commit847f4c1f67c48b52e8420406ea895acbc9c36131 (patch)
treec289fa00d3c169f13102f4c28345f276e02680ad
parentc3da55c5d2ba81ef01a882bbfff5fd11ede15163 (diff)
CWS-TOOLING: integrate CWS l10nframework01
-rw-r--r--configmgr/source/backendhelper/makefile.mk2
-rw-r--r--configmgr/source/platformbe/makefile.mk2
-rw-r--r--configmgr/util/makefile.mk2
-rw-r--r--desktop/prj/build.lst6
-rw-r--r--desktop/prj/d.lst9
-rw-r--r--desktop/registry/data/org/openoffice/Office/Jobs.xcu78
-rw-r--r--desktop/registry/data/org/openoffice/Office/makefile.mk81
-rw-r--r--desktop/source/deployment/registry/help/dp_help.cxx2
-rw-r--r--desktop/source/registration/com/sun/star/registration/Registration.java342
-rw-r--r--desktop/source/registration/com/sun/star/registration/makefile.mk59
-rw-r--r--desktop/source/registration/com/sun/star/registration/manifest2
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java205
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/Installer.java947
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java194
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/RegistrationData.java473
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java374
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/Registry.java558
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/ServiceTag.java640
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java68
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java159
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SunConnection.java296
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java380
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java341
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java (renamed from xmlhelp/inc/xmlhelp/helplinkerdllapi.h)39
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/Util.java297
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java145
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/makefile.mk83
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd301
-rw-r--r--desktop/util/makefile.mk7
-rw-r--r--eventattacher/source/makefile.mk3
-rw-r--r--fileaccess/source/makefile.mk2
-rw-r--r--oovbaapi/genconstidl/makefile.mk6
-rw-r--r--oovbaapi/ooo/vba/constants/makefile.mk8
-rw-r--r--oovbaapi/ooo/vba/makefile.mk4
-rw-r--r--oovbaapi/util/makefile.mk2
-rw-r--r--sandbox/com/sun/star/lib/sandbox/makefile.mk4
-rw-r--r--sandbox/util/makefile.mk4
-rwxr-xr-xscripting/examples/java/makefile.mk2
-rwxr-xr-xscripting/examples/makefile.mk4
-rwxr-xr-xscripting/java/makefile.mk2
-rw-r--r--sfx2/sdi/makefile.mk3
-rw-r--r--svx/sdi/makefile.mk4
-rw-r--r--sysui/desktop/tg_rpm.mk2
-rw-r--r--ucb/inc/makefile.mk3
-rw-r--r--ucb/source/cacher/makefile.mk2
-rw-r--r--ucb/source/core/makefile.mk3
-rw-r--r--ucb/source/regexp/makefile.mk2
-rw-r--r--ucb/source/sorter/makefile.mk2
-rw-r--r--ucb/source/ucp/expand/makefile.mk4
-rw-r--r--ucb/source/ucp/file/makefile.mk2
-rw-r--r--ucb/source/ucp/ftp/makefile.mk3
-rw-r--r--ucb/source/ucp/gio/makefile.mk2
-rw-r--r--ucb/source/ucp/gvfs/makefile.mk2
-rw-r--r--ucb/source/ucp/hierarchy/makefile.mk2
-rw-r--r--ucb/source/ucp/package/makefile.mk2
-rw-r--r--ucb/source/ucp/tdoc/makefile.mk3
-rw-r--r--ucb/source/ucp/webdav/makefile.mk2
-rw-r--r--xmlhelp/inc/xmlhelp/compilehelp.hxx70
-rw-r--r--xmlhelp/prj/build.lst2
-rw-r--r--xmlhelp/source/com/sun/star/help/HelpCompiler.cxx593
-rw-r--r--xmlhelp/source/com/sun/star/help/HelpCompiler.hxx320
-rw-r--r--xmlhelp/source/com/sun/star/help/HelpFileDocument.java89
-rw-r--r--xmlhelp/source/com/sun/star/help/HelpIndexer.java299
-rw-r--r--xmlhelp/source/com/sun/star/help/HelpLinker.cxx1161
-rw-r--r--xmlhelp/source/com/sun/star/help/makefile.mk67
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx2
-rw-r--r--xmloff/util/makefile.mk4
-rw-r--r--xmlscript/source/misc/makefile.mk3
-rw-r--r--xmlscript/source/xml_helper/makefile.mk4
-rw-r--r--xmlscript/source/xmldlg_imexp/makefile.mk4
-rw-r--r--xmlscript/source/xmlflat_imexp/makefile.mk4
-rw-r--r--xmlscript/source/xmllib_imexp/makefile.mk5
-rw-r--r--xmlscript/source/xmlmod_imexp/makefile.mk4
73 files changed, 6210 insertions, 2597 deletions
diff --git a/configmgr/source/backendhelper/makefile.mk b/configmgr/source/backendhelper/makefile.mk
index 44b502b451..f9a27c8167 100644
--- a/configmgr/source/backendhelper/makefile.mk
+++ b/configmgr/source/backendhelper/makefile.mk
@@ -39,6 +39,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings ---
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
.INCLUDE : $(PRJ)$/makefile.pmk
DLLPRE =
@@ -66,6 +67,7 @@ DEF1EXPORTFILE=exports.dxp
DEF1DES=Configuration: Backend Helper
# --- Targets ---
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/configmgr/source/platformbe/makefile.mk b/configmgr/source/platformbe/makefile.mk
index 19796b2442..9cbe53f5cf 100644
--- a/configmgr/source/platformbe/makefile.mk
+++ b/configmgr/source/platformbe/makefile.mk
@@ -42,6 +42,7 @@ SYSMGR_MAJOR=1
# --- Settings ---
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
.INCLUDE : $(PRJ)$/makefile.pmk
DLLPRE =
@@ -69,6 +70,7 @@ DEF1EXPORTFILE=exports.dxp
DEF1DES=Configuration: System Integration Manager
# --- Targets ---
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/configmgr/util/makefile.mk b/configmgr/util/makefile.mk
index 6fd7c63195..eaea5d3435 100644
--- a/configmgr/util/makefile.mk
+++ b/configmgr/util/makefile.mk
@@ -36,6 +36,7 @@ TARGET=configmgr
ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
.INCLUDE : $(PRJ)$/makefile.pmk
.INCLUDE : $(PRJ)$/version.mk
DLLPRE =
@@ -75,6 +76,7 @@ DEF1NAME= $(SHL1TARGET)
DEF1EXPORTFILE= exports.dxp
# --- Targets ----------------------------------
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/desktop/prj/build.lst b/desktop/prj/build.lst
index 3aa56e273f..ce2ed07f57 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 uui BERKELEYDB:berkeleydb sysui SO:sysui_so BOOST:boost svx xmlhelp sal unoil officecfg NULL
dt desktop usr1 - all dt_mkout NULL
dt desktop\inc nmake - all dt_inc NULL
dt desktop\prj get - all dt_prj NULL
@@ -38,3 +38,7 @@ dt desktop\source\deployment\registry\executable nmake - all dt_dp_registry_exe
dt desktop\scripts nmake - u dt_scripts dt_inc NULL
dt desktop\util nmake - all dt_util dt_app dt_so_comp dt_spl dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr dt_rebase.w NULL
dt desktop\zipintro nmake - all dt_zipintro NULL
+dt desktop\registry\data\org\openoffice\Office nmake - all sn_regconfig NULL
+dt desktop\source\registration\com\sun\star\servicetag\resources get - all sn_svctagres NULL
+dt desktop\source\registration\com\sun\star\servicetag nmake - all sn_svctag NULL
+dt desktop\source\registration\com\sun\star\registration nmake - all sn_regjob sn_svctag NULL
diff --git a/desktop/prj/d.lst b/desktop/prj/d.lst
index eb0d93886e..fe688e2c4b 100644
--- a/desktop/prj/d.lst
+++ b/desktop/prj/d.lst
@@ -134,3 +134,12 @@ mkdir: %COMMON_DEST%\pck%_EXT%\broffice_nologo
..\scripts\basis-link %_DEST%\bin%_EXT%\c08\basis-link
..\scripts\so-basis-link %_DEST%\bin%_EXT%\so\basis-link
..\scripts\odf-basis-link %_DEST%\bin%_EXT%\odf4ms\basis-link
+
+mkdir: %_DEST%\xml%_EXT%\registry\spool
+mkdir: %_DEST%\xml%_EXT%\registry\spool\org
+mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice
+mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office
+mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Jobs
+
+..\%__SRC%\class\*.jar %_DEST%\bin%_EXT%\*.jar
+..\%__SRC%\misc\registry\spool\org\openoffice\Office\Jobs\*.xcu %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Jobs
diff --git a/desktop/registry/data/org/openoffice/Office/Jobs.xcu b/desktop/registry/data/org/openoffice/Office/Jobs.xcu
new file mode 100644
index 0000000000..b613e86eb2
--- /dev/null
+++ b/desktop/registry/data/org/openoffice/Office/Jobs.xcu
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * 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: Jobs.xcu,v $
+ *
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="Jobs">
+ <node oor:name="ProductRegistration" oor:op="replace">
+ <prop oor:name="Service">
+ <value>com.sun.star.comp.framework.DoRegistrationJob</value>
+ </prop>
+ <node oor:name="Arguments">
+ <prop oor:name="ProductName" oor:op="replace" oor:type="xs:string">
+ <value>${SERVICETAG_PRODUCTNAME}</value>
+ </prop>
+ <prop oor:name="ProductVersion" oor:op="replace" oor:type="xs:string">
+ <value>${SERVICETAG_PRODUCTVERSION}</value>
+ </prop>
+ <prop oor:name="ProductURN" oor:op="replace" oor:type="xs:string">
+ <value>${SERVICETAG_URN}</value>
+ </prop>
+ <prop oor:name="ProductSource" oor:op="replace" oor:type="xs:string">
+ <value>${SERVICETAG_SOURCE}</value>
+ </prop>
+ <prop oor:name="ProductParent" oor:op="replace" oor:type="xs:string">
+ <value>${SERVICETAG_PARENTNAME}</value>
+ </prop>
+ <prop oor:name="Vendor" oor:op="replace" oor:type="xs:string">
+ <value>Sun Microsystems, Inc.</value>
+ </prop>
+ <prop oor:name="RegistrationData" oor:op="replace" oor:type="xs:string">
+ <value>$(user)/registration.xml</value>
+ </prop>
+ <prop oor:name="RegistrationURL" oor:op="replace" oor:type="xs:string">
+ <value>${REGISTRATION_HOST}/register/${registry_urn}?product=${REGISTRATION_PRODUCT}&amp;locale=${locale}&amp;cid=${REGISTRATION_CID}</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="Events">
+ <node oor:name="onRegisterNow" oor:op="fuse">
+ <node oor:name="JobList">
+ <node oor:name="ProductRegistration" oor:op="replace"/>
+ </node>
+ </node>
+ <node oor:name="onRegisterLater" oor:op="fuse">
+ <node oor:name="JobList">
+ <node oor:name="ProductRegistration" oor:op="replace"/>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/desktop/registry/data/org/openoffice/Office/makefile.mk b/desktop/registry/data/org/openoffice/Office/makefile.mk
new file mode 100644
index 0000000000..651c731fa4
--- /dev/null
+++ b/desktop/registry/data/org/openoffice/Office/makefile.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.5 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..$/..
+PRJNAME=setup_native
+TARGET=data_registration
+PACKAGE=org.openoffice.Office
+
+ABSXCSROOT=$(SOLARXMLDIR)
+XCSROOT=..
+DTDDIR=$(ABSXCSROOT)
+XSLDIR=$(ABSXCSROOT)$/processing
+PROCESSOUT=$(MISC)$/$(TARGET)
+PROCESSORDIR=$(SOLARBINDIR)
+
+.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+
+# --- Files -------------------------------------------------------
+
+.IF "$(BUILD_SPECIAL)"!=""
+
+XCUFILES= \
+ Jobs.xcu
+
+MODULEFILES=
+
+LOCALIZEDFILES=
+
+PACKAGEDIR=$(subst,.,$/ $(PACKAGE))
+SPOOLDIR=$(MISC)$/registry$/spool
+
+MYXCUFILES= \
+ $(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-registration.xcu
+
+.ELSE # "$(BUILD_SPECIAL)"!=""
+
+dummy:
+ @echo "Nothing to build"
+
+.ENDIF # "$(BUILD_SPECIAL)"!=""
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.ENDIF # L10N_framework
+ALLTAR : $(MYXCUFILES)
+
+$(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-registration.xcu : $(PROCESSOUT)$/registry$/data$/$/$(PACKAGEDIR)$/Jobs.xcu
+ @-$(MKDIRHIER) $(@:d)
+ @$(COPY) $< $@
+
diff --git a/desktop/source/deployment/registry/help/dp_help.cxx b/desktop/source/deployment/registry/help/dp_help.cxx
index 175d83934d..8ef0a7141a 100644
--- a/desktop/source/deployment/registry/help/dp_help.cxx
+++ b/desktop/source/deployment/registry/help/dp_help.cxx
@@ -40,7 +40,7 @@
#include "comphelper/servicedecl.hxx"
#include "svtools/inettype.hxx"
-#include <xmlhelp/compilehelp.hxx>
+#include <transex3/compilehelp.hxx>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
diff --git a/desktop/source/registration/com/sun/star/registration/Registration.java b/desktop/source/registration/com/sun/star/registration/Registration.java
new file mode 100644
index 0000000000..3d396e3b8d
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/registration/Registration.java
@@ -0,0 +1,342 @@
+/*************************************************************************
+ *
+ * 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
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.registration;
+
+import com.sun.star.beans.NamedValue;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.frame.DispatchResultEvent;
+import com.sun.star.frame.DispatchResultState;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.registry.*;
+import com.sun.star.servicetag.*;
+import com.sun.star.system.*;
+import com.sun.star.task.*;
+import com.sun.star.uno.*;
+import com.sun.star.uri.XExternalUriReferenceTranslator;
+import com.sun.star.util.XStringSubstitution;
+
+import java.io.*;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Set;
+import java.net.HttpURLConnection;
+
+public class Registration {
+
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory, XRegistryKey regKey) {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals(Registration.class.getName())) {
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(_Registration.class, _serviceName, multiFactory, regKey);
+ }
+
+ return xSingleServiceFactory;
+ }
+
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return FactoryHelper.writeRegistryServiceInfo(Registration.class.getName(), _serviceName, regKey);
+ }
+
+ static final String _serviceName = "com.sun.star.comp.framework.DoRegistrationJob";
+
+ static public class _Registration implements XJob {
+ XComponentContext xComponentContext;
+
+ XStringSubstitution xPathSubstService = null;
+ XExternalUriReferenceTranslator xUriTranslator = null;
+
+ RegistrationData theRegistrationData = null;
+
+ public _Registration(XComponentContext xComponentContext) {
+ this.xComponentContext = xComponentContext;
+ }
+
+ private String resolvePath(String path) {
+ try {
+ if( xPathSubstService == null || xUriTranslator == null ) {
+ XMultiComponentFactory theServiceManager = xComponentContext.getServiceManager();
+ if( xPathSubstService == null ) {
+ Object o = theServiceManager.createInstanceWithContext(
+ "com.sun.star.util.PathSubstitution",
+ xComponentContext );
+ xPathSubstService = (XStringSubstitution)
+ UnoRuntime.queryInterface(XStringSubstitution.class, o);
+ }
+
+ if( xUriTranslator == null ) {
+ Object o = theServiceManager.createInstanceWithContext(
+ "com.sun.star.uri.ExternalUriReferenceTranslator",
+ xComponentContext );
+ xUriTranslator = (XExternalUriReferenceTranslator)
+ UnoRuntime.queryInterface(XExternalUriReferenceTranslator.class, o);
+ }
+ }
+
+ String s = xPathSubstService.substituteVariables(path, true);
+ return xUriTranslator.translateToExternal(s);
+ } catch (java.lang.Exception e) {
+ return path;
+ }
+ }
+
+ private void openBrowser(String url) {
+ try {
+ XMultiComponentFactory theServiceManager = xComponentContext.getServiceManager();
+
+ Object o = theServiceManager.createInstanceWithContext(
+ "com.sun.star.system.SystemShellExecute",
+ xComponentContext );
+
+ XSystemShellExecute xShellExecuteService = (XSystemShellExecute)
+ UnoRuntime.queryInterface(XSystemShellExecute.class, o);
+
+ xShellExecuteService.execute( url, "", SystemShellExecuteFlags.DEFAULTS );
+ } catch (java.lang.Exception e) {
+ }
+ }
+
+ private ServiceTag getServiceTagFromRegistrationData(File xmlFile, String productURN) {
+ try {
+ RegistrationData storedRegData = RegistrationData.loadFromXML(new FileInputStream(xmlFile));
+ Set<ServiceTag> storedServiceTags = storedRegData.getServiceTags();
+
+ Iterator<ServiceTag> tagIterator = storedServiceTags.iterator();
+ while( tagIterator.hasNext() ) {
+ ServiceTag tag = tagIterator.next();
+ if( tag.getProductURN().equals(productURN) ) {
+ theRegistrationData = storedRegData;
+ return tag;
+ }
+ }
+
+ // product URN has changed, remove registration data file
+ xmlFile.delete();
+ } catch (IOException e) {
+ // fall through intentionally
+ } catch (IllegalArgumentException e) {
+ // file is damaged (or a name clash appeared)
+ xmlFile.delete();
+ }
+ return null;
+ }
+
+ /*
+ * XJob
+ *
+ * NOTE: as this Job hets triggered by the the JobExecutor service from first start
+ * wizard and registration reminder code (because their frames do not implement
+ * XDispatchProvider), making this an XAsyncJob doesn't make sense as the
+ * JobExecutor waits for the jobFinished call on the listener passed.
+ */
+ public Object execute(NamedValue[] args)
+ throws com.sun.star.lang.IllegalArgumentException, com.sun.star.uno.Exception {
+
+ final NamedValue[] f_args = args;
+
+ new Thread(
+ new Runnable () {
+ public void run() {
+ try {
+ executeImpl(f_args);
+ } catch(com.sun.star.uno.Exception e) {
+ }
+ }
+ }
+ ).start();
+
+ NamedValue ret[] = new NamedValue[1];
+ ret[0] = new NamedValue( "Deactivate", new Boolean(false) );
+ return ret;
+ }
+
+ public synchronized void executeImpl(NamedValue[] args)
+ throws com.sun.star.lang.IllegalArgumentException, com.sun.star.uno.Exception {
+
+ // extract the interesting part of the argument list
+ NamedValue[] theJobConfig = null;
+ NamedValue[] theEnvironment = null;
+
+ int c = args.length;
+ for (int i=0; i<c; ++i) {
+ if (args[i].Name.equals("JobConfig"))
+ theJobConfig = (NamedValue[]) AnyConverter.toArray(args[i].Value);
+ else if (args[i].Name.equals("Environment"))
+ theEnvironment = (NamedValue[]) AnyConverter.toArray(args[i].Value);
+ }
+
+ if (theEnvironment==null)
+ throw new com.sun.star.lang.IllegalArgumentException("no environment");
+
+ boolean saveConfig = false;
+
+ String productName = "";
+ String productVersion = "";
+ String productURN = "";
+ String productParent = "";
+ String productParentURN = "";
+ String productDefinedInstanceID = "";
+ String productSource = "";
+ String vendor = "";
+
+ String urlRegData = null;
+ String registrationURL = null;
+
+ c = theJobConfig.length;
+ for (int i=0; i<c; ++i) {
+ if( theJobConfig[i].Name.equals("ProductName") ) {
+ productName = AnyConverter.toString(theJobConfig[i].Value);
+ } else if( theJobConfig[i].Name.equals("ProductVersion") ) {
+ productVersion = AnyConverter.toString(theJobConfig[i].Value);
+ } else if( theJobConfig[i].Name.equals("ProductURN") ) {
+ productURN = AnyConverter.toString(theJobConfig[i].Value);
+ } else if( theJobConfig[i].Name.equals("ProductParent") ) {
+ productParent = AnyConverter.toString(theJobConfig[i].Value);
+ } else if( theJobConfig[i].Name.equals("ProductParentURN") ) {
+ productParentURN = AnyConverter.toString(theJobConfig[i].Value);
+ } else if( theJobConfig[i].Name.equals("ProductSource") ) {
+ productSource = AnyConverter.toString(theJobConfig[i].Value);
+ } else if( theJobConfig[i].Name.equals("Vendor") ) {
+ vendor = AnyConverter.toString(theJobConfig[i].Value);
+ } else if( theJobConfig[i].Name.equals("RegistrationData") ) {
+ urlRegData = resolvePath(AnyConverter.toString(theJobConfig[i].Value));
+ } else if( theJobConfig[i].Name.equals("RegistrationURL") ) {
+ registrationURL = AnyConverter.toString(theJobConfig[i].Value);
+ } else {
+ System.err.println( theJobConfig[i].Name + " = " + AnyConverter.toString(theJobConfig[i].Value) );
+ }
+ }
+
+ if (registrationURL==null)
+ throw new com.sun.star.lang.IllegalArgumentException("no registration url");
+
+ boolean local_only = false;
+
+ c = theEnvironment.length;
+ for (int i=0; i<c; ++i) {
+ if( theEnvironment[i].Name.equals("EventName") ) {
+ if( ! AnyConverter.toString(theEnvironment[i].Value).equals("onRegisterNow") ) {
+ local_only = true;
+ }
+ }
+ }
+
+ try {
+
+ /* ensure only one thread accesses/writes registration.xml at a time
+ * regardless how many instances of this Job exist.
+ */
+ synchronized( _serviceName ) {
+
+ File xmlRegData = new File( new URI( urlRegData ) );
+
+ ServiceTag tag = getServiceTagFromRegistrationData(xmlRegData, productURN);
+ if( tag == null ) {
+ tag = ServiceTag.newInstance(
+ ServiceTag.generateInstanceURN(),
+ productName,
+ productVersion,
+ productURN,
+ productParent,
+ productParentURN,
+ productDefinedInstanceID,
+ vendor,
+ System.getProperty("os.arch"),
+ Installer.getZoneName(),
+ productSource);
+
+ theRegistrationData = new RegistrationData();
+ theRegistrationData.addServiceTag(tag);
+ theRegistrationData.storeToXML( new FileOutputStream( xmlRegData ) );
+ }
+
+ // Store the service tag in local registry, which might have been installed later
+ if( Registry.isSupported() ) {
+ // ignore communication failures with local service tag client
+ try {
+ if( Registry.getSystemRegistry().getServiceTag(tag.getInstanceURN()) == null ) {
+ Registry.getSystemRegistry().addServiceTag(tag);
+ }
+ } catch( java.io.IOException e) {
+ e.printStackTrace();
+ } catch (java.lang.RuntimeException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if( ! local_only ) {
+ registrationURL = registrationURL.replaceAll("\\$\\{registry_urn\\}", theRegistrationData.getRegistrationURN());
+ registrationURL = registrationURL.replaceAll("\\$\\{locale\\}", Locale.getDefault().getLanguage());
+
+ HttpURLConnection con = (HttpURLConnection) new URL(registrationURL).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\"");
+ try {
+ con.connect();
+
+ OutputStream out = con.getOutputStream();
+ theRegistrationData.storeToXML(out);
+ out.flush();
+ out.close();
+
+ int returnCode = con.getResponseCode();
+// if (returnCode == HttpURLConnection.HTTP_OK);
+ } catch(java.lang.Exception e) {
+ // IOException and UnknownHostException
+ }
+ openBrowser(registrationURL);
+ }
+ } catch (java.net.MalformedURLException e) {
+ e.printStackTrace();
+ throw new com.sun.star.lang.IllegalArgumentException( e.toString() );
+ } catch (java.net.URISyntaxException e) {
+ e.printStackTrace();
+ throw new com.sun.star.lang.IllegalArgumentException( e.toString() );
+ } catch (java.io.IOException e) {
+ e.printStackTrace();
+ throw new com.sun.star.uno.RuntimeException( e.toString() );
+ } catch (java.lang.RuntimeException e) {
+ e.printStackTrace();
+ throw new com.sun.star.uno.RuntimeException( e.toString() );
+ }
+ }
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/registration/makefile.mk b/desktop/source/registration/com/sun/star/registration/makefile.mk
new file mode 100644
index 0000000000..f20eaf71ad
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/registration/makefile.mk
@@ -0,0 +1,59 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.2 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJNAME = setup_native
+PRJ = ..$/..$/..$/..$/..$/..
+TARGET = productregistration
+PACKAGE = com$/sun$/star$/registration
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(ENABLE_SVCTAGS)" == "YES"
+
+JARFILES = jurt.jar unoil.jar ridl.jar
+JAVAFILES = \
+ Registration.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+JARCLASSDIRS = $(PACKAGE) com$/sun$/star$/servicetag
+CUSTOMMANIFESTFILE = manifest
+.ENDIF # "$(ENABLE_SVCTAGS)" == "YES"
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
diff --git a/desktop/source/registration/com/sun/star/registration/manifest b/desktop/source/registration/com/sun/star/registration/manifest
new file mode 100644
index 0000000000..952aaa804e
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/registration/manifest
@@ -0,0 +1,2 @@
+RegistrationClassName: com.sun.star.registration.Registration
+UNO-Type-Path:
diff --git a/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java b/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java
new file mode 100644
index 0000000000..7623e7f2f6
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/BrowserSupport.java
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * 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: BrowserSupport.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.io.IOException;
+import java.net.URI;
+
+/**
+ * BrowserSupport class.
+ *
+ * The implementation of the com.sun.servicetag API needs to be
+ * compiled with JDK 5 as well since the consumer of this API
+ * may require to support JDK 5 (e.g. NetBeans).
+ *
+ * The Desktop.browse() method can be backported in this class
+ * if needed. The current implementation only supports JDK 6.
+ */
+class BrowserSupport {
+ private static boolean isBrowseSupported = false;
+ private static Method browseMethod = null;
+ private static Object desktop = null;
+ private static volatile Boolean result = false;
+
+
+ private static void initX() {
+ if (desktop != null) {
+ return;
+ }
+ boolean supported = false;
+ Method browseM = null;
+ Object desktopObj = null;
+ try {
+ // Determine if java.awt.Desktop is supported
+ Class desktopCls = Class.forName("java.awt.Desktop", true, null);
+ Method getDesktopM = desktopCls.getMethod("getDesktop");
+ browseM = desktopCls.getMethod("browse", URI.class);
+
+ Class actionCls = Class.forName("java.awt.Desktop$Action", true, null);
+ final Method isDesktopSupportedMethod = desktopCls.getMethod("isDesktopSupported");
+ Method isSupportedMethod = desktopCls.getMethod("isSupported", actionCls);
+ Field browseField = actionCls.getField("BROWSE");
+ // isDesktopSupported calls getDefaultToolkit which can block
+ // infinitely, see 6636099 for details, to workaround we call
+ // in a thread and time it out, noting that the issue is specific
+ // to X11, it does not hurt for Windows.
+ Thread xthread = new Thread() {
+ public void run() {
+ try {
+ // support only if Desktop.isDesktopSupported() and
+ // Desktop.isSupported(Desktop.Action.BROWSE) return true.
+ result = (Boolean) isDesktopSupportedMethod.invoke(null);
+ } catch (IllegalAccessException e) {
+ // should never reach here
+ InternalError x =
+ new InternalError("Desktop.getDesktop() method not found");
+ x.initCause(e);
+ } catch (InvocationTargetException e) {
+ // browser not supported
+ if (Util.isVerbose()) {
+ e.printStackTrace();
+ }
+ }
+ }
+ };
+ // set it to daemon, so that the vm will exit.
+ xthread.setDaemon(true);
+ xthread.start();
+ try {
+ xthread.join(5 * 1000);
+ } catch (InterruptedException ie) {
+ // ignore the exception
+ }
+ if (result.booleanValue()) {
+ desktopObj = getDesktopM.invoke(null);
+ result = (Boolean) isSupportedMethod.invoke(desktopObj, browseField.get(null));
+ supported = result.booleanValue();
+ }
+ } catch (ClassNotFoundException e) {
+ // browser not supported
+ if (Util.isVerbose()) {
+ e.printStackTrace();
+ }
+ } catch (NoSuchMethodException e) {
+ // browser not supported
+ if (Util.isVerbose()) {
+ e.printStackTrace();
+ }
+ } catch (NoSuchFieldException e) {
+ // browser not supported
+ if (Util.isVerbose()) {
+ e.printStackTrace();
+ }
+ } catch (IllegalAccessException e) {
+ // should never reach here
+ InternalError x =
+ new InternalError("Desktop.getDesktop() method not found");
+ x.initCause(e);
+ throw x;
+ } catch (InvocationTargetException e) {
+ // browser not supported
+ if (Util.isVerbose()) {
+ e.printStackTrace();
+ }
+ }
+ isBrowseSupported = supported;
+ browseMethod = browseM;
+ desktop = desktopObj;
+ }
+
+ static boolean isSupported() {
+ initX();
+ return isBrowseSupported;
+ }
+
+ /**
+ * Launches the default browser to display a {@code URI}.
+ * If the default browser is not able to handle the specified
+ * {@code URI}, the application registered for handling
+ * {@code URIs} of the specified type is invoked. The application
+ * is determined from the protocol and path of the {@code URI}, as
+ * defined by the {@code URI} class.
+ * <p>
+ * This method calls the Desktop.getDesktop().browse() method.
+ * <p>
+ * @param uri the URI to be displayed in the user default browser
+ *
+ * @throws NullPointerException if {@code uri} is {@code null}
+ * @throws UnsupportedOperationException if the current platform
+ * does not support the {@link Desktop.Action#BROWSE} action
+ * @throws IOException if the user default browser is not found,
+ * or it fails to be launched, or the default handler application
+ * failed to be launched
+ * @throws IllegalArgumentException if the necessary permissions
+ * are not available and the URI can not be converted to a {@code URL}
+ */
+ static void browse(URI uri) throws IOException {
+ if (uri == null) {
+ throw new NullPointerException("null uri");
+ }
+ if (!isSupported()) {
+ throw new UnsupportedOperationException("Browse operation is not supported");
+ }
+
+ // Call Desktop.browse() method
+ try {
+ if (Util.isVerbose()) {
+ System.out.println("desktop: " + desktop + ":browsing..." + uri);
+ }
+ browseMethod.invoke(desktop, uri);
+ } catch (IllegalAccessException e) {
+ // should never reach here
+ InternalError x =
+ new InternalError("Desktop.getDesktop() method not found");
+ x.initCause(e);
+ throw x;
+ } catch (InvocationTargetException e) {
+ Throwable x = e.getCause();
+ if (x != null) {
+ if (x instanceof UnsupportedOperationException) {
+ throw (UnsupportedOperationException) x;
+ } else if (x instanceof IllegalArgumentException) {
+ throw (IllegalArgumentException) x;
+ } else if (x instanceof IOException) {
+ throw (IOException) x;
+ } else if (x instanceof SecurityException) {
+ throw (SecurityException) x;
+ } else {
+ // ignore
+ }
+ }
+ }
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/Installer.java b/desktop/source/registration/com/sun/star/servicetag/Installer.java
new file mode 100644
index 0000000000..b8e6e34dfd
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/Installer.java
@@ -0,0 +1,947 @@
+/*************************************************************************
+ *
+ * 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: Installer.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+import java.io.*;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+import static com.sun.star.servicetag.Util.*;
+
+/**
+ * Service Tag Installer for Java SE.
+ */
+public class Installer {
+ // System properties for testing
+ private static String SVCTAG_DIR_PATH =
+ "servicetag.dir.path";
+ private static String SVCTAG_ENABLE_REGISTRATION =
+ "servicetag.registration.enabled";
+ private final static String SUN_VENDOR = "Sun Microsystems";
+ private final static String REGISTRATION_XML = "registration.xml";
+ private final static String SERVICE_TAG_FILE = "servicetag";
+ private final static String REGISTRATION_HTML_NAME = "register";
+
+ private final static Locale[] knownSupportedLocales =
+ new Locale[] { Locale.ENGLISH,
+ Locale.JAPANESE,
+ Locale.SIMPLIFIED_CHINESE};
+
+ private final static String javaHome = System.getProperty("java.home");
+ private static File svcTagDir;
+ private static File serviceTagFile;
+ private static File regXmlFile;
+ private static RegistrationData registration;
+ private static boolean supportRegistration;
+ private static String registerHtmlParent;
+ private static Set<Locale> supportedLocales = new HashSet<Locale>();
+ private static Properties swordfishProps = null;
+ private static String[] jreArchs = null;
+ static {
+ String dir = System.getProperty(SVCTAG_DIR_PATH);
+ if (dir == null) {
+ svcTagDir = new File(getJrePath(), "lib" + File.separator + SERVICE_TAG_FILE);
+ } else {
+ svcTagDir = new File(dir);
+ }
+ serviceTagFile = new File(svcTagDir, SERVICE_TAG_FILE);
+ regXmlFile = new File(svcTagDir, REGISTRATION_XML);
+ if (System.getProperty(SVCTAG_ENABLE_REGISTRATION) == null) {
+ supportRegistration = isJdk();
+ } else {
+ supportRegistration = true;
+ }
+ }
+
+ private Installer() {
+ }
+
+ // Implementation of ServiceTag.getJavaServiceTag(String) method
+ static ServiceTag getJavaServiceTag(String source) throws IOException {
+ if (!System.getProperty("java.vendor").startsWith(SUN_VENDOR)) {
+ // Products bundling this implementation may run on
+ // Mac OS which is not a Sun JDK
+ return null;
+ }
+ boolean cleanup = false;
+ try {
+ // Check if we have the swordfish entries for this JRE version
+ if (loadSwordfishEntries() == null) {
+ return null;
+ }
+
+ ServiceTag st = getJavaServiceTag();
+ // Check if the service tag created by this bundle owner
+ if (st != null && st.getSource().equals(source)) {
+ // Install the system service tag if supported
+ // stclient may be installed after the service tag creation
+ if (Registry.isSupported()) {
+ installSystemServiceTag();
+ }
+ return st;
+ }
+
+ // in case any exception thrown during the cleanup
+ cleanup = true;
+
+ // re-create a new one for this bundle owner
+ // first delete the registration data
+ deleteRegistrationData();
+ cleanup = false;
+
+ // create service tag and generate new register.html pages
+ return createServiceTag(source);
+ } finally {
+ if (cleanup) {
+ if (regXmlFile.exists()) {
+ regXmlFile.delete();
+ }
+ if (serviceTagFile.exists()) {
+ serviceTagFile.delete();
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the Java SE registration data located in
+ * the <JRE>/lib/servicetag/registration.xml by default.
+ *
+ * @throws IllegalArgumentException if the registration data
+ * is of invalid format.
+ */
+ private static synchronized RegistrationData getRegistrationData()
+ throws IOException {
+ if (registration != null) {
+ return registration;
+ }
+ if (regXmlFile.exists()) {
+ BufferedInputStream in = null;
+ try {
+ in = new BufferedInputStream(new FileInputStream(regXmlFile));
+ registration = RegistrationData.loadFromXML(in);
+ } catch (IllegalArgumentException ex) {
+ System.err.println("Error: Bad registration data \"" +
+ regXmlFile + "\":" + ex.getMessage());
+ throw ex;
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ } else {
+ registration = new RegistrationData();
+ }
+ return registration;
+ }
+
+ /**
+ * Write the registration data to the registration.xml file.
+ *
+ * The offline registration page has to be regenerated with
+ * the new registration data.
+ *
+ * @throws java.io.IOException
+ */
+ private static synchronized void writeRegistrationXml()
+ throws IOException {
+ if (!svcTagDir.exists()) {
+ // This check is for NetBeans or other products that
+ // bundles this com.sun.servicetag implementation for
+ // pre-6u5 release.
+ if (!svcTagDir.mkdir()) {
+ throw new IOException("Failed to create directory: " + svcTagDir);
+ }
+ }
+
+ // regenerate the new offline registration page
+ deleteRegistrationHtmlPage();
+ getRegistrationHtmlPage();
+
+ BufferedOutputStream out = null;
+ try {
+ out = new BufferedOutputStream(new FileOutputStream(regXmlFile));
+ getRegistrationData().storeToXML(out);
+ } catch (IllegalArgumentException ex) {
+ System.err.println("Error: Bad registration data \"" +
+ regXmlFile + "\":" + ex.getMessage());
+ throw ex;
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ /**
+ * Returns the instance urn(s) stored in the servicetag file
+ * or empty set if file not exists.
+ */
+ private static Set<String> getInstalledURNs() throws IOException {
+ Set<String> urnSet = new HashSet<String>();
+ if (serviceTagFile.exists()) {
+ BufferedReader in = null;
+ try {
+ in = new BufferedReader(new FileReader(serviceTagFile));
+ String urn;
+ while ((urn = in.readLine()) != null) {
+ urn = urn.trim();
+ if (urn.length() > 0) {
+ urnSet.add(urn);
+ }
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+ return urnSet;
+ }
+
+ /**
+ * Return the Java SE service tag(s) if it exists.
+ * Typically only one Java SE service tag but it could have two for
+ * Solaris 32-bit and 64-bit on the same install directory.
+ *
+ * @return the service tag(s) for Java SE
+ */
+ private static ServiceTag[] getJavaServiceTagArray() throws IOException {
+ RegistrationData regData = getRegistrationData();
+ Set<ServiceTag> svcTags = regData.getServiceTags();
+ Set<ServiceTag> result = new HashSet<ServiceTag>();
+
+ Properties props = loadSwordfishEntries();
+ String jdkUrn = props.getProperty("servicetag.jdk.urn");
+ String jreUrn = props.getProperty("servicetag.jre.urn");
+ for (ServiceTag st : svcTags) {
+ if (st.getProductURN().equals(jdkUrn) ||
+ st.getProductURN().equals(jreUrn)) {
+ result.add(st);
+ }
+ }
+ return result.toArray(new ServiceTag[0]);
+ }
+
+ /**
+ * Returns the Java SE service tag for this running platform;
+ * or null if not exist.
+ * This method will return the 64-bit service tag if the JDK
+ * supports both 32-bit and 64-bit if already created.
+ */
+ private static ServiceTag getJavaServiceTag() throws IOException {
+ String definedId = getProductDefinedId();
+ for (ServiceTag st : getJavaServiceTagArray()) {
+ if (st.getProductDefinedInstanceID().equals(definedId)) {
+ return st;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Create a service tag for Java SE and install in the system
+ * service tag registry if supported.
+ *
+ * A registration data <JRE>/lib/servicetag/registration.xml
+ * will be created to storeToXML the XML entry for Java SE service tag.
+ * If the system supports service tags, this method will install
+ * the Java SE service tag in the system service tag registry and
+ * its <tt>instance_urn</tt> will be stored to <JRE>/lib/servicetag/servicetag.
+ *
+ * If <JRE>/lib/servicetag/registration.xml exists but is not installed
+ * in the system service tag registry (i.e. servicetag doesn't exist),
+ * this method will install it as described above.
+ *
+ * If the system supports service tag, stclient will be used
+ * to create the Java SE service tag.
+ *
+ * A Solaris 32-bit and 64-bit JDK will be installed in the same
+ * directory but the registration.xml will have 2 service tags.
+ * The servicetag file will also contain 2 instance_urns for that case.
+ */
+ private static ServiceTag createServiceTag(String svcTagSource)
+ throws IOException {
+ // determine if a new service tag is needed to be created
+ ServiceTag newSvcTag = null;
+ if (getJavaServiceTag() == null) {
+ newSvcTag = newServiceTag(svcTagSource);
+ }
+
+ // Add the new service tag in the registration data
+ if (newSvcTag != null) {
+ RegistrationData regData = getRegistrationData();
+
+ // Add the service tag to the registration data in JDK/JRE
+ newSvcTag = regData.addServiceTag(newSvcTag);
+
+ // add if there is a service tag for the OS
+ ServiceTag osTag = SolarisServiceTag.getServiceTag();
+ if (osTag != null && regData.getServiceTag(osTag.getInstanceURN()) == null) {
+ regData.addServiceTag(osTag);
+ }
+ // write to the registration.xml
+ writeRegistrationXml();
+ }
+
+ // Install the system service tag if supported
+ if (Registry.isSupported()) {
+ installSystemServiceTag();
+ }
+ return newSvcTag;
+ }
+
+ private static void installSystemServiceTag() throws IOException {
+ // only install the service tag in the registry if
+ // it has permission to write the servicetag file.
+ if ((!serviceTagFile.exists() && !svcTagDir.canWrite()) ||
+ (serviceTagFile.exists() && !serviceTagFile.canWrite())) {
+ return;
+ }
+
+ Set<String> urns = getInstalledURNs();
+ ServiceTag[] javaSvcTags = getJavaServiceTagArray();
+ if (urns.size() < javaSvcTags.length) {
+ for (ServiceTag st : javaSvcTags) {
+ // Add the service tag in the system service tag registry
+ // if not installed
+ String instanceURN = st.getInstanceURN();
+ if (!urns.contains(instanceURN)) {
+ Registry.getSystemRegistry().addServiceTag(st);
+ }
+ }
+ }
+ writeInstalledUrns();
+ }
+
+ private static ServiceTag newServiceTag(String svcTagSource) throws IOException {
+ // Load the swoRDFish information for the service tag creation
+ Properties props = loadSwordfishEntries();
+
+ // Determine the product URN and name
+ String productURN;
+ String productName;
+
+ if (isJdk()) {
+ // <HOME>/jre exists which implies it's a JDK
+ productURN = props.getProperty("servicetag.jdk.urn");
+ productName = props.getProperty("servicetag.jdk.name");
+ } else {
+ // Otherwise, it's a JRE
+ productURN = props.getProperty("servicetag.jre.urn");
+ productName = props.getProperty("servicetag.jre.name");
+ }
+
+ return ServiceTag.newInstance(ServiceTag.generateInstanceURN(),
+ productName,
+ System.getProperty("java.version"),
+ productURN,
+ props.getProperty("servicetag.parent.name"),
+ props.getProperty("servicetag.parent.urn"),
+ getProductDefinedId(),
+ SUN_VENDOR,
+ System.getProperty("os.arch"),
+ getZoneName(),
+ svcTagSource);
+ }
+
+ /**
+ * Delete the registration data, the offline registration pages and
+ * the service tags in the system service tag registry if installed.
+ *
+ * The registration.xml and servicetag file will be removed.
+ */
+ private static synchronized void deleteRegistrationData()
+ throws IOException {
+ try {
+ // delete the offline registration page
+ deleteRegistrationHtmlPage();
+
+ // Remove the service tag from the system ST registry if exists
+ Set<String> urns = getInstalledURNs();
+ if (urns.size() > 0 && Registry.isSupported()) {
+ for (String u : urns) {
+ Registry.getSystemRegistry().removeServiceTag(u);
+ }
+ }
+ registration = null;
+ } finally {
+ // Delete the registration.xml and servicetag files if exists
+ if (regXmlFile.exists()) {
+ if (!regXmlFile.delete()) {
+ throw new IOException("Failed to delete " + regXmlFile);
+ }
+ }
+ if (serviceTagFile.exists()) {
+ if (!serviceTagFile.delete()) {
+ throw new IOException("Failed to delete " + serviceTagFile);
+ }
+ }
+ }
+ }
+
+ /**
+ * Updates the registration data to contain one single service tag
+ * for the running Java runtime.
+ */
+ private static synchronized void updateRegistrationData(String svcTagSource)
+ throws IOException {
+ RegistrationData regData = getRegistrationData();
+ ServiceTag curSvcTag = newServiceTag(svcTagSource);
+
+ ServiceTag[] javaSvcTags = getJavaServiceTagArray();
+ Set<String> urns = getInstalledURNs();
+ for (ServiceTag st : javaSvcTags) {
+ if (!st.getProductDefinedInstanceID().equals(curSvcTag.getProductDefinedInstanceID())) {
+ String instanceURN = st.getInstanceURN();
+ regData.removeServiceTag(instanceURN);
+
+ // remove it from the system service tag registry if exists
+ if (urns.contains(instanceURN) && Registry.isSupported()) {
+ Registry.getSystemRegistry().removeServiceTag(instanceURN);
+ }
+ }
+ }
+ writeRegistrationXml();
+ writeInstalledUrns();
+ }
+
+ private static void writeInstalledUrns() throws IOException {
+ // if the Registry is not supported,
+ // remove the servicetag file
+ if (!Registry.isSupported() && serviceTagFile.exists()) {
+ serviceTagFile.delete();
+ return;
+ }
+
+ PrintWriter out = null;
+ try {
+ out = new PrintWriter(serviceTagFile);
+
+ ServiceTag[] javaSvcTags = getJavaServiceTagArray();
+ for (ServiceTag st : javaSvcTags) {
+ // Write the instance_run to the servicetag file
+ String instanceURN = st.getInstanceURN();
+ out.println(instanceURN);
+ }
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
+ }
+
+ /**
+ * Load the values associated with the swoRDFish metadata entries
+ * for Java SE. The swoRDFish metadata entries are different for
+ * different release.
+ *
+ * @param version Version of Java SE
+ */
+ private static synchronized Properties loadSwordfishEntries() throws IOException {
+ if (swordfishProps != null) {
+ return swordfishProps;
+ }
+
+ // The version string for Java SE 6 is 1.6.0
+ // We just need the minor number in the version string
+ int version = Util.getJdkVersion();
+
+ String filename = "/com/sun/servicetag/resources/javase_" +
+ version + "_swordfish.properties";
+ InputStream in = Installer.class.getClass().getResourceAsStream(filename);
+ if (in == null) {
+ return null;
+ }
+ swordfishProps = new Properties();
+ try {
+ swordfishProps.load(in);
+ } finally {
+ in.close();
+ }
+ return swordfishProps;
+ }
+
+ /**
+ * Returns the product defined instance ID for Java SE.
+ * It is a list of comma-separated name/value pairs:
+ * "id=<full-version> <arch> [<arch>]*"
+ * "dir=<java.home system property value>"
+ *
+ * where <full-version> is the full version string of the JRE,
+ * <arch> is the architecture that the runtime supports
+ * (i.e. "sparc", "sparcv9", "i386", "amd64" (ISA list))
+ *
+ * For Solaris, it can be dual mode that can support both
+ * 32-bit and 64-bit. the "id" will be set to
+ * "1.6.0_03-b02 sparc sparcv9"
+ *
+ * The "dir" property is included in the service tag to enable
+ * the Service Tag software to determine if a service tag for
+ * Java SE is invalid and perform appropriate service tag
+ * cleanup if necessary. See RFE# 6574781 Service Tags Enhancement.
+ *
+ */
+ private static String getProductDefinedId() {
+ StringBuilder definedId = new StringBuilder();
+ definedId.append("id=");
+ definedId.append(System.getProperty("java.runtime.version"));
+
+ String[] archs = getJreArchs();
+ for (String name : archs) {
+ definedId.append(" " + name);
+ }
+
+ String location = ",dir=" + javaHome;
+ if ((definedId.length() + location.length()) < 256) {
+ definedId.append(",dir=");
+ definedId.append(javaHome);
+ } else {
+ // if it exceeds the limit, we will not include the location
+ if (isVerbose()) {
+ System.err.println("Warning: Product defined instance ID exceeds the field limit:");
+ }
+ }
+
+ return definedId.toString();
+ }
+
+ /**
+ * Returns the architectures that the runtime supports
+ * (i.e. "sparc", "sparcv9", "i386", "amd64" (ISA list))
+ * The directory name where libjava.so is located.
+ *
+ * On Windows, returns the "os.arch" system property value.
+ */
+ private synchronized static String[] getJreArchs() {
+ if (jreArchs != null) {
+ return jreArchs;
+ }
+
+ Set<String> archs = new HashSet<String>();
+
+ String os = System.getProperty("os.name");
+ if (os.equals("SunOS") || os.equals("Linux")) {
+ // Traverse the directories under <JRE>/lib.
+ // If <JRE>/lib/<arch>/libjava.so exists, add <arch>
+ // to the product defined ID
+ File dir = new File(getJrePath() + File.separator + "lib");
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (String name : children) {
+ File f = new File(dir, name + File.separator + "libjava.so");
+ if (f.exists()) {
+ archs.add(name);
+ }
+ }
+ }
+ } else {
+ // Windows - append the os.arch
+ archs.add(System.getProperty("os.arch"));
+ }
+ jreArchs = archs.toArray(new String[0]);
+ return jreArchs;
+ }
+
+ /**
+ * Return the zonename if zone is supported; otherwise, return
+ * "global".
+ */
+ public static String getZoneName() throws IOException {
+ String zonename = "global";
+
+ String command = "/usr/bin/zonename";
+ File f = new File(command);
+ // com.sun.servicetag package has to be compiled with JDK 5 as well
+ // JDK 5 doesn't support the File.canExecute() method.
+ // Risk not checking isExecute() for the zonename command is very low.
+ if (f.exists()) {
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ String output = commandOutput(p);
+ if (p.exitValue() == 0) {
+ zonename = output.trim();
+ }
+
+ }
+ return zonename;
+ }
+
+ private synchronized static String getRegisterHtmlParent() throws IOException {
+ if (registerHtmlParent == null) {
+ File htmlDir; // register.html is put under the JDK directory
+ if (getJrePath().endsWith(File.separator + "jre")) {
+ htmlDir = new File(getJrePath(), "..");
+ } else {
+ // j2se non-image build
+ htmlDir = new File(getJrePath());
+ }
+
+ // initialize the supported locales
+ initSupportedLocales(htmlDir);
+
+ // Determine the location of the offline registration page
+ String path = System.getProperty(SVCTAG_DIR_PATH);
+ if (path == null) {
+ // Default is <JDK>/register.html
+ registerHtmlParent = htmlDir.getCanonicalPath();
+ } else {
+ File f = new File(path);
+ registerHtmlParent = f.getCanonicalPath();
+ if (!f.isDirectory()) {
+ throw new InternalError("Path " + path + " set in \"" +
+ SVCTAG_DIR_PATH + "\" property is not a directory");
+ }
+ }
+ }
+ return registerHtmlParent;
+ }
+
+ /**
+ * Returns the File object of the offline registration page localized
+ * for the default locale in the JDK directory.
+ */
+ static synchronized File getRegistrationHtmlPage() throws IOException {
+ if (!supportRegistration) {
+ // No register.html page generated if JRE
+ return null;
+ }
+
+ String parent = getRegisterHtmlParent();
+
+ // check if the offline registration page is already generated
+ File f = new File(parent, REGISTRATION_HTML_NAME + ".html");
+ if (!f.exists()) {
+ // Generate the localized version of the offline registration Page
+ generateRegisterHtml(parent);
+ }
+
+ String name = REGISTRATION_HTML_NAME;
+ List<Locale> candidateLocales = getCandidateLocales(Locale.getDefault());
+ for (Locale l : candidateLocales) {
+ if (supportedLocales.contains(l)) {
+ name = REGISTRATION_HTML_NAME + "_" + l.toString();
+ break;
+ }
+ }
+ File htmlFile = new File(parent, name + ".html");
+ if (isVerbose()) {
+ System.out.print("Offline registration page: " + htmlFile);
+ System.out.println((htmlFile.exists() ?
+ "" : " not exist. Use register.html"));
+ }
+ if (htmlFile.exists()) {
+ return htmlFile;
+ } else {
+ return new File(parent,
+ REGISTRATION_HTML_NAME + ".html");
+ }
+ }
+
+ private static List<Locale> getCandidateLocales(Locale locale) {
+ String language = locale.getLanguage();
+ String country = locale.getCountry();
+ String variant = locale.getVariant();
+
+ List<Locale> locales = new ArrayList<Locale>(3);
+ if (variant.length() > 0) {
+ locales.add(locale);
+ }
+ if (country.length() > 0) {
+ locales.add((locales.size() == 0) ?
+ locale : new Locale(language, country, ""));
+ }
+ if (language.length() > 0) {
+ locales.add((locales.size() == 0) ?
+ locale : new Locale(language, "", ""));
+ }
+ return locales;
+ }
+
+ // Remove the offline registration pages
+ private static void deleteRegistrationHtmlPage() throws IOException {
+ String parent = getRegisterHtmlParent();
+ if (parent == null) {
+ return;
+ }
+
+ for (Locale locale : supportedLocales) {
+ String name = REGISTRATION_HTML_NAME;
+ if (!locale.equals(Locale.ENGLISH)) {
+ name += "_" + locale.toString();
+ }
+ File f = new File(parent, name + ".html");
+ if (f.exists()) {
+ if (!f.delete()) {
+ throw new IOException("Failed to delete " + f);
+ }
+ }
+ }
+ }
+
+ private static void initSupportedLocales(File jdkDir) {
+ if (supportedLocales.isEmpty()) {
+ // initialize with the known supported locales
+ for (Locale l : knownSupportedLocales) {
+ supportedLocales.add(l);
+ }
+ }
+
+ // Determine unknown supported locales if any
+ // by finding the localized version of README.html
+ // This prepares if a new locale in JDK is supported in
+ // e.g. in the OpenSource world
+ FilenameFilter ff = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ String fname = name.toLowerCase();
+ if (fname.startsWith("readme") && fname.endsWith(".html")) {
+ return true;
+ }
+ return false;
+ }
+ };
+
+ String[] readmes = jdkDir.list(ff);
+ for (String name : readmes) {
+ String basename = name.substring(0, name.length() - ".html".length());
+ String[] ss = basename.split("_");
+ switch (ss.length) {
+ case 1:
+ // English version
+ break;
+ case 2:
+ supportedLocales.add(new Locale(ss[1]));
+ break;
+ case 3:
+ supportedLocales.add(new Locale(ss[1], ss[2]));
+ break;
+ default:
+ // ignore
+ break;
+ }
+ }
+ if (isVerbose()) {
+ System.out.println("Supported locales: ");
+ for (Locale l : supportedLocales) {
+ System.out.println(l);
+ }
+ }
+ }
+
+ private static final String JDK_HEADER_PNG_KEY = "@@JDK_HEADER_PNG@@";
+ private static final String JDK_VERSION_KEY = "@@JDK_VERSION@@";
+ private static final String REGISTRATION_URL_KEY = "@@REGISTRATION_URL@@";
+ private static final String REGISTRATION_PAYLOAD_KEY = "@@REGISTRATION_PAYLOAD@@";
+
+ @SuppressWarnings("unchecked")
+ private static void generateRegisterHtml(String parent) throws IOException {
+ int version = Util.getJdkVersion();
+ int update = Util.getUpdateVersion();
+ String jdkVersion = "Version " + version;
+ if (update > 0) {
+ // product name is not translated
+ jdkVersion += " Update " + update;
+ }
+ RegistrationData regData = getRegistrationData();
+ String registerURL = SunConnection.getRegistrationURL(
+ regData.getRegistrationURN()).toString();
+ // Make sure it uses the canonical path before getting the URI.
+ File img = new File(svcTagDir.getCanonicalPath(), "jdk_header.png");
+ String headerImageSrc = img.toURI().toString();
+
+ // Format the registration data in one single line
+ StringBuilder payload = new StringBuilder();
+ String xml = regData.toString().replaceAll("\"", "%22");
+ BufferedReader reader = new BufferedReader(new StringReader(xml));
+ try {
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ payload.append(line.trim());
+ }
+ } finally {
+ reader.close();
+ }
+
+ String resourceFilename = "/com/sun/star/servicetag/resources/register";
+ for (Locale locale : supportedLocales) {
+ String name = REGISTRATION_HTML_NAME;
+ String resource = resourceFilename;
+ if (!locale.equals(Locale.ENGLISH)) {
+ name += "_" + locale.toString();
+ resource += "_" + locale.toString();
+ }
+ File f = new File(parent, name + ".html");
+ InputStream in = null;
+ BufferedReader br = null;
+ PrintWriter pw = null;
+ try {
+ in = Installer.class.getClass().getResourceAsStream(resource + ".html");
+ if (in == null) {
+ // if the resource file is missing
+ if (isVerbose()) {
+ System.out.println("Missing resouce file: " + resource + ".html");
+ }
+ continue;
+ }
+ if (isVerbose()) {
+ System.out.println("Generating " + f + " from " + resource + ".html");
+ }
+
+ br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
+ pw = new PrintWriter(f, "UTF-8");
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ String output = line;
+ if (line.contains(JDK_VERSION_KEY)) {
+ output = line.replace(JDK_VERSION_KEY, jdkVersion);
+ } else if (line.contains(JDK_HEADER_PNG_KEY)) {
+ output = line.replace(JDK_HEADER_PNG_KEY, headerImageSrc);
+ } else if (line.contains(REGISTRATION_URL_KEY)) {
+ output = line.replace(REGISTRATION_URL_KEY, registerURL);
+ } else if (line.contains(REGISTRATION_PAYLOAD_KEY)) {
+ output = line.replace(REGISTRATION_PAYLOAD_KEY, payload.toString());
+ }
+ pw.println(output);
+ }
+ f.setReadOnly();
+ pw.flush();
+ } finally {
+ if (pw != null) {
+ pw.close();
+ }
+ if (in != null) {
+ in.close();
+ }
+ if (br!= null) {
+ br.close();
+ }
+ }
+ }
+ }
+
+ /**
+ * A utility class to create a service tag for Java SE.
+ * <p>
+ * <b>Usage:</b><br>
+ * <blockquote><tt>
+ * &lt;JAVA_HOME&gt;/bin/java com.sun.servicetag.Installer
+ * </tt></blockquote>
+ * <p>
+ */
+ public static void main(String[] args) {
+ String source = "Manual";
+
+ // Parse the options (arguments starting with "-" )
+ boolean delete = false;
+ boolean update = false;
+ boolean register = false;
+ int count = 0;
+ while (count < args.length) {
+ String arg = args[count];
+ if (arg.trim().length() == 0) {
+ // skip empty arguments
+ count++;
+ continue;
+ }
+
+ if (arg.equals("-source")) {
+ source = args[++count];
+ } else if (arg.equals("-delete")) {
+ delete = true;
+ } else if (arg.equals("-register")) {
+ register = true;
+ } else {
+ usage();
+ return;
+ }
+ count++;
+ }
+ try {
+ if (delete) {
+ deleteRegistrationData();
+ } else {
+ ServiceTag[] javaSvcTags = getJavaServiceTagArray();
+ String[] archs = getJreArchs();
+ if (javaSvcTags.length > archs.length) {
+ // 64-bit has been uninstalled
+ // so remove the service tag
+ updateRegistrationData(source);
+ } else {
+ // create the service tag
+ createServiceTag(source);
+ }
+ }
+
+ if (register) {
+ // Registration is only supported by JDK
+ // For testing purpose, override with a "servicetag.enable.registration" property
+
+ RegistrationData regData = getRegistrationData();
+ if (supportRegistration && !regData.getServiceTags().isEmpty()) {
+ SunConnection.register(regData);
+ }
+ }
+ System.exit(0);
+ } catch (IOException e) {
+ System.err.println("I/O Error: " + e.getMessage());
+ if (isVerbose()) {
+ e.printStackTrace();
+ }
+ } catch (IllegalArgumentException ex) {
+ if (isVerbose()) {
+ ex.printStackTrace();
+ }
+ } catch (Exception e) {
+ System.err.println("Error: " + e.getMessage());
+ if (isVerbose()) {
+ e.printStackTrace();
+ }
+ }
+ System.exit(1);
+ }
+
+ private static void usage() {
+ System.out.println("Usage:");
+ System.out.print(" " + Installer.class.getName());
+ System.out.println(" [-delete|-source <source>|-register]");
+ System.out.println(" to create a service tag for the Java platform");
+ System.out.println("");
+ System.out.println("Internal Options:");
+ System.out.println(" -source: to specify the source of the service tag to be created");
+ System.out.println(" -delete: to delete the service tag ");
+ System.out.println(" -register: to register the JDK");
+ System.out.println(" -help: to print this help message");
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java
new file mode 100644
index 0000000000..88ccd453a1
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/LinuxSystemEnvironment.java
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * 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: LinuxSystemEnvironment.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+// The Service Tags team maintains the latest version of the implementation
+// for system environment data collection. JDK will include a copy of
+// the most recent released version for a JDK release. We rename
+// the package to com.sun.servicetag so that the Sun Connection
+// product always uses the latest version from the com.sun.scn.servicetags
+// package. JDK and users of the com.sun.servicetag API
+// (e.g. NetBeans and SunStudio) will use the version in JDK.
+
+import java.io.*;
+
+/**
+ * Linux implementation of the SystemEnvironment class.
+ */
+class LinuxSystemEnvironment extends SystemEnvironment {
+ LinuxSystemEnvironment() {
+ setHostId(getLinuxHostId());
+ setSystemModel(getCommandOutput("/bin/uname", "-i"));
+ setSystemManufacturer(getLinuxSystemManufacturer());
+ setCpuManufacturer(getLinuxCpuManufacturer());
+ setSerialNumber(getLinuxSN());
+ }
+ private String dmiInfo = null;
+
+ private static final int SN = 1;
+ private static final int SYS = 2;
+ private static final int CPU = 3;
+
+ private String getLinuxHostId() {
+ String output = getCommandOutput("/usr/bin/hostid");
+ // trim off the leading 0x
+ if (output.startsWith("0x")) {
+ output = output.substring(2);
+ }
+ return output;
+ }
+
+ /**
+ * Tries to obtain and return the cpu manufacturer.
+ * @return The cpu manufacturer (an empty string if not found or an error occurred)
+ */
+ private String getLinuxCpuManufacturer() {
+ String tmp = getLinuxPSNInfo(CPU);
+ if (tmp.length() > 0) {
+ return tmp;
+ }
+
+ String contents = getFileContent("/proc/cpuinfo");
+ for (String line : contents.split("\n")) {
+ if (line.contains("vendor_id")) {
+ String[] ss = line.split(":", 2);
+ if (ss.length > 1) {
+ return ss[1].trim();
+ }
+ }
+ }
+
+ // returns an empty string if it can't be found or an error happened
+ return getLinuxDMIInfo("dmi type 4", "manufacturer");
+ }
+
+
+ /**
+ * Tries to obtain and return the system manufacturer.
+ * @return The system manufacturer (an empty string if not found or an error occurred)
+ */
+ private String getLinuxSystemManufacturer() {
+ String tmp = getLinuxPSNInfo(SYS);
+ if (tmp.length() > 0) {
+ return tmp;
+ }
+
+ // returns an empty string if it can't be found or an error happened
+ return getLinuxDMIInfo("dmi type 1", "manufacturer");
+ }
+
+ /**
+ * Tries to obtain and return the serial number of the system.
+ * @return The serial number (an empty string if not found or an error occurred)
+ */
+ private String getLinuxSN() {
+ String tmp = getLinuxPSNInfo(SN);
+ if (tmp.length() > 0) {
+ return tmp;
+ }
+
+ // returns an empty string if it can't be found or an error happened
+ return getLinuxDMIInfo("dmi type 1", "serial number");
+ }
+
+ private String getLinuxPSNInfo(int target) {
+ // try to read from the psn file if it exists
+ String contents = getFileContent("/var/run/psn");
+ String[] ss = contents.split("\n");
+ if (target <= ss.length) {
+ return ss[target-1];
+ }
+
+ // default case is to return ""
+ return "";
+ }
+
+ // reads from dmidecode with the given type and target
+ // returns an empty string if nothing was found or an error occurred
+ //
+ // Sample output segment:
+ // Handle 0x0001
+ // DMI type 1, 25 bytes.
+ // System Information
+ // Manufacturer: System manufacturer
+ // Product Name: System Product Name
+ // Version: System Version
+ // Serial Number: System Serial Number
+ // UUID: 3091D719-B25B-D911-959D-6D1B12C7686E
+ // Wake-up Type: Power Switch
+
+ private synchronized String getLinuxDMIInfo(String dmiType, String target) {
+ // only try to get dmidecode information once, after that, we can
+ // reuse the output
+ if (dmiInfo == null) {
+ Thread dmidecodeThread = new Thread() {
+ public void run() {
+ dmiInfo = getCommandOutput("/usr/sbin/dmidecode");
+ }
+ };
+ dmidecodeThread.start();
+
+ try {
+ dmidecodeThread.join(2000);
+ if (dmidecodeThread.isAlive()) {
+ dmidecodeThread.interrupt();
+ dmiInfo = "";
+ }
+ } catch (InterruptedException ie) {
+ dmidecodeThread.interrupt();
+ }
+ }
+
+ if (dmiInfo.length() == 0) {
+ return "";
+ }
+ boolean dmiFlag = false;
+ for (String s : dmiInfo.split("\n")) {
+ String line = s.toLowerCase();
+ if (dmiFlag) {
+ if (line.contains(target)) {
+ String key = target + ":";
+ int indx = line.indexOf(key) + key.length();
+ if (line.contains(key) && indx < line.length()) {
+ return line.substring(indx).trim();
+ }
+ String[] ss = line.split(":");
+ return ss[ss.length-1];
+ }
+ } else if (line.contains(dmiType)) {
+ dmiFlag = true;
+ }
+ }
+ return "";
+ }
+
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java
new file mode 100644
index 0000000000..44ce33dece
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationData.java
@@ -0,0 +1,473 @@
+/*************************************************************************
+ *
+ * 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: RegistrationData.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+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.
+ * <a name="EnvMap"></a>
+ * It also has an <i>environment map</i> with
+ * the following elements:
+ * <blockquote>
+ * <table border=0>
+ * <tr>
+ * <td><tt>hostname</tt></td>
+ * <td>Hostname of the system</td>
+ * <td>e.g. woody</td>
+ * </tr>
+ * <tr>
+ * <td><tt>hostId</tt></td>
+ * <td>Host ID of the system</td>
+ * <td>e.g. 83abc1ab</td>
+ * </tr>
+ * <tr>
+ * <td><tt>osName</tt></td>
+ * <td>Operating system name</td>
+ * <td> e.g. SunOS</td>
+ * </tr>
+ * <tr>
+ * <td><tt>osVersion</tt></td>
+ * <td>Operating system version</td>
+ * <td> e.g. 5.10</td>
+ * </tr>
+ * <tr>
+ * <td><tt>osArchitecture</tt></td>
+ * <td>Operating system architecture</td>
+ * <td> e.g. sparc</td>
+ * </tr>
+ * <tr>
+ * <td><tt>systemModel</tt></td>
+ * <td>System model</td>
+ * <td> e.g. SUNW,Sun-Fire-V440</td>
+ * </tr>
+ * <tr>
+ * <td><tt>systemManufacturer</tt></td>
+ * <td>System manufacturer</td>
+ * <td> e.g. Sun Microsystems</td>
+ * </tr>
+ * <tr>
+ * <td><tt>cpuManufacturer</tt></td>
+ * <td>CPU manufacturer</td>
+ * <td> e.g. Sun Microsystems</td>
+ * </tr>
+ * <tr>
+ * <td><tt>serialNumber</tt></td>
+ * <td>System serial number</td>
+ * <td> e.g. BEL078932</td>
+ * </tr>
+ * </table>
+ * </blockquote>
+ * The <tt>hostname</tt> and <tt>osName</tt> element must have a non-empty value.
+ * If an element is not available on a system and their value will be
+ * empty.
+ * <p>
+ * <a name="XMLSchema">
+ * <b>Registration XML Schema</b></a>
+ * <p>
+ * A {@code RegistrationData} object can be {@link #loadFromXML loaded} from
+ * and {@link #storeToXML stored} into an XML file in the format described
+ * by the
+ * <a href="https://sn-tools.central.sun.com/twiki/pub/ServiceTags/RegistrationRelayService/product_registration.xsd">
+ * registration data schema</a>. The registration data schema is defined by the
+ * Service Tags Technology.
+ * <p>
+ * Typically the registration data is constructed at installation time
+ * and stored in an XML file for later service tag lookup or registration.
+ *
+ * <p>
+ * <b>Example Usage</b>
+ * <p>
+ * The examples below show how the {@code RegistrationData} can be
+ * used for product registration.
+ * Exception handling is not shown in these examples for clarity.
+ * <ol>
+ * <li>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.
+ * <br>
+ * <blockquote><pre>
+ * // 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);
+ * </pre></blockquote>
+ * </li>
+ * <li>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 <i>Registration Relay Service</i>.
+ * <p>
+ * There are several registration services for Sun Connection. For example,
+ * the <a href="https://sn-tools.central.sun.com/twiki/bin/view/ServiceTags/RegistrationRelayService">
+ * Registration Relay Service</a> 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.
+ * <p>
+ * <blockquote><pre>
+ * // 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();
+ * </pre></blockquote>
+ * </li>
+ * <li>This example shows how to store the registration data in an XML file.
+ * for later service tag lookup or registration.
+ * <br>
+ * <blockquote><pre>
+ * BufferedOutputStream out = new BufferedOutputStream(
+ * new FileOutputStream(""&lt;JAVA_HOME&gt;/lib/servicetag/registration.xml"));
+ * registration.storeToXML(out);
+ * out.close();
+ * </pre></blockquote>
+ * </li>
+ * <li>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.
+ * <br>
+ * <blockquote><pre>
+ * if (Registry.isSupported()) {
+ * Set&lt;ServiceTag&gt; svctags = registration.getServiceTags();
+ * for (ServiceTag st : svctags) {
+ * Registry.getSystemRegistry().addServiceTag(st);
+ * }
+ * }
+ * </pre></blockquote>
+ * </li>
+ * </ol>
+ *
+ * @see <a href="https://sunconnection.sun.com/inventory">Sun Connection Inventory Channel</a>
+ */
+public class RegistrationData {
+ private final Map<String, String> environment;
+ private final Map<String, ServiceTag> 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:
+ * <blockquote>
+ * <tt>hostname</tt>, <tt>osName</tt>, <tt>osVersion</tt> and
+ * <tt>osArchitecture</tt>
+ * </blockquote>
+ * 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<String, ServiceTag>();
+ }
+
+ private Map<String, String> initEnvironment() {
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ 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:
+ * <tt>urn:st:&lt;32-char {@link java.util.UUID uuid}&gt;</tt>
+ *
+ * @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 <a href="#EnvMap">keys</a>
+ * 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<String, String> getEnvironmentMap() {
+ return new LinkedHashMap<String,String>(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<ServiceTag> getServiceTags() {
+ return new HashSet<ServiceTag>(svcTagMap.values());
+ }
+
+ /**
+ * Adds a service tag to this registration data.
+ * If the given service tag has an empty <tt>instance_urn</tt>,
+ * 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
+ * <tt>instance_urn</tt>} 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 <tt>instance_urn</tt> in this registration
+ * data.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> of the service tag
+ * @return the {@code ServiceTag} object of the given <tt>instance_urn</tt>
+ * 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 <tt>instance_urn</tt> from this
+ * registration data.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> 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 <tt>product_defined_instance_id</tt> in the service tag
+ * of the given <tt>instance_urn</tt> in this registration data.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> of the service tag to be updated.
+ * @param productDefinedInstanceID the value of the
+ * <tt>product_defined_instance_id</tt> 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 <a href="#XMLSchema">
+ * registration data schema</a>.
+ * 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 <a href="#XMLSchema">
+ * registration data schema</a> 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
new file mode 100644
index 0000000000..ae810d205f
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java
@@ -0,0 +1,374 @@
+/*************************************************************************
+ *
+ * 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: RegistrationDocument.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+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/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";
+ 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<ServiceTag> 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<String, String> envMap) {
+ Element root = getRegistrationDataRoot(document);
+ Element env = document.createElement(ST_NODE_ENVIRONMENT);
+ root.appendChild(env);
+ Set<Map.Entry<String, String>> keys = envMap.entrySet();
+ for (Map.Entry<String, String> 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;
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/Registry.java b/desktop/source/registration/com/sun/star/servicetag/Registry.java
new file mode 100644
index 0000000000..879db1fdec
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/Registry.java
@@ -0,0 +1,558 @@
+/*************************************************************************
+ *
+ * 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: Registry.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import static com.sun.star.servicetag.Util.*;
+import static com.sun.star.servicetag.RegistrationDocument.*;
+
+/**
+ * A service tag registry is a XML-based registry containing
+ * the list of {@link ServiceTag service tags} installed in the system.
+ * The {@code Registry} class provides interfaces
+ * to add, remove, update, and get a service tag from a service tag
+ * registry.
+ * This {@code Registry} class may not be supported
+ * on all systems. The {@link #isSupported} method
+ * can be called to determine if it is supported.
+ * <p>
+ * A registry may implement restrictions to only allow certain users
+ * to {@link #updateServiceTag update} and
+ * to {@link #removeServiceTag remove} a service tag record. Typically,
+ * only the owner of the service tag, the owner of the registry
+ * and superuser are authorized to update or remove a service tag in
+ * the registry.
+ *
+ * @see <a href="https://sn-tools.central.sun.com/twiki/bin/view/ServiceTags/ServiceTagDevGuideHelper">
+ * Service Tag User Guide</a>
+ */
+public class Registry {
+
+ private static final String STCLIENT_SOLARIS = "/usr/bin/stclient";
+ private static final String STCLIENT_LINUX = "/opt/sun/servicetag/bin/stclient";
+ // stclient exit value (see sthelper.h)
+ private static final int ST_ERR_NOT_AUTH = 245;
+ private static final int ST_ERR_REC_NOT_FOUND = 225;
+
+ // The stclient output has to be an exported interface
+ private static final String INSTANCE_URN_DESC = "Product instance URN=";
+ private static boolean initialized = false;
+ private static boolean supportsHelperClass = true; // default
+ private static File stclient = null;
+ private static String stclientPath = null;
+ private static Registry registry = new Registry();
+
+ // System properties for testing
+ private static String SVCTAG_STCLIENT_CMD = "servicetag.stclient.cmd";
+ private static String SVCTAG_STHELPER_SUPPORTED = "servicetag.sthelper.supported";
+
+ private Registry() {
+ }
+
+ private synchronized static String getSTclient() {
+ if (!initialized) {
+ // the system property always overrides the default setting
+ if (System.getProperty(SVCTAG_STHELPER_SUPPORTED) != null) {
+ supportsHelperClass = Boolean.getBoolean(SVCTAG_STHELPER_SUPPORTED);
+ }
+
+ // This is only used for testing
+ stclientPath = System.getProperty(SVCTAG_STCLIENT_CMD);
+ if (stclientPath != null) {
+ return stclientPath;
+ }
+
+ // Initialization to determine the platform's stclient pathname
+ String os = System.getProperty("os.name");
+ if (os.equals("SunOS")) {
+ stclient = new File(STCLIENT_SOLARIS);
+ } else if (os.equals("Linux")) {
+ stclient = new File(STCLIENT_LINUX);
+ } else if (os.startsWith("Windows")) {
+ stclient = getWindowsStClientFile();
+ } else {
+ if (isVerbose()) {
+ System.out.println("Running on non-Sun JDK");
+ }
+ }
+ initialized = true;
+ }
+
+ // com.sun.servicetag package has to be compiled with JDK 5 as well
+ // JDK 5 doesn't support the File.canExecute() method.
+ // Risk not checking isExecute() for the stclient command is very low.
+
+ if (stclientPath == null && stclient != null && stclient.exists()) {
+ stclientPath = stclient.getAbsolutePath();
+ }
+ return stclientPath;
+ }
+
+ /**
+ * Returns the system service tag registry. The {@code Registry} class
+ * may not be supported on some platforms; use the {@link #isSupported}
+ * method to determine if it is supported.
+ *
+ * @return the {@code Registry} object for the system service tag registry.
+ *
+ * @throws UnsupportedOperationException if the {@code Registry} class is
+ * not supported.
+ */
+ public static Registry getSystemRegistry() {
+ if (isSupported()) {
+ return registry;
+ } else {
+ throw new UnsupportedOperationException("Registry class is not supported");
+ }
+ }
+
+ /**
+ * Returns {@code true} if the {@code Registry} class is supported on this system.
+ *
+ * @return {@code true} if the {@code Registry} class is supported;
+ * otherwise, return {@code false}.
+ */
+ public static boolean isSupported() {
+ return (getSTclient() != null && supportsHelperClass);
+ }
+
+ private static List<String> getCommandList() {
+ // Set up the arguments to call stclient
+ List<String> command = new ArrayList<String>();
+ if (System.getProperty(SVCTAG_STCLIENT_CMD) != null) {
+ // This is for jtreg testing use. This will be set to something
+ // like:
+ // $JAVA_HOME/bin/java -cp $TEST_DIR \
+ // -Dstclient.registry.path=$TEST_DIR/registry.xml \
+ // SvcTagClient
+ //
+ // On Windows, the JAVA_HOME and TEST_DIR path could contain
+ // space e.g. c:\Program Files\Java\jdk1.6.0_05\bin\java.
+ // The SVCTAG_STCLIENT_CMD must be set with a list of
+ // space-separated parameters. If a parameter contains spaces,
+ // it must be quoted with '"'.
+
+ String cmd = getSTclient();
+ int len = cmd.length();
+ int i = 0;
+ while (i < len) {
+ char separator = ' ';
+ if (cmd.charAt(i) == '"') {
+ separator = '"';
+ i++;
+ }
+ // look for the separator or matched the closing '"'
+ int j;
+ for (j = i+1; j < len; j++) {
+ if (cmd.charAt(j) == separator) {
+ break;
+ }
+ }
+
+ if (i == j-1) {
+ // add an empty parameter
+ command.add("\"\"");
+ } else {
+ // double quotes and space are not included
+ command.add(cmd.substring(i,j));
+ }
+
+ // skip spaces
+ for (i = j+1; i < len; i++) {
+ if (!Character.isSpaceChar(cmd.charAt(i))) {
+ break;
+ }
+ }
+ }
+ if (isVerbose()) {
+ System.out.println("Command list:");
+ for (String s : command) {
+ System.out.println(s);
+ }
+ }
+ } else {
+ command.add(getSTclient());
+ }
+ return command;
+ }
+
+ // Returns null if the service tag record not found;
+ // or throw UnauthorizedAccessException or IOException
+ // based on the exitValue.
+ private static ServiceTag checkReturnError(int exitValue,
+ String output,
+ ServiceTag st) throws IOException {
+ switch (exitValue) {
+ case ST_ERR_REC_NOT_FOUND:
+ return null;
+ case ST_ERR_NOT_AUTH:
+ if (st != null) {
+ throw new UnauthorizedAccessException(
+ "Not authorized to access " + st.getInstanceURN() +
+ " installer_uid=" + st.getInstallerUID());
+ } else {
+ throw new UnauthorizedAccessException(
+ "Not authorized:" + output);
+ }
+ default:
+ throw new IOException("stclient exits with error" +
+ " (" + exitValue + ")\n" + output);
+ }
+ }
+
+ /**
+ * Adds a service tag to this registry.
+ * If the given service tag has an empty <tt>instance_urn</tt>,
+ * this helper class will generate a URN and place it in the
+ * copy of the service tag in this registry.
+ * This method will return the {@code ServiceTag} representing
+ * the service tag entry to this registry.
+ *
+ * @param st {@code ServiceTag} object
+ * @return a {@code ServiceTag} object representing the service tag
+ * entry to this registry.
+ *
+ * @throws IllegalArgumentException if a service tag of the same
+ * <tt>instance_urn</tt> already exists in this registry.
+ *
+ * @throws java.io.IOException if an I/O error occurs in this operation.
+ */
+ public ServiceTag addServiceTag(ServiceTag st) throws IOException {
+ List<String> command = getCommandList();
+ command.add("-a");
+ if (st.getInstanceURN().length() > 0) {
+ ServiceTag sysSvcTag = getServiceTag(st.getInstanceURN());
+ if (sysSvcTag != null) {
+ throw new IllegalArgumentException("Instance_urn = " +
+ st.getInstanceURN() + " already exists");
+ }
+ command.add("-i");
+ command.add(st.getInstanceURN());
+ }
+ command.add("-p");
+ command.add(st.getProductName());
+ command.add("-e");
+ command.add(st.getProductVersion());
+ command.add("-t");
+ command.add(st.getProductURN());
+ if (st.getProductParentURN().length() > 0) {
+ command.add("-F");
+ command.add(st.getProductParentURN());
+ }
+ command.add("-P");
+ command.add(st.getProductParent());
+ if (st.getProductDefinedInstanceID().length() > 0) {
+ command.add("-I");
+ command.add(st.getProductDefinedInstanceID());
+ }
+ command.add("-m");
+ command.add(st.getProductVendor());
+ command.add("-A");
+ command.add(st.getPlatformArch());
+ command.add("-z");
+ command.add(st.getContainer());
+ command.add("-S");
+ command.add(st.getSource());
+
+ BufferedReader in = null;
+ try {
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ String output = commandOutput(p);
+ if (isVerbose()) {
+ System.out.println("Output from stclient -a command:");
+ System.out.println(output);
+ }
+ String urn = "";
+ if (p.exitValue() == 0) {
+ // Obtain the instance urn from the stclient output
+ in = new BufferedReader(new StringReader(output));
+ String line = null;
+ while ((line = in.readLine()) != null) {
+ line = line.trim();
+ if (line.startsWith(INSTANCE_URN_DESC)) {
+ urn = line.substring(INSTANCE_URN_DESC.length());
+ break;
+ }
+ }
+ if (urn.length() == 0) {
+ throw new IOException("Error in creating service tag:\n" +
+ output);
+ }
+ return getServiceTag(urn);
+ } else {
+ return checkReturnError(p.exitValue(), output, st);
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+
+ /**
+ * Removes a service tag of the given <tt>instance_urn</tt> from this
+ * registry.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> of the service tag
+ * to be removed.
+ *
+ * @return the {@code ServiceTag} object removed from this registry;
+ * or {@code null} if the service tag does not exist in this registry.
+ *
+ * @throws UnauthorizedAccessException if the user is not authorized to
+ * remove the service tag of the given <tt>instance_urn</tt>
+ * from this registry.
+ *
+ * @throws java.io.IOException if an I/O error occurs in this operation.
+ */
+ public ServiceTag removeServiceTag(String instanceURN) throws IOException {
+ ServiceTag st = getServiceTag(instanceURN);
+ if (st == null) {
+ return null;
+ }
+
+ List<String> command = getCommandList();
+ command.add("-d");
+ command.add("-i");
+ command.add(instanceURN);
+
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ String output = commandOutput(p);
+ if (isVerbose()) {
+ System.out.println("Output from stclient -d command:");
+ System.out.println(output);
+ }
+ if (p.exitValue() == 0) {
+ return st;
+ } else {
+ return checkReturnError(p.exitValue(), output, st);
+ }
+ }
+
+ /**
+ * Updates the <tt>product_defined_instance_id</tt> in the service tag
+ * of the specified <tt>instance_urn</tt> in this registry.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> of the service tag to be updated.
+ * @param productDefinedInstanceID the value of the
+ * <tt>product_defined_instance_id</tt> to be set.
+ *
+ * @return the updated {@code ServiceTag} object;
+ * or {@code null} if the service tag does not exist in this
+ * registry.
+ *
+ * @throws UnauthorizedAccessException if the user is not authorized to
+ * update the service tag from this registry.
+ *
+ * @throws IOException if an I/O error occurs in this operation.
+ */
+ public ServiceTag updateServiceTag(String instanceURN,
+ String productDefinedInstanceID)
+ throws IOException {
+ ServiceTag svcTag = getServiceTag(instanceURN);
+ if (svcTag == null) {
+ return null;
+ }
+
+ List<String> command = getCommandList();
+ command.add("-u");
+ command.add("-i");
+ command.add(instanceURN);
+ command.add("-I");
+ if (productDefinedInstanceID.length() > 0) {
+ command.add(productDefinedInstanceID);
+ } else {
+ command.add("\"\"");
+ }
+
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ String output = commandOutput(p);
+ if (isVerbose()) {
+ System.out.println("Output from stclient -u command:");
+ System.out.println(output);
+ }
+
+ if (p.exitValue() == 0) {
+ return getServiceTag(instanceURN);
+ } else {
+ return checkReturnError(p.exitValue(), output, svcTag);
+ }
+ }
+
+ /**
+ * Returns a {@code ServiceTag} object of the given <tt>instance_urn</tt>
+ * in this registry.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> of the service tag
+ * @return a {@code ServiceTag} object of the given <tt>instance_urn</tt>
+ * in this registry; or {@code null} if not found.
+ *
+ * @throws java.io.IOException if an I/O error occurs in this operation.
+ */
+ public ServiceTag getServiceTag(String instanceURN) throws IOException {
+ if (instanceURN == null) {
+ throw new NullPointerException("instanceURN is null");
+ }
+
+ List<String> command = getCommandList();
+ command.add("-g");
+ command.add("-i");
+ command.add(instanceURN);
+
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ String output = commandOutput(p);
+ if (isVerbose()) {
+ System.out.println("Output from stclient -g command:");
+ System.out.println(output);
+ }
+ if (p.exitValue() == 0) {
+ return parseServiceTag(output);
+ } else {
+ return checkReturnError(p.exitValue(), output, null);
+ }
+ }
+
+ private ServiceTag parseServiceTag(String output) throws IOException {
+ BufferedReader in = null;
+ try {
+ Properties props = new Properties();
+ // parse the service tag output from stclient
+ in = new BufferedReader(new StringReader(output));
+ String line = null;
+ while ((line = in.readLine()) != null) {
+ if ((line = line.trim()).length() > 0) {
+ String[] ss = line.trim().split("=", 2);
+ if (ss.length == 2) {
+ props.setProperty(ss[0].trim(), ss[1].trim());
+ } else {
+ props.setProperty(ss[0].trim(), "");
+ }
+ }
+ }
+
+ String urn = props.getProperty(ST_NODE_INSTANCE_URN);
+ String productName = props.getProperty(ST_NODE_PRODUCT_NAME);
+ String productVersion = props.getProperty(ST_NODE_PRODUCT_VERSION);
+ String productURN = props.getProperty(ST_NODE_PRODUCT_URN);
+ String productParent = props.getProperty(ST_NODE_PRODUCT_PARENT);
+ String productParentURN = props.getProperty(ST_NODE_PRODUCT_PARENT_URN);
+ String productDefinedInstanceID =
+ props.getProperty(ST_NODE_PRODUCT_DEFINED_INST_ID);
+ String productVendor = props.getProperty(ST_NODE_PRODUCT_VENDOR);
+ String platformArch = props.getProperty(ST_NODE_PLATFORM_ARCH);
+ String container = props.getProperty(ST_NODE_CONTAINER);
+ String source = props.getProperty(ST_NODE_SOURCE);
+ int installerUID =
+ Util.getIntValue(props.getProperty(ST_NODE_INSTALLER_UID));
+ Date timestamp =
+ Util.parseTimestamp(props.getProperty(ST_NODE_TIMESTAMP));
+
+ return new ServiceTag(urn,
+ productName,
+ productVersion,
+ productURN,
+ productParent,
+ productParentURN,
+ productDefinedInstanceID,
+ productVendor,
+ platformArch,
+ container,
+ source,
+ installerUID,
+ timestamp);
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+
+ }
+
+ /**
+ * Returns the service tags of the specified
+ * <tt>product_urn</tt> in this registry.
+ *
+ * @param productURN the <tt>product_urn</tt> to look up
+ * @return a {@code Set} of {@code ServiceTag} objects
+ * of the specified <tt>product_urn</tt> in this registry.
+ *
+ * @throws java.io.IOException if an I/O error occurs in this operation.
+ */
+ public Set<ServiceTag> findServiceTags(String productURN) throws IOException {
+ if (productURN == null) {
+ throw new NullPointerException("productURN is null");
+ }
+
+ List<String> command = getCommandList();
+ command.add("-f");
+ command.add("-t");
+ command.add(productURN);
+
+ BufferedReader in = null;
+ try {
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ String output = commandOutput(p);
+
+ Set<ServiceTag> instances = new HashSet<ServiceTag>();
+ if (p.exitValue() == 0) {
+ // parse the service tag output from stclient
+ in = new BufferedReader(new StringReader(output));
+ String line = null;
+ while ((line = in.readLine()) != null) {
+ String s = line.trim();
+ if (s.startsWith("urn:st:")) {
+ instances.add(getServiceTag(s));
+ }
+ }
+ } else {
+ checkReturnError(p.exitValue(), output, null);
+ }
+ return instances;
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java b/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java
new file mode 100644
index 0000000000..26a2bbdd60
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/ServiceTag.java
@@ -0,0 +1,640 @@
+/*************************************************************************
+ *
+ * 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: ServiceTag.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+import java.util.Date;
+import java.io.IOException;
+import static com.sun.star.servicetag.RegistrationDocument.*;
+
+/**
+ * A service tag is an XML-based data structure that identifies a product or
+ * a component on a system. The service tag schema is defined by the
+ * Service Tags Technology. The location of the DTD file is platform dependent.
+ * On Solaris, see <tt>/usr/share/lib/xml/dtd/servicetag.dtd</tt>.
+ * <p>
+ * A valid {@code ServiceTag} instance must comply to the service tag schema
+ * and contain the following fields:
+ * <ul>
+ * <li>{@link #getInstanceURN <tt>instance_urn</tt>}</li>
+ * <li>{@link #getProductName <tt>product_name</tt>}</li>
+ * <li>{@link #getProductVersion <tt>product_version</tt>}</li>
+ * <li>{@link #getProductURN <tt>product_urn</tt>}</li>
+ * <li>{@link #getProductParent <tt>product_parent</tt>}</li>
+ * <li>{@link #getProductParentURN <tt>product_parent_urn</tt>}</li>
+ * <li>{@link #getProductDefinedInstanceID <tt>product_defined_inst_id</tt>}</li>
+ * <li>{@link #getProductVendor <tt>product_vendor</tt>}</li>
+ * <li>{@link #getPlatformArch <tt>platform_arch</tt>}</li>
+ * <li>{@link #getContainer <tt>container</tt>}</li>
+ * <li>{@link #getSource <tt>source</tt>}</li>
+ * <li>{@link #getInstallerUID <tt>installer_uid</tt>}</li>
+ * <li>{@link #getTimestamp <tt>timestamp</tt>}</li>
+ * </ul>
+ *
+ * The <tt>instance_urn</tt> can be specified when a {@code ServiceTag}
+ * object is created, or it can be generated when it is added to
+ * a {@link RegistrationData} object, or {@link Registry
+ * system service tag registry}. The <tt>installer_uid</tt> and
+ * <tt>timestamp</tt> are set when a {@code ServiceTag} object
+ * is added to a {@link RegistrationData} object, or {@link Registry
+ * system service tag registry}.
+ *
+ * @see <a href="https://sunconnection.sun.com/FAQ/sc_faq.html">Service Tags FAQ</a>
+ */
+public class ServiceTag {
+
+ private String instanceURN;
+ private String productName;
+ private String productVersion;
+ private String productURN;
+ private String productParent;
+ private String productParentURN;
+ private String productDefinedInstanceID;
+ private String productVendor;
+ private String platformArch;
+ private String container;
+ private String source;
+ private int installerUID;
+ private Date timestamp;
+
+ // Service Tag Field Lengths (defined in sthelper.h)
+ // Since the constants defined in sthelper.h includes the null-terminated
+ // character, so minus 1 from the sthelper.h defined values.
+ private final int MAX_URN_LEN = 256 - 1;
+ private final int MAX_PRODUCT_NAME_LEN = 256 - 1;
+ private final int MAX_PRODUCT_VERSION_LEN = 64 - 1;
+ private final int MAX_PRODUCT_PARENT_LEN = 256 - 1;
+ private final int MAX_PRODUCT_VENDOR_LEN = 64 - 1;
+ private final int MAX_PLATFORM_ARCH_LEN = 64 - 1;
+ private final int MAX_CONTAINER_LEN = 64 - 1;
+ private final int MAX_SOURCE_LEN = 64 - 1;
+
+ // private constructors
+ private ServiceTag() {
+ }
+ // package private
+ ServiceTag(String instanceURN,
+ String productName,
+ String productVersion,
+ String productURN,
+ String productParent,
+ String productParentURN,
+ String productDefinedInstanceID,
+ String productVendor,
+ String platformArch,
+ String container,
+ String source,
+ int installerUID,
+ Date timestamp) {
+ setInstanceURN(instanceURN);
+ setProductName(productName);
+ setProductVersion(productVersion);
+ setProductURN(productURN);
+ setProductParentURN(productParentURN);
+ setProductParent(productParent);
+ setProductDefinedInstanceID(productDefinedInstanceID);
+ setProductVendor(productVendor);
+ setPlatformArch(platformArch);
+ setContainer(container);
+ setSource(source);
+ setInstallerUID(installerUID);
+ setTimestamp(timestamp);
+ }
+
+ /**
+ * Creates a service tag object with no <tt>instance_urn</tt>.
+ *
+ * @param productName the name of the product.
+ * @param productVersion the version of the product.
+ * @param productURN the uniform resource name of the product
+ * @param productParent the name of the product's parent.
+ * @param productParentURN the uniform resource name of the product's parent.
+ * @param productDefinedInstanceID the instance identifier.
+ * @param productVendor the vendor of the product.
+ * @param platformArch the operating system architecture.
+ * @param container the container of the product.
+ * @param source the source of the product.
+ *
+ * @throws IllegalArgumentException if any value of the input fields
+ * does not conform to the service tag XML schema.
+ */
+ public static ServiceTag newInstance(String productName,
+ String productVersion,
+ String productURN,
+ String productParent,
+ String productParentURN,
+ String productDefinedInstanceID,
+ String productVendor,
+ String platformArch,
+ String container,
+ String source) {
+ return new ServiceTag("", /* empty instance_urn */
+ productName,
+ productVersion,
+ productURN,
+ productParent,
+ productParentURN,
+ productDefinedInstanceID,
+ productVendor,
+ platformArch,
+ container,
+ source,
+ -1,
+ null);
+ }
+
+ /**
+ * Creates a service tag object with a specified <tt>instance_urn</tt>.
+ *
+ * @param instanceURN the uniform resource name of this instance.
+ * @param productName the name of the product.
+ * @param productVersion the version of the product.
+ * @param productURN the uniform resource name of the product
+ * @param productParent the name of the product's parent.
+ * @param productParentURN the uniform resource name of the product's parent.
+ * @param productDefinedInstanceID the instance identifier.
+ * @param productVendor the vendor of the product.
+ * @param platformArch the operating system architecture.
+ * @param container the container of the product.
+ * @param source the source of the product.
+ *
+ * @throws IllegalArgumentException if any value of the input fields
+ * does not conform to the service tag XML schema.
+ */
+ public static ServiceTag newInstance(String instanceURN,
+ String productName,
+ String productVersion,
+ String productURN,
+ String productParent,
+ String productParentURN,
+ String productDefinedInstanceID,
+ String productVendor,
+ String platformArch,
+ String container,
+ String source) {
+ return new ServiceTag(instanceURN,
+ productName,
+ productVersion,
+ productURN,
+ productParent,
+ productParentURN,
+ productDefinedInstanceID,
+ productVendor,
+ platformArch,
+ container,
+ source,
+ -1,
+ null);
+ }
+
+ // Creates a copy of the ServiceTag instance
+ // with instance_urn and timestamp initialized
+ static ServiceTag newInstanceWithUrnTimestamp(ServiceTag st) {
+ String instanceURN =
+ (st.getInstanceURN().length() == 0 ? Util.generateURN() :
+ st.getInstanceURN());
+ ServiceTag svcTag = new ServiceTag(instanceURN,
+ st.getProductName(),
+ st.getProductVersion(),
+ st.getProductURN(),
+ st.getProductParent(),
+ st.getProductParentURN(),
+ st.getProductDefinedInstanceID(),
+ st.getProductVendor(),
+ st.getPlatformArch(),
+ st.getContainer(),
+ st.getSource(),
+ st.getInstallerUID(),
+ new Date());
+ return svcTag;
+ }
+
+ /**
+ * Returns a uniform resource name (URN) in this format:
+ * <blockquote>
+ * "<tt>urn:st:<32-char {@link java.util.UUID uuid}></tt>"
+ * </blockquote>
+ * @return a URN.
+ */
+ public static String generateInstanceURN() {
+ return Util.generateURN();
+ }
+
+ /**
+ * Returns the uniform resource name of this service tag instance.
+ *
+ * @return the <tt>instance_urn</tt> of this service tag.
+ */
+ public String getInstanceURN() {
+ return instanceURN;
+ }
+
+ /**
+ * Returns the name of the product.
+ *
+ * @return the product name.
+ */
+ public String getProductName() {
+ return productName;
+ }
+
+ /**
+ * Returns the version of the product.
+ *
+ * @return the product version.
+ */
+ public String getProductVersion() {
+ return productVersion;
+ }
+
+ /**
+ * Returns the uniform resource name of the product.
+ *
+ * @return the product URN.
+ */
+ public String getProductURN() {
+ return productURN;
+ }
+
+ /**
+ * Returns the uniform resource name of the product's parent.
+ *
+ * @return the product's parent URN.
+ */
+ public String getProductParentURN() {
+ return productParentURN;
+ }
+
+ /**
+ * Returns the name of the product's parent.
+ *
+ * @return the product's parent name.
+ */
+ public String getProductParent() {
+ return productParent;
+ }
+
+ /**
+ * Returns the identifier defined for this product instance.
+ *
+ * @return the identifier defined for this product instance.
+ */
+ public String getProductDefinedInstanceID() {
+ return productDefinedInstanceID;
+ }
+
+ /**
+ * Returns the vendor of the product.
+ *
+ * @return the product vendor.
+ */
+ public String getProductVendor() {
+ return productVendor;
+ }
+
+ /**
+ * Returns the platform architecture on which the product
+ * is running on.
+ *
+ * @return the platform architecture on which the product is running on.
+ */
+ public String getPlatformArch() {
+ return platformArch;
+ }
+
+ /**
+ * Returns the timestamp. This timestamp is set when this service tag
+ * is added to or updated in a {@code RegistrationData} object or
+ * the system service tag registry.
+ * This method may return {@code null}.
+ *
+ * @return timestamp when this service tag
+ * is added to or updated in a {@code RegistrationData} object or
+ * the system service tag registry, or {@code null}.
+ */
+ public Date getTimestamp() {
+ if (timestamp != null) {
+ return (Date) timestamp.clone();
+ } else {
+ return null;
+ }
+ }
+
+
+ /**
+ * Returns the container of the product.
+ *
+ * @return the container of the product.
+ */
+ public String getContainer() {
+ return container;
+ }
+
+ /**
+ * Returns the source of this service tag.
+ *
+ * @return source of this service tag.
+ */
+ public String getSource() {
+ return source;
+ }
+
+ /**
+ * Returns the UID. The UID is set when this service tag
+ * is added to or updated in the system service tag registry.
+ * This is platform dependent whose default value is {@code -1}.
+ * When this service tag is added to a {@code RegistrationData},
+ * the UID is not set.
+ *
+ * @return the UID of whom this service tag
+ * is added to or updated in the system service tag registry,
+ * or {@code -1}.
+ */
+ public int getInstallerUID() {
+ return installerUID;
+ }
+
+ // The following setter methods are used to validate the
+ // input field when constructing a ServiceTag instance
+
+ private void setInstanceURN(String instanceURN) {
+ if (instanceURN == null) {
+ throw new NullPointerException("Parameter instanceURN cannot be null");
+ }
+ if (instanceURN.length() > MAX_URN_LEN) {
+ throw new IllegalArgumentException("instanceURN \"" + instanceURN +
+ "\" exceeds maximum length " + MAX_URN_LEN);
+ }
+ this.instanceURN = instanceURN;
+ }
+
+ private void setProductName(String productName) {
+ if (productName == null) {
+ throw new NullPointerException("Parameter productName cannot be null");
+ }
+ if (productName.length() == 0) {
+ throw new IllegalArgumentException("product name cannot be empty");
+ }
+ if (productName.length() > MAX_PRODUCT_NAME_LEN) {
+ throw new IllegalArgumentException("productName \"" + productName +
+ "\" exceeds maximum length " + MAX_PRODUCT_NAME_LEN);
+ }
+ this.productName = productName;
+ }
+
+ private void setProductVersion(String productVersion) {
+ if (productVersion == null) {
+ throw new NullPointerException("Parameter productVersion cannot be null");
+ }
+
+ if (productVersion.length() == 0) {
+ throw new IllegalArgumentException("product version cannot be empty");
+ }
+ if (productVersion.length() > MAX_PRODUCT_VERSION_LEN) {
+ throw new IllegalArgumentException("productVersion \"" +
+ productVersion + "\" exceeds maximum length " +
+ MAX_PRODUCT_VERSION_LEN);
+ }
+ this.productVersion = productVersion;
+ }
+
+ private void setProductURN(String productURN) {
+ if (productURN == null) {
+ throw new NullPointerException("Parameter productURN cannot be null");
+ }
+ if (productURN.length() == 0) {
+ throw new IllegalArgumentException("product URN cannot be empty");
+ }
+ if (productURN.length() > MAX_URN_LEN) {
+ throw new IllegalArgumentException("productURN \"" + productURN +
+ "\" exceeds maximum length " + MAX_URN_LEN);
+ }
+ this.productURN = productURN;
+ }
+
+ private void setProductParentURN(String productParentURN) {
+ if (productParentURN == null) {
+ throw new NullPointerException("Parameter productParentURN cannot be null");
+ }
+ // optional field - can be empty
+ if (productParentURN.length() > MAX_URN_LEN) {
+ throw new IllegalArgumentException("productParentURN \"" +
+ productParentURN + "\" exceeds maximum length " +
+ MAX_URN_LEN);
+ }
+ this.productParentURN = productParentURN;
+ }
+
+ private void setProductParent(String productParent) {
+ if (productParent == null) {
+ throw new NullPointerException("Parameter productParent cannot be null");
+ }
+ if (productParent.length() == 0) {
+ throw new IllegalArgumentException("product parent cannot be empty");
+ }
+ if (productParent.length() > MAX_PRODUCT_PARENT_LEN) {
+ throw new IllegalArgumentException("productParent \"" +
+ productParent + "\" exceeds maximum length " +
+ MAX_PRODUCT_PARENT_LEN);
+ }
+ this.productParent = productParent;
+ }
+
+ void setProductDefinedInstanceID(String productDefinedInstanceID) {
+ if (productDefinedInstanceID == null) {
+ throw new NullPointerException("Parameter productDefinedInstanceID cannot be null");
+ }
+ if (productDefinedInstanceID.length() > MAX_URN_LEN) {
+ throw new IllegalArgumentException("productDefinedInstanceID \"" +
+ productDefinedInstanceID + "\" exceeds maximum length " +
+ MAX_URN_LEN);
+ }
+ // optional field - can be empty
+ this.productDefinedInstanceID = productDefinedInstanceID;
+ }
+
+ private void setProductVendor(String productVendor) {
+ if (productVendor == null) {
+ throw new NullPointerException("Parameter productVendor cannot be null");
+ }
+ if (productVendor.length() == 0) {
+ throw new IllegalArgumentException("product vendor cannot be empty");
+ }
+ if (productVendor.length() > MAX_PRODUCT_VENDOR_LEN) {
+ throw new IllegalArgumentException("productVendor \"" +
+ productVendor + "\" exceeds maximum length " +
+ MAX_PRODUCT_VENDOR_LEN);
+ }
+ this.productVendor = productVendor;
+ }
+
+ private void setPlatformArch(String platformArch) {
+ if (platformArch == null) {
+ throw new NullPointerException("Parameter platformArch cannot be null");
+ }
+ if (platformArch.length() == 0) {
+ throw new IllegalArgumentException("platform architecture cannot be empty");
+ }
+ if (platformArch.length() > MAX_PLATFORM_ARCH_LEN) {
+ throw new IllegalArgumentException("platformArch \"" +
+ platformArch + "\" exceeds maximum length " +
+ MAX_PLATFORM_ARCH_LEN);
+ }
+ this.platformArch = platformArch;
+ }
+
+ private void setTimestamp(Date timestamp) {
+ // can be null
+ this.timestamp = timestamp;
+ }
+
+ private void setContainer(String container) {
+ if (container == null) {
+ throw new NullPointerException("Parameter container cannot be null");
+ }
+ if (container.length() == 0) {
+ throw new IllegalArgumentException("container cannot be empty");
+ }
+ if (container.length() > MAX_CONTAINER_LEN) {
+ throw new IllegalArgumentException("container \"" +
+ container + "\" exceeds maximum length " +
+ MAX_CONTAINER_LEN);
+ }
+ this.container = container;
+ }
+
+ private void setSource(String source) {
+ if (source == null) {
+ throw new NullPointerException("Parameter source cannot be null");
+ }
+ if (source.length() == 0) {
+ throw new IllegalArgumentException("source cannot be empty");
+ }
+ if (source.length() > MAX_SOURCE_LEN) {
+ throw new IllegalArgumentException("source \"" + source +
+ "\" exceeds maximum length " + MAX_SOURCE_LEN);
+ }
+ this.source = source;
+ }
+
+ private void setInstallerUID(int installerUID) {
+ this.installerUID = installerUID;
+ }
+
+ /**
+ * Compares this service tag to the specified object.
+ * The result is {@code true} if and only if the argument is
+ * not {@code null} and is a {@code ServiceTag} object whose
+ * <tt>instance_urn</tt> is the same as the
+ * <tt>instance_urn</tt> of this service tag.
+ *
+ * @return {@code true} if this service tag is the same as
+ * the specified object.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null || !(obj instanceof ServiceTag)) {
+ return false;
+ }
+ ServiceTag st = (ServiceTag) obj;
+ if (st == this) {
+ return true;
+ }
+ return st.getInstanceURN().equals(getInstanceURN());
+ }
+
+ /**
+ * Returns the hash code value for this service tag.
+ * @return the hash code value for this service tag.
+ */
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 19 * hash + (this.instanceURN != null ? this.instanceURN.hashCode() : 0);
+ return hash;
+ }
+
+ /**
+ * Returns the string representation of this service tag.
+ * The format is implementation specific.
+ *
+ * @return the string representation of this service tag.
+ */
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(ST_NODE_INSTANCE_URN).append("=").append(instanceURN).append("\n");
+ sb.append(ST_NODE_PRODUCT_NAME).append("=").append(productName).append("\n");
+ sb.append(ST_NODE_PRODUCT_VERSION).append("=").append(productVersion).append("\n");
+ sb.append(ST_NODE_PRODUCT_URN).append("=").append(productURN).append("\n");
+ sb.append(ST_NODE_PRODUCT_PARENT_URN).append("=").append(productParentURN).append("\n");
+ sb.append(ST_NODE_PRODUCT_PARENT).append("=").append(productParent).append("\n");
+ sb.append(ST_NODE_PRODUCT_DEFINED_INST_ID).append("=").append(productDefinedInstanceID).append("\n");
+ sb.append(ST_NODE_PRODUCT_VENDOR).append("=").append(productVendor).append("\n");
+ sb.append(ST_NODE_PLATFORM_ARCH).append("=").append(platformArch).append("\n");
+ sb.append(ST_NODE_TIMESTAMP).append("=").append(Util.formatTimestamp(timestamp)).append("\n");
+ sb.append(ST_NODE_CONTAINER).append("=").append(container).append("\n");
+ sb.append(ST_NODE_SOURCE).append("=").append(source).append("\n");
+ sb.append(ST_NODE_INSTALLER_UID).append("=").append(String.valueOf(installerUID)).append("\n");
+ return sb.toString();
+ }
+
+
+ /**
+ * Returns the {@link ServiceTag} instance for the running Java
+ * platform. The {@link ServiceTag#setSource source} field
+ * of the {@code ServiceTag} will be set to the given {@code source}.
+ * This method will return {@code null} if there is no service tag
+ * for the running Java platform.
+ * <p>
+ * This method is designed for Sun software that bundles the JDK
+ * or the JRE to use. It is recommended that the {@code source}
+ * string contains information about the bundling software
+ * such as the name and the version of the software bundle,
+ * for example,
+ * <blockquote>
+ * <tt>NetBeans IDE 6.0 with JDK 6 Update 5 Bundle</tt>
+ * </blockquote>
+ * in a NetBeans/JDK bundle.
+ * <p>
+ * At the first time to call this method the application
+ * is required to have the write permission to the installed
+ * directory of this running JDK or JRE instance.
+ *
+ * @param source the source that bundles the JDK or the JRE.
+ * @return a {@code ServiceTag} object for the Java platform,
+ * or {@code null} if not supported.
+ * @throws IOException if an error occurs in this operation.
+ */
+ public static ServiceTag getJavaServiceTag(String source) throws IOException {
+ return Installer.getJavaServiceTag(source);
+ }
+
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java b/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java
new file mode 100644
index 0000000000..45ff7b8f7d
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/SolarisServiceTag.java
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * 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: SolarisServiceTag.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+import java.io.IOException;
+import java.util.Set;
+
+/**
+ * Utility class to obtain the service tag for the Solaris Operating System.
+ */
+class SolarisServiceTag {
+ private final static String[] SolarisProductURNs = new String[] {
+ "urn:uuid:a7a38948-2bd5-11d6-98ce-9d3ac1c0cfd7", /* Solaris 8 */
+ "urn:uuid:4f82caac-36f3-11d6-866b-85f428ef944e", /* Solaris 9 */
+ "urn:uuid:a19de03b-48bc-11d9-9607-080020a9ed93", /* Solaris 9 sparc */
+ "urn:uuid:4c35c45b-4955-11d9-9607-080020a9ed93", /* Solaris 9 x86 */
+ "urn:uuid:5005588c-36f3-11d6-9cec-fc96f718e113", /* Solaris 10 */
+ "urn:uuid:6df19e63-7ef5-11db-a4bd-080020a9ed93" /* Solaris 11 */
+ };
+
+ /**
+ * Returns null if not found.
+ *
+ * There is only one service tag for the operating system.
+ */
+ static ServiceTag getServiceTag() throws IOException {
+ if (Registry.isSupported()) {
+ Registry streg = Registry.getSystemRegistry();
+ for (String parentURN : SolarisProductURNs) {
+ Set<ServiceTag> instances = streg.findServiceTags(parentURN);
+ for (ServiceTag st : instances) {
+ // there should have only one service tag for the OS
+ return st;
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java
new file mode 100644
index 0000000000..35dcdba239
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/SolarisSystemEnvironment.java
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * 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: SolarisSystemEnvironment.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+// The Service Tags team maintains the latest version of the implementation
+// for system environment data collection. JDK will include a copy of
+// the most recent released version for a JDK release. We rename
+// the package to com.sun.servicetag so that the Sun Connection
+// product always uses the latest version from the com.sun.scn.servicetags
+// package. JDK and users of the com.sun.servicetag API
+// (e.g. NetBeans and SunStudio) will use the version in JDK.
+
+import java.io.*;
+
+/**
+ * Solaris implementation of the SystemEnvironment class.
+ */
+class SolarisSystemEnvironment extends SystemEnvironment {
+ SolarisSystemEnvironment() {
+ setHostId(getCommandOutput("/usr/bin/hostid"));
+ setSystemModel(getCommandOutput("/usr/bin/uname", "-i"));
+ setSystemManufacturer(getSolarisSystemManufacturer());
+ setCpuManufacturer(getSolarisCpuManufacturer());
+ setSerialNumber(getSolarisSN());
+ }
+
+ /**
+ * Tries to obtain the cpu manufacturer.
+ * @return The cpu manufacturer (an empty string if not found or an error occurred)
+ */
+ private String getSolarisCpuManufacturer() {
+ // 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: ");
+ }
+
+ /**
+ * Tries to obtain the system manufacturer.
+ * @return The system manufacturer (an empty string if not found or an error occurred)
+ */
+ private String getSolarisSystemManufacturer() {
+ // 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 1)
+ return getSmbiosData("1", "Manufacturer: ");
+ }
+
+ /**
+ * Tries to obtain the serial number.
+ * @return The serial number (empty string if not found or an error occurred)
+ */
+ private String getSolarisSN() {
+ // try to read from the psn file if it exists
+ String tmp = getFileContent("/var/run/psn");
+ if (tmp.length() > 0) {
+ return tmp.trim();
+ }
+
+ // if we're here, then we'll try sneep
+ String tmpSN = getSneepSN();
+ if (tmpSN.length() > 0) {
+ return tmpSN;
+ }
+
+ // if we're here, then we'll try smbios (type 1)
+ tmpSN = getSmbiosData("1", "Serial Number: ");
+ if (tmpSN.length() > 0) {
+ return tmpSN;
+ }
+
+ // if we're here, then we'll try smbios (type 3)
+ tmpSN = getSmbiosData("3", "Serial Number: ");
+ if (tmpSN.length() > 0) {
+ return tmpSN;
+ }
+
+ // give up and return
+ return "";
+ }
+
+ // Sample smbios output segment:
+ // ID SIZE TYPE
+ // 1 150 SMB_TYPE_SYSTEM (system information)
+ //
+ // Manufacturer: Sun Microsystems
+ // Product: Sun Fire X4600
+ // Version: To Be Filled By O.E.M.
+ // Serial Number: 00:14:4F:45:0C:2A
+ private String getSmbiosData(String type, String target) {
+ String output = getCommandOutput("/usr/sbin/smbios", "-t", type);
+ for (String s : output.split("\n")) {
+ if (s.contains(target)) {
+ int indx = s.indexOf(target) + target.length();
+ if (indx < s.length()) {
+ String tmp = s.substring(indx).trim();
+ String lowerCaseStr = tmp.toLowerCase();
+ if (!lowerCaseStr.startsWith("not available")
+ && !lowerCaseStr.startsWith("to be filled by o.e.m")) {
+ return tmp;
+ }
+ }
+ }
+ }
+
+ return "";
+ }
+
+ private String getSneepSN() {
+ String basedir = getCommandOutput("pkgparam","SUNWsneep","BASEDIR");
+ File f = new File(basedir + "/bin/sneep");
+ if (f.exists()) {
+ String sneepSN = getCommandOutput(basedir + "/bin/sneep");
+ if (sneepSN.equalsIgnoreCase("unknown")) {
+ return "";
+ } else {
+ return sneepSN;
+ }
+ } else {
+ return "";
+ }
+ }
+
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/SunConnection.java b/desktop/source/registration/com/sun/star/servicetag/SunConnection.java
new file mode 100644
index 0000000000..36c527e018
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/SunConnection.java
@@ -0,0 +1,296 @@
+/*************************************************************************
+ *
+ * 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: SunConnection.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+import java.io.*;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.io.OutputStreamWriter;
+import java.util.Locale;
+import javax.net.ssl.HttpsURLConnection;
+
+/**
+ * Sun Connection Class for Product Registration.
+ *
+ * Registration Web Application Interface
+ * 1) POST the product registry to the output stream of the registration
+ * relay service.
+ * 2) Open the webapp URL from a browser with the following parameters:
+ * registry-urn
+ * product=jdk
+ * locale=<locale-lang>
+ *
+ * @see https://sn-tools.central.sun.com/twiki/pub/ServiceTags/RegistrationRelayService/
+ *
+ */
+class SunConnection {
+
+ private static String JDK_REGISTRATION_URL =
+ "https://inventory.sun.com/RegistrationWeb/register";
+ private static String SANDBOX_TESTING_URL =
+ "https://connection-tst.sun.com/RegistrationWeb/register";
+
+ // System properties for testing
+ private static String SVCTAG_REGISTER_TESTING = "servicetag.register.testing";
+ private static String SVCTAG_REGISTRATION_URL = "servicetag.registration.url";
+ private static String SVCTAG_CONNECTION_TIMEOUT = "servicetag.connection.timeout";
+
+ private SunConnection() {
+ }
+
+ /**
+ * Returns a URL for JDK registration interfacing with the Sun Connection
+ * registration relay service in this form:
+ * <registration-url>/<registry_urn>?product=jdk&locale=<locale-lang>
+ *
+ * The <registration-url> can be overridden by an environment
+ * variable or a system property.
+ *
+ * 1) "servicetag.register.testing" system property to switch to the
+ * Sun Connection registration sandbox testing.
+ * 2) "servicetag.registration.url" system property to override
+ * the URL
+ * 3) Default production URL
+ *
+ */
+ static URL getRegistrationURL(String registrationURN) {
+ String url = System.getProperty(SVCTAG_REGISTRATION_URL);
+ if (url == null) {
+ if (System.getProperty(SVCTAG_REGISTER_TESTING) != null) {
+ url = SANDBOX_TESTING_URL;
+ } else {
+ url = JDK_REGISTRATION_URL;
+ }
+ }
+
+ // trim whitespaces
+ url = url.trim();
+ if (url.length() == 0) {
+ throw new InternalError("Empty registration url set");
+ }
+
+ // Add the registry_urn in the URL's query
+ String registerURL = rewriteURL(url, registrationURN);
+ try {
+ return new URL(registerURL);
+ } catch (MalformedURLException ex) {
+ // should never reach here
+ InternalError x =
+ new InternalError(ex.getMessage());
+ x.initCause(ex);
+ throw x;
+ }
+ }
+
+ private static String rewriteURL(String url, String registryURN) {
+ StringBuilder sb = new StringBuilder(url.trim());
+ int len = sb.length();
+ if (sb.charAt(len-1) != '/') {
+ sb.append('/');
+ }
+ sb.append(registryURN);
+ sb.append("?");
+ sb.append("product=jdk");
+ sb.append("&");
+ sb.append("locale=").append(Locale.getDefault().getLanguage());
+ return sb.toString();
+ }
+
+ /**
+ * Registers all products in the given product registry. If it fails
+ * to post the service tag registry, open the browser with the offline
+ * registration page.
+ *
+ * @param regData registration data to be posted to the Sun Connection
+ * for registration.
+ *
+ * @throws IOException if I/O error occurs in this operation
+ */
+ public static void register(RegistrationData regData) throws IOException {
+ // Gets the URL for SunConnection registration relay service
+ URL url = getRegistrationURL(regData.getRegistrationURN());
+
+ // Post the Product Registry to Sun Connection
+ boolean succeed = postRegistrationData(url, regData);
+ if (succeed) {
+ // service tags posted successfully
+ // now prompt for registration
+ openBrowser(url);
+ } else {
+ // open browser with the offline registration page
+ openOfflineRegisterPage();
+ }
+ }
+
+ /**
+ * Opens a browser for JDK product registration.
+ * @param url Registration Webapp URL
+ */
+ private static void openBrowser(URL url) throws IOException {
+ if (!BrowserSupport.isSupported()) {
+ if (Util.isVerbose()) {
+ System.out.println("Browser is not supported");
+ }
+ return;
+ }
+
+ try {
+ BrowserSupport.browse(url.toURI());
+ } catch (URISyntaxException ex) {
+ InternalError x = new InternalError("Error in registering: " + ex.getMessage());
+ x.initCause(ex);
+ throw x;
+ } catch (IllegalArgumentException ex) {
+ if (Util.isVerbose()) {
+ ex.printStackTrace();
+ }
+ } catch (UnsupportedOperationException ex) {
+ // ignore if not supported
+ if (Util.isVerbose()) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * POST service tag registry to Sun Connection
+ * @param loc the URL of the webapp to handle the POST request
+ * @param streg the Service Tag registry
+ * @return true if posting succeeds; otherwise, false.
+ */
+ private static boolean postRegistrationData(URL url,
+ RegistrationData registration) {
+ try {
+ HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
+ con.setDoInput(true);
+ con.setDoOutput(true);
+ con.setUseCaches(false);
+ con.setAllowUserInteraction(false);
+
+ // default 10 seconds timeout
+ String timeout = System.getProperty(SVCTAG_CONNECTION_TIMEOUT, "10");
+ con.setConnectTimeout(Util.getIntValue(timeout) * 1000);
+
+ if (Util.isVerbose()) {
+ System.out.println("Connecting to post registration data at " + url);
+ }
+
+ con.setRequestMethod("POST");
+ con.setRequestProperty("Content-Type", "text/xml;charset=\"utf-8\"");
+ con.connect();
+
+ OutputStream out = con.getOutputStream();
+ registration.storeToXML(out);
+ out.flush();
+ out.close();
+
+ int returnCode = con.getResponseCode();
+ if (Util.isVerbose()) {
+ System.out.println("POST return status = " + returnCode);
+ printReturnData(con, returnCode);
+ }
+ return (returnCode == HttpURLConnection.HTTP_OK);
+ } catch (MalformedURLException me) {
+ // should never reach here
+ InternalError x = new InternalError("Error in registering: " + me.getMessage());
+ x.initCause(me);
+ throw x;
+ } catch (Exception ioe) {
+ // SocketTimeoutException, IOException or UnknownHostException
+ if (Util.isVerbose()) {
+ ioe.printStackTrace();
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Opens the offline registratioin page in the browser.
+ *
+ */
+ private static void openOfflineRegisterPage()
+ throws IOException {
+ if (!BrowserSupport.isSupported()) {
+ if (Util.isVerbose()) {
+ System.out.println("Browser is not supported");
+ }
+ return;
+ }
+
+ File registerPage = Installer.getRegistrationHtmlPage();
+ try {
+ BrowserSupport.browse(registerPage.toURI());
+ } catch (FileNotFoundException ex) {
+ // should never reach here
+ InternalError x =
+ new InternalError("Error in launching " + registerPage + ": " + ex.getMessage());
+ x.initCause(ex);
+ throw x;
+ } catch (IllegalArgumentException ex) {
+ if (Util.isVerbose()) {
+ ex.printStackTrace();
+ }
+ } catch (UnsupportedOperationException ex) {
+ // ignore if not supported
+ if (Util.isVerbose()) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static void printReturnData(HttpURLConnection con, int returnCode)
+ throws IOException {
+ BufferedReader reader = null;
+ try {
+ if (returnCode < 400) {
+ reader = new BufferedReader(
+ new InputStreamReader(con.getInputStream()));
+ } else {
+ reader = new BufferedReader(
+ new InputStreamReader(con.getErrorStream()));
+ }
+ StringBuilder sb = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ sb.append(line).append("\n");
+ }
+ System.out.println("Response is : ");
+ System.out.println(sb.toString());
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java b/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java
new file mode 100644
index 0000000000..3295a2d45d
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/SysnetRegistryHelper.java
@@ -0,0 +1,380 @@
+/*************************************************************************
+ *
+ * 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: SysnetRegistryHelper.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import static com.sun.star.servicetag.Util.*;
+import static com.sun.star.servicetag.RegistrationDocument.*;
+
+/**
+ * Class containing additional methods that are not yet
+ * in the JDK Registry class. Note that all methods in this class
+ * will be superceeded by the JDK classes.
+ */
+public class SysnetRegistryHelper {
+
+ private static final String STCLIENT_SOLARIS = "/usr/bin/stclient";
+ private static final String STCLIENT_LINUX = "/opt/sun/servicetag/bin/stclient";
+ // stclient exit value (see sthelper.h)
+ private static final int ST_ERR_NOT_AUTH = 245;
+ private static final int ST_ERR_REC_NOT_FOUND = 225;
+
+ // The stclient output has to be an exported interface
+ private static final String INSTANCE_URN_OPEN_ELEMENT = "<instance_urn>";
+ private static final String INSTANCE_URN_CLOSE_ELEMENT = "</instance_urn>";
+ private static final String REGISTRY_URN = "<registry urn=\"";
+ private static final String INSTANCE_URN_DESC = "Product instance URN=";
+ private static boolean initialized = false;
+ private static boolean supportsHelperClass = true; // default
+ private static File stclient = null;
+ private static String stclientPath = null;
+
+ // System properties for testing
+ private static String SVCTAG_STCLIENT_CMD = "servicetag.stclient.cmd";
+ private static String SVCTAG_STHELPER_SUPPORTED = "servicetag.sthelper.supported";
+
+ private synchronized static String getSTclient() {
+ if (!initialized) {
+ // the system property always overrides the default setting
+ if (System.getProperty(SVCTAG_STHELPER_SUPPORTED) != null) {
+ supportsHelperClass = Boolean.getBoolean(SVCTAG_STHELPER_SUPPORTED);
+ }
+
+ // This is only used for testing
+ stclientPath = System.getProperty(SVCTAG_STCLIENT_CMD);
+ if (stclientPath != null) {
+ return stclientPath;
+ }
+
+ // Initialization to determine the platform's stclient pathname
+ String os = System.getProperty("os.name");
+ if (os.equals("SunOS")) {
+ stclient = new File(STCLIENT_SOLARIS);
+ } else if (os.equals("Linux")) {
+ stclient = new File(STCLIENT_LINUX);
+ } else if (os.startsWith("Windows")) {
+ stclient = getWindowsStClientFile();
+ } else {
+ if (isVerbose()) {
+ System.out.println("Running on non-Sun JDK");
+ }
+ }
+ initialized = true;
+ }
+
+ // com.sun.servicetag package has to be compiled with JDK 5 as well
+ // JDK 5 doesn't support the File.canExecute() method.
+ // Risk not checking isExecute() for the stclient command is very low.
+
+ if (stclientPath == null && stclient != null && stclient.exists()) {
+ stclientPath = stclient.getAbsolutePath();
+ }
+ return stclientPath;
+ }
+
+ private static List<String> getCommandList() {
+ // Set up the arguments to call stclient
+ List<String> command = new ArrayList<String>();
+ if (System.getProperty(SVCTAG_STCLIENT_CMD) != null) {
+ // This is for jtreg testing use. This will be set to something
+ // like:
+ // $JAVA_HOME/bin/java -cp $TEST_DIR \
+ // -Dstclient.registry.path=$TEST_DIR/registry.xml \
+ // SvcTagClient
+ //
+ // On Windows, the JAVA_HOME and TEST_DIR path could contain
+ // space e.g. c:\Program Files\Java\jdk1.6.0_05\bin\java.
+ // The SVCTAG_STCLIENT_CMD must be set with a list of
+ // space-separated parameters. If a parameter contains spaces,
+ // it must be quoted with '"'.
+
+ String cmd = getSTclient();
+ int len = cmd.length();
+ int i = 0;
+ while (i < len) {
+ char separator = ' ';
+ if (cmd.charAt(i) == '"') {
+ separator = '"';
+ i++;
+ }
+ // look for the separator or matched the closing '"'
+ int j;
+ for (j = i+1; j < len; j++) {
+ if (cmd.charAt(j) == separator) {
+ break;
+ }
+ }
+
+ if (i == j-1) {
+ // add an empty parameter
+ command.add("\"\"");
+ } else {
+ // double quotes and space are not included
+ command.add(cmd.substring(i,j));
+ }
+
+ // skip spaces
+ for (i = j+1; i < len; i++) {
+ if (!Character.isSpaceChar(cmd.charAt(i))) {
+ break;
+ }
+ }
+ }
+ if (isVerbose()) {
+ System.out.println("Command list:");
+ for (String s : command) {
+ System.out.println(s);
+ }
+ }
+ } else {
+ command.add(getSTclient());
+ }
+ return command;
+ }
+
+ // Returns null if the service tag record not found;
+ // or throw UnauthorizedAccessException or IOException
+ // based on the exitValue.
+ private static ServiceTag checkReturnError(int exitValue,
+ String output,
+ ServiceTag st) throws IOException {
+ switch (exitValue) {
+ case ST_ERR_REC_NOT_FOUND:
+ return null;
+ case ST_ERR_NOT_AUTH:
+ if (st != null) {
+ throw new UnauthorizedAccessException(
+ "Not authorized to access " + st.getInstanceURN() +
+ " installer_uid=" + st.getInstallerUID());
+ } else {
+ throw new UnauthorizedAccessException(
+ "Not authorized:" + output);
+ }
+ default:
+ throw new IOException("stclient exits with error" +
+ " (" + exitValue + ")\n" + output);
+ }
+ }
+
+ /**
+ * Returns a {@code ServiceTag} object of the given <tt>instance_urn</tt>
+ * in this registry.
+ *
+ * @param instanceURN the <tt>instance_urn</tt> of the service tag
+ * @return a {@code ServiceTag} object of the given <tt>instance_urn</tt>
+ * in this registry; or {@code null} if not found.
+ *
+ * @throws java.io.IOException if an I/O error occurs in this operation.
+ */
+ private static ServiceTag getServiceTag(String instanceURN) throws IOException {
+ if (instanceURN == null) {
+ throw new NullPointerException("instanceURN is null");
+ }
+
+ List<String> command = getCommandList();
+ command.add("-g");
+ command.add("-i");
+ command.add(instanceURN);
+
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ String output = commandOutput(p);
+ if (isVerbose()) {
+ System.out.println("Output from stclient -g command:");
+ System.out.println(output);
+ }
+ if (p.exitValue() == 0) {
+ return parseServiceTag(output);
+ } else {
+ return checkReturnError(p.exitValue(), output, null);
+ }
+ }
+
+ private static ServiceTag parseServiceTag(String output) throws IOException {
+ BufferedReader in = null;
+ try {
+ Properties props = new Properties();
+ // parse the service tag output from stclient
+ in = new BufferedReader(new StringReader(output));
+ String line = null;
+ while ((line = in.readLine()) != null) {
+ if ((line = line.trim()).length() > 0) {
+ String[] ss = line.trim().split("=", 2);
+ if (ss.length == 2) {
+ props.setProperty(ss[0].trim(), ss[1].trim());
+ } else {
+ props.setProperty(ss[0].trim(), "");
+ }
+ }
+ }
+
+ String urn = props.getProperty(ST_NODE_INSTANCE_URN);
+ String productName = props.getProperty(ST_NODE_PRODUCT_NAME);
+ String productVersion = props.getProperty(ST_NODE_PRODUCT_VERSION);
+ String productURN = props.getProperty(ST_NODE_PRODUCT_URN);
+ String productParent = props.getProperty(ST_NODE_PRODUCT_PARENT);
+ String productParentURN = props.getProperty(ST_NODE_PRODUCT_PARENT_URN);
+ String productDefinedInstanceID =
+ props.getProperty(ST_NODE_PRODUCT_DEFINED_INST_ID);
+ String productVendor = props.getProperty(ST_NODE_PRODUCT_VENDOR);
+ String platformArch = props.getProperty(ST_NODE_PLATFORM_ARCH);
+ String container = props.getProperty(ST_NODE_CONTAINER);
+ String source = props.getProperty(ST_NODE_SOURCE);
+ int installerUID =
+ Util.getIntValue(props.getProperty(ST_NODE_INSTALLER_UID));
+ Date timestamp =
+ Util.parseTimestamp(props.getProperty(ST_NODE_TIMESTAMP));
+
+ return new ServiceTag(urn,
+ productName,
+ productVersion,
+ productURN,
+ productParent,
+ productParentURN,
+ productDefinedInstanceID,
+ productVendor,
+ platformArch,
+ container,
+ source,
+ installerUID,
+ timestamp);
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+
+ }
+
+ /**
+ * Returns the urn of this registry.
+ *
+ * @return a {@code String} for the urn of this registry.
+ *
+ * @throws java.io.IOException if an I/O error occurs in this operation.
+ */
+ // Once JDK makes this method available, we'll deprecate this method
+ // @deprecated Use the JDK version when available.
+ public static String getRegistryURN() throws IOException {
+ List<String> command = getCommandList();
+ command.add("-x");
+
+ BufferedReader in = null;
+ try {
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ String output = commandOutput(p);
+
+ String registryURN = null;
+ if (p.exitValue() == 0) {
+ // parse the service tag output from stclient
+ in = new BufferedReader(new StringReader(output));
+ String line = null;
+ while ((line = in.readLine()) != null) {
+ String s = line.trim();
+ if (s.indexOf(REGISTRY_URN) != -1) {
+ s = s.substring(s.indexOf(REGISTRY_URN)
+ + REGISTRY_URN.length());
+ if (s.indexOf("\"") != -1) {
+ s = s.substring(0, s.indexOf("\""));
+ registryURN = s;
+ break;
+ }
+ }
+ }
+ } else {
+ checkReturnError(p.exitValue(), output, null);
+ }
+ return registryURN;
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+
+ /**
+ * Returns all the service tags in this registry.
+ *
+ * @return a {@code Set} of {@code ServiceTag} objects
+ * in this registry.
+ *
+ * @throws java.io.IOException if an I/O error occurs in this operation.
+ */
+ // Once JDK makes this method available, we'll deprecate this method
+ // @deprecated Use the JDK version when available.
+ public static Set<ServiceTag> getServiceTags() throws IOException {
+ List<String> command = getCommandList();
+ command.add("-x");
+
+ BufferedReader in = null;
+ try {
+ ProcessBuilder pb = new ProcessBuilder(command);
+ Process p = pb.start();
+ String output = commandOutput(p);
+
+ Set<ServiceTag> instances = new HashSet<ServiceTag>();
+ if (p.exitValue() == 0) {
+ // parse the service tag output from stclient
+ in = new BufferedReader(new StringReader(output));
+ String line = null;
+ while ((line = in.readLine()) != null) {
+ String s = line.trim();
+ if (s.indexOf(INSTANCE_URN_OPEN_ELEMENT) != -1
+ && s.indexOf(INSTANCE_URN_CLOSE_ELEMENT) != -1) {
+ s = s.substring(s.indexOf(INSTANCE_URN_OPEN_ELEMENT)
+ + INSTANCE_URN_OPEN_ELEMENT.length(),
+ s.indexOf(INSTANCE_URN_CLOSE_ELEMENT));
+ try {
+ instances.add(getServiceTag(s));
+ } catch (Exception e) {
+ }
+ }
+ }
+ } else {
+ checkReturnError(p.exitValue(), output, null);
+ }
+ return instances;
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java
new file mode 100644
index 0000000000..40151dfa4c
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java
@@ -0,0 +1,341 @@
+/*************************************************************************
+ *
+ * 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: SystemEnvironment.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+// The Service Tags team maintains the latest version of the implementation
+// for system environment data collection. JDK will include a copy of
+// the most recent released version for a JDK release. We rename
+// the package to com.sun.servicetag so that the Sun Connection
+// product always uses the latest version from the com.sun.scn.servicetags
+// package. JDK and users of the com.sun.servicetag API
+// (e.g. NetBeans and SunStudio) will use the version in JDK.
+
+import java.io.*;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/**
+ * SystemEnvironment class collects the environment data with the
+ * best effort from the underlying platform.
+ */
+public class SystemEnvironment {
+ private String hostname;
+ private String hostId;
+ private String osName;
+ private String osVersion;
+ private String osArchitecture;
+ private String systemModel;
+ private String systemManufacturer;
+ private String cpuManufacturer;
+ private String serialNumber;
+ private static SystemEnvironment sysEnv = null;
+
+ public static synchronized SystemEnvironment getSystemEnvironment() {
+ if (sysEnv == null) {
+ String os = System.getProperty("os.name");
+ if (os.equals("SunOS")) {
+ sysEnv = new SolarisSystemEnvironment();
+ } else if (os.equals("Linux")) {
+ sysEnv = new LinuxSystemEnvironment();
+ } else if (os.startsWith("Windows")) {
+ sysEnv = new WindowsSystemEnvironment();
+ } else {
+ sysEnv = new SystemEnvironment();
+ }
+ }
+ return sysEnv;
+ }
+
+ // package-private
+ SystemEnvironment() {
+ try {
+ this.hostname = InetAddress.getLocalHost().getHostName();
+ } catch (UnknownHostException ex) {
+ this.hostname = "Unknown host";
+ }
+ this.hostId = "";
+ this.osName = System.getProperty("os.name");
+ this.osVersion = System.getProperty("os.version");
+ this.osArchitecture = System.getProperty("os.arch");
+ this.systemModel = "";
+ this.systemManufacturer = "";
+ this.cpuManufacturer = "";
+ this.serialNumber = "";
+ }
+
+
+ /**
+ * Sets the hostname.
+ * @param hostname The hostname to set.
+ */
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ /**
+ * Sets the OS name.
+ * @param osName The osName to set.
+ */
+ public void setOsName(String osName) {
+ this.osName = osName;
+ }
+
+ /**
+ * Sets the OS version.
+ * @param osVersion The osVersion to set.
+ */
+ public void setOsVersion(String osVersion) {
+ this.osVersion = osVersion;
+ }
+
+ /**
+ * Sets the OS architecture.
+ * @param osArchitecture The osArchitecture to set.
+ */
+ public void setOsArchitecture(String osArchitecture) {
+ this.osArchitecture = osArchitecture;
+ }
+
+ /**
+ * Sets the system model.
+ * @param systemModel The systemModel to set.
+ */
+ public void setSystemModel(String systemModel) {
+ this.systemModel = systemModel;
+ }
+
+ /**
+ * Sets the system manufacturer.
+ * @param systemManufacturer The systemManufacturer to set.
+ */
+ public void setSystemManufacturer(String systemManufacturer) {
+ this.systemManufacturer = systemManufacturer;
+ }
+
+ /**
+ * Sets the cpu manufacturer.
+ * @param cpuManufacturer The cpuManufacturer to set.
+ */
+ public void setCpuManufacturer(String cpuManufacturer) {
+ this.cpuManufacturer = cpuManufacturer;
+ }
+
+ /**
+ * Sets the serial number.
+ * @param serialNumber The serialNumber to set.
+ */
+ public void setSerialNumber(String serialNumber) {
+ this.serialNumber = serialNumber;
+ }
+
+ /**
+ * Sets the hostid. Truncates to a max length of 16 chars.
+ * @param hostId The hostid to set.
+ */
+ public void setHostId(String hostId) {
+ if (hostId == null || hostId.equals("null")) {
+ hostId = "";
+ }
+ if (hostId.length() > 16) {
+ hostId = hostId.substring(0,16);
+ }
+ this.hostId = hostId;
+ }
+
+ /**
+ * Returns the hostname.
+ * @return The hostname.
+ */
+ public String getHostname() {
+ return hostname;
+ }
+
+ /**
+ * Returns the osName.
+ * @return The osName.
+ */
+ public String getOsName() {
+ return osName;
+ }
+
+ /**
+ * Returns the osVersion.
+ * @return The osVersion.
+ */
+ public String getOsVersion() {
+ return osVersion;
+ }
+
+ /**
+ * Returns the osArchitecture.
+ * @return The osArchitecture.
+ */
+ public String getOsArchitecture() {
+ return osArchitecture;
+ }
+
+ /**
+ * Returns the systemModel.
+ * @return The systemModel.
+ */
+ public String getSystemModel() {
+ return systemModel;
+ }
+
+ /**
+ * Returns the systemManufacturer.
+ * @return The systemManufacturer.
+ */
+ public String getSystemManufacturer() {
+ return systemManufacturer;
+ }
+
+ /**
+ * Returns the serialNumber.
+ * @return The serialNumber.
+ */
+ public String getSerialNumber() {
+ return serialNumber;
+ }
+
+ /**
+ * Returns the hostId.
+ * @return The hostId.
+ */
+ public String getHostId() {
+ return hostId;
+ }
+
+ /**
+ * Returns the cpuManufacturer.
+ * @return The cpuManufacturer.
+ */
+ public String getCpuManufacturer() {
+ return cpuManufacturer;
+ }
+
+ protected String getCommandOutput(String... command) {
+ StringBuilder sb = new StringBuilder();
+ BufferedReader br = null;
+ Process p = null;
+ try {
+ ProcessBuilder pb = new ProcessBuilder(command);
+ p = pb.start();
+ p.waitFor();
+
+ if (p.exitValue() == 0) {
+ br = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ line = line.trim();
+ if (line.length() > 0) {
+ if (sb.length() > 0) {
+ sb.append("\n");
+ }
+ sb.append(line);
+ }
+ }
+ }
+ return sb.toString();
+ } catch (InterruptedException ie) {
+ // in case the command hangs
+ if (p != null) {
+ p.destroy();
+ }
+ return "";
+ } catch (Exception e) {
+ // ignore exception
+ return "";
+ } finally {
+ if (p != null) {
+ try {
+ p.getErrorStream().close();
+ } catch (IOException e) {
+ // ignore
+ }
+ try {
+ p.getInputStream().close();
+ } catch (IOException e) {
+ // ignore
+ }
+ try {
+ p.getOutputStream().close();
+ } catch (IOException e) {
+ // ignore
+ }
+ p = null;
+ }
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ protected String getFileContent(String filename) {
+ File f = new File(filename);
+ if (!f.exists()) {
+ return "";
+ }
+
+ StringBuilder sb = new StringBuilder();
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new FileReader(f));
+ String line = null;
+ while ((line = br.readLine()) != null) {
+ line = line.trim();
+ if (line.length() > 0) {
+ if (sb.length() > 0) {
+ sb.append("\n");
+ }
+ sb.append(line);
+ }
+ }
+ return sb.toString();
+ } catch (Exception e) {
+ // ignore exception
+ return "";
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+}
diff --git a/xmlhelp/inc/xmlhelp/helplinkerdllapi.h b/desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java
index 25d3790b8b..196e987955 100644
--- a/xmlhelp/inc/xmlhelp/helplinkerdllapi.h
+++ b/desktop/source/registration/com/sun/star/servicetag/UnauthorizedAccessException.java
@@ -6,8 +6,9 @@
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: helplinkerdllapi.h,v $
- * $Revision: 1.3 $
+ * $RCSfile: UnauthorizedAccessException.java,v $
+ *
+ * $Revision: 1.2 $
*
* This file is part of OpenOffice.org.
*
@@ -28,17 +29,31 @@
*
************************************************************************/
-#ifndef INCLUDED_HELPLINKERDLLAPI_H
-#define INCLUDED_HELPLINKERDLLAPI_H
+package com.sun.star.servicetag;
-#include "sal/types.h"
+/**
+ * Thrown if the user is not authorized to
+ * {@link Registry#updateServiceTag update} or
+ * {@link Registry#removeServiceTag remove}
+ * a service tag from a {@link Registry}.
+ */
+public class UnauthorizedAccessException extends RuntimeException {
-#if defined(HELPLINKER_DLLIMPLEMENTATION)
-#define HELPLINKER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
-#else
-#define HELPLINKER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
-#endif
-#define HELPLINKER_DLLPRIVATE SAL_DLLPRIVATE
+ /**
+ * Constructs an <code>UnauthorizedAccessException</code> object
+ * without detail message.
+ */
+ public UnauthorizedAccessException() {
+ }
-#endif /* INCLUDED_HELPLINKERDLLAPI_H */
+ /**
+ * Constructs an <code>UnauthorizedAccessException</code> object
+ * with the specified detail message.
+ *
+ * @param msg the detail message.
+ */
+ public UnauthorizedAccessException(String msg) {
+ super(msg);
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/Util.java b/desktop/source/registration/com/sun/star/servicetag/Util.java
new file mode 100644
index 0000000000..e8ae3fc6ed
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/Util.java
@@ -0,0 +1,297 @@
+/*************************************************************************
+ *
+ * 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: Util.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+import java.io.*;
+import java.util.Date;
+import java.text.SimpleDateFormat;
+import java.text.ParseException;
+import java.util.TimeZone;
+import java.util.UUID;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+// Utility class for com.sun.star.servicetag package
+class Util {
+ private static boolean verbose = (System.getProperty("servicetag.verbose") != null);
+ private static String jrepath = null;
+
+ // for debugging and tracing
+ static boolean isVerbose() {
+ return verbose;
+ }
+
+ /**
+ * Gets the pathname of JRE in the running platform
+ * This can be a JDK or JRE.
+ */
+ static synchronized String getJrePath() {
+ if (jrepath == null) {
+ // Determine the JRE path by checking the existence of
+ // <HOME>/jre/lib and <HOME>/lib.
+ String javaHome = System.getProperty("java.home");
+ jrepath = javaHome + File.separator + "jre";
+ File f = new File(jrepath, "lib");
+ if (!f.exists()) {
+ // java.home usually points to the JRE path
+ jrepath = javaHome;
+ }
+ }
+ return jrepath;
+ }
+
+ /**
+ * Tests if the running platform is a JDK.
+ */
+ static boolean isJdk() {
+ // <HOME>/jre exists which implies it's a JDK
+ return getJrePath().endsWith(File.separator + "jre");
+ }
+
+ /**
+ * Generates the URN string of "urn:st" namespace
+ */
+ static String generateURN() {
+ return "urn:st:" + UUID.randomUUID().toString();
+ }
+
+ static int getIntValue(String value) {
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("\"" + value + "\"" +
+ " expected to be an integer");
+ }
+ }
+
+ /**
+ * Formats the Date into a timestamp string in YYYY-MM-dd HH:mm:ss GMT.
+ * @param timestamp Date
+ * @return a string representation of the timestamp
+ * in the YYYY-MM-dd HH:mm:ss GMT format.
+ */
+ static String formatTimestamp(Date timestamp) {
+ if (timestamp == null) {
+ return "[No timestamp]";
+ }
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
+ df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ return df.format(timestamp);
+ }
+
+ /**
+ * Parses a timestamp string in YYYY-MM-dd HH:mm:ss GMT format.
+ * @param timestamp Timestamp in the YYYY-MM-dd HH:mm:ss GMT format.
+ * @return Date
+ */
+ static Date parseTimestamp(String timestamp) {
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
+ df.setTimeZone(TimeZone.getTimeZone("GMT"));
+ try {
+ return df.parse(timestamp);
+ } catch (ParseException e) {
+ // should not reach here
+ e.printStackTrace();
+ return new Date();
+ }
+ }
+
+ static String commandOutput(Process p) throws IOException {
+ Reader r = null;
+ Reader err = null;
+ try {
+ r = new InputStreamReader(p.getInputStream());
+ err = new InputStreamReader(p.getErrorStream());
+ String output = commandOutput(r);
+ String errorMsg = commandOutput(err);
+ p.waitFor();
+ return output + errorMsg.trim();
+ } catch (InterruptedException e) {
+ if (isVerbose()) {
+ e.printStackTrace();
+ }
+ return e.getMessage();
+ } finally {
+ if (r != null) {
+ r.close();
+ }
+ if (err != null) {
+ err.close();
+ }
+ }
+ }
+
+ static String commandOutput(Reader r) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ int c;
+ while ((c = r.read()) > 0) {
+ if (c != '\r') {
+ sb.append((char) c);
+ }
+ }
+ return sb.toString();
+ }
+
+ static int getJdkVersion() {
+ parseVersion();
+ return jdkVersion;
+ }
+
+ static int getUpdateVersion() {
+ parseVersion();
+ return jdkUpdate;
+ }
+
+ private static int jdkVersion = 0;
+ private static int jdkUpdate = 0;
+ private static synchronized void parseVersion() {
+ if (jdkVersion > 0) {
+ return;
+ }
+
+ // parse java.runtime.version
+ // valid format of the version string is:
+ // n.n.n[_uu[c]][-<identifer>]-bxx
+ String cs = System.getProperty("java.runtime.version");
+ if (cs.length() >= 5 &&
+ Character.isDigit(cs.charAt(0)) && cs.charAt(1) == '.' &&
+ Character.isDigit(cs.charAt(2)) && cs.charAt(3) == '.' &&
+ Character.isDigit(cs.charAt(4))) {
+ jdkVersion = Character.digit(cs.charAt(2), 10);
+ cs = cs.substring(5, cs.length());
+ if (cs.charAt(0) == '_' && cs.length() >= 3 &&
+ Character.isDigit(cs.charAt(1)) &&
+ Character.isDigit(cs.charAt(2))) {
+ int nextChar = 3;
+ try {
+ String uu = cs.substring(1, 3);
+ jdkUpdate = Integer.valueOf(uu).intValue();
+ } catch (NumberFormatException e) {
+ // not conforming to the naming convention
+ return;
+ }
+ }
+ } else {
+ throw new InternalError("Invalid java.runtime.version" + cs);
+ }
+ }
+
+ /**
+ * Returns this java string as a null-terminated byte array
+ */
+ private static byte[] stringToByteArray(String str) {
+ return (str + "\u0000").getBytes();
+ }
+
+ /**
+ * Converts a null-terminated byte array to java string
+ */
+ private static String byteArrayToString(byte[] array) {
+ return new String(array, 0, array.length -1);
+ }
+
+ /**
+ * Gets the stclient path using a well known location from
+ * the Windows platform Registry, otherwise it will return null.
+ */
+ static File getWindowsStClientFile() {
+ File out = null;
+ String regKey = "software\\microsoft\\windows\\currentversion\\app paths\\stclient.exe";
+ String keyName = "" ; // use the default key
+ String path = getRegistryKey(regKey, keyName);
+
+ if (path != null && (new File(path)).exists()) {
+ out = new File(path);
+ }
+ if (isVerbose()) {
+ System.out.println("stclient=" + out);
+ }
+ return out;
+ }
+
+ /**
+ * This uses reflection to access a private java windows registry
+ * interface, any changes to that Class must be appropriately adjusted.
+ * Returns a null if unsuccessful.
+ */
+ private static String getRegistryKey(String regKey, String keyName) {
+ String out = null;
+ try {
+ Class<?> clazz = Class.forName("java.util.prefs.WindowsPreferences");
+
+ // Get the registry methods
+ Method winRegOpenKeyM = clazz.getDeclaredMethod("WindowsRegOpenKey",
+ int.class, byte[].class, int.class);
+ winRegOpenKeyM.setAccessible(true);
+
+ Method winRegCloseKeyM = clazz.getDeclaredMethod("WindowsRegCloseKey",
+ int.class);
+ winRegCloseKeyM.setAccessible(true);
+
+ Method winRegQueryValueM = clazz.getDeclaredMethod("WindowsRegQueryValueEx",
+ int.class, byte[].class);
+ winRegQueryValueM.setAccessible(true);
+
+ // Get all the constants we need
+ int HKLM = getValueFromStaticField("HKEY_LOCAL_MACHINE", clazz);
+ int KEY_READ = getValueFromStaticField("KEY_READ", clazz);
+ int ERROR_CODE = getValueFromStaticField("ERROR_CODE", clazz);
+ int NATIVE_HANDLE = getValueFromStaticField("NATIVE_HANDLE", clazz);
+ int ERROR_SUCCESS = getValueFromStaticField("ERROR_SUCCESS", clazz);
+
+ // Convert keys
+ byte[] reg = stringToByteArray(regKey);
+ byte[] key = stringToByteArray(keyName);
+
+ // Open the registry
+ int[] result = (int[]) winRegOpenKeyM.invoke(null, HKLM, reg, KEY_READ);
+
+ if (result[ERROR_CODE] == ERROR_SUCCESS) {
+ byte[] stvalue = (byte[]) winRegQueryValueM.invoke(null,
+ result[NATIVE_HANDLE], key);
+ out = byteArrayToString(stvalue);
+ winRegCloseKeyM.invoke(null, result[NATIVE_HANDLE]);
+ }
+ } catch (Exception ex) {
+ if (isVerbose()) {
+ ex.printStackTrace();
+ }
+ }
+ return out;
+ }
+
+ private static int getValueFromStaticField(String fldName, Class<?> klass) throws Exception {
+ Field f = klass.getDeclaredField(fldName);
+ f.setAccessible(true);
+ return f.getInt(null);
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java
new file mode 100644
index 0000000000..97ceeb5e7d
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/WindowsSystemEnvironment.java
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * 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: WindowsSystemEnvironment.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.servicetag;
+
+// The Service Tags team maintains the latest version of the implementation
+// for system environment data collection. JDK will include a copy of
+// the most recent released version for a JDK release. We rename
+// the package to com.sun.servicetag so that the Sun Connection
+// product always uses the latest version from the com.sun.scn.servicetags
+// package. JDK and users of the com.sun.servicetag API
+// (e.g. NetBeans and SunStudio) will use the version in JDK.
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Windows implementation of the SystemEnvironment class.
+ */
+class WindowsSystemEnvironment extends SystemEnvironment {
+ WindowsSystemEnvironment() {
+ super();
+
+ // run a call to make sure things are initialized
+ // ignore the first call result as the system may
+ // give inconsistent data on the first invocation ever
+ getWmicResult("computersystem", "get", "model");
+
+ setSystemModel(getWmicResult("computersystem", "get", "model"));
+ setSystemManufacturer(getWmicResult("computersystem", "get", "manufacturer"));
+ setSerialNumber(getWmicResult("bios", "get", "serialnumber"));
+
+ String cpuMfr = getWmicResult("cpu", "get", "manufacturer");
+ // this isn't as good an option, but if we couldn't get anything
+ // from wmic, try the processor_identifier
+ if (cpuMfr.length() == 0) {
+ String procId = System.getenv("processor_identifer");
+ if (procId != null) {
+ String[] s = procId.split(",");
+ cpuMfr = s[s.length - 1].trim();
+ }
+ }
+ setCpuManufacturer(cpuMfr);
+
+ // try to remove the temp file that gets created from running wmic cmds
+ try {
+ // look in the current working directory
+ File f = new File("TempWmicBatchFile.bat");
+ if (f.exists()) {
+ f.delete();
+ }
+ } catch (Exception e) {
+ // ignore the exception
+ }
+ }
+
+
+ /**
+ * This method invokes wmic outside of the normal environment
+ * collection routines.
+ *
+ * An initial call to wmic can be costly in terms of time.
+ *
+ * <code>
+ * Details of why the first call is costly can be found at:
+ *
+ * http://support.microsoft.com/kb/290216/en-us
+ *
+ * "When you run the Wmic.exe utility for the first time, the utility
+ * compiles its .mof files into the repository. To save time during
+ * Windows installation, this operation takes place as necessary."
+ * </code>
+ */
+ private String getWmicResult(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;
+ }
+ res = line;
+ }
+ // return the *last* line read
+ return res;
+ }
+
+ } catch (Exception e) {
+ // ignore the exception
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ return res.trim();
+ }
+}
diff --git a/desktop/source/registration/com/sun/star/servicetag/makefile.mk b/desktop/source/registration/com/sun/star/servicetag/makefile.mk
new file mode 100644
index 0000000000..d4ebbed2f0
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/makefile.mk
@@ -0,0 +1,83 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.2 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJNAME = setup_native
+PRJ = ..$/..$/..$/..$/..$/..
+TARGET = servicetag
+PACKAGE = com$/sun$/star$/servicetag
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(ENABLE_SVCTAGS)" == "YES"
+
+JARFILES = jurt.jar unoil.jar ridl.jar
+JAVAFILES = \
+ BrowserSupport.java \
+ Installer.java \
+ LinuxSystemEnvironment.java \
+ RegistrationData.java \
+ RegistrationDocument.java \
+ Registry.java \
+ ServiceTag.java \
+ SolarisServiceTag.java \
+ SolarisSystemEnvironment.java \
+ SunConnection.java \
+ SysnetRegistryHelper.java \
+ SystemEnvironment.java \
+ UnauthorizedAccessException.java \
+ Util.java \
+ WindowsSystemEnvironment.java
+
+JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+JARCLASSDIRS = $(PACKAGE)
+
+JAVARES= $(CLASSDIR)$/$(PACKAGE)$/resources$/product_registration.xsd
+
+.ENDIF # "$(ENABLE_SVCTAGS)" == "YES"
+
+# --- Targets ------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_SVCTAGS)" == "YES"
+ALLTAR: $(JAVARES)
+
+$(JAVARES) : $$(@:d:d:f)$/$$(@:f)
+ $(MKDIRHIER) $(@:d)
+ $(COPY) $< $@
+
+.ENDIF # "$(ENABLE_SVCTAGS)" == "YES"
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
new file mode 100644
index 0000000000..e9b34417d9
--- /dev/null
+++ b/desktop/source/registration/com/sun/star/servicetag/resources/product_registration.xsd
@@ -0,0 +1,301 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+<xs:element name="registration_data">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="environment"
+ minOccurs="1"
+ maxOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="hostname"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="hostId"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="osName"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="osVersion"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="osArchitecture"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="systemModel"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="systemManufacturer"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="cpuManufacturer"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="serialNumber"
+ minOccurs='1'
+ maxOccurs='1'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="registry"
+ minOccurs="1"
+ maxOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="service_tag"
+ minOccurs="0"
+ maxOccurs="1024">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="instance_urn"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_name"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_version"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_urn"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_parent_urn"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_parent"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_defined_inst_id"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="product_vendor"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="platform_arch"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="timestamp"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="container"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="source"
+ minOccurs='1'
+ maxOccurs='1'/>
+ <xs:element ref="installer_uid"
+ minOccurs='1'
+ maxOccurs='1'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="urn"
+ type="xs:string"
+ use="required"/>
+ <xs:attribute name="version"
+ type="xs:string"
+ use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="version"
+ type="xs:string"
+ use="required"/>
+ </xs:complexType>
+</xs:element>
+
+ <!-- definition of simple elements -->
+ <xs:element name="hostname">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="hostId">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="16"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="osName">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="256"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="osVersion">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="50"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="osArchitecture">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="256"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="systemModel">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="50"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="systemManufacturer">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="50"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="cpuManufacturer">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="50"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="serialNumber">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="256"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="instance_urn">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_name">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_version">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_urn">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_parent_urn">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_parent">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_defined_inst_id">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="0"/>
+ <xs:maxLength value="255"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="product_vendor">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="platform_arch">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:minLength value="1"/>
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="timestamp">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="24"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="container">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="source">
+ <xs:simpleType>
+ <xs:restriction base="xs:string">
+ <xs:maxLength value="63"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+ <xs:element name="installer_uid">
+ <xs:simpleType>
+ <xs:restriction base="xs:integer">
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:element>
+
+</xs:schema>
diff --git a/desktop/util/makefile.mk b/desktop/util/makefile.mk
index b04162cf0a..69b9c2254f 100644
--- a/desktop/util/makefile.mk
+++ b/desktop/util/makefile.mk
@@ -78,6 +78,7 @@ RESLIB1IMAGES= $(PRJ)$/res
RESLIB1SRSFILES= $(SRS)$/desktop.srs \
$(SRS)$/wizard.srs
+.IF "$(L10N_framework)"==""
.IF "$(GUI)" != "OS2"
APP1TARGET=so$/$(TARGET)
APP1NOSAL=TRUE
@@ -241,10 +242,14 @@ APP5DEPN= $(APP1TARGETN) $(APP5RES) ooverinfo.rc
APP5DEF= $(MISCX)$/$(TARGET).def
.ENDIF # WNT
+.ENDIF
+
# --- Targets -------------------------------------------------------------
.INCLUDE : target.mk
+.IF "$(L10N_framework)"==""
+
.IF "$(APP1TARGETN)"!=""
$(APP1TARGETN) : $(MISC)$/binso_created.flg
.ENDIF # "$(APP1TARGETN)"!=""
@@ -333,3 +338,5 @@ $(BIN)$/$(TARGET).bin: $(BIN)$/$(TARGET)$(EXECPOST)
$(MISC)$/binso_created.flg :
@@-$(MKDIRHIER) $(BIN)$/so && $(TOUCH) $@
+
+.ENDIF
diff --git a/eventattacher/source/makefile.mk b/eventattacher/source/makefile.mk
index 1a1cbe3f75..f642559b80 100644
--- a/eventattacher/source/makefile.mk
+++ b/eventattacher/source/makefile.mk
@@ -40,6 +40,7 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
# ------------------------------------------------------------------
+.IF "$(L10N_framework)"==""
SLOFILES= \
$(SLO)$/eventattacher.obj
@@ -59,6 +60,8 @@ SHL1STDLIBS= \
SHL1DEPN=
SHL1LIBS= $(SLB)$/$(TARGET).lib
+.ENDIF # L10N_framework
+
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
diff --git a/fileaccess/source/makefile.mk b/fileaccess/source/makefile.mk
index 36906af4e1..ff9eaab41f 100644
--- a/fileaccess/source/makefile.mk
+++ b/fileaccess/source/makefile.mk
@@ -40,6 +40,7 @@ COMPRDB=$(SOLARBINDIR)$/types.rdb
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
# ------------------------------------------------------------------
SLOFILES= \
@@ -65,6 +66,7 @@ SHL1DEPN=
SHL1LIBS=$(SLB)$/$(TARGET).lib
# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/oovbaapi/genconstidl/makefile.mk b/oovbaapi/genconstidl/makefile.mk
index 42219545c6..95363d56c3 100644
--- a/oovbaapi/genconstidl/makefile.mk
+++ b/oovbaapi/genconstidl/makefile.mk
@@ -36,6 +36,8 @@ PRJNAME=oovbaapi
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+
.IF "$(ENABLE_VBA)"!="YES"
dummy:
@echo "not building vba..."
@@ -70,3 +72,7 @@ CLEAN :
@$(RM) $(MY_GEN_IDL_PATH)$/*.idl
@$(RM) $(foreach,i,$(MYSYMFILES) $(MISC)$/$(i:b).done)
+.ELSE
+ivo:
+ $(ECHO)
+.ENDIF # L10N_framework
diff --git a/oovbaapi/ooo/vba/constants/makefile.mk b/oovbaapi/ooo/vba/constants/makefile.mk
index 9fb0e9144d..0b092e6f79 100644
--- a/oovbaapi/ooo/vba/constants/makefile.mk
+++ b/oovbaapi/ooo/vba/constants/makefile.mk
@@ -36,6 +36,7 @@ TARGET=constants
PACKAGE=org$/vba$/constants
# --- Settings -----------------------------------------------------
+
.INCLUDE : $(PRJ)$/util$/makefile.pmk
.IF "$(ENABLE_VBA)"!="YES"
@@ -43,8 +44,8 @@ dummy:
@echo "not building vba..."
.ELSE
+.IF "$(L10N_framework)"==""
# ------------------------------------------------------------------------
-
# I tried to use the IDLFILES target but it failed dismally
MY_GEN_IDL_PATH=$(MISC)$/idl
MY_GEN_UCR_PATH=$(OUT)$/ucr$/$(PACKAGE)
@@ -53,10 +54,12 @@ MYTMPIDLFILES=$(shell @ls $(MY_GEN_IDL_PATH))
MYIDLFILES=$(foreach,i,$(MYTMPIDLFILES) $(MY_GEN_IDL_PATH)$/$(i))
MYURDFILES=$(foreach,i,$(MYIDLFILES) $(MY_GEN_UCR_PATH)$/$(i:b).urd)
MYDBTARGET=$(OUT)$/ucr/constants.db
-
+.ENDIF
+.ENDIF
.INCLUDE : target.mk
+.IF "$(L10N_framework)"==""
ALLTAR: $(MYDBTARGET)
$(MY_GEN_UCR_PATH)$/%.urd: $(MY_GEN_IDL_PATH)$/%.idl
@@ -66,4 +69,3 @@ $(MYDBTARGET) : $(MYURDFILES) $(MYIDLFILES)
$(REGMERGE) $(OUT)$/ucr/constants.db /UCR @$(mktmp $(MYURDFILES))
.ENDIF
-
diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk
index ee63d6373f..6f9815bfeb 100644
--- a/oovbaapi/ooo/vba/makefile.mk
+++ b/oovbaapi/ooo/vba/makefile.mk
@@ -44,7 +44,7 @@ dummy:
.ENDIF
# ------------------------------------------------------------------------
-
+.IF "$(L10N_framework)"=""
IDLFILES=\
XErrObject.idl \
XGlobals.idl \
@@ -60,5 +60,5 @@ IDLFILES=\
Globals.idl\
# ------------------------------------------------------------------
-
+.ENDIF
.INCLUDE : target.mk
diff --git a/oovbaapi/util/makefile.mk b/oovbaapi/util/makefile.mk
index 97e592a7c0..9fbd349b08 100644
--- a/oovbaapi/util/makefile.mk
+++ b/oovbaapi/util/makefile.mk
@@ -45,6 +45,7 @@ dummy:
@echo "not building vba..."
.ENDIF
+.IF "$(L10N_framework)"==""
# ------------------------------------------------------------------
UNOIDLDBFILES= \
$(UCR)$/vba.db \
@@ -53,5 +54,6 @@ UNOIDLDBFILES= \
$(UCR)$/constants.db
# --- Targets ------------------------------------------------------
+.ENDIF
.INCLUDE : target.mk
diff --git a/sandbox/com/sun/star/lib/sandbox/makefile.mk b/sandbox/com/sun/star/lib/sandbox/makefile.mk
index f68414510c..81e7fdcace 100644
--- a/sandbox/com/sun/star/lib/sandbox/makefile.mk
+++ b/sandbox/com/sun/star/lib/sandbox/makefile.mk
@@ -37,6 +37,7 @@ PACKAGE = com$/sun$/star$/lib$/sandbox
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
.IF "$(JDK)" == "gcj"
all:
@@ -81,7 +82,8 @@ JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
RC_SUBDIRSDEPS=$(JAVATARGET)
# --- Targets ------------------------------------------------------
+.ENDIF
+.ENDIF
.INCLUDE : target.mk
-.ENDIF
diff --git a/sandbox/util/makefile.mk b/sandbox/util/makefile.mk
index 3e02636bc8..ac5684ec8a 100644
--- a/sandbox/util/makefile.mk
+++ b/sandbox/util/makefile.mk
@@ -34,7 +34,7 @@ PRJNAME = sandbox
TARGET = lib_sandbox_util
# --- Settings -----------------------------------------------------
-
+.IF "$(L10N_framework)"==""
.INCLUDE : settings.mk
JARCLASSDIRS = com$/sun$/star$/lib$/sandbox
@@ -42,5 +42,7 @@ JARTARGET = sandbox.jar
JARCOMPRESS = TRUE
# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
.INCLUDE : target.mk
+
diff --git a/scripting/examples/java/makefile.mk b/scripting/examples/java/makefile.mk
index c4a4c2a081..b8138c755a 100755
--- a/scripting/examples/java/makefile.mk
+++ b/scripting/examples/java/makefile.mk
@@ -36,5 +36,7 @@ TARGET=javaexamples
.INCLUDE : ant.mk
.IF "$(SOLAR_JAVA)"!=""
+.IF "$(L10N_framework)"==""
ALLTAR : ANTBUILD
.ENDIF
+.ENDIF
diff --git a/scripting/examples/makefile.mk b/scripting/examples/makefile.mk
index 5366059553..f071060f02 100755
--- a/scripting/examples/makefile.mk
+++ b/scripting/examples/makefile.mk
@@ -34,7 +34,7 @@ TARGET=scriptinginstaller
no_common_build_zip=true
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
.IF "$(SOLAR_JAVA)"!=""
ZIP1FLAGS=-r
ZIP1TARGET=ScriptsJava
@@ -58,5 +58,5 @@ ZIP5FLAGS=-r
ZIP5TARGET=scriptbindinglib
ZIP5DIR=$(PRJ)$/workben$/bindings
ZIP5LIST=*.xlb Highlight.xdl
-
+.ENDIF
.INCLUDE : target.mk
diff --git a/scripting/java/makefile.mk b/scripting/java/makefile.mk
index bb87b9da21..9b3255e6be 100755
--- a/scripting/java/makefile.mk
+++ b/scripting/java/makefile.mk
@@ -35,6 +35,8 @@ TARGET=scriptruntimeforjava
.INCLUDE : ant.mk
+.IF "$(L10N_framework)"==""
.IF "$(SOLAR_JAVA)"!=""
ALLTAR : ANTBUILD
.ENDIF
+.ENDIF
diff --git a/sfx2/sdi/makefile.mk b/sfx2/sdi/makefile.mk
index ddf487094c..f8def0a3c2 100644
--- a/sfx2/sdi/makefile.mk
+++ b/sfx2/sdi/makefile.mk
@@ -39,10 +39,13 @@ TARGET=sfxslots
.INCLUDE : settings.mk
.INCLUDE : $(PRJ)$/util$/makefile.pmk
+.IF "$(L10N_framework)"==""
+
SDI1NAME=$(TARGET)
SDI1EXPORT=sfx
#SIDHRCNAME=sfx.hrc unused???
+.ENDIF
# --- Files --------------------------------------------------------
SVSDI1DEPEND= \
diff --git a/svx/sdi/makefile.mk b/svx/sdi/makefile.mk
index 60f3cc3fb5..2ea64ddedb 100644
--- a/svx/sdi/makefile.mk
+++ b/svx/sdi/makefile.mk
@@ -39,6 +39,8 @@ TARGET=svxslots
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
+
SDI1NAME=$(TARGET)
SDI1EXPORT=svx
@@ -53,6 +55,6 @@ SVSDI1DEPEND= \
svxitems.sdi
# --- Targets -------------------------------------------------------
-
+.ENDIF
.INCLUDE : target.mk
diff --git a/sysui/desktop/tg_rpm.mk b/sysui/desktop/tg_rpm.mk
index 269ff27b4e..63895151da 100644
--- a/sysui/desktop/tg_rpm.mk
+++ b/sysui/desktop/tg_rpm.mk
@@ -31,7 +31,9 @@
.IF "$(PKGFORMAT)"!="$(PKGFORMAT:s/rpm//)"
+.IF "L10N_framework"==""
ALLTAR : $(RPMFLAGFILES)
+.ENDIF
$(RPMFLAGFILES) : $(SPECFILE)
@-$(MKDIRHIER) $(@:d)
diff --git a/ucb/inc/makefile.mk b/ucb/inc/makefile.mk
index 90c4f96a1f..c98dc5fe07 100644
--- a/ucb/inc/makefile.mk
+++ b/ucb/inc/makefile.mk
@@ -41,6 +41,7 @@ TARGET=inc
# --- Targets -------------------------------------------------------
.INCLUDE : target.mk
+.IF "$(L10N_framework)"==""
.IF "$(ENABLE_PCH)"!=""
ALLTAR : \
@@ -48,4 +49,4 @@ ALLTAR : \
$(SLO)$/precompiled_ex.pch
.ENDIF # "$(ENABLE_PCH)"!=""
-
+.ENDIF # L10N_framework
diff --git a/ucb/source/cacher/makefile.mk b/ucb/source/cacher/makefile.mk
index dd4d9b3982..09717b3f0f 100644
--- a/ucb/source/cacher/makefile.mk
+++ b/ucb/source/cacher/makefile.mk
@@ -39,6 +39,7 @@ NO_BSYMBOLIC=TRUE
UCB_MAJOR=1
.INCLUDE: settings.mk
+.IF "$(L10N_framework)"==""
SLOFILES=\
$(SLO)$/contentresultsetwrapper.obj \
@@ -65,6 +66,7 @@ SHL1IMPLIB=i$(TARGET)
SHL1VERSIONMAP=exports.map
DEF1NAME=$(SHL1TARGET)
+.ENDIF # L10N_framework
.INCLUDE: target.mk
diff --git a/ucb/source/core/makefile.mk b/ucb/source/core/makefile.mk
index 963aa038da..e70b5ca879 100644
--- a/ucb/source/core/makefile.mk
+++ b/ucb/source/core/makefile.mk
@@ -39,6 +39,7 @@ NO_BSYMBOLIC=TRUE
UCB_MAJOR=1
.INCLUDE: settings.mk
+.IF "$(L10N_framework)"==""
SLOFILES=\
$(SLO)$/identify.obj \
@@ -72,5 +73,7 @@ SHL1VERSIONMAP=exports.map
DEF1NAME=$(SHL1TARGET)
+.ENDIF # L10N_framework
+
.INCLUDE: target.mk
diff --git a/ucb/source/regexp/makefile.mk b/ucb/source/regexp/makefile.mk
index 898a4d5adb..8d0b938402 100644
--- a/ucb/source/regexp/makefile.mk
+++ b/ucb/source/regexp/makefile.mk
@@ -36,8 +36,10 @@ AUTOSEG=true
ENABLE_EXCEPTIONS=true
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
SLOFILES=\
$(SLO)$/regexp.obj
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/ucb/source/sorter/makefile.mk b/ucb/source/sorter/makefile.mk
index cbe4e360ee..bcd3b64447 100644
--- a/ucb/source/sorter/makefile.mk
+++ b/ucb/source/sorter/makefile.mk
@@ -38,6 +38,7 @@ ENABLE_EXCEPTIONS=TRUE
UCB_MAJOR=1
.INCLUDE: settings.mk
+.IF "$(L10N_framework)"==""
SLOFILES=\
$(SLO)$/sortdynres.obj \
@@ -60,6 +61,7 @@ SHL1IMPLIB=i$(TARGET)
SHL1VERSIONMAP=exports.map
DEF1NAME=$(SHL1TARGET)
+.ENDIF # L10N_framework
.INCLUDE: target.mk
diff --git a/ucb/source/ucp/expand/makefile.mk b/ucb/source/ucp/expand/makefile.mk
index 03e0e5a638..6b4ffc8581 100644
--- a/ucb/source/ucp/expand/makefile.mk
+++ b/ucb/source/ucp/expand/makefile.mk
@@ -39,6 +39,8 @@ NO_BSYMBOLIC = TRUE
.INCLUDE : settings.mk
DLLPRE =
+.IF "$(L10N_framework)"==""
+
SLOFILES= \
$(SLO)$/ucpexpand.obj
@@ -58,4 +60,6 @@ SHL1DEF = $(MISC)$/$(SHL1TARGET).def
DEF1NAME = $(SHL1TARGET)
+.ENDIF # L10N_framework
+
.INCLUDE : target.mk
diff --git a/ucb/source/ucp/file/makefile.mk b/ucb/source/ucp/file/makefile.mk
index 31fbaf8f1e..d03983bca0 100644
--- a/ucb/source/ucp/file/makefile.mk
+++ b/ucb/source/ucp/file/makefile.mk
@@ -39,6 +39,7 @@ NO_BSYMBOLIC=TRUE
UCPFILE_MAJOR=1
.INCLUDE: settings.mk
+.IF "$(L10N_framework)"==""
SLOFILES=\
$(SLO)$/prov.obj \
@@ -77,6 +78,7 @@ DEF1EXPORTFILE=exports2.dxp
.ENDIF
DEF1NAME=$(SHL1TARGET)
+.ENDIF # L10N_framework
.INCLUDE: target.mk
diff --git a/ucb/source/ucp/ftp/makefile.mk b/ucb/source/ucp/ftp/makefile.mk
index 05254484eb..75f5512c72 100644
--- a/ucb/source/ucp/ftp/makefile.mk
+++ b/ucb/source/ucp/ftp/makefile.mk
@@ -45,7 +45,7 @@ UCPFTP_MAJOR=1
.INCLUDE: settings.mk
# --- General -----------------------------------------------------
-
+.IF "$(L10N_framework)"==""
# first target ( shared library )
SLOFILES1=\
@@ -93,6 +93,7 @@ SHL1LIBS= \
DEF1NAME=$(SHL1TARGET)
+.ENDIF # L10N_framework
.INCLUDE: target.mk
diff --git a/ucb/source/ucp/gio/makefile.mk b/ucb/source/ucp/gio/makefile.mk
index a0f33f8dbb..2e7009e52a 100644
--- a/ucb/source/ucp/gio/makefile.mk
+++ b/ucb/source/ucp/gio/makefile.mk
@@ -39,6 +39,7 @@ USE_DEFFILE=TRUE
NO_BSYMBOLIC=TRUE
.INCLUDE: settings.mk
+.IF "$(L10N_framework)"==""
UNIXTEXT=$(MISC)/$(TARGET)-ucd.txt
@@ -79,5 +80,6 @@ SHL1STDLIBS+=$(PKGCONFIG_LIBS)
SHL1VERSIONMAP= exports.map
.ENDIF # "$(ENABLE_GIO)"!=""
+.ENDIF # L10N_framework
.INCLUDE: target.mk
diff --git a/ucb/source/ucp/gvfs/makefile.mk b/ucb/source/ucp/gvfs/makefile.mk
index 0f7ae15db9..889e3ffd41 100644
--- a/ucb/source/ucp/gvfs/makefile.mk
+++ b/ucb/source/ucp/gvfs/makefile.mk
@@ -39,6 +39,7 @@ USE_DEFFILE=TRUE
NO_BSYMBOLIC=TRUE
.INCLUDE: settings.mk
+.IF "$(L10N_framework)"==""
UNIXTEXT=$(MISC)/$(TARGET)-ucd.txt
@@ -83,6 +84,7 @@ SHL1STDLIBS+=$(PKGCONFIG_LIBS)
SHL1VERSIONMAP= exports.map
.ENDIF # "$(ENABLE_GNOMEVFS)"!=""
+.ENDIF # L10N_framework
.INCLUDE: target.mk
diff --git a/ucb/source/ucp/hierarchy/makefile.mk b/ucb/source/ucp/hierarchy/makefile.mk
index 9500b02482..b71ee7fa18 100644
--- a/ucb/source/ucp/hierarchy/makefile.mk
+++ b/ucb/source/ucp/hierarchy/makefile.mk
@@ -44,6 +44,7 @@ UCPHIER_MAJOR=1
.INCLUDE: settings.mk
# --- General -----------------------------------------------------
+.IF "$(L10N_framework)"==""
SLOFILES=\
$(SLO)$/hierarchyservices.obj \
@@ -82,5 +83,6 @@ DEF1NAME=$(SHL1TARGET)
# --- Targets ----------------------------------------------------------
+.ENDIF # L10N_framework
.INCLUDE: target.mk
diff --git a/ucb/source/ucp/package/makefile.mk b/ucb/source/ucp/package/makefile.mk
index 64e76da3ea..4b4f066ac1 100644
--- a/ucb/source/ucp/package/makefile.mk
+++ b/ucb/source/ucp/package/makefile.mk
@@ -50,6 +50,7 @@ NO_BSYMBOLIC=TRUE
.INCLUDE: settings.mk
# --- General -----------------------------------------------------
+.IF "$(L10N_framework)"==""
SLOFILES=\
$(SLO)$/pkgservices.obj \
@@ -86,5 +87,6 @@ DEF1NAME=$(SHL1TARGET)
# --- Targets ----------------------------------------------------------
+.ENDIF # L10N_framework
.INCLUDE: target.mk
diff --git a/ucb/source/ucp/tdoc/makefile.mk b/ucb/source/ucp/tdoc/makefile.mk
index 78b3123fa2..1c2c44b124 100644
--- a/ucb/source/ucp/tdoc/makefile.mk
+++ b/ucb/source/ucp/tdoc/makefile.mk
@@ -43,6 +43,7 @@ NO_BSYMBOLIC=TRUE
.INCLUDE: settings.mk
# --- General -----------------------------------------------------
+.IF "$(L10N_framework)"==""
# no "lib" prefix
DLLPRE =
@@ -89,6 +90,8 @@ SYMBOLPREFIX=$(TARGET)
DEF1NAME=$(SHL1TARGET)
+.ENDIF # L10N_framework
+
# --- Targets ----------------------------------------------------------
.INCLUDE: target.mk
diff --git a/ucb/source/ucp/webdav/makefile.mk b/ucb/source/ucp/webdav/makefile.mk
index 496b33b822..c8891723cd 100644
--- a/ucb/source/ucp/webdav/makefile.mk
+++ b/ucb/source/ucp/webdav/makefile.mk
@@ -50,6 +50,7 @@ NO_BSYMBOLIC=TRUE
# --- Settings ---------------------------------------------------------
.INCLUDE: settings.mk
+.IF "$(L10N_framework)"==""
.IF "$(DISABLE_NEON)" == "TRUE"
@@ -160,6 +161,7 @@ DEF1NAME=$(SHL1TARGET)
.ENDIF #"$(DISABLE_NEON)" == "TRUE"
+.ENDIF # L10N_framework
# --- Targets ----------------------------------------------------------
.INCLUDE: target.mk
diff --git a/xmlhelp/inc/xmlhelp/compilehelp.hxx b/xmlhelp/inc/xmlhelp/compilehelp.hxx
deleted file mode 100644
index de59a0b7f5..0000000000
--- a/xmlhelp/inc/xmlhelp/compilehelp.hxx
+++ /dev/null
@@ -1,70 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: compilehelp.hxx,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
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef COMPILE_HXX
-#define COMPILE_HXX
-
-#include <xmlhelp/helplinkerdllapi.h>
-#include <rtl/ustring.hxx>
-
-enum HelpProcessingErrorClass
-{
- HELPPROCESSING_NO_ERROR,
- HELPPROCESSING_GENERAL_ERROR, // Missing files, options etc.
- HELPPROCESSING_INTERNAL_ERROR, // Unexpected problems
- HELPPROCESSING_XMLPARSING_ERROR // Errors thrown by libxml
-};
-
-struct HelpProcessingErrorInfo
-{
- HelpProcessingErrorClass m_eErrorClass;
- rtl::OUString m_aErrorMsg;
- rtl::OUString m_aXMLParsingFile;
- sal_Int32 m_nXMLParsingLine;
-
- HelpProcessingErrorInfo( void )
- : m_eErrorClass( HELPPROCESSING_NO_ERROR )
- , m_nXMLParsingLine( -1 )
- {}
-
- HelpProcessingErrorInfo& operator=( const struct HelpProcessingException& e );
-};
-
-
-// Returns true in case of success, false in case of error
-HELPLINKER_DLLPUBLIC bool compileExtensionHelp
-(
- const rtl::OUString& aExtensionName,
- const rtl::OUString& aExtensionLanguageRoot,
- sal_Int32 nXhpFileCount, const rtl::OUString* pXhpFiles,
- HelpProcessingErrorInfo& o_rHelpProcessingErrorInfo
-);
-
-#endif
diff --git a/xmlhelp/prj/build.lst b/xmlhelp/prj/build.lst
index b360e5f763..3f468f593a 100644
--- a/xmlhelp/prj/build.lst
+++ b/xmlhelp/prj/build.lst
@@ -1,4 +1,4 @@
-xh xmlhelp : ucbhelper LIBXSLT:libxslt unoil BERKELEYDB:berkeleydb svtools LUCENE:lucene unotools javaunohelper NULL
+xh xmlhelp : ucbhelper transex3 LIBXSLT:libxslt unoil BERKELEYDB:berkeleydb svtools LUCENE:lucene unotools javaunohelper NULL
xh xmlhelp usr1 - all xh_mkout NULL
xh xmlhelp\inc nmake - all xh_inc NULL
xh xmlhelp\source\treeview nmake - all xh_treeview xh_inc NULL
diff --git a/xmlhelp/source/com/sun/star/help/HelpCompiler.cxx b/xmlhelp/source/com/sun/star/help/HelpCompiler.cxx
deleted file mode 100644
index 2609606e68..0000000000
--- a/xmlhelp/source/com/sun/star/help/HelpCompiler.cxx
+++ /dev/null
@@ -1,593 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: HelpCompiler.cxx,v $
- * $Revision: 1.9 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-
-#include "HelpCompiler.hxx"
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include <libxslt/xslt.h>
-#include <libxslt/xsltInternals.h>
-#include <libxslt/transform.h>
-#include <libxslt/xsltutils.h>
-#ifdef __MINGW32__
-#include <tools/prewin.h>
-#include <tools/postwin.h>
-#endif
-#include <osl/thread.hxx>
-
-static void impl_sleep( sal_uInt32 nSec )
-{
- TimeValue aTime;
- aTime.Seconds = nSec;
- aTime.Nanosec = 0;
-
- osl::Thread::wait( aTime );
-}
-
-HelpCompiler::HelpCompiler(StreamTable &in_streamTable, const fs::path &in_inputFile,
- const fs::path &in_src, const fs::path &in_resEmbStylesheet,
- const std::string &in_module, const std::string &in_lang, bool in_bExtensionMode)
- : streamTable(in_streamTable), inputFile(in_inputFile),
- src(in_src), module(in_module), lang(in_lang), resEmbStylesheet(in_resEmbStylesheet),
- bExtensionMode( in_bExtensionMode )
-{
- xmlKeepBlanksDefaultValue = 0;
-}
-
-xmlDocPtr HelpCompiler::getSourceDocument(const fs::path &filePath)
-{
- static const char *params[4 + 1];
- static xsltStylesheetPtr cur = NULL;
-
- xmlDocPtr res;
- if( bExtensionMode )
- {
- res = xmlParseFile(filePath.native_file_string().c_str());
- if( !res ){
- impl_sleep( 3 );
- res = xmlParseFile(filePath.native_file_string().c_str());
- }
- }
- else
- {
- if (!cur)
- {
- static std::string fsroot('\'' + src.toUTF8() + '\'');
- static std::string esclang('\'' + lang + '\'');
-
- xmlSubstituteEntitiesDefault(1);
- xmlLoadExtDtdDefaultValue = 1;
- cur = xsltParseStylesheetFile((const xmlChar *)resEmbStylesheet.native_file_string().c_str());
-
- int nbparams = 0;
- params[nbparams++] = "Language";
- params[nbparams++] = esclang.c_str();
- params[nbparams++] = "fsroot";
- params[nbparams++] = fsroot.c_str();
- params[nbparams] = NULL;
- }
- xmlDocPtr doc = xmlParseFile(filePath.native_file_string().c_str());
- if( !doc )
- {
- impl_sleep( 3 );
- doc = xmlParseFile(filePath.native_file_string().c_str());
- }
-
- //???res = xmlParseFile(filePath.native_file_string().c_str());
-
- res = xsltApplyStylesheet(cur, doc, params);
- xmlFreeDoc(doc);
- }
- return res;
-}
-
-HashSet HelpCompiler::switchFind(xmlDocPtr doc)
-{
- HashSet hs;
- xmlChar *xpath = (xmlChar*)"//switchinline";
-
- xmlXPathContextPtr context = xmlXPathNewContext(doc);
- xmlXPathObjectPtr result = xmlXPathEvalExpression(xpath, context);
- xmlXPathFreeContext(context);
- if (result)
- {
- xmlNodeSetPtr nodeset = result->nodesetval;
- for (int i = 0; i < nodeset->nodeNr; i++)
- {
- xmlNodePtr el = nodeset->nodeTab[i];
- xmlChar *select = xmlGetProp(el, (xmlChar*)"select");
- if (select)
- {
- if (!strcmp((const char*)select, "appl"))
- {
- xmlNodePtr n1 = el->xmlChildrenNode;
- while (n1)
- {
- if ((!xmlStrcmp(n1->name, (const xmlChar*)"caseinline")))
- {
- xmlChar *appl = xmlGetProp(n1, (xmlChar*)"select");
- hs.push_back(std::string((const char*)appl));
- xmlFree(appl);
- }
- else if ((!xmlStrcmp(n1->name, (const xmlChar*)"defaultinline")))
- hs.push_back(std::string("DEFAULT"));
- n1 = n1->next;
- }
- }
- xmlFree(select);
- }
- }
- xmlXPathFreeObject(result);
- }
- hs.push_back(std::string("DEFAULT"));
- return hs;
-}
-
-// returns a node representing the whole stuff compiled for the current
-// application.
-xmlNodePtr HelpCompiler::clone(xmlNodePtr node, const std::string& appl)
-{
- xmlNodePtr parent = xmlCopyNode(node, 2);
- xmlNodePtr n = node->xmlChildrenNode;
- while (n != NULL)
- {
- bool isappl = false;
- if ( (!strcmp((const char*)n->name, "switchinline")) ||
- (!strcmp((const char*)n->name, "switch")) )
- {
- xmlChar *select = xmlGetProp(n, (xmlChar*)"select");
- if (select)
- {
- if (!strcmp((const char*)select, "appl"))
- isappl = true;
- xmlFree(select);
- }
- }
- if (isappl)
- {
- xmlNodePtr caseNode = n->xmlChildrenNode;
- if (appl == "DEFAULT")
- {
- while (caseNode)
- {
- if (!strcmp((const char*)caseNode->name, "defaultinline"))
- {
- xmlNodePtr cnl = caseNode->xmlChildrenNode;
- while (cnl)
- {
- xmlAddChild(parent, clone(cnl, appl));
- cnl = cnl->next;
- }
- break;
- }
- caseNode = caseNode->next;
- }
- }
- else
- {
- while (caseNode)
- {
- isappl=false;
- if (!strcmp((const char*)caseNode->name, "caseinline"))
- {
- xmlChar *select = xmlGetProp(n, (xmlChar*)"select");
- if (select)
- {
- if (!strcmp((const char*)select, appl.c_str()))
- isappl = true;
- xmlFree(select);
- }
- if (isappl)
- {
- xmlNodePtr cnl = caseNode->xmlChildrenNode;
- while (cnl)
- {
- xmlAddChild(parent, clone(cnl, appl));
- cnl = cnl->next;
- }
- break;
- }
-
- }
- caseNode = caseNode->next;
- }
- }
-
- }
- else
- xmlAddChild(parent, clone(n, appl));
-
- n = n->next;
- }
- return parent;
-}
-
-class myparser
-{
-public:
- std::string documentId;
- std::string fileName;
- std::string title;
- HashSet *hidlist;
- Hashtable *keywords;
- Stringtable *helptexts;
-private:
- HashSet extendedHelpText;
-public:
- myparser(const std::string &indocumentId, const std::string &infileName,
- const std::string &intitle) : documentId(indocumentId), fileName(infileName),
- title(intitle)
- {
- hidlist = new HashSet;
- keywords = new Hashtable;
- helptexts = new Stringtable;
- }
- void traverse( xmlNodePtr parentNode );
-private:
- std::string dump(xmlNodePtr node);
-};
-
-std::string myparser::dump(xmlNodePtr node)
-{
- std::string app;
- if (node->xmlChildrenNode)
- {
- xmlNodePtr list = node->xmlChildrenNode;
- while (list)
- {
- app += dump(list);
- list = list->next;
- }
- }
- if (xmlNodeIsText(node))
- {
- xmlChar *pContent = xmlNodeGetContent(node);
- app += std::string((const char*)pContent);
- xmlFree(pContent);
- // std::cout << app << std::endl;
- }
- return app;
-}
-
-void trim(std::string& str)
-{
- std::string::size_type pos = str.find_last_not_of(' ');
- if(pos != std::string::npos)
- {
- str.erase(pos + 1);
- pos = str.find_first_not_of(' ');
- if(pos != std::string::npos)
- str.erase(0, pos);
- }
- else
- str.erase(str.begin(), str.end());
-}
-
-void myparser::traverse( xmlNodePtr parentNode )
-{
- // traverse all nodes that belong to the parent
- xmlNodePtr test ;
- for (test = parentNode->xmlChildrenNode; test; test = test->next)
- {
- if (fileName.empty() && !strcmp((const char*)test->name, "filename"))
- {
- xmlNodePtr node = test->xmlChildrenNode;
- if (xmlNodeIsText(node))
- {
- xmlChar *pContent = xmlNodeGetContent(node);
- fileName = std::string((const char*)pContent);
- xmlFree(pContent);
- }
- }
- else if (title.empty() && !strcmp((const char*)test->name, "title"))
- {
- title = dump(test);
- if (title.empty())
- title = "<notitle>";
- }
- else if (!strcmp((const char*)test->name, "bookmark"))
- {
- xmlChar *branchxml = xmlGetProp(test, (const xmlChar*)"branch");
- xmlChar *idxml = xmlGetProp(test, (const xmlChar*)"id");
- std::string branch((const char*)branchxml);
- std::string anchor((const char*)idxml);
- xmlFree (branchxml);
- xmlFree (idxml);
-
- std::string hid;
-
- if (branch.find("hid") == 0)
- {
- size_t index = branch.find('/');
- if (index != std::string::npos)
- {
- hid = branch.substr(1 + index);
- // one shall serve as a documentId
- if (documentId.empty())
- documentId = hid;
- extendedHelpText.push_back(hid);
- std::string foo = anchor.empty() ? hid : hid + "#" + anchor;
- HCDBG(std::cerr << "hid pushback" << foo << std::endl);
- hidlist->push_back( anchor.empty() ? hid : hid + "#" + anchor);
- }
- else
- continue;
- }
- else if (branch.compare("index") == 0)
- {
- LinkedList ll;
-
- for (xmlNodePtr nd = test->xmlChildrenNode; nd; nd = nd->next)
- {
- if (strcmp((const char*)nd->name, "bookmark_value"))
- continue;
-
- std::string embedded;
- xmlChar *embeddedxml = xmlGetProp(nd, (const xmlChar*)"embedded");
- if (embeddedxml)
- {
- embedded = std::string((const char*)embeddedxml);
- xmlFree (embeddedxml);
- std::transform (embedded.begin(), embedded.end(),
- embedded.begin(), tolower);
- }
-
- bool isEmbedded = !embedded.empty() && embedded.compare("true") == 0;
- if (isEmbedded)
- continue;
-
- std::string keyword = dump(nd);
- size_t keywordSem = keyword.find(';');
- if (keywordSem != std::string::npos)
- {
- std::string tmppre =
- keyword.substr(0,keywordSem);
- trim(tmppre);
- std::string tmppos =
- keyword.substr(1+keywordSem);
- trim(tmppos);
- keyword = tmppre + ";" + tmppos;
- }
- ll.push_back(keyword);
- }
- if (!ll.empty())
- (*keywords)[anchor] = ll;
- }
- else if (branch.compare("contents") == 0)
- {
- // currently not used
- }
- }
- else if (!strcmp((const char*)test->name, "ahelp"))
- {
- std::string text = dump(test);
- trim(text);
- std::string name;
-
- HashSet::const_iterator aEnd = extendedHelpText.end();
- for (HashSet::const_iterator iter = extendedHelpText.begin(); iter != aEnd;
- ++iter)
- {
- name = *iter;
- (*helptexts)[name] = text;
- }
- extendedHelpText.clear();
- }
-
- // traverse children
- traverse(test);
- }
-}
-
-bool HelpCompiler::compile( void ) throw( HelpProcessingException )
-{
- // we now have the jaroutputstream, which will contain the document.
- // now determine the document as a dom tree in variable docResolved
-
- xmlDocPtr docResolvedOrg = getSourceDocument(inputFile);
-
- // now add path to the document
- // resolve the dom
- if (!docResolvedOrg)
- {
- impl_sleep( 3 );
- docResolvedOrg = getSourceDocument(inputFile);
- if( !docResolvedOrg )
- {
- std::stringstream aStrStream;
- aStrStream << "ERROR: file not existing: " << inputFile.native_file_string().c_str() << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- }
-
- // now find all applications for which one has to compile
- std::string documentId;
- std::string fileName;
- std::string title;
- // returns all applications for which one has to compile
- HashSet applications = switchFind(docResolvedOrg);
-
- HashSet::const_iterator aEnd = applications.end();
- for (HashSet::const_iterator aI = applications.begin(); aI != aEnd; ++aI)
- {
- std::string appl = *aI;
- std::string modulename = appl;
- if (modulename[0] == 'S')
- {
- modulename = modulename.substr(1);
- std::transform(modulename.begin(), modulename.end(), modulename.begin(), tolower);
- }
- if (modulename != "DEFAULT" && modulename != module)
- continue;
-
- // returns a clone of the document with swich-cases resolved
- xmlNodePtr docResolved = clone(xmlDocGetRootElement(docResolvedOrg), appl);
- myparser aparser(documentId, fileName, title);
- aparser.traverse(docResolved);
-
- documentId = aparser.documentId;
- fileName = aparser.fileName;
- title = aparser.title;
-
- HCDBG(std::cerr << documentId << " : " << fileName << " : " << title << std::endl);
-
- xmlDocPtr docResolvedDoc = xmlCopyDoc(docResolvedOrg, false);
- xmlDocSetRootElement(docResolvedDoc, docResolved);
-
- if (modulename == "DEFAULT")
- {
- streamTable.dropdefault();
- streamTable.default_doc = docResolvedDoc;
- streamTable.default_hidlist = aparser.hidlist;
- streamTable.default_helptexts = aparser.helptexts;
- streamTable.default_keywords = aparser.keywords;
- }
- else if (modulename == module)
- {
- streamTable.dropappl();
- streamTable.appl_doc = docResolvedDoc;
- streamTable.appl_hidlist = aparser.hidlist;
- streamTable.appl_helptexts = aparser.helptexts;
- streamTable.appl_keywords = aparser.keywords;
- }
- else
- {
- std::stringstream aStrStream;
- aStrStream << "ERROR: Found unexpected module name \"" << modulename
- << "\" in file" << src.native_file_string().c_str() << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- } // end iteration over all applications
-
- streamTable.document_id = documentId;
- streamTable.document_path = fileName;
- streamTable.document_title = title;
- std::string actMod = module;
- if ( !bExtensionMode && !fileName.empty())
- {
- if (fileName.find("/text/") == 0)
- {
- int len = strlen("/text/");
- actMod = fileName.substr(len);
- actMod = actMod.substr(0, actMod.find('/'));
- }
- }
- streamTable.document_module = actMod;
-
- xmlFreeDoc(docResolvedOrg);
- return true;
-}
-
-namespace fs
-{
- rtl_TextEncoding getThreadTextEncoding( void )
- {
- static bool bNeedsInit = true;
- static rtl_TextEncoding nThreadTextEncoding;
- if( bNeedsInit )
- {
- bNeedsInit = false;
- nThreadTextEncoding = osl_getThreadTextEncoding();
- }
- return nThreadTextEncoding;
- }
-
- void create_directory(const fs::path indexDirName)
- {
- HCDBG(
- std::cerr << "creating " <<
- rtl::OUStringToOString(indexDirName.data, RTL_TEXTENCODING_UTF8).getStr()
- << std::endl
- );
- osl::Directory::createPath(indexDirName.data);
- }
-
- void rename(const fs::path &src, const fs::path &dest)
- {
- osl::File::move(src.data, dest.data);
- }
-
- void copy(const fs::path &src, const fs::path &dest)
- {
- osl::File::copy(src.data, dest.data);
- }
-
- bool exists(const fs::path &in)
- {
- osl::File tmp(in.data);
- return (tmp.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None);
- }
-
- void remove(const fs::path &in)
- {
- osl::File::remove(in.data);
- }
-
- void removeRecursive(rtl::OUString const& _suDirURL)
- {
- {
- osl::Directory aDir(_suDirURL);
- aDir.open();
- if (aDir.isOpen())
- {
- osl::DirectoryItem aItem;
- osl::FileStatus aStatus(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes);
- while (aDir.getNextItem(aItem) == ::osl::FileBase::E_None)
- {
- if (osl::FileBase::E_None == aItem.getFileStatus(aStatus) &&
- aStatus.isValid(osl_FileStatus_Mask_FileName | osl_FileStatus_Mask_Attributes))
- {
- rtl::OUString suFilename = aStatus.getFileName();
- rtl::OUString suFullFileURL;
- suFullFileURL += _suDirURL;
- suFullFileURL += rtl::OUString::createFromAscii("/");
- suFullFileURL += suFilename;
-
- if (aStatus.getFileType() == osl::FileStatus::Directory)
- removeRecursive(suFullFileURL);
- else
- osl::File::remove(suFullFileURL);
- }
- }
- aDir.close();
- }
- }
- osl::Directory::remove(_suDirURL);
- }
-
- void remove_all(const fs::path &in)
- {
- removeRecursive(in.data);
- }
-}
-
-/* vi:set tabstop=4 shiftwidth=4 expandtab: */
diff --git a/xmlhelp/source/com/sun/star/help/HelpCompiler.hxx b/xmlhelp/source/com/sun/star/help/HelpCompiler.hxx
deleted file mode 100644
index 61233d0299..0000000000
--- a/xmlhelp/source/com/sun/star/help/HelpCompiler.hxx
+++ /dev/null
@@ -1,320 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: HelpCompiler.hxx,v $
- * $Revision: 1.8 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef HELPCOMPILER_HXX
-#define HELPCOMPILER_HXX
-
-#include <string>
-#include <hash_map>
-#include <vector>
-#include <list>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <algorithm>
-#include <ctype.h>
-#ifdef SYSTEM_DB
-#include <db.h>
-#else
-#include <berkeleydb/db.h>
-#endif
-
-#include <boost/shared_ptr.hpp>
-
-#include <libxml/xmlmemory.h>
-#include <libxml/debugXML.h>
-#include <libxml/HTMLtree.h>
-#include <libxml/xmlIO.h>
-#include <libxml/xinclude.h>
-#include <libxml/catalog.h>
-
-#include <rtl/ustring.hxx>
-#include <osl/thread.h>
-#include <osl/process.h>
-#include <osl/file.hxx>
-
-#include <xmlhelp/compilehelp.hxx>
-
-#define EMULATEORIGINAL 1
-
-#ifdef CMCDEBUG
- #define HCDBG(foo) do { if (1) foo; } while(0)
-#else
- #define HCDBG(foo) do { if (0) foo; } while(0)
-#endif
-
-namespace fs
-{
- rtl_TextEncoding getThreadTextEncoding( void );
-
- enum convert { native };
- class path
- {
- public:
- ::rtl::OUString data;
- public:
- path() {}
- path(const path &rOther) : data(rOther.data) {}
- path(const std::string &in, convert)
- {
- rtl::OUString sWorkingDir;
- osl_getProcessWorkingDir(&sWorkingDir.pData);
-
- rtl::OString tmp(in.c_str());
- rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding()));
- osl::File::getFileURLFromSystemPath(ustrSystemPath, data);
- osl::File::getAbsoluteFileURL(sWorkingDir, data, data);
- }
- path(const std::string &FileURL)
- {
- rtl::OString tmp(FileURL.c_str());
- data = rtl::OStringToOUString(tmp, getThreadTextEncoding());
- }
- std::string native_file_string() const
- {
- ::rtl::OUString ustrSystemPath;
- osl::File::getSystemPathFromFileURL(data, ustrSystemPath);
- rtl::OString tmp(rtl::OUStringToOString(ustrSystemPath, getThreadTextEncoding()));
- HCDBG(std::cerr << "native_file_string is " << tmp.getStr() << std::endl);
- return std::string(tmp.getStr());
- }
- std::string native_directory_string() const { return native_file_string(); }
- std::string toUTF8() const
- {
- rtl::OString tmp(rtl::OUStringToOString(data, RTL_TEXTENCODING_UTF8));
- return std::string(tmp.getStr());
- }
- bool empty() const { return data.getLength() == 0; }
- path operator/(const std::string &in) const
- {
- path ret(*this);
- HCDBG(std::cerr << "orig was " <<
- rtl::OUStringToOString(ret.data, RTL_TEXTENCODING_UTF8).getStr() << std::endl);
- rtl::OString tmp(in.c_str());
- rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding()));
- ret.data += rtl::OUString(sal_Unicode('/'));
- ret.data += ustrSystemPath;
- HCDBG(std::cerr << "final is " <<
- rtl::OUStringToOString(ret.data, RTL_TEXTENCODING_UTF8).getStr() << std::endl);
- return ret;
- }
- void append(const char *in)
- {
- rtl::OString tmp(in);
- rtl::OUString ustrSystemPath(rtl::OStringToOUString(tmp, getThreadTextEncoding()));
- data = data + ustrSystemPath;
- }
- void append(const std::string &in) { append(in.c_str()); }
- };
-
- void create_directory(const fs::path indexDirName);
- void rename(const fs::path &src, const fs::path &dest);
- void copy(const fs::path &src, const fs::path &dest);
- bool exists(const fs::path &in);
- void remove_all(const fs::path &in);
- void remove(const fs::path &in);
-}
-
-struct joaat_hash
-{
- size_t operator()(const std::string &str) const
- {
- size_t hash = 0;
- const char *key = str.data();
- for (size_t i = 0; i < str.size(); i++)
- {
- hash += key[i];
- hash += (hash << 10);
- hash ^= (hash >> 6);
- }
- hash += (hash << 3);
- hash ^= (hash >> 11);
- hash += (hash << 15);
- return hash;
- }
-};
-
-#define get16bits(d) ((((sal_uInt32)(((const sal_uInt8 *)(d))[1])) << 8)\
- +(sal_uInt32)(((const sal_uInt8 *)(d))[0]) )
-
-struct SuperFastHash
-{
- size_t operator()(const std::string &str) const
- {
- const char * data = str.data();
- int len = str.size();
- size_t hash = len, tmp;
- if (len <= 0 || data == NULL) return 0;
-
- int rem = len & 3;
- len >>= 2;
-
- /* Main loop */
- for (;len > 0; len--)
- {
- hash += get16bits (data);
- tmp = (get16bits (data+2) << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- data += 2*sizeof (sal_uInt16);
- hash += hash >> 11;
- }
-
- /* Handle end cases */
- switch (rem)
- {
- case 3: hash += get16bits (data);
- hash ^= hash << 16;
- hash ^= data[sizeof (sal_uInt16)] << 18;
- hash += hash >> 11;
- break;
- case 2: hash += get16bits (data);
- hash ^= hash << 11;
- hash += hash >> 17;
- break;
- case 1: hash += *data;
- hash ^= hash << 10;
- hash += hash >> 1;
- }
-
- /* Force "avalanching" of final 127 bits */
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 4;
- hash += hash >> 17;
- hash ^= hash << 25;
- hash += hash >> 6;
-
- return hash;
- }
-};
-
-#define pref_hash joaat_hash
-
-typedef std::hash_map<std::string, std::string, pref_hash> Stringtable;
-typedef std::list<std::string> LinkedList;
-typedef std::vector<std::string> HashSet;
-
-typedef std::hash_map<std::string, LinkedList, pref_hash> Hashtable;
-
-class StreamTable
-{
-public:
- std::string document_id;
- std::string document_path;
- std::string document_module;
- std::string document_title;
-
- HashSet *appl_hidlist;
- Hashtable *appl_keywords;
- Stringtable *appl_helptexts;
- xmlDocPtr appl_doc;
-
- HashSet *default_hidlist;
- Hashtable *default_keywords;
- Stringtable *default_helptexts;
- xmlDocPtr default_doc;
-
- StreamTable() :
- appl_hidlist(NULL), appl_keywords(NULL), appl_helptexts(NULL), appl_doc(NULL),
- default_hidlist(NULL), default_keywords(NULL), default_helptexts(NULL), default_doc(NULL)
- {}
- void dropdefault()
- {
- delete default_hidlist;
- delete default_keywords;
- delete default_helptexts;
- if (default_doc) xmlFreeDoc(default_doc);
- }
- void dropappl()
- {
- delete appl_hidlist;
- delete appl_keywords;
- delete appl_helptexts;
- if (appl_doc) xmlFreeDoc(appl_doc);
- }
- ~StreamTable()
- {
- dropappl();
- dropdefault();
- }
-};
-
-struct HelpProcessingException
-{
- HelpProcessingErrorClass m_eErrorClass;
- std::string m_aErrorMsg;
- std::string m_aXMLParsingFile;
- int m_nXMLParsingLine;
-
- HelpProcessingException( HelpProcessingErrorClass eErrorClass, const std::string& aErrorMsg )
- : m_eErrorClass( eErrorClass )
- , m_aErrorMsg( aErrorMsg )
- {}
- HelpProcessingException( const std::string& aErrorMsg, const std::string& aXMLParsingFile, int nXMLParsingLine )
- : m_eErrorClass( HELPPROCESSING_XMLPARSING_ERROR )
- , m_aErrorMsg( aErrorMsg )
- , m_aXMLParsingFile( aXMLParsingFile )
- , m_nXMLParsingLine( nXMLParsingLine )
- {}
-};
-
-class HelpCompiler
-{
-public:
- HelpCompiler(StreamTable &streamTable,
- const fs::path &in_inputFile,
- const fs::path &in_src,
- const fs::path &in_resEmbStylesheet,
- const std::string &in_module,
- const std::string &in_lang,
- bool in_bExtensionMode);
- bool compile( void ) throw (HelpProcessingException);
- void addEntryToJarFile(const std::string &prefix,
- const std::string &entryName, const std::string &bytesToAdd);
- void addEntryToJarFile(const std::string &prefix,
- const std::string &entryName, const HashSet &bytesToAdd);
- void addEntryToJarFile(const std::string &prefix,
- const std::string &entryName, const Stringtable &bytesToAdd);
- void addEntryToJarFile(const std::string &prefix,
- const std::string &entryName, const Hashtable &bytesToAdd);
-private:
- xmlDocPtr getSourceDocument(const fs::path &filePath);
- HashSet switchFind(xmlDocPtr doc);
- xmlNodePtr clone(xmlNodePtr node, const std::string& appl);
- StreamTable &streamTable;
- const fs::path inputFile, src;
- const std::string module, lang;
- const fs::path resEmbStylesheet;
- bool bExtensionMode;
-};
-
-#endif
-
-/* vi:set tabstop=4 shiftwidth=4 expandtab: */
diff --git a/xmlhelp/source/com/sun/star/help/HelpFileDocument.java b/xmlhelp/source/com/sun/star/help/HelpFileDocument.java
deleted file mode 100644
index a86ddfa350..0000000000
--- a/xmlhelp/source/com/sun/star/help/HelpFileDocument.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: HelpFileDocument.java,v $
- * $Revision: 1.2 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-package com.sun.star.help;
-
-import java.io.File;
-import java.io.Reader;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-//import java.io.FileReader;
-import java.io.StringReader;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-
-/** Lucene Document for help files */
-public class HelpFileDocument
-{
- /** Creates reader for UTF-8 files
- */
- private static Reader getReaderForFile( File aFile )
- throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException {
- Reader aReader;
- if( aFile != null ) {
- FileInputStream fis = new FileInputStream( aFile );
- aReader = new InputStreamReader( fis, "UTF-8" );
- }
- else {
- aReader = new StringReader( "" );
- }
- return aReader;
- }
-
- /** Makes a document for a File.
- */
- public static Document Document( String aModule, File aCaptionFile, File aContentFile )
- throws java.io.FileNotFoundException, java.io.UnsupportedEncodingException {
- Document doc = new Document();
-
- // Add the path of the file as a field named "path". Use a field that is
- // indexed (i.e. searchable), but don't tokenize the field into words.
- File aFile = aCaptionFile != null ? aCaptionFile : aContentFile;
- if( aFile != null )
- {
- String aPath = "#HLP#" + aModule + "/" + aFile.getName();
- doc.add(new Field("path", aPath, Field.Store.YES, Field.Index.UN_TOKENIZED));
- }
-
- // Add the caption of the file to a field named "caption". Specify a Reader,
- // so that the text of the file is tokenized and indexed, but not stored.
- doc.add( new Field( "caption", getReaderForFile( aCaptionFile ) ) );
-
- // Add the contents of the file to a field named "content". Specify a Reader,
- // so that the text of the file is tokenized and indexed, but not stored.
- doc.add( new Field( "content", getReaderForFile( aContentFile ) ) );
-
- // return the document
- return doc;
- }
-
- private HelpFileDocument() {}
-}
diff --git a/xmlhelp/source/com/sun/star/help/HelpIndexer.java b/xmlhelp/source/com/sun/star/help/HelpIndexer.java
index 03f0611b69..5fecf5abe6 100644
--- a/xmlhelp/source/com/sun/star/help/HelpIndexer.java
+++ b/xmlhelp/source/com/sun/star/help/HelpIndexer.java
@@ -37,23 +37,11 @@ import com.sun.star.beans.XIntrospectionAccess;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.XComponentContext;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-import java.util.zip.CRC32;
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.analysis.cjk.CJKAnalyzer;
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.index.IndexWriter;
-
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
+import java.util.zip.ZipOutputStream;
public class HelpIndexer extends WeakBase
implements XServiceInfo, XInvocation
@@ -62,6 +50,8 @@ public class HelpIndexer extends WeakBase
"com.sun.star.help.HelpIndexer";
static private final String aCreateIndexMethodName = "createIndex";
+ static private com.sun.star.help.HelpIndexerTool helpindexer = new com.sun.star.help.HelpIndexerTool();
+
public HelpIndexer()
{
}
@@ -69,293 +59,27 @@ public class HelpIndexer extends WeakBase
public HelpIndexer(XComponentContext xCompContext)
{
}
-
- /**
- * @param args the command line arguments
- */
- public static void main( String[] args )
- {
- boolean bExtensionMode = false;
- mainImpl( args, bExtensionMode );
- }
-
- private static void mainImpl( String[] args, boolean bExtensionMode )
- {
- String aDirToZipStr = "";
- String aSrcDirStr = "";
- String aLanguageStr = "";
- String aModule = "";
- String aTargetZipFileStr = "";
-
- // Scan arguments
- boolean bLang = false;
- boolean bMod = false;
- boolean bZipDir = false;
- boolean bSrcDir = false;
- boolean bOutput = false;
-
- int nArgCount = args.length;
- for( int i = 0 ; i < nArgCount ; i++ )
- {
- if( "-lang".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aLanguageStr = args[i + 1];
- bLang = true;
- }
- i++;
- }
- else if( "-mod".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aModule = args[i + 1];
- bMod = true;
- }
- i++;
- }
- else if( "-zipdir".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aDirToZipStr = args[i + 1];
- bZipDir = true;
- }
- i++;
- }
- else if( "-srcdir".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aSrcDirStr = args[i + 1];
- bSrcDir = true;
- }
- i++;
- }
- else if( "-o".equals(args[i]) )
- {
- if( i + 1 < nArgCount )
- {
- aTargetZipFileStr = args[i + 1];
- bOutput = true;
- }
- i++;
- }
- }
-
- if( !bLang || !bMod || !bZipDir || (!bOutput && !bExtensionMode) )
- {
- if( bExtensionMode )
- return;
-
- System.out.println("Usage: HelpIndexer -lang ISOLangCode -mod HelpModule -zipdir TempZipDir -o OutputZipFile");
- System.exit( -1 );
- }
-
- String aIndexDirName = aModule + ".idxl";
- File aIndexDir = new File( aDirToZipStr + File.separator + aIndexDirName );
- if( !bSrcDir )
- aSrcDirStr = aDirToZipStr;
- File aCaptionFilesDir = new File( aSrcDirStr + File.separator + "caption" );
- File aContentFilesDir = new File( aSrcDirStr + File.separator + "content" );
-
- try
- {
- Date start = new Date();
- Analyzer analyzer = aLanguageStr.equals("ja") ? (Analyzer)new CJKAnalyzer() : (Analyzer)new StandardAnalyzer();
- IndexWriter writer = new IndexWriter( aIndexDir, analyzer, true );
- if( !bExtensionMode )
- System.out.println( "Lucene: Indexing to directory '" + aIndexDir + "'..." );
- int nRet = indexDocs( writer, aModule, bExtensionMode, aCaptionFilesDir, aContentFilesDir );
- if( nRet != -1 )
- {
- if( !bExtensionMode )
- {
- System.out.println();
- System.out.println( "Optimizing ..." );
- }
- writer.optimize();
- }
- writer.close();
-
- if( bExtensionMode )
- {
- if( !bSrcDir )
- {
- deleteRecursively( aCaptionFilesDir );
- deleteRecursively( aContentFilesDir );
- }
- }
- else
- {
- if( nRet == -1 )
- deleteRecursively( aIndexDir );
-
- if( !bExtensionMode )
- System.out.println( "Zipping ..." );
- File aDirToZipFile = new File( aDirToZipStr );
- createZipFile( aDirToZipFile, aTargetZipFileStr );
- deleteRecursively( aDirToZipFile );
- }
-
- Date end = new Date();
- if( !bExtensionMode )
- System.out.println(end.getTime() - start.getTime() + " total milliseconds");
- }
- catch (IOException e)
- {
- if( bExtensionMode )
- return;
-
- System.out.println(" caught a " + e.getClass() +
- "\n with message: " + e.getMessage());
- System.exit( -1 );
- }
- }
- private static int indexDocs(IndexWriter writer, String aModule, boolean bExtensionMode,
- File aCaptionFilesDir, File aContentFilesDir) throws IOException
+ public static void mainImpl( String[] args, boolean bExtensionMode )
{
- if( !aCaptionFilesDir.canRead() || !aCaptionFilesDir.isDirectory() )
- {
- if( !bExtensionMode )
- System.out.println( "Not found: " + aCaptionFilesDir );
- return -1;
- }
- if( !aContentFilesDir.canRead() || !aContentFilesDir.isDirectory() )
- {
- if( !bExtensionMode )
- System.out.println( "Not found: " + aContentFilesDir );
- return -1;
- }
-
- String[] aCaptionFiles = aCaptionFilesDir.list();
- List aCaptionFilesList = Arrays.asList( aCaptionFiles );
- HashSet aCaptionFilesHashSet = new HashSet( aCaptionFilesList );
-
- String[] aContentFiles = aContentFilesDir.list();
- List aContentFilesList = Arrays.asList( aContentFiles );
- HashSet aContentFilesHashSet = new HashSet( aContentFilesList );
-
- // Loop over caption files and find corresponding content file
- if( !bExtensionMode )
- System.out.println( "Indexing, adding files" );
- int nCaptionFilesLen = aCaptionFiles.length;
- for( int i = 0 ; i < nCaptionFilesLen ; i++ )
- {
- String aCaptionFileStr = aCaptionFiles[i];
- File aCaptionFile = new File( aCaptionFilesDir, aCaptionFileStr );
- File aContentFile = null;
- if( aContentFilesHashSet.contains( aCaptionFileStr ) )
- aContentFile = new File( aContentFilesDir, aCaptionFileStr );
-
- if( !bExtensionMode )
- System.out.print( "." );
- writer.addDocument( HelpFileDocument.Document( aModule, aCaptionFile, aContentFile ) );
- }
-
- // Loop over content files to find remaining files not mapped to caption files
- int nContentFilesLen = aContentFiles.length;
- for( int i = 0 ; i < nContentFilesLen ; i++ )
- {
- String aContentFileStr = aContentFiles[i];
- if( !aCaptionFilesHashSet.contains( aContentFileStr ) )
- {
- // Not already handled in caption files loop
- File aCaptionFile = null;
- File aContentFile = new File( aContentFilesDir, aContentFileStr );
- if( !bExtensionMode )
- System.out.print( "." );
- writer.addDocument( HelpFileDocument.Document( aModule, aCaptionFile, aContentFile ) );
- }
- }
- return 0;
+ helpindexer.mainImpl( args , bExtensionMode );
}
public static void createZipFile( File aDirToZip, String aTargetZipFileStr )
throws FileNotFoundException, IOException
{
- FileOutputStream fos = new FileOutputStream( aTargetZipFileStr );
- ZipOutputStream zos = new ZipOutputStream( fos );
-
- File[] aChildrenFiles = aDirToZip.listFiles();
- int nFileCount = aChildrenFiles.length;
- for( int i = 0 ; i < nFileCount ; i++ )
- addToZipRecursively( zos, aChildrenFiles[i], null );
-
- zos.close();
+ helpindexer.createZipFile( aDirToZip , aTargetZipFileStr );
}
public static void addToZipRecursively( ZipOutputStream zos, File aFile, String aBasePath )
throws FileNotFoundException, IOException
{
- if( aFile.isDirectory() )
- {
- String aDirName = aFile.getName();
- if( aDirName.equalsIgnoreCase( "caption" ) || aDirName.equalsIgnoreCase( "content" ) )
- return;
-
- File[] aChildrenFiles = aFile.listFiles();
- String aNewBasePath = "";
- if( aBasePath != null )
- aNewBasePath += aBasePath + File.separator;
- aNewBasePath += aDirName;
-
- int nFileCount = aChildrenFiles.length;
- for( int i = 0 ; i < nFileCount ; i++ )
- addToZipRecursively( zos, aChildrenFiles[i], aNewBasePath );
-
- return;
- }
-
- // No directory
- // read contents of file we are going to put in the zip
- int fileLength = (int) aFile.length();
- FileInputStream fis = new FileInputStream( aFile );
- byte[] wholeFile = new byte[fileLength];
- int bytesRead = fis.read( wholeFile, 0, fileLength );
- fis.close();
-
- String aFileName = aFile.getName();
- String aEntryName = "";
- if( aBasePath != null )
- aEntryName += aBasePath + "/";
- aEntryName += aFileName;
- ZipEntry aZipEntry = new ZipEntry( aEntryName );
- aZipEntry.setTime( aFile.lastModified() );
- aZipEntry.setSize( fileLength );
-
- int nMethod = ( aFileName.toLowerCase().endsWith( ".jar" ) )
- ? ZipEntry.STORED : ZipEntry.DEFLATED;
- aZipEntry.setMethod( nMethod );
-
- CRC32 tempCRC = new CRC32();
- tempCRC.update( wholeFile, 0, wholeFile.length );
- aZipEntry.setCrc( tempCRC.getValue() );
-
- // write the contents into the zip element
- zos.putNextEntry( aZipEntry );
- zos.write( wholeFile, 0, fileLength );
- zos.closeEntry();
+ helpindexer.addToZipRecursively( zos , aFile , aBasePath );
}
static public boolean deleteRecursively( File aFile )
{
- if( aFile.isDirectory() )
- {
- File[] aChildrenFiles = aFile.listFiles();
- int nFileCount = aChildrenFiles.length;
- for( int i = 0 ; i < nFileCount ; i++ )
- {
- File aChildrenFile = aChildrenFiles[i];
- boolean bSuccess = deleteRecursively( aChildrenFile );
- if( !bSuccess )
- return false;
- }
- }
-
- return aFile.delete();
+ return helpindexer.deleteRecursively( aFile );
}
//===================================================
@@ -371,7 +95,8 @@ public class HelpIndexer extends WeakBase
com.sun.star.script.CannotConvertException,
com.sun.star.reflection.InvocationTargetException
{
- if( !aFunctionName.equals( aCreateIndexMethodName ) )
+ if(
+ !aFunctionName.equals( aCreateIndexMethodName ) )
throw new com.sun.star.lang.IllegalArgumentException();
aOutParamIndex[0] = new short[0];
@@ -421,6 +146,7 @@ public class HelpIndexer extends WeakBase
}
+
/** This method returns an array of all supported service names.
* @return Array of supported service names.
*/
@@ -439,6 +165,7 @@ public class HelpIndexer extends WeakBase
return sSupportedServiceNames;
}
+
/** This method returns true, if the given service will be
* supported by the component.
* @param sServiceName Service name.
@@ -449,6 +176,7 @@ public class HelpIndexer extends WeakBase
return sServiceName.equals( __serviceName );
}
+
/** Return the class name of the component.
* @return Class name of the component.
*/
@@ -456,5 +184,6 @@ public class HelpIndexer extends WeakBase
{
return HelpIndexer.class.getName();
}
+
}
diff --git a/xmlhelp/source/com/sun/star/help/HelpLinker.cxx b/xmlhelp/source/com/sun/star/help/HelpLinker.cxx
deleted file mode 100644
index 57591e7999..0000000000
--- a/xmlhelp/source/com/sun/star/help/HelpLinker.cxx
+++ /dev/null
@@ -1,1161 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: HelpLinker.cxx,v $
- * $Revision: 1.16 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "HelpCompiler.hxx"
-
-#include <map>
-
-#include <string.h>
-#include <limits.h>
-
-#include <libxslt/xslt.h>
-#include <libxslt/transform.h>
-#include <libxslt/xsltutils.h>
-#include <libxslt/functions.h>
-#include <libxslt/extensions.h>
-
-#include <sal/types.h>
-#include <osl/time.h>
-#include <rtl/bootstrap.hxx>
-
-#ifdef SYSTEM_EXPAT
-#include <expat.h>
-#else
-#include <expat/xmlparse.h>
-#endif
-
-#define DBHELP_ONLY
-
-
-class IndexerPreProcessor
-{
-private:
- std::string m_aModuleName;
- fs::path m_fsIndexBaseDir;
- fs::path m_fsCaptionFilesDirName;
- fs::path m_fsContentFilesDirName;
-
- xsltStylesheetPtr m_xsltStylesheetPtrCaption;
- xsltStylesheetPtr m_xsltStylesheetPtrContent;
-
-public:
- IndexerPreProcessor( const std::string& aModuleName, const fs::path& fsIndexBaseDir,
- const fs::path& idxCaptionStylesheet, const fs::path& idxContentStylesheet );
- ~IndexerPreProcessor();
-
- void processDocument( xmlDocPtr doc, const std::string& EncodedDocPath );
-};
-
-IndexerPreProcessor::IndexerPreProcessor
- ( const std::string& aModuleName, const fs::path& fsIndexBaseDir,
- const fs::path& idxCaptionStylesheet, const fs::path& idxContentStylesheet )
- : m_aModuleName( aModuleName )
- , m_fsIndexBaseDir( fsIndexBaseDir )
-{
- m_fsCaptionFilesDirName = fsIndexBaseDir / "caption";
- fs::create_directory( m_fsCaptionFilesDirName );
-
- m_fsContentFilesDirName = fsIndexBaseDir / "content";
- fs::create_directory( m_fsContentFilesDirName );
-
- m_xsltStylesheetPtrCaption = xsltParseStylesheetFile
- ((const xmlChar *)idxCaptionStylesheet.native_file_string().c_str());
- m_xsltStylesheetPtrContent = xsltParseStylesheetFile
- ((const xmlChar *)idxContentStylesheet.native_file_string().c_str());
-}
-
-IndexerPreProcessor::~IndexerPreProcessor()
-{
- if( m_xsltStylesheetPtrCaption )
- xsltFreeStylesheet( m_xsltStylesheetPtrCaption );
- if( m_xsltStylesheetPtrContent )
- xsltFreeStylesheet( m_xsltStylesheetPtrContent );
-}
-
-
-std::string getEncodedPath( const std::string& Path )
-{
- rtl::OString aOStr_Path( Path.c_str() );
- rtl::OUString aOUStr_Path( rtl::OStringToOUString
- ( aOStr_Path, fs::getThreadTextEncoding() ) );
- rtl::OUString aPathURL;
- osl::File::getFileURLFromSystemPath( aOUStr_Path, aPathURL );
- rtl::OString aOStr_PathURL( rtl::OUStringToOString
- ( aPathURL, fs::getThreadTextEncoding() ) );
- std::string aStdStr_PathURL( aOStr_PathURL.getStr() );
- return aStdStr_PathURL;
-}
-
-void IndexerPreProcessor::processDocument
- ( xmlDocPtr doc, const std::string &EncodedDocPath )
-{
- std::string aStdStr_EncodedDocPathURL = getEncodedPath( EncodedDocPath );
-
- xmlDocPtr resCaption = xsltApplyStylesheet( m_xsltStylesheetPtrCaption, doc, NULL );
- xmlNodePtr pResNodeCaption = resCaption->xmlChildrenNode;
- if( pResNodeCaption )
- {
- fs::path fsCaptionPureTextFile_docURL = m_fsCaptionFilesDirName / aStdStr_EncodedDocPathURL;
- std::string aCaptionPureTextFileStr_docURL = fsCaptionPureTextFile_docURL.native_file_string();
- FILE* pFile_docURL = fopen( aCaptionPureTextFileStr_docURL.c_str(), "w" );
- if( pFile_docURL )
- {
- fprintf( pFile_docURL, "%s\n", pResNodeCaption->content );
- fclose( pFile_docURL );
- }
- }
- xmlFreeDoc(resCaption);
-
- xmlDocPtr resContent = xsltApplyStylesheet( m_xsltStylesheetPtrContent, doc, NULL );
- xmlNodePtr pResNodeContent = resContent->xmlChildrenNode;
- if( pResNodeContent )
- {
- fs::path fsContentPureTextFile_docURL = m_fsContentFilesDirName / aStdStr_EncodedDocPathURL;
- std::string aContentPureTextFileStr_docURL = fsContentPureTextFile_docURL.native_file_string();
- FILE* pFile_docURL = fopen( aContentPureTextFileStr_docURL.c_str(), "w" );
- if( pFile_docURL )
- {
- fprintf( pFile_docURL, "%s\n", pResNodeContent->content );
- fclose( pFile_docURL );
- }
- }
- xmlFreeDoc(resContent);
-}
-
-struct Data
-{
- std::vector<std::string> _idList;
- typedef std::vector<std::string>::const_iterator cIter;
-
- void append(const std::string &id)
- {
- _idList.push_back(id);
- }
-
- std::string getString() const
- {
- std::string ret;
- cIter aEnd = _idList.end();
- for (cIter aIter = _idList.begin(); aIter != aEnd; ++aIter)
- ret += *aIter + ";";
- return ret;
- }
-};
-
-void writeKeyValue_DBHelp( FILE* pFile, const std::string& aKeyStr, const std::string& aValueStr )
-{
- if( pFile == NULL )
- return;
- char cLF = 10;
- int nKeyLen = aKeyStr.length();
- int nValueLen = aValueStr.length();
- fprintf( pFile, "%x ", nKeyLen );
- if( nKeyLen > 0 )
- fwrite( aKeyStr.c_str(), 1, nKeyLen, pFile );
- fprintf( pFile, " %x ", nValueLen );
- if( nValueLen > 0 )
- fwrite( aValueStr.c_str(), 1, nValueLen, pFile );
- fprintf( pFile, "%c", cLF );
-}
-
-class HelpKeyword
-{
-private:
- typedef std::hash_map<std::string, Data, pref_hash> DataHashtable;
- DataHashtable _hash;
-
-public:
- void insert(const std::string &key, const std::string &id)
- {
- Data &data = _hash[key];
- data.append(id);
- }
-
- void dump(DB* table)
- {
- DataHashtable::const_iterator aEnd = _hash.end();
- for (DataHashtable::const_iterator aIter = _hash.begin(); aIter != aEnd; ++aIter)
- {
- const std::string &keystr = aIter->first;
- DBT key;
- memset(&key, 0, sizeof(key));
- key.data = const_cast<char*>(keystr.c_str());
- key.size = keystr.length();
-
- const Data &data = aIter->second;
- std::string str = data.getString();
- DBT value;
- memset(&value, 0, sizeof(value));
- value.data = const_cast<char*>(str.c_str());
- value.size = str.length();
-
- table->put(table, NULL, &key, &value, 0);
- }
- }
-
- void dump_DBHelp( const std::string& rFileName )
- {
- FILE* pFile = fopen( rFileName.c_str(), "wb" );
- if( pFile == NULL )
- return;
-
- DataHashtable::const_iterator aEnd = _hash.end();
- for (DataHashtable::const_iterator aIter = _hash.begin(); aIter != aEnd; ++aIter)
- writeKeyValue_DBHelp( pFile, aIter->first, aIter->second.getString() );
-
- fclose( pFile );
- }
-};
-
-class HelpLinker
-{
-public:
- void main(std::vector<std::string> &args, std::string* pExtensionPath = NULL )
- throw( HelpProcessingException );
-
- HelpLinker()
- : init(true)
- , m_pIndexerPreProcessor(NULL)
- {}
- ~HelpLinker()
- { delete m_pIndexerPreProcessor; }
-
-private:
- int locCount, totCount;
- Stringtable additionalFiles;
- HashSet helpFiles;
- fs::path sourceRoot;
- fs::path embeddStylesheet;
- fs::path idxCaptionStylesheet;
- fs::path idxContentStylesheet;
- fs::path zipdir;
- fs::path outputFile;
- std::string module;
- std::string lang;
- std::string hid;
- std::string extensionPath;
- bool bExtensionMode;
- fs::path indexDirName;
- Stringtable hidlistTranslation;
- fs::path indexDirParentName;
- bool init;
- IndexerPreProcessor* m_pIndexerPreProcessor;
- void initIndexerPreProcessor();
- void link() throw( HelpProcessingException );
- void addBookmark( DB* dbBase, FILE* pFile_DBHelp, std::string thishid,
- const std::string& fileB, const std::string& anchorB,
- const std::string& jarfileB, const std::string& titleB );
-#if 0
- /**
- * @param outputFile
- * @param module
- * @param lang
- * @param hid
- * @param helpFiles
- * @param additionalFiles
- */
-
- private HelpURLStreamHandlerFactory urlHandler = null;
-#endif
-};
-
-namespace URLEncoder
-{
- static std::string encode(const std::string &rIn)
- {
- const char *good = "!$&'()*+,-.=@_";
- static const char hex[17] = "0123456789ABCDEF";
-
- std::string result;
- for (size_t i=0; i < rIn.length(); ++i)
- {
- unsigned char c = rIn[i];
- if (isalnum (c) || strchr (good, c))
- result += c;
- else {
- result += '%';
- result += hex[c >> 4];
- result += hex[c & 0xf];
- }
- }
- return result;
- }
-}
-
-void HelpLinker::addBookmark( DB* dbBase, FILE* pFile_DBHelp, std::string thishid,
- const std::string& fileB, const std::string& anchorB,
- const std::string& jarfileB, const std::string& titleB)
-{
- HCDBG(std::cerr << "HelpLinker::addBookmark " << thishid << " " <<
- fileB << " " << anchorB << " " << jarfileB << " " << titleB << std::endl);
-
- std::string temp = thishid;
- std::transform (temp.begin(), temp.end(), temp.begin(), toupper);
- std::replace(temp.begin(), temp.end(), ':', '_');
- const std::string& translatedHid = hidlistTranslation[temp];
- if (!translatedHid.empty())
- thishid = translatedHid;
-
- thishid = URLEncoder::encode(thishid);
-
- DBT key;
- memset(&key, 0, sizeof(key));
- key.data = const_cast<char*>(thishid.c_str());
- key.size = thishid.length();
-
- int fileLen = fileB.length();
- if (!anchorB.empty())
- fileLen += (1 + anchorB.length());
- int dataLen = 1 + fileLen + 1 + jarfileB.length() + 1 + titleB.length();
-
- std::vector<unsigned char> dataB(dataLen);
- size_t i = 0;
- dataB[i++] = static_cast<unsigned char>(fileLen);
- for (size_t j = 0; j < fileB.length(); ++j)
- dataB[i++] = fileB[j];
- if (!anchorB.empty())
- {
- dataB[i++] = '#';
- for (size_t j = 0; j < anchorB.length(); ++j)
- dataB[i++] = anchorB[j];
- }
- dataB[i++] = static_cast<unsigned char>(jarfileB.length());
- for (size_t j = 0; j < jarfileB.length(); ++j)
- dataB[i++] = jarfileB[j];
-
- dataB[i++] = static_cast<unsigned char>(titleB.length());
- for (size_t j = 0; j < titleB.length(); ++j)
- dataB[i++] = titleB[j];
-
- DBT data;
- memset(&data, 0, sizeof(data));
- data.data = &dataB[0];
- data.size = dataB.size();
-
- if( dbBase != NULL )
- dbBase->put(dbBase, NULL, &key, &data, 0);
-
- if( pFile_DBHelp != NULL )
- {
- std::string aValueStr( dataB.begin(), dataB.end() );
- writeKeyValue_DBHelp( pFile_DBHelp, thishid, aValueStr );
- }
-}
-
-void HelpLinker::initIndexerPreProcessor()
-{
- if( m_pIndexerPreProcessor )
- delete m_pIndexerPreProcessor;
- std::string mod = module;
- std::transform (mod.begin(), mod.end(), mod.begin(), tolower);
- m_pIndexerPreProcessor = new IndexerPreProcessor( mod, indexDirParentName,
- idxCaptionStylesheet, idxContentStylesheet );
-}
-
-/**
-*
-*/
-void HelpLinker::link() throw( HelpProcessingException )
-{
- bool bIndexForExtension = true;
-
- if( bExtensionMode )
- {
- indexDirParentName = sourceRoot;
- }
- else
- {
- indexDirParentName = zipdir;
- fs::create_directory(indexDirParentName);
- }
-
-#ifdef CMC_DEBUG
- std::cerr << "will not delete tmpdir of " << indexDirParentName.native_file_string().c_str() << std::endl;
-#endif
-
- std::string mod = module;
- std::transform (mod.begin(), mod.end(), mod.begin(), tolower);
-
- // do the work here
- // continue with introduction of the overall process thing into the
- // here all hzip files will be worked on
- std::string appl = mod;
- if (appl[0] == 's')
- appl = appl.substr(1);
-
- bool bUse_ = true;
-#ifdef DBHELP_ONLY
- if( !bExtensionMode )
- bUse_ = false;
-#endif
-
- DB* helpText(0);
-#ifndef DBHELP_ONLY
- fs::path helpTextFileName(indexDirParentName / (mod + ".ht"));
- db_create(&helpText,0,0);
- helpText->open(helpText, NULL, helpTextFileName.native_file_string().c_str(), NULL, DB_BTREE,
- DB_CREATE | DB_TRUNCATE, 0644);
-#endif
-
- fs::path helpTextFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".ht_" : ".ht")));
- FILE* pFileHelpText_DBHelp = fopen
- ( helpTextFileName_DBHelp.native_file_string().c_str(), "wb" );
-
- DB* dbBase(0);
-#ifndef DBHELP_ONLY
- fs::path dbBaseFileName(indexDirParentName / (mod + ".db"));
- db_create(&dbBase,0,0);
- dbBase->open(dbBase, NULL, dbBaseFileName.native_file_string().c_str(), NULL, DB_BTREE,
- DB_CREATE | DB_TRUNCATE, 0644);
-#endif
-
- fs::path dbBaseFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".db_" : ".db")));
- FILE* pFileDbBase_DBHelp = fopen
- ( dbBaseFileName_DBHelp.native_file_string().c_str(), "wb" );
-
-#ifndef DBHELP_ONLY
- DB* keyWord(0);
- fs::path keyWordFileName(indexDirParentName / (mod + ".key"));
- db_create(&keyWord,0,0);
- keyWord->open(keyWord, NULL, keyWordFileName.native_file_string().c_str(), NULL, DB_BTREE,
- DB_CREATE | DB_TRUNCATE, 0644);
-#endif
-
- fs::path keyWordFileName_DBHelp(indexDirParentName / (mod + (bUse_ ? ".key_" : ".key")));
-
- HelpKeyword helpKeyword;
-
- // catch HelpProcessingException to avoid locking data bases
- try
- {
-
- std::ifstream fileReader(hid.c_str());
- while (fileReader)
- {
- std::string key;
- fileReader >> key;
- std::transform (key.begin(), key.end(), key.begin(), toupper);
- std::replace(key.begin(), key.end(), ':', '_');
- std::string data;
- fileReader >> data;
- if (!key.empty() && !data.empty())
- hidlistTranslation[key] = data;
- }
- fileReader.close();
-
- // lastly, initialize the indexBuilder
- if ( (!bExtensionMode || bIndexForExtension) && !helpFiles.empty())
- initIndexerPreProcessor();
-
- if( !bExtensionMode )
- {
-#ifndef OS2 // YD @TODO@ crashes libc runtime :-(
- std::cout << "Making " << outputFile.native_file_string() <<
- " from " << helpFiles.size() << " input files" << std::endl;
-#endif
- }
-
- // here we start our loop over the hzip files.
- HashSet::iterator end = helpFiles.end();
- for (HashSet::iterator iter = helpFiles.begin(); iter != end; ++iter)
- {
- if( !bExtensionMode )
- {
- std::cout << ".";
- std::cout.flush();
- }
-
- // process one file
- // streamTable contains the streams in the hzip file
- StreamTable streamTable;
- const std::string &xhpFileName = *iter;
-
- if (!bExtensionMode && xhpFileName.rfind(".xhp") != xhpFileName.length()-4)
- {
- // only work on .xhp - files
- std::cerr <<
- "ERROR: input list entry '"
- << xhpFileName
- << "' has the wrong extension (only files with extension .xhp "
- << "are accepted)";
- continue;
- }
-
- fs::path langsourceRoot(sourceRoot);
- fs::path xhpFile;
-
- if( bExtensionMode )
- {
- // langsourceRoot == sourceRoot for extensions
- std::string xhpFileNameComplete( extensionPath );
- xhpFileNameComplete.append( '/' + xhpFileName );
- xhpFile = fs::path( xhpFileNameComplete );
- }
- else
- {
- langsourceRoot.append('/' + lang + '/');
- xhpFile = fs::path(xhpFileName, fs::native);
- }
-
- HelpCompiler hc( streamTable, xhpFile, langsourceRoot,
- embeddStylesheet, module, lang, bExtensionMode );
-
- HCDBG(std::cerr << "before compile of " << xhpFileName << std::endl);
- bool success = hc.compile();
- HCDBG(std::cerr << "after compile of " << xhpFileName << std::endl);
-
- if (!success && !bExtensionMode)
- {
- std::stringstream aStrStream;
- aStrStream <<
- "\nERROR: compiling help particle '"
- << xhpFileName
- << "' for language '"
- << lang
- << "' failed!";
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- const std::string documentBaseId = streamTable.document_id;
- std::string documentPath = streamTable.document_path;
- if (documentPath.find("/") == 0)
- documentPath = documentPath.substr(1);
-
- std::string documentJarfile = streamTable.document_module + ".jar";
-
- std::string documentTitle = streamTable.document_title;
- if (documentTitle.empty())
- documentTitle = "<notitle>";
-
-#if 0
- std::cout << "for " << xhpFileName << " documentBaseId is " << documentBaseId << "\n";
- std::cout << "for " << xhpFileName << " documentPath is " << documentPath << "\n";
- std::cout << "for " << xhpFileName << " documentJarfile is " << documentJarfile << "\n";
- std::cout << "for " << xhpFileName << " documentPath is " << documentTitle << "\n";
-#endif
-
- const std::string& fileB = documentPath;
- const std::string& jarfileB = documentJarfile;
- std::string& titleB = documentTitle;
-
- // add once this as its own id.
- addBookmark(dbBase, pFileDbBase_DBHelp, documentPath, fileB, std::string(), jarfileB, titleB);
-
- // first the database *.db
- // ByteArrayInputStream bais = null;
- // ObjectInputStream ois = null;
-
- const HashSet *hidlist = streamTable.appl_hidlist;
- if (!hidlist)
- hidlist = streamTable.default_hidlist;
- if (hidlist && !hidlist->empty())
- {
- // now iterate over all elements of the hidlist
- HashSet::const_iterator aEnd = hidlist->end();
- for (HashSet::const_iterator hidListIter = hidlist->begin();
- hidListIter != aEnd; ++hidListIter)
- {
- std::string thishid = *hidListIter;
-
- std::string anchorB;
- size_t index = thishid.rfind('#');
- if (index != std::string::npos)
- {
- anchorB = thishid.substr(1 + index);
- thishid = thishid.substr(0, index);
- }
- addBookmark(dbBase, pFileDbBase_DBHelp, thishid, fileB, anchorB, jarfileB, titleB);
- }
- }
-
- // now the keywords
- const Hashtable *anchorToLL = streamTable.appl_keywords;
- if (!anchorToLL)
- anchorToLL = streamTable.default_keywords;
- if (anchorToLL && !anchorToLL->empty())
- {
- std::string fakedHid = URLEncoder::encode(documentPath);
- Hashtable::const_iterator aEnd = anchorToLL->end();
- for (Hashtable::const_iterator enumer = anchorToLL->begin();
- enumer != aEnd; ++enumer)
- {
- const std::string &anchor = enumer->first;
- addBookmark(dbBase, pFileDbBase_DBHelp, documentPath, fileB,
- anchor, jarfileB, titleB);
- std::string totalId = fakedHid + "#" + anchor;
- // std::cerr << hzipFileName << std::endl;
- const LinkedList& ll = enumer->second;
- LinkedList::const_iterator aOtherEnd = ll.end();
- for (LinkedList::const_iterator llIter = ll.begin();
- llIter != aOtherEnd; ++llIter)
- {
- helpKeyword.insert(*llIter, totalId);
- }
- }
-
- }
-
- // and last the helptexts
- const Stringtable *helpTextHash = streamTable.appl_helptexts;
- if (!helpTextHash)
- helpTextHash = streamTable.default_helptexts;
- if (helpTextHash && !helpTextHash->empty())
- {
- Stringtable::const_iterator aEnd = helpTextHash->end();
- for (Stringtable::const_iterator helpTextIter = helpTextHash->begin();
- helpTextIter != aEnd; ++helpTextIter)
- {
- std::string helpTextId = helpTextIter->first;
- const std::string& helpTextText = helpTextIter->second;
-
- std::string temp = helpTextId;
- std::transform (temp.begin(), temp.end(), temp.begin(), toupper);
- std::replace(temp.begin(), temp.end(), ':', '_');
-
- const std::string& tHid = hidlistTranslation[temp];
- if (!tHid.empty())
- helpTextId = tHid;
- helpTextId = URLEncoder::encode(helpTextId);
-
- DBT keyDbt;
- memset(&keyDbt, 0, sizeof(keyDbt));
- keyDbt.data = const_cast<char*>(helpTextId.c_str());
- keyDbt.size = helpTextId.length();
-
- DBT textDbt;
- memset(&textDbt, 0, sizeof(textDbt));
- textDbt.data = const_cast<char*>(helpTextText.c_str());
- textDbt.size = helpTextText.length();
-
- if( helpText != NULL )
- helpText->put(helpText, NULL, &keyDbt, &textDbt, 0);
-
- if( pFileHelpText_DBHelp != NULL )
- writeKeyValue_DBHelp( pFileHelpText_DBHelp, helpTextId, helpTextText );
- }
- }
-
- //IndexerPreProcessor
- if( !bExtensionMode || bIndexForExtension )
- {
- // now the indexing
- xmlDocPtr document = streamTable.appl_doc;
- if (!document)
- document = streamTable.default_doc;
- if (document)
- {
- std::string temp = module;
- std::transform (temp.begin(), temp.end(), temp.begin(), tolower);
- m_pIndexerPreProcessor->processDocument(document, URLEncoder::encode(documentPath) );
- }
- }
-
- } // while loop over hzip files ending
- if( !bExtensionMode )
- std::cout << std::endl;
-
- } // try
- catch( HelpProcessingException& )
- {
- // catch HelpProcessingException to avoid locking data bases
-#ifndef DBHELP_ONLY
- helpText->close(helpText, 0);
- dbBase->close(dbBase, 0);
- keyWord->close(keyWord, 0);
-#endif
- if( pFileHelpText_DBHelp != NULL )
- fclose( pFileHelpText_DBHelp );
- if( pFileDbBase_DBHelp != NULL )
- fclose( pFileDbBase_DBHelp );
- throw;
- }
-
-#ifndef DBHELP_ONLY
- helpText->close(helpText, 0);
- dbBase->close(dbBase, 0);
- helpKeyword.dump(keyWord);
- keyWord->close(keyWord, 0);
-#endif
- if( pFileHelpText_DBHelp != NULL )
- fclose( pFileHelpText_DBHelp );
- if( pFileDbBase_DBHelp != NULL )
- fclose( pFileDbBase_DBHelp );
-
- helpKeyword.dump_DBHelp( keyWordFileName_DBHelp.native_file_string() );
-
- if( !bExtensionMode )
- {
- // New index
- Stringtable::iterator aEnd = additionalFiles.end();
- for (Stringtable::iterator enumer = additionalFiles.begin(); enumer != aEnd;
- ++enumer)
- {
- const std::string &additionalFileName = enumer->second;
- const std::string &additionalFileKey = enumer->first;
-
- fs::path fsAdditionalFileName( additionalFileName, fs::native );
- std::string aNativeStr = fsAdditionalFileName.native_file_string();
- const char* pStr = aNativeStr.c_str();
- std::cerr << pStr;
-
- fs::path fsTargetName( indexDirParentName / additionalFileKey );
-
- fs::copy( fsAdditionalFileName, fsTargetName );
- }
- }
-
-/*
- /////////////////////////////////////////////////////////////////////////
- /// remove temprary directory for index creation
- /////////////////////////////////////////////////////////////////////////
-#ifndef CMC_DEBUG
- if( !bExtensionMode )
- fs::remove_all( indexDirParentName );
-#endif
-*/
-}
-
-
-void HelpLinker::main(std::vector<std::string> &args, std::string* pExtensionPath)
- throw( HelpProcessingException )
-{
- rtl::OUString aOfficeHelpPath;
-
- bExtensionMode = false;
- if( pExtensionPath && pExtensionPath->length() > 0 )
- {
- helpFiles.clear();
- bExtensionMode = true;
- extensionPath = *pExtensionPath;
- sourceRoot = fs::path(extensionPath);
-
- aOfficeHelpPath = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/help") );
- rtl::Bootstrap::expandMacros( aOfficeHelpPath );
- }
- if (args.size() > 0 && args[0][0] == '@')
- {
- std::vector<std::string> stringList;
- std::string strBuf;
- std::ifstream fileReader(args[0].substr(1).c_str());
-
- while (fileReader)
- {
- std::string token;
- fileReader >> token;
- if (!token.empty())
- stringList.push_back(token);
- }
- fileReader.close();
-
- args = stringList;
- }
-
- size_t i = 0;
-
- while (i < args.size())
- {
- if (args[i].compare("-src") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "sourceroot missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- if( !bExtensionMode )
- sourceRoot = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-sty") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "embeddingStylesheet missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- embeddStylesheet = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-zipdir") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "idxtemp missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- zipdir = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-idxcaption") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "idxcaption stylesheet missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- idxCaptionStylesheet = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-idxcontent") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "idxcontent stylesheet missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- idxContentStylesheet = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-o") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "outputfilename missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- outputFile = fs::path(args[i], fs::native);
- }
- else if (args[i].compare("-mod") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "module name missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- module = args[i];
- }
- else if (args[i].compare("-lang") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "language name missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- lang = args[i];
- }
- else if (args[i].compare("-hid") == 0)
- {
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "hid list missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- hid = args[i];
- }
- else if (args[i].compare("-add") == 0)
- {
- std::string addFile, addFileUnderPath;
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "pathname missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- addFileUnderPath = args[i];
- ++i;
- if (i >= args.size())
- {
- std::stringstream aStrStream;
- aStrStream << "pathname missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- addFile = args[i];
- if (!addFileUnderPath.empty() && !addFile.empty())
- additionalFiles[addFileUnderPath] = addFile;
- }
- else
- helpFiles.push_back(args[i]);
- ++i;
- }
-
- if (!bExtensionMode && zipdir.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no index dir given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (!bExtensionMode && idxCaptionStylesheet.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no index caption stylesheet given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- else if ( bExtensionMode )
- {
- rtl::OUString aIdxCaptionPathFileURL( aOfficeHelpPath );
- aIdxCaptionPathFileURL += rtl::OUString::createFromAscii( "/idxcaption.xsl" );
-
- rtl::OString aOStr_IdxCaptionPathFileURL( rtl::OUStringToOString
- ( aIdxCaptionPathFileURL, fs::getThreadTextEncoding() ) );
- std::string aStdStr_IdxCaptionPathFileURL( aOStr_IdxCaptionPathFileURL.getStr() );
-
- idxCaptionStylesheet = fs::path( aStdStr_IdxCaptionPathFileURL );
- }
- if (!bExtensionMode && idxContentStylesheet.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no index content stylesheet given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- else if ( bExtensionMode )
- {
- rtl::OUString aIdxContentPathFileURL( aOfficeHelpPath );
- aIdxContentPathFileURL += rtl::OUString::createFromAscii( "/idxcontent.xsl" );
-
- rtl::OString aOStr_IdxContentPathFileURL( rtl::OUStringToOString
- ( aIdxContentPathFileURL, fs::getThreadTextEncoding() ) );
- std::string aStdStr_IdxContentPathFileURL( aOStr_IdxContentPathFileURL.getStr() );
-
- idxContentStylesheet = fs::path( aStdStr_IdxContentPathFileURL );
- }
- if (!bExtensionMode && embeddStylesheet.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no embedding resolving file given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (sourceRoot.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no sourceroot given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (!bExtensionMode && outputFile.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "no output file given" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (module.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "module missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (!bExtensionMode && lang.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "language missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
- if (!bExtensionMode && hid.empty())
- {
- std::stringstream aStrStream;
- aStrStream << "hid list missing" << std::endl;
- throw HelpProcessingException( HELPPROCESSING_GENERAL_ERROR, aStrStream.str() );
- }
-
- link();
-}
-
-int main(int argc, char**argv)
-{
- sal_uInt32 starttime = osl_getGlobalTimer();
- std::vector<std::string> args;
- for (int i = 1; i < argc; ++i)
- args.push_back(std::string(argv[i]));
- try
- {
- HelpLinker* pHelpLinker = new HelpLinker();
- pHelpLinker->main( args );
- delete pHelpLinker;
- }
- catch( const HelpProcessingException& e )
- {
- std::cerr << e.m_aErrorMsg;
- exit(1);
- }
- sal_uInt32 endtime = osl_getGlobalTimer();
-#ifndef OS2 // YD @TODO@ crashes libc runtime :-(
- std::cout << "time taken was " << (endtime-starttime)/1000.0 << " seconds" << std::endl;
-#endif
- return 0;
-}
-
-// Variable to set an exception in "C" StructuredXMLErrorFunction
-static const HelpProcessingException* GpXMLParsingException = NULL;
-
-extern "C" void StructuredXMLErrorFunction(void *userData, xmlErrorPtr error)
-{
- (void)userData;
- (void)error;
-
- std::string aErrorMsg = error->message;
- std::string aXMLParsingFile;
- if( error->file != NULL )
- aXMLParsingFile = error->file;
- int nXMLParsingLine = error->line;
- HelpProcessingException* pException = new HelpProcessingException( aErrorMsg, aXMLParsingFile, nXMLParsingLine );
- GpXMLParsingException = pException;
-
- // Reset error handler
- xmlSetStructuredErrorFunc( NULL, NULL );
-}
-
-HelpProcessingErrorInfo& HelpProcessingErrorInfo::operator=( const struct HelpProcessingException& e )
-{
- m_eErrorClass = e.m_eErrorClass;
- rtl::OString tmpErrorMsg( e.m_aErrorMsg.c_str() );
- m_aErrorMsg = rtl::OStringToOUString( tmpErrorMsg, fs::getThreadTextEncoding() );
- rtl::OString tmpXMLParsingFile( e.m_aXMLParsingFile.c_str() );
- m_aXMLParsingFile = rtl::OStringToOUString( tmpXMLParsingFile, fs::getThreadTextEncoding() );
- m_nXMLParsingLine = e.m_nXMLParsingLine;
- return *this;
-}
-
-
-// Returns true in case of success, false in case of error
-HELPLINKER_DLLPUBLIC bool compileExtensionHelp
-(
- const rtl::OUString& aExtensionName,
- const rtl::OUString& aExtensionLanguageRoot,
- sal_Int32 nXhpFileCount, const rtl::OUString* pXhpFiles,
- HelpProcessingErrorInfo& o_rHelpProcessingErrorInfo
-)
-{
- bool bSuccess = true;
-
- sal_Int32 argc = nXhpFileCount + 3;
- const char** argv = new const char*[argc];
- argv[0] = "";
- argv[1] = "-mod";
- rtl::OString aOExtensionName = rtl::OUStringToOString( aExtensionName, fs::getThreadTextEncoding() );
- argv[2] = aOExtensionName.getStr();
-
- for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp )
- {
- rtl::OUString aXhpFile = pXhpFiles[iXhp];
-
- rtl::OString aOXhpFile = rtl::OUStringToOString( aXhpFile, fs::getThreadTextEncoding() );
- char* pArgStr = new char[aOXhpFile.getLength() + 1];
- strcpy( pArgStr, aOXhpFile.getStr() );
- argv[iXhp + 3] = pArgStr;
- }
-
- std::vector<std::string> args;
- for( sal_Int32 i = 1; i < argc; ++i )
- args.push_back(std::string( argv[i]) );
-
- for( sal_Int32 iXhp = 0 ; iXhp < nXhpFileCount ; ++iXhp )
- delete argv[iXhp + 3];
- delete[] argv;
-
- rtl::OString aOExtensionLanguageRoot = rtl::OUStringToOString( aExtensionLanguageRoot, fs::getThreadTextEncoding() );
- const char* pExtensionPath = aOExtensionLanguageRoot.getStr();
- std::string aStdStrExtensionPath = pExtensionPath;
-
- // Set error handler
- xmlSetStructuredErrorFunc( NULL, (xmlStructuredErrorFunc)StructuredXMLErrorFunction );
- try
- {
- HelpLinker* pHelpLinker = new HelpLinker();
- pHelpLinker->main( args,&aStdStrExtensionPath );
- delete pHelpLinker;
- }
- catch( const HelpProcessingException& e )
- {
- if( GpXMLParsingException != NULL )
- {
- o_rHelpProcessingErrorInfo = *GpXMLParsingException;
- delete GpXMLParsingException;
- GpXMLParsingException = NULL;
- }
- else
- {
- o_rHelpProcessingErrorInfo = e;
- }
- bSuccess = false;
- }
- // Reset error handler
- xmlSetStructuredErrorFunc( NULL, NULL );
-
- // i83624: Tree files
- ::rtl::OUString aTreeFileURL = aExtensionLanguageRoot;
- aTreeFileURL += rtl::OUString::createFromAscii( "/help.tree" );
- osl::DirectoryItem aTreeFileItem;
- osl::FileBase::RC rcGet = osl::DirectoryItem::get( aTreeFileURL, aTreeFileItem );
- osl::FileStatus aFileStatus( FileStatusMask_FileSize );
- if( rcGet == osl::FileBase::E_None &&
- aTreeFileItem.getFileStatus( aFileStatus ) == osl::FileBase::E_None &&
- aFileStatus.isValid( FileStatusMask_FileSize ) )
- {
- sal_uInt64 ret, len = aFileStatus.getFileSize();
- char* s = new char[ int(len) ]; // the buffer to hold the installed files
- osl::File aFile( aTreeFileURL );
- aFile.open( OpenFlag_Read );
- aFile.read( s, len, ret );
- aFile.close();
-
- XML_Parser parser = XML_ParserCreate( 0 );
- int parsed = XML_Parse( parser, s, int( len ), true );
-
- if( parsed == 0 )
- {
- XML_Error nError = XML_GetErrorCode( parser );
- o_rHelpProcessingErrorInfo.m_eErrorClass = HELPPROCESSING_XMLPARSING_ERROR;
- o_rHelpProcessingErrorInfo.m_aErrorMsg = rtl::OUString::createFromAscii( XML_ErrorString( nError ) );;
- o_rHelpProcessingErrorInfo.m_aXMLParsingFile = aTreeFileURL;
- // CRAHSES!!! o_rHelpProcessingErrorInfo.m_nXMLParsingLine = XML_GetCurrentLineNumber( parser );
- bSuccess = false;
- }
-
- XML_ParserFree( parser );
- delete[] s;
- }
-
- return bSuccess;
-}
-
-// vnd.sun.star.help://swriter/52821?Language=en-US&System=UNIX
-/* vi:set tabstop=4 shiftwidth=4 expandtab: */
-
diff --git a/xmlhelp/source/com/sun/star/help/makefile.mk b/xmlhelp/source/com/sun/star/help/makefile.mk
index c30b36bea8..75823ce8ea 100644
--- a/xmlhelp/source/com/sun/star/help/makefile.mk
+++ b/xmlhelp/source/com/sun/star/help/makefile.mk
@@ -56,62 +56,36 @@ CFLAGS+=-DSYSTEM_DB -I$(DB_INCLUDES)
CFLAGS+=-DSYSTEM_EXPAT
.ENDIF
-OBJFILES=\
- $(OBJ)$/HelpLinker.obj \
- $(OBJ)$/HelpCompiler.obj
-SLOFILES=\
- $(SLO)$/HelpLinker.obj \
- $(SLO)$/HelpCompiler.obj
-
-EXCEPTIONSFILES=\
- $(OBJ)$/HelpLinker.obj \
- $(OBJ)$/HelpCompiler.obj \
- $(SLO)$/HelpLinker.obj \
- $(SLO)$/HelpCompiler.obj
-.IF "$(OS)" == "MACOSX" && "$(CPU)" == "P" && "$(COM)" == "GCC"
-# There appears to be a GCC 4.0.1 optimization error causing _file:good() to
-# report true right before the call to writeOut at HelpLinker.cxx:1.12 l. 954
-# but out.good() to report false right at the start of writeOut at
-# HelpLinker.cxx:1.12 l. 537:
-NOOPTFILES=\
- $(OBJ)$/HelpLinker.obj \
- $(SLO)$/HelpLinker.obj
-.ENDIF
-APP1TARGET= $(TARGET)
-APP1OBJS=\
- $(OBJ)$/HelpLinker.obj \
- $(OBJ)$/HelpCompiler.obj
-APP1RPATH=NONE
+JAVACLASSFILES = \
+ $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpIndexerTool.class \
+ $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpFileDocument.class \
+ $(CLASSDIR)$/$(PACKAGE)$/HelpSearch.class \
+ $(CLASSDIR)$/$(PACKAGE)$/HelpComponent.class \
+ $(CLASSDIR)$/$(PACKAGE)$/HelpIndexer.class
-APP1STDLIBS+=$(SALLIB) $(BERKELEYLIB) $(XSLTLIB) $(EXPATASCII3RDLIB)
+JAVAFILES = \
+ HelpSearch.java \
+ HelpComponent.java \
+ HelpIndexer.java
-SHL1TARGET =$(LIBBASENAME)$(DLLPOSTFIX)
-SHL1LIBS= $(SLB)$/$(TARGET).lib
-SHL1IMPLIB =i$(LIBBASENAME)
-SHL1DEF =$(MISC)$/$(SHL1TARGET).def
-SHL1STDLIBS =$(SALLIB) $(BERKELEYLIB) $(XSLTLIB) $(EXPATASCII3RDLIB)
-SHL1USE_EXPORTS =ordinal
+TRANSEX3FILES = \
+ $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpIndexerTool.class \
+ $(SOLARBINDIR)$/help$/$(PACKAGE)$/HelpFileDocument.class
-DEF1NAME =$(SHL1TARGET)
-DEFLIB1NAME =$(TARGET)
+ADDFILES = $(subst,$(SOLARBINDIR)$/help,$(CLASSDIR) $(TRANSEX3FILES))
-JAVACLASSFILES = \
- $(CLASSDIR)$/$(PACKAGE)$/HelpSearch.class \
- $(CLASSDIR)$/$(PACKAGE)$/HelpIndexer.class \
- $(CLASSDIR)$/$(PACKAGE)$/HelpComponent.class \
- $(CLASSDIR)$/$(PACKAGE)$/HelpFileDocument.class
+#JAVAFILES = $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES)))
-JARFILES = ridl.jar jurt.jar unoil.jar juh.jar
+JARFILES = ridl.jar jurt.jar unoil.jar juh.jar HelpIndexerTool.jar
.IF "$(SYSTEM_LUCENE)" == "YES"
XCLASSPATH!:=$(XCLASSPATH)$(PATH_SEPERATOR)$(LUCENE_CORE_JAR)$(PATH_SEPERATOR)$(LUCENE_ANALYZERS_JAR)
COMP=fix_system_lucene
.ELSE
JARFILES += lucene-core-2.3.jar lucene-analyzers-2.3.jar
.ENDIF
-JAVAFILES = $(subst,$(CLASSDIR)$/$(PACKAGE)$/, $(subst,.class,.java $(JAVACLASSFILES)))
-JARTARGET = LuceneHelpWrapper.jar
+JARTARGET = LuceneHelpWrapper.jar
JARCOMPRESS = TRUE
CUSTOMMANIFESTFILE = MANIFEST.MF
@@ -119,10 +93,17 @@ CUSTOMMANIFESTFILE = MANIFEST.MF
.INCLUDE : target.mk
+ALLTAR : $(ADDFILES)
+
.IF "$(JARTARGETN)"!=""
$(JARTARGETN) : $(COMP)
.ENDIF
+$(CLASSDIR)$/$(PACKAGE)$/%.class : $(SOLARBINDIR)$/help$/$(PACKAGE)$/%.class
+ $(MKDIRHIER) $(@:d)
+ $(COPY) $< $@
+
+
fix_system_lucene:
@echo "Fix Java Class-Path entry for Lucene libraries from system."
@$(SED) -r -e "s#^(Class-Path:).*#\1 file://$(LUCENE_CORE_JAR) file://$(LUCENE_ANALYZERS_JAR)#" \
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index ec6b75857f..17b8714952 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -59,7 +59,7 @@
#include <com/sun/star/script/XInvocation.hpp>
#include <comphelper/locale.hxx>
-#include <xmlhelp/compilehelp.hxx>
+#include <transex3/compilehelp.hxx>
#include "databases.hxx"
#include "urlparameter.hxx"
diff --git a/xmloff/util/makefile.mk b/xmloff/util/makefile.mk
index d9ef85c217..31852e1517 100644
--- a/xmloff/util/makefile.mk
+++ b/xmloff/util/makefile.mk
@@ -41,7 +41,7 @@ USE_DEFFILE=TRUE
.INCLUDE: $(PRJ)$/util$/makefile.pmk
# --- Allgemein ----------------------------------------------------
-
+.IF "$(L10N_framework)"==""
LIB1TARGET= $(SLB)$/xo.lib
LIB1FILES= \
$(SLB)$/core.lib \
@@ -115,5 +115,5 @@ DEFLIB1NAME =xo
DEF1DES =XML Office Lib
# --- Targets ----------------------------------------------------------
-
+.ENDIF
.INCLUDE : target.mk
diff --git a/xmlscript/source/misc/makefile.mk b/xmlscript/source/misc/makefile.mk
index 8bd9b79198..fbd7b0b098 100644
--- a/xmlscript/source/misc/makefile.mk
+++ b/xmlscript/source/misc/makefile.mk
@@ -39,7 +39,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
#-----------------------------------------------------------
SLOFILES = \
@@ -48,4 +48,5 @@ SLOFILES = \
# --- Targets ------------------------------------------------------
.INCLUDE : $(PRJ)$/util$/target.pmk
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/xmlscript/source/xml_helper/makefile.mk b/xmlscript/source/xml_helper/makefile.mk
index 61f2636064..e5e96ff686 100644
--- a/xmlscript/source/xml_helper/makefile.mk
+++ b/xmlscript/source/xml_helper/makefile.mk
@@ -38,7 +38,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
#-----------------------------------------------------------
SLOFILES = \
@@ -49,4 +49,6 @@ SLOFILES = \
# --- Targets ------------------------------------------------------
.INCLUDE : $(PRJ)$/util$/target.pmk
+.ENDIF # L10N_framework
+
.INCLUDE : target.mk
diff --git a/xmlscript/source/xmldlg_imexp/makefile.mk b/xmlscript/source/xmldlg_imexp/makefile.mk
index acb8321266..86b57a27f6 100644
--- a/xmlscript/source/xmldlg_imexp/makefile.mk
+++ b/xmlscript/source/xmldlg_imexp/makefile.mk
@@ -38,7 +38,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
#-----------------------------------------------------------
SLOFILES = \
@@ -51,4 +51,6 @@ SLOFILES = \
# --- Targets ------------------------------------------------------
.INCLUDE : $(PRJ)$/util$/target.pmk
+.ENDIF # L10N_framework
+
.INCLUDE : target.mk
diff --git a/xmlscript/source/xmlflat_imexp/makefile.mk b/xmlscript/source/xmlflat_imexp/makefile.mk
index f2c677fd88..8d6f9fbfa9 100644
--- a/xmlscript/source/xmlflat_imexp/makefile.mk
+++ b/xmlscript/source/xmlflat_imexp/makefile.mk
@@ -39,7 +39,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
#-----------------------------------------------------------
SLOFILES = \
@@ -49,4 +49,6 @@ SLOFILES = \
# --- Targets ------------------------------------------------------
.INCLUDE : $(PRJ)$/util$/target.pmk
+.ENDIF # L10N_framework
+
.INCLUDE : target.mk
diff --git a/xmlscript/source/xmllib_imexp/makefile.mk b/xmlscript/source/xmllib_imexp/makefile.mk
index ca4cae0e23..2d29c3d2d4 100644
--- a/xmlscript/source/xmllib_imexp/makefile.mk
+++ b/xmlscript/source/xmllib_imexp/makefile.mk
@@ -38,7 +38,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
#-----------------------------------------------------------
SLOFILES = \
@@ -48,4 +48,7 @@ SLOFILES = \
# --- Targets ------------------------------------------------------
.INCLUDE : $(PRJ)$/util$/target.pmk
+
+.ENDIF # L10N_framework
+
.INCLUDE : target.mk
diff --git a/xmlscript/source/xmlmod_imexp/makefile.mk b/xmlscript/source/xmlmod_imexp/makefile.mk
index ee5bb85cec..96d74a41dd 100644
--- a/xmlscript/source/xmlmod_imexp/makefile.mk
+++ b/xmlscript/source/xmlmod_imexp/makefile.mk
@@ -38,7 +38,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
#-----------------------------------------------------------
SLOFILES = \
@@ -48,4 +48,6 @@ SLOFILES = \
# --- Targets ------------------------------------------------------
.INCLUDE : $(PRJ)$/util$/target.pmk
+
+.ENDIF # L10N_framework
.INCLUDE : target.mk