summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorCarsten Driesner <cd@openoffice.org>2009-12-09 13:31:58 +0000
committerCarsten Driesner <cd@openoffice.org>2009-12-09 13:31:58 +0000
commit724842d9b72155dac4f2ade8ed5385da302a15bf (patch)
tree1e5180c118a7d477f6f74f251a349931fcc9a406 /desktop
parent888c37e376701a749b4b102036f488287bc89fb8 (diff)
#161124# Fix problem with cpu frequency as float. Added context class loader code to fix problems with certain Java versions.
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java44
-rw-r--r--desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java4
2 files changed, 40 insertions, 8 deletions
diff --git a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java
index 9e9a9b65bd93..93a1f25a6c2f 100644
--- a/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java
+++ b/desktop/source/registration/com/sun/star/servicetag/RegistrationDocument.java
@@ -74,7 +74,7 @@ import javax.xml.transform.stream.StreamResult;
class RegistrationDocument {
private static final String REGISTRATION_DATA_SCHEMA =
- "/com/sun/servicetag/resources/product_registration.xsd";
+ "/com/sun/star/servicetag/resources/product_registration.xsd";
private static final String REGISTRATION_DATA_VERSION = "1.0";
private static final String SERVICE_TAG_VERSION = "1.0";
final static String ST_NODE_REGISTRATION_DATA = "registration_data";
@@ -155,16 +155,46 @@ class RegistrationDocument {
// initialize a document from an input stream
private static Document initializeDocument(InputStream in) throws IOException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ SchemaFactory sf = null;
try {
- // XML schema for validation
- SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA);
- Schema schema = sf.newSchema(xsdUrl);
- Validator validator = schema.newValidator();
+ // Some Java versions (e.g., 1.5.0_06-b05) fail with a
+ // NullPointerException if SchemaFactory.newInstance is called with
+ // a null context class loader, so work around that here (and the
+ // class loader of this class hopefully is not the null bootstrap
+ // class loader):
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (cl == null) {
+ Thread.currentThread().setContextClassLoader(
+ RegistrationDocument.class.getClassLoader());
+ }
+ try {
+ sf = SchemaFactory.newInstance(
+ XMLConstants.W3C_XML_SCHEMA_NS_URI);
+ } finally {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+
+ Schema schema = null;
+ try {
+ // Even using the workaround above is not enough on some
+ // Java versions. Therefore try to workaround the validation
+ // completely!
+ URL xsdUrl = RegistrationDocument.class.getResource(REGISTRATION_DATA_SCHEMA);
+ schema = sf.newSchema(xsdUrl);
+ }
+ catch (NullPointerException nex) {
+ }
+
+ Validator validator = null;
+ if (schema != null)
+ validator = schema.newValidator();
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse(new InputSource(in));
- validator.validate(new DOMSource(doc));
+
+ if (validator != null)
+ validator.validate(new DOMSource(doc));
+
return doc;
} catch (SAXException sxe) {
IllegalArgumentException e = new IllegalArgumentException("Error generated in parsing");
diff --git a/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java
index b433600f7995..4628034723e1 100644
--- a/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java
+++ b/desktop/source/registration/com/sun/star/servicetag/SystemEnvironment.java
@@ -213,7 +213,9 @@ public class SystemEnvironment {
* @param clockrate The clockrate to set.
*/
public void setClockRate(String clockrate) {
- this.clockrate = clockrate;
+ Float f = Float.parseFloat(clockrate);
+ Integer nClockrate = f.intValue();
+ this.clockrate = nClockrate.toString();
}
/**