Ate Douma pushed to branch bugfix/REPO-1540 at cms-community / hippo-repository


Commits:
a715b4c6 by Ate Douma at 2016-08-05T17:04:50+02:00
REPO-1540: automatically and always (re)load repository resourcebundle 
initialize items

- - - - -


2 changed files:

- engine/src/main/java/org/onehippo/repository/bootstrap/InitializeItem.java
- 
engine/src/main/java/org/onehippo/repository/bootstrap/instructions/ResourceBundlesInstruction.java


Changes:

=====================================
engine/src/main/java/org/onehippo/repository/bootstrap/InitializeItem.java
=====================================
--- a/engine/src/main/java/org/onehippo/repository/bootstrap/InitializeItem.java
+++ b/engine/src/main/java/org/onehippo/repository/bootstrap/InitializeItem.java
@@ -422,7 +422,7 @@ public class InitializeItem {
         final Node initializationFolder = 
tempItemNode.getSession().getNode(INITIALIZATION_FOLDER);
         itemNode = JcrUtils.getNodeIfExists(initializationFolder, 
tempItemNode.getName());
 
-        if (itemNode != null && isReloadRequested()) {
+        if (itemNode != null && (isResourceBundles() || isReloadRequested())) {
             if (isDeltaMerge()) {
                 String message = "Cannot reload initialize item " + getName() 
+ " because it is a combine or overlay delta";
                 log.error(message);


=====================================
engine/src/main/java/org/onehippo/repository/bootstrap/instructions/ResourceBundlesInstruction.java
=====================================
--- 
a/engine/src/main/java/org/onehippo/repository/bootstrap/instructions/ResourceBundlesInstruction.java
+++ 
b/engine/src/main/java/org/onehippo/repository/bootstrap/instructions/ResourceBundlesInstruction.java
@@ -25,8 +25,10 @@ import java.util.Iterator;
 import java.util.Map;
 
 import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.ValueFormatException;
 
 import org.apache.commons.lang.StringUtils;
 import org.onehippo.repository.bootstrap.InitializeInstruction;
@@ -136,6 +138,14 @@ public class ResourceBundlesInstruction extends 
InitializeInstruction {
         final Node bundles = getOrCreateResourceBundles(bundleInfo.getName());
         final Node bundle = getOrCreateNode(bundleInfo.getLocale().toString(), 
bundles, NT_RESOURCEBUNDLE);
         for (Map.Entry<String, String> entry : 
bundleInfo.getTranslations().entrySet()) {
+            // only set new or changed property value
+            try {
+                if 
(entry.getValue().equals(bundle.getProperty(entry.getKey()).getString())) {
+                    continue;
+                }
+            } catch (PathNotFoundException|ValueFormatException e) {
+                // undefined or multi-valued property
+            }
             bundle.setProperty(entry.getKey(), entry.getValue());
         }
     }



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-repository/commit/a715b4c69f381e8aa1bcf06c5cb54d3a731b4717
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to