You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by as...@apache.org on 2018/05/07 22:25:26 UTC

[1/2] portals-pluto git commit: PLUTO-711 AbstractPortletConfigImpl.getSupportedLocales() does not parse language an country codes

Repository: portals-pluto
Updated Branches:
  refs/heads/master 0722405ce -> 6cd9382aa


PLUTO-711 AbstractPortletConfigImpl.getSupportedLocales() does not parse language an country codes


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/bb0df7fc
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/bb0df7fc
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/bb0df7fc

Branch: refs/heads/master
Commit: bb0df7fc26c5397ededb5137a68307d29c737f76
Parents: 0722405
Author: Neil Griffin <ne...@gmail.com>
Authored: Mon May 7 18:24:54 2018 -0400
Committer: Neil Griffin <ne...@gmail.com>
Committed: Mon May 7 18:24:54 2018 -0400

----------------------------------------------------------------------
 .../impl/AbstractPortletConfigImpl.java         | 40 ++++++++++++++++++--
 1 file changed, 36 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/bb0df7fc/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java b/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java
index 28e7bb6..95d9551 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/impl/AbstractPortletConfigImpl.java
@@ -163,10 +163,10 @@ public abstract class AbstractPortletConfigImpl implements PortletConfig
 		// for each String entry in SupportedLocales (portletDD)
 		// add an entry in the resut list (new Locale(string))
 		List<Locale> locals = new ArrayList<Locale>();
-		List<String> localsAsStrings = portlet.getSupportedLocales();
-		if (localsAsStrings!=null){
-			for (String string : localsAsStrings) {
-				locals.add(new Locale(string));
+		List<String> languageIds = portlet.getSupportedLocales();
+		if (languageIds!=null){
+			for (String languageId : languageIds) {
+				locals.add(getLocale(languageId));
 			}
 		}
 		return Collections.enumeration(locals);
@@ -224,4 +224,36 @@ public abstract class AbstractPortletConfigImpl implements PortletConfig
         }
         return Collections.emptyMap();
 	}
+
+	private Locale getLocale(String languageId) {
+
+    	Locale locale;
+
+		int pos = languageId.indexOf("_");
+
+		if (pos == -1) {
+			locale = Locale.forLanguageTag(languageId);
+		}
+		else {
+			String[] languageIdParts = languageId.split("_");
+
+			String languageCode = languageIdParts[0];
+			String countryCode = languageIdParts[1];
+
+			String variant = null;
+
+			if (languageIdParts.length > 2) {
+				variant = languageIdParts[2];
+			}
+
+			if ((variant != null) && (variant.trim().length() > 0)) {
+				locale = new Locale(languageCode, countryCode, variant);
+			}
+			else {
+				locale = new Locale(languageCode, countryCode);
+			}
+		}
+
+		return locale;
+	}
 }


[2/2] portals-pluto git commit: PLUTO-712 Contesting V3AnnotationPortletConfigTests_SPEC2_28_SupportedLocales_declaringSupportedLocales1

Posted by as...@apache.org.
PLUTO-712 Contesting V3AnnotationPortletConfigTests_SPEC2_28_SupportedLocales_declaringSupportedLocales1


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/6cd9382a
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/6cd9382a
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/6cd9382a

Branch: refs/heads/master
Commit: 6cd9382aa0029f56082286123ebc64d2d506dd9b
Parents: bb0df7f
Author: Neil Griffin <ne...@gmail.com>
Authored: Mon May 7 18:25:10 2018 -0400
Committer: Neil Griffin <ne...@gmail.com>
Committed: Mon May 7 18:25:10 2018 -0400

----------------------------------------------------------------------
 .../AnnotationPortletConfigTests_SPEC2_28_SupportedLocales.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/6cd9382a/portlet-tck_3.0/V3AnnotationPortletConfigTests/src/main/java/javax/portlet/tck/portlets/AnnotationPortletConfigTests_SPEC2_28_SupportedLocales.java
----------------------------------------------------------------------
diff --git a/portlet-tck_3.0/V3AnnotationPortletConfigTests/src/main/java/javax/portlet/tck/portlets/AnnotationPortletConfigTests_SPEC2_28_SupportedLocales.java b/portlet-tck_3.0/V3AnnotationPortletConfigTests/src/main/java/javax/portlet/tck/portlets/AnnotationPortletConfigTests_SPEC2_28_SupportedLocales.java
index c13874f..f53df92 100644
--- a/portlet-tck_3.0/V3AnnotationPortletConfigTests/src/main/java/javax/portlet/tck/portlets/AnnotationPortletConfigTests_SPEC2_28_SupportedLocales.java
+++ b/portlet-tck_3.0/V3AnnotationPortletConfigTests/src/main/java/javax/portlet/tck/portlets/AnnotationPortletConfigTests_SPEC2_28_SupportedLocales.java
@@ -81,8 +81,8 @@ public class AnnotationPortletConfigTests_SPEC2_28_SupportedLocales implements P
          Enumeration<Locale> supportedLocales = portletConfig.getSupportedLocales();
          List<Locale> supportedLocalesList = Collections.list(supportedLocales);
          if(supportedLocalesList.size()==2
-               && supportedLocalesList.get(0).toString().equals("en_us")
-               && supportedLocalesList.get(1).toString().equals("de")){
+               && supportedLocalesList.get(0).equals(Locale.US)
+               && supportedLocalesList.get(1).equals(Locale.GERMAN)) {
             result.setTcSuccess(true);
          } else {
             result.appendTcDetail("Failed because more than 2 supported locales are found - "+supportedLocalesList.size()