Jeroen Hoffman pushed to branch master at cms-community / hippo-repository

Commits:
558e52a7 by Jasper Floor at 2018-02-27T14:59:40+01:00
REPO-1869 prevent document variants from being counted as duplicates

- - - - -
0c15259e by Jeroen Hoffman at 2018-03-07T09:45:05+01:00
REPO-1869 remove parent-check logic: lot of code for a situation that is very 
very unlikely (2 or 3 found variants with different parent)

- - - - -
f69fe4e6 by Jeroen Hoffman at 2018-03-07T09:46:48+01:00
REPO-1869 simplify code

- - - - -
ff5cb5d3 by Jeroen Hoffman at 2018-03-07T10:03:13+01:00
REPO-1869 Reintegrate branch 'bugfix/REPO-1869' into master

- - - - -


1 changed file:

- 
builtin/src/main/java/org/hippoecm/repository/translation/HippoTranslatedNode.java


Changes:

=====================================
builtin/src/main/java/org/hippoecm/repository/translation/HippoTranslatedNode.java
=====================================
--- 
a/builtin/src/main/java/org/hippoecm/repository/translation/HippoTranslatedNode.java
+++ 
b/builtin/src/main/java/org/hippoecm/repository/translation/HippoTranslatedNode.java
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2012-2013 Hippo B.V. (http://www.onehippo.com)
+ *  Copyright 2012-2018 Hippo B.V. (http://www.onehippo.com)
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -64,20 +64,24 @@ public final class HippoTranslatedNode {
     }
 
     public Node getTranslation(String language) throws RepositoryException {
-        String id = node.getProperty(HippoTranslationNodeType.ID).getString();
-        Query query = 
node.getSession().getWorkspace().getQueryManager().createQuery(
+        final String id = 
node.getProperty(HippoTranslationNodeType.ID).getString();
+        final Query query = 
node.getSession().getWorkspace().getQueryManager().createQuery(
                 "SELECT * FROM " + HippoTranslationNodeType.NT_TRANSLATED
                         + " WHERE " + HippoTranslationNodeType.ID + "='" + id 
+ "'"
                         + " AND " + HippoTranslationNodeType.LOCALE + "='" + 
language + "'",
                 Query.SQL);
         final QueryResult result = query.execute();
-        NodeIterator nodes = result.getNodes();
+        final NodeIterator nodes = result.getNodes();
         if (!nodes.hasNext()) {
-            throw new ItemNotFoundException("Folder was not translated to " + 
language);
+            throw new ItemNotFoundException("Node " + node.getPath() + " was 
not translated to " + language);
         }
-        if (nodes.getSize() > 1) {
-            log.warn("More than one translated variant found for node " + id + 
" in language " + language);
+
+        if (nodes.getSize() > 3) {
+            // check 3 for the stable draft/unpublished/published versions
+            log.warn("Not a maximum of 3 but {} translated variants found for 
node {} with translation id {} and language {}.",
+                    nodes.getSize(), node.getPath(), id, language);
         }
+
         return nodes.nextNode();
     }
 



View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-repository/compare/4b64f92ed4d59d9317c30766a4a704d9cf391337...ff5cb5d301089dddf5ee3cf394a778ea8a53ea9a

---
View it on GitLab: 
https://code.onehippo.org/cms-community/hippo-repository/compare/4b64f92ed4d59d9317c30766a4a704d9cf391337...ff5cb5d301089dddf5ee3cf394a778ea8a53ea9a
You're receiving this email because of your account on code.onehippo.org.
_______________________________________________
Hippocms-svn mailing list
Hippocms-svn@lists.onehippo.org
https://lists.onehippo.org/mailman/listinfo/hippocms-svn

Reply via email to