Skip to content

Commit bbb2a51

Browse files
Revert on multilocale not being properly handled
1 parent eeaa85b commit bbb2a51

File tree

2 files changed

+15
-53
lines changed

2 files changed

+15
-53
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ Name of the action : verifyIntegrityOfSiteContent
1616

1717
Example of URL to call : http://localhost:8080/cms/render/default/en/sites/mySite/home.verifyIntegrityOfSiteContent.do
1818

19-
Parameters of the action :
20-
- performMultiLocaleVerification : true by default. Allow to perform check on only the main site's locale if needed, by
21-
setting it to false
22-
2319
The action will then log detected node in errors with a message specifying the issue
2420
It will also return JSON result for automation. You can check for those keys in the result :
2521
- siteContentIsValid : "true" or "false" value, depending on the result of the verification

src/main/java/org/jahia/modules/verifyintegrity/actions/VerifyIntegrityOfSiteContent.java

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package org.jahia.modules.verifyintegrity.actions;
22

33

4-
import org.jahia.api.Constants;
54
import org.jahia.bin.Action;
65
import org.jahia.bin.ActionResult;
76
import org.jahia.modules.verifyintegrity.exceptions.CompositeIntegrityViolationException;
87
import org.jahia.modules.verifyintegrity.services.VerifyIntegrityService;
9-
import org.jahia.services.content.*;
8+
import org.jahia.services.content.JCRNodeWrapper;
9+
import org.jahia.services.content.JCRSessionWrapper;
1010
import org.jahia.services.content.decorator.JCRSiteNode;
1111
import org.jahia.services.query.QueryResultWrapper;
1212
import org.jahia.services.render.RenderContext;
@@ -19,7 +19,9 @@
1919
import javax.jcr.RepositoryException;
2020
import javax.jcr.query.Query;
2121
import javax.servlet.http.HttpServletRequest;
22-
import java.util.*;
22+
import java.util.HashMap;
23+
import java.util.List;
24+
import java.util.Map;
2325

2426
/**
2527
* Jahia action to be called on a site to check integrity of its content
@@ -28,8 +30,6 @@ public class VerifyIntegrityOfSiteContent extends Action {
2830

2931
private static Logger LOGGER = org.slf4j.LoggerFactory.getLogger(VerifyIntegrityOfSiteContent.class);
3032

31-
private static final String PARAM_MULTI_LOCALE_CHECK = "performMultiLocaleVerification";
32-
3333
private VerifyIntegrityService verifyIntegrityService;
3434

3535
public void setVerifyIntegrityService(VerifyIntegrityService verifyIntegrityService) {
@@ -40,54 +40,20 @@ public void setVerifyIntegrityService(VerifyIntegrityService verifyIntegrityServ
4040
public ActionResult doExecute(HttpServletRequest req, RenderContext renderContext, Resource resource, JCRSessionWrapper session, Map<String, List<String>> parameters, URLResolver urlResolver) throws Exception {
4141
final JCRSiteNode siteNode = renderContext.getSite();
4242

43-
LOGGER.debug("VerifyIntegrityOfSiteContent action has been called on site : " + siteNode.getName());
4443

45-
CompositeIntegrityViolationException cive = new CompositeIntegrityViolationException();
44+
LOGGER.debug("VerifyIntegrityOfSiteContent action has been called on site : " + siteNode.getName());
4645

47-
boolean performMultiLocaleVerification = Boolean.parseBoolean(getParameter(parameters,
48-
PARAM_MULTI_LOCALE_CHECK, "true"));
49-
List<Locale> localesToCheck;
50-
if (performMultiLocaleVerification) {
51-
localesToCheck = siteNode.getLanguagesAsLocales();
52-
}
53-
else {
54-
localesToCheck = new ArrayList();
55-
localesToCheck.add(session.getLocale());
56-
}
46+
CompositeIntegrityViolationException cive = null;
5747

58-
for (Locale locale : localesToCheck) {
59-
CompositeIntegrityViolationException civeForThisLocale = (((CompositeIntegrityViolationException)
60-
JCRTemplate.getInstance()
61-
.doExecuteWithSystemSession
62-
(null,
63-
Constants.EDIT_WORKSPACE, locale, new JCRCallback
64-
() {
65-
@Override
66-
public CompositeIntegrityViolationException doInJCR(JCRSessionWrapper sessionTemp) throws
67-
RepositoryException {
68-
LOGGER.debug("Locale : " + sessionTemp.getLocale());
69-
70-
CompositeIntegrityViolationException civeTemp = null;
71-
72-
try {
73-
Query query = sessionTemp.getWorkspace().getQueryManager().createQuery("SELECT * FROM [jnt:content] WHERE " +
74-
"ISDESCENDANTNODE('" + siteNode.getPath() + "')", Query.JCR_SQL2);
75-
QueryResultWrapper queryResult = (QueryResultWrapper) query.execute();
76-
for (Node node : queryResult.getNodes()) {
77-
civeTemp = verifyIntegrityService.validateNodeIntegrity((JCRNodeWrapper) node, sessionTemp,
78-
civeTemp);
79-
}
80-
} catch (RepositoryException e) {
81-
e.printStackTrace();
82-
}
83-
84-
return civeTemp;
85-
}
86-
})));
87-
88-
if ((civeForThisLocale != null) && (civeForThisLocale.getErrors() != null)) {
89-
cive.addExceptions(civeForThisLocale.getErrors());
48+
try {
49+
Query query = session.getWorkspace().getQueryManager().createQuery("SELECT * FROM [jnt:content] WHERE " +
50+
"ISDESCENDANTNODE('" + siteNode.getPath() + "')", Query.JCR_SQL2);
51+
QueryResultWrapper queryResult = (QueryResultWrapper) query.execute();
52+
for (Node node : queryResult.getNodes()) {
53+
cive = verifyIntegrityService.validateNodeIntegrity((JCRNodeWrapper) node, session, cive);
9054
}
55+
} catch (RepositoryException e) {
56+
e.printStackTrace();
9157
}
9258

9359
Map<String, String> resultAsMap = new HashMap();

0 commit comments

Comments
 (0)