marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [2/3] git commit: MARMOTTA-155: fixed issue with 3-char locales (LocaleUtils.toLocale() does not handle them properly)
Date Tue, 10 Sep 2013 12:44:39 GMT
MARMOTTA-155: fixed issue with 3-char locales (LocaleUtils.toLocale() does not handle them
properly)


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/d467cec7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/d467cec7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/d467cec7

Branch: refs/heads/develop
Commit: d467cec7e5dbabf37a9f4f9f3b2f71979e1b4726
Parents: be890b6
Author: Sergio Fernández <wikier@apache.org>
Authored: Tue Sep 10 14:44:16 2013 +0200
Committer: Sergio Fernández <wikier@apache.org>
Committed: Tue Sep 10 14:44:16 2013 +0200

----------------------------------------------------------------------
 .../apache/marmotta/kiwi/model/rdf/KiWiLiteral.java  | 15 ++++++---------
 .../marmotta/kiwi/persistence/KiWiConnection.java    |  9 ++++++---
 .../apache/marmotta/kiwi/sail/KiWiValueFactory.java  | 10 +++++-----
 3 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d467cec7/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java
index 9526081..e96220e 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java
@@ -17,20 +17,17 @@
  */
 package org.apache.marmotta.kiwi.model.rdf;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Locale;
+
+import javax.xml.datatype.XMLGregorianCalendar;
+
 import org.apache.marmotta.commons.sesame.model.Namespaces;
-import com.google.common.hash.HashCode;
-import com.google.common.hash.HashFunction;
-import com.google.common.hash.Hasher;
-import com.google.common.hash.Hashing;
 import org.openrdf.model.Literal;
 import org.openrdf.model.URI;
 import org.openrdf.model.datatypes.XMLDatatypeUtil;
 
-import javax.xml.datatype.XMLGregorianCalendar;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Locale;
-
 /**
  * KiWiLiterals store literal information from the knowledge base. They directly
  * correspond to an RDF literal stored in Sesame. KiWiLiterals are

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d467cec7/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
index 3467525..cbba4e2 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
@@ -18,12 +18,16 @@
 package org.apache.marmotta.kiwi.persistence;
 
 import info.aduna.iteration.*;
+
 import org.apache.marmotta.commons.sesame.model.LiteralCommons;
 import org.apache.marmotta.commons.sesame.model.Namespaces;
 import org.apache.marmotta.commons.util.DateUtils;
+
 import com.google.common.base.Preconditions;
+
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.Element;
+
 import org.apache.commons.lang3.LocaleUtils;
 import org.apache.marmotta.kiwi.caching.KiWiCacheManager;
 import org.apache.marmotta.kiwi.config.KiWiConfiguration;
@@ -1707,9 +1711,8 @@ public class KiWiConnection {
     protected static Locale getLocale(String language) {
         Locale locale = localeMap.get(language);
         if(locale == null && language != null) {
-            locale = LocaleUtils.toLocale(language.replace("-","_"));
-            localeMap.put(language,locale);
-
+            locale = Locale.forLanguageTag(language);
+            localeMap.put(language, locale);
         }
         return locale;
     }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d467cec7/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
index 0074ede..78f630e 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
@@ -49,7 +49,6 @@ public class KiWiValueFactory implements ValueFactory {
 
     private Random anonIdGenerator;
 
-
     /**
      * This is a hash map for storing references to resources that have not yet been persisted.
It is used e.g. when
      * one or more transactions are currently active and request the creation of same resource
several times
@@ -393,14 +392,15 @@ public class KiWiValueFactory implements ValueFactory {
         Locale locale;
         if(lang != null) {
             try {
-                locale = LocaleUtils.toLocale(lang.replace("-","_"));
+                locale = Locale.forLanguageTag(lang);
             } catch (IllegalArgumentException ex) {
                 log.warn("malformed language literal (language: {})", lang);
                 locale = null;
-                lang   = null;
+                lang = null;
             }
-        } else
-            locale  = null;
+        } else {
+            locale = null;
+        }
 
         if (lang != null) {
             // FIXME: MARMOTTA-39 (no rdf:langString)


Mime
View raw message