Author: theute
Date: 2011-08-18 11:47:03 -0400 (Thu, 18 Aug 2011)
New Revision: 7176
Modified:
epp/portal/branches/EPP_5_2_Branch/
epp/portal/branches/EPP_5_2_Branch/component/
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/description/DescriptionServiceImpl.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/importer/NavigationFragmentImporter.java
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/importer/TestNavigationImporter.java
Log:
JBEPP-1085
Navigation Importer doesn't update extended labels during import
Property changes on: epp/portal/branches/EPP_5_2_Branch
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795:5868
/portal/branches/branch-GTNPORTAL-1592:4894
/portal/branches/branch-GTNPORTAL-1643:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731:5622,5668
/portal/branches/branch-GTNPORTAL-1745:5765
/portal/branches/branch-GTNPORTAL-1822:5943,5952
/portal/branches/branch-GTNPORTAL-1832:6030,6063
/portal/branches/branch-GTNPORTAL-1872:6400,6551
/portal/branches/branch-GTNPORTAL-1921:6603
/portal/branches/branch-GTNPORTAL-1963:6904,6915-6916
/portal/branches/decoupled-webos:6214-6243
/portal/branches/gatein-management:6920-6958
/portal/branches/global-portlet-metadata:6298-6384
/portal/branches/site-describability:6171-6235
/portal/trunk:4891,5744,5822,5943,6168,6196,6201-6203,6205-6206,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
Property changes on: epp/portal/branches/EPP_5_2_Branch/component
___________________________________________________________________
Modified: svn:mergeinfo
- /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042
+ /epp/portal/branches/EPP_5_1_0_GA_JBEPP-795/component:5868
/portal/branches/branch-GTNPORTAL-1592/component:4894
/portal/branches/branch-GTNPORTAL-1643/component:5002,5063,5167
/portal/branches/branch-GTNPORTAL-1700/component:5348,5363,5402,5445
/portal/branches/branch-GTNPORTAL-1731/component:5622,5668
/portal/branches/branch-GTNPORTAL-1745/component:5765
/portal/branches/branch-GTNPORTAL-1822/component:5943,5952
/portal/branches/branch-GTNPORTAL-1832/component:6030,6063
/portal/branches/branch-GTNPORTAL-1872/component:6400,6551
/portal/branches/branch-GTNPORTAL-1921/component:6603
/portal/branches/branch-GTNPORTAL-1963/component:6904,6915-6916
/portal/trunk/component:4891,5744,5822,5943,6031,6033,6168,6196,6201-6203,6205-6206,6292,6437,6440,6449,6452,6573,6783-6784,6912-6913,6960,7042,7061
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/description/DescriptionServiceImpl.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/description/DescriptionServiceImpl.java 2011-08-18
15:23:53 UTC (rev 7175)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/description/DescriptionServiceImpl.java 2011-08-18
15:47:03 UTC (rev 7176)
@@ -187,10 +187,15 @@
{
cache.removeState(new CacheKey(locale, id));
}
- for (Map.Entry<Locale, Described.State> entry : descriptions.entrySet())
+
+ // Interface specifies it allows a null description map
+ if (descriptions != null)
{
- Described described = able.addI18NMixin(Described.class, entry.getKey());
- described.setState(entry.getValue());
+ for (Map.Entry<Locale, Described.State> entry : descriptions.entrySet())
+ {
+ Described described = able.addI18NMixin(Described.class, entry.getKey());
+ described.setState(entry.getValue());
+ }
}
}
}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/importer/NavigationFragmentImporter.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/importer/NavigationFragmentImporter.java 2011-08-18
15:23:53 UTC (rev 7175)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/main/java/org/exoplatform/portal/mop/importer/NavigationFragmentImporter.java 2011-08-18
15:47:03 UTC (rev 7176)
@@ -257,7 +257,7 @@
//
if (config.updatedSame)
{
- dstChild.setState(srcChild.getState());
+ update(srcChild, dstChild, labelMap);
}
//
@@ -280,7 +280,7 @@
{
if (config.updatedSame)
{
- dstChild.setState(srcChild.getState());
+ update(srcChild, dstChild, labelMap);
}
previousChild = dstChild;
}
@@ -362,4 +362,39 @@
//
return child;
}
+
+ private void update(PageNode src, NodeContext<?> target,
+ Map<NodeContext<?>, Map<Locale,
Described.State>> labelMap)
+ {
+ target.setState(src.getState());
+
+ // Update extended labels if necessary
+ I18NString labels = src.getLabels();
+ Map<Locale, Described.State> description;
+ if (labels.isSimple())
+ {
+ description = null;
+ }
+ else if (labels.isEmpty())
+ {
+ description = null;
+ }
+ else
+ {
+ description = new HashMap<Locale, Described.State>();
+ for (Map.Entry<Locale, String> entry :
labels.getExtended(portalLocale).entrySet())
+ {
+ description.put(entry.getKey(), new Described.State(entry.getValue(),
null));
+ }
+ }
+
+ if (description != null)
+ {
+ labelMap.put(target, description);
+ }
+ else
+ {
+ labelMap.put(target, Collections.<Locale, Described.State>emptyMap());
+ }
+ }
}
Modified:
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/importer/TestNavigationImporter.java
===================================================================
---
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/importer/TestNavigationImporter.java 2011-08-18
15:23:53 UTC (rev 7175)
+++
epp/portal/branches/EPP_5_2_Branch/component/portal/src/test/java/org/exoplatform/portal/mop/importer/TestNavigationImporter.java 2011-08-18
15:47:03 UTC (rev 7176)
@@ -338,6 +338,84 @@
Map<Locale, Described.State> cDesc =
descriptionService.getDescriptions(c.getId());
assertNull(cDesc);
assertEquals("c_en", c.getState().getLabel());
+
+ //----------------- Now test extended labels merge -----------------//
+ src = new PageNavigation("portal",
"extended_label").addFragment(fragment().add(node("a"),
node("b"), node("c")).build());
+ fragment = src.getFragment();
+ fragment.getNode("a").setLabels(new I18NString(new
LocalizedString("a_it", Locale.ITALIAN), new LocalizedString("a_de",
Locale.GERMAN)));
+ fragment.getNode("b").setLabels(new I18NString(new
LocalizedString("foo_b_en"), new LocalizedString("b_it",
Locale.ITALIAN)));
+ fragment.getNode("c").setLabels(new I18NString(new
LocalizedString("foo_c_en")));
+ src.setOwnerId("extended_label");
+
+ importer = new NavigationImporter(Locale.ENGLISH, ImportMode.MERGE, src, service,
descriptionService);
+ importer.perform();
+
+ //
+ ctx = service.loadNavigation(SiteKey.portal("extended_label"));
+ node = service.loadNode(NodeModel.SELF_MODEL, ctx, Scope.ALL, null).getNode();
+
+ // The fully explicit case
+ a = (NodeContext<?>)node.getNode("a");
+ aDesc = descriptionService.getDescriptions(a.getId());
+ assertNotNull(aDesc);
+ assertEquals(Tools.toSet(Locale.ITALIAN, Locale.GERMAN), aDesc.keySet());
+ assertEquals(new Described.State("a_it", null),
aDesc.get(Locale.ITALIAN));
+ assertEquals(new Described.State("a_de", null),
aDesc.get(Locale.GERMAN));
+ assertNull(a.getState().getLabel());
+
+ // No explicit language means to use the portal locale
+ b = (NodeContext<?>)node.getNode("b");
+ bDesc = descriptionService.getDescriptions(b.getId());
+ assertNotNull(bDesc);
+ assertEquals(Tools.toSet(Locale.ENGLISH, Locale.ITALIAN), bDesc.keySet());
+ assertEquals(new Described.State("foo_b_en", null),
bDesc.get(Locale.ENGLISH));
+ assertEquals(new Described.State("b_it", null),
bDesc.get(Locale.ITALIAN));
+ assertNull(b.getState().getLabel());
+
+ // The simple use case : one single label without the xml:lang attribute
+ c = (NodeContext<?>)node.getNode("c");
+ cDesc = descriptionService.getDescriptions(c.getId());
+ assertNull(cDesc);
+ assertEquals("foo_c_en", c.getState().getLabel());
+
+ //----------------- Now test extended labels overwrite -----------------//
+ src = new PageNavigation("portal",
"extended_label").addFragment(fragment().add(node("a"),
node("b"), node("c")).build());
+ fragment = src.getFragment();
+ fragment.getNode("a").setLabels(new I18NString(new
LocalizedString("bar_a_en", Locale.ENGLISH), new
LocalizedString("bar_a_fr", Locale.FRENCH)));
+ fragment.getNode("b").setLabels(new I18NString(new
LocalizedString("bar_b_en"), new LocalizedString("bar_b_fr",
Locale.FRENCH)));
+ fragment.getNode("c").setLabels(new I18NString(new
LocalizedString("bar_c_en")));
+ src.setOwnerId("extended_label");
+
+ importer = new NavigationImporter(Locale.ENGLISH, ImportMode.OVERWRITE, src,
service, descriptionService);
+ importer.perform();
+
+ //
+ ctx = service.loadNavigation(SiteKey.portal("extended_label"));
+ node = service.loadNode(NodeModel.SELF_MODEL, ctx, Scope.ALL, null).getNode();
+
+ // The fully explicit case
+ a = (NodeContext<?>)node.getNode("a");
+ aDesc = descriptionService.getDescriptions(a.getId());
+ assertNotNull(aDesc);
+ assertEquals(Tools.toSet(Locale.ENGLISH, Locale.FRENCH), aDesc.keySet());
+ assertEquals(new Described.State("bar_a_en", null),
aDesc.get(Locale.ENGLISH));
+ assertEquals(new Described.State("bar_a_fr", null),
aDesc.get(Locale.FRENCH));
+ assertNull(a.getState().getLabel());
+
+ // No explicit language means to use the portal locale
+ b = (NodeContext<?>)node.getNode("b");
+ bDesc = descriptionService.getDescriptions(b.getId());
+ assertNotNull(bDesc);
+ assertEquals(Tools.toSet(Locale.ENGLISH, Locale.FRENCH), bDesc.keySet());
+ assertEquals(new Described.State("bar_b_en", null),
bDesc.get(Locale.ENGLISH));
+ assertEquals(new Described.State("bar_b_fr", null),
bDesc.get(Locale.FRENCH));
+ assertNull(b.getState().getLabel());
+
+ // The simple use case : one single label without the xml:lang attribute
+ c = (NodeContext<?>)node.getNode("c");
+ cDesc = descriptionService.getDescriptions(c.getId());
+ assertNull(cDesc);
+ assertEquals("bar_c_en", c.getState().getLabel());
}
public void testFullNavigation()