struts git commit: replaced constants for marking status with enum
Repository: struts Updated Branches: refs/heads/master 7873eb910 -> 45c113eaa replaced constants for marking status with enum Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/45c113ea Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/45c113ea Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/45c113ea Branch: refs/heads/master Commit: 45c113eaa98554ab1ca8d3d184968095e1ac3cca Parents: 7873eb9 Author: Stefaan Dutry Authored: Fri Sep 16 08:17:38 2016 +0200 Committer: Stefaan Dutry Committed: Fri Sep 16 08:17:38 2016 +0200 -- .../xwork2/config/providers/CycleDetector.java | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts/blob/45c113ea/core/src/main/java/com/opensymphony/xwork2/config/providers/CycleDetector.java -- diff --git a/core/src/main/java/com/opensymphony/xwork2/config/providers/CycleDetector.java b/core/src/main/java/com/opensymphony/xwork2/config/providers/CycleDetector.java index 82a7266..0e45f5d 100644 --- a/core/src/main/java/com/opensymphony/xwork2/config/providers/CycleDetector.java +++ b/core/src/main/java/com/opensymphony/xwork2/config/providers/CycleDetector.java @@ -6,11 +6,11 @@ import java.util.List; import java.util.Map; public class CycleDetector { -private static final String marked = "marked"; -private static final String complete = "complete"; private DirectedGraph graph; -private Map marks; +private Map marks; private List verticesInCycles; + +private enum Status { MARKED, COMPLETE }; public CycleDetector(DirectedGraph graph) { this.graph = graph; @@ -35,9 +35,9 @@ public class CycleDetector { * return statements commented out for fail slow behavior detect all nodes in cycles instead of just the first one */ List localCycles = new ArrayList(); -marks.put(vertex, marked); +marks.put(vertex, Status.MARKED); for (T u : graph.edgesFrom(vertex)) { -if (marks.containsKey(u) && marks.get(u).equals(marked)) { +if (marks.get(u) == Status.MARKED) { localCycles.add(vertex); // return true; } else if (!marks.containsKey(u)) { @@ -47,7 +47,7 @@ public class CycleDetector { } } } -marks.put(vertex, complete); +marks.put(vertex, Status.COMPLETE); // return false; verticesInCycles.addAll(localCycles); return !localCycles.isEmpty();
[2/3] struts git commit: WW-4685 Uses dedicated prefixes to access I18N and Struts internals
WW-4685 Uses dedicated prefixes to access I18N and Struts internals Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/431e50e9 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/431e50e9 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/431e50e9 Branch: refs/heads/support-2-3 Commit: 431e50e92242b24b98f36eaec9ac84c938bb82b6 Parents: 156db8e Author: Lukasz Lenart Authored: Wed Sep 7 09:27:43 2016 +0200 Committer: Lukasz Lenart Committed: Fri Sep 16 16:00:45 2016 +0200 -- .../struts2/tiles/I18NAttributeEvaluator.java | 68 .../struts2/tiles/StrutsAttributeEvaluator.java | 33 ++ .../tiles/StrutsTilesContainerFactory.java | 9 ++- 3 files changed, 80 insertions(+), 30 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts/blob/431e50e9/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java -- diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java new file mode 100644 index 000..37150ae --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.struts2.tiles; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.LocaleProvider; +import com.opensymphony.xwork2.TextProvider; +import com.opensymphony.xwork2.TextProviderFactory; +import com.opensymphony.xwork2.config.ConfigurationException; +import com.opensymphony.xwork2.ognl.OgnlUtil; +import ognl.OgnlException; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.struts2.ServletActionContext; +import org.apache.tiles.evaluator.AbstractAttributeEvaluator; +import org.apache.tiles.evaluator.EvaluationException; +import org.apache.tiles.request.Request; +import org.apache.tiles.request.servlet.ServletUtil; + +import javax.servlet.http.HttpServletRequest; + +public class I18NAttributeEvaluator extends AbstractAttributeEvaluator { + +private static final Logger LOG = LogManager.getLogger(I18NAttributeEvaluator.class); + +@Override +public Object evaluate(String expression, Request request) { +Object result = expression; + +HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest(); +ActionContext ctx = ServletActionContext.getActionContext(httpRequest); + +if (ctx == null) { +LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName()); +throw new ConfigurationException("There is no ActionContext for current request!"); +} + +TextProviderFactory tpf = new TextProviderFactory(); +ctx.getContainer().inject(tpf); +LocaleProvider localeProvider = ctx.getContainer().getInstance(LocaleProvider.class); + +TextProvider textProvider = tpf.createInstance(ctx.getActionInvocation().getAction().getClass(), localeProvider); + +if (textProvider != null) { +LOG.debug("Trying find text [{}] using TextProvider {}", expression, textProvider); +result = textProvider.getText(expression); +} +return result; +} + +} http://git-wip-us.apache.org/repos/asf/struts/blob/431e50e9/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java -- diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java index 8b98ab2..b4ef56a 100644 --- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java +++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java @@ -20,
[3/3] struts git commit: WW-4685 Adjusts cherry pick to 2.3.x
WW-4685 Adjusts cherry pick to 2.3.x Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/81371e09 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/81371e09 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/81371e09 Branch: refs/heads/support-2-3 Commit: 81371e09c54a1ba9c2d4d3207567263cc6e62474 Parents: 431e50e Author: Lukasz Lenart Authored: Fri Sep 16 16:07:59 2016 +0200 Committer: Lukasz Lenart Committed: Fri Sep 16 16:07:59 2016 +0200 -- .../struts2/tiles/I18NAttributeEvaluator.java| 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts/blob/81371e09/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java -- diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java index 37150ae..29b7ad2 100644 --- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java +++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/I18NAttributeEvaluator.java @@ -24,24 +24,21 @@ import com.opensymphony.xwork2.LocaleProvider; import com.opensymphony.xwork2.TextProvider; import com.opensymphony.xwork2.TextProviderFactory; import com.opensymphony.xwork2.config.ConfigurationException; -import com.opensymphony.xwork2.ognl.OgnlUtil; -import ognl.OgnlException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; +import com.opensymphony.xwork2.util.logging.Logger; +import com.opensymphony.xwork2.util.logging.LoggerFactory; import org.apache.struts2.ServletActionContext; +import org.apache.tiles.context.TilesRequestContext; import org.apache.tiles.evaluator.AbstractAttributeEvaluator; -import org.apache.tiles.evaluator.EvaluationException; -import org.apache.tiles.request.Request; -import org.apache.tiles.request.servlet.ServletUtil; +import org.apache.tiles.servlet.context.ServletUtil; import javax.servlet.http.HttpServletRequest; +import java.util.Map; public class I18NAttributeEvaluator extends AbstractAttributeEvaluator { -private static final Logger LOG = LogManager.getLogger(I18NAttributeEvaluator.class); +private static final Logger LOG = LoggerFactory.getLogger(I18NAttributeEvaluator.class); -@Override -public Object evaluate(String expression, Request request) { +public Object evaluate(String expression, TilesRequestContext request) { Object result = expression; HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest(); @@ -65,4 +62,6 @@ public class I18NAttributeEvaluator extends AbstractAttributeEvaluator { return result; } +public void init(Map initParameters) { +} }
[1/3] struts git commit: WW-4685 Supports evaluating expressions from tiles definitions as a Struts values
Repository: struts Updated Branches: refs/heads/support-2-3 6f5ddca47 -> 81371e09c WW-4685 Supports evaluating expressions from tiles definitions as a Struts values Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/156db8e5 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/156db8e5 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/156db8e5 Branch: refs/heads/support-2-3 Commit: 156db8e5dfb82c394564d8268d9ef553f28356af Parents: 6f5ddca Author: Lukasz Lenart Authored: Tue Sep 6 21:33:31 2016 +0200 Committer: Lukasz Lenart Committed: Fri Sep 16 16:00:27 2016 +0200 -- .../struts2/tiles/StrutsAttributeEvaluator.java | 91 .../tiles/StrutsTilesContainerFactory.java | 24 +- 2 files changed, 111 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts/blob/156db8e5/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java -- diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java new file mode 100644 index 000..8b98ab2 --- /dev/null +++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsAttributeEvaluator.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.struts2.tiles; + +import com.opensymphony.xwork2.ActionContext; +import com.opensymphony.xwork2.LocaleProvider; +import com.opensymphony.xwork2.TextProvider; +import com.opensymphony.xwork2.TextProviderFactory; +import com.opensymphony.xwork2.config.ConfigurationException; +import com.opensymphony.xwork2.ognl.OgnlUtil; +import com.opensymphony.xwork2.util.logging.Logger; +import com.opensymphony.xwork2.util.logging.LoggerFactory; +import ognl.OgnlException; +import org.apache.struts2.ServletActionContext; +import org.apache.tiles.context.TilesRequestContext; +import org.apache.tiles.evaluator.AbstractAttributeEvaluator; +import org.apache.tiles.evaluator.EvaluationException; +import org.apache.tiles.servlet.context.ServletUtil; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +public class StrutsAttributeEvaluator extends AbstractAttributeEvaluator { + +private static final Logger LOG = LoggerFactory.getLogger(StrutsAttributeEvaluator.class); + +public Object evaluate(String expression, TilesRequestContext request) { +try { +Object result = null; + +HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest(); +ActionContext ctx = ServletActionContext.getActionContext(httpRequest); + +if (ctx == null) { +LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName()); +throw new ConfigurationException("There is no ActionContext for current request!"); +} + +TextProviderFactory tpf = new TextProviderFactory(); +ctx.getContainer().inject(tpf); +LocaleProvider localeProvider = ctx.getContainer().getInstance(LocaleProvider.class); + +TextProvider textProvider = tpf.createInstance(ctx.getActionInvocation().getAction().getClass(), localeProvider); + +if (textProvider != null) { +LOG.debug("Trying find text [{}] using TextProvider {}", expression, textProvider); +result = textProvider.getText(expression); +if (expression.equals(result)) { +LOG.debug("Could not evaluate expression [{}] as a I18N key", expression); +result = null; +} +} + +if (result == null) { +OgnlUtil ognlUtil = ctx.getContainer().getInstance(OgnlUtil.class); +LOG.debug("Trying evaluate expression [{}] using OgnlUtil's getValue", expression); +result = ognlUtil.getVal
struts git commit: WW-4674 Uses the same logic as in Dispatcher to control handling exception
Repository: struts Updated Branches: refs/heads/master 45c113eaa -> 459e19802 WW-4674 Uses the same logic as in Dispatcher to control handling exception Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/459e1980 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/459e1980 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/459e1980 Branch: refs/heads/master Commit: 459e198022e8b96e9c3d5f97b1d4c428794ffb96 Parents: 45c113e Author: Lukasz Lenart Authored: Fri Sep 16 16:31:17 2016 +0200 Committer: Lukasz Lenart Committed: Fri Sep 16 16:31:17 2016 +0200 -- .../java/org/apache/struts2/dispatcher/Dispatcher.java| 10 +- .../org/apache/struts2/dispatcher/PrepareOperations.java | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts/blob/459e1980/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java -- diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index 728498f..2bc1901 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -216,7 +216,11 @@ public class Dispatcher { */ @Inject(StrutsConstants.STRUTS_DEVMODE) public void setDevMode(String mode) { -devMode = "true".equals(mode); +devMode = Boolean.parseBoolean(mode); +} + +public boolean isDevMode() { +return devMode; } /** @@ -270,6 +274,10 @@ public class Dispatcher { this.handleException = Boolean.parseBoolean(handleException); } +public boolean isHandleException() { +return handleException; +} + @Inject public void setDispatcherErrorHandler(DispatcherErrorHandler errorHandler) { this.errorHandler = errorHandler; http://git-wip-us.apache.org/repos/asf/struts/blob/459e1980/core/src/main/java/org/apache/struts2/dispatcher/PrepareOperations.java -- diff --git a/core/src/main/java/org/apache/struts2/dispatcher/PrepareOperations.java b/core/src/main/java/org/apache/struts2/dispatcher/PrepareOperations.java index efa4ea7..8bfb954 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/PrepareOperations.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/PrepareOperations.java @@ -188,7 +188,9 @@ public class PrepareOperations { request.setAttribute(STRUTS_ACTION_MAPPING_KEY, mapping); } } catch (Exception ex) { -dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); +if (dispatcher.isHandleException() || dispatcher.isDevMode()) { +dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); +} } }
struts git commit: WW-4674 Uses the same logic as in Dispatcher to control handling exception
Repository: struts Updated Branches: refs/heads/support-2-3 81371e09c -> b348fc552 WW-4674 Uses the same logic as in Dispatcher to control handling exception Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/b348fc55 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/b348fc55 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/b348fc55 Branch: refs/heads/support-2-3 Commit: b348fc552c3265707181db4a42a41abc72b98488 Parents: 81371e0 Author: Lukasz Lenart Authored: Fri Sep 16 16:31:17 2016 +0200 Committer: Lukasz Lenart Committed: Fri Sep 16 16:37:29 2016 +0200 -- .../java/org/apache/struts2/dispatcher/Dispatcher.java| 10 +- .../apache/struts2/dispatcher/ng/PrepareOperations.java | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts/blob/b348fc55/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java -- diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index 18e8a90..3af0690 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -211,7 +211,11 @@ public class Dispatcher { */ @Inject(StrutsConstants.STRUTS_DEVMODE) public void setDevMode(String mode) { -devMode = "true".equals(mode); +devMode = Boolean.parseBoolean(mode); +} + +public boolean isDevMode() { +return devMode; } /** @@ -265,6 +269,10 @@ public class Dispatcher { this.handleException = Boolean.parseBoolean(handleException); } +public boolean isHandleException() { +return handleException; +} + @Inject public void setDispatcherErrorHandler(DispatcherErrorHandler errorHandler) { this.errorHandler = errorHandler; http://git-wip-us.apache.org/repos/asf/struts/blob/b348fc55/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java -- diff --git a/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java b/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java index ebc8925..e92cef1 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java @@ -168,7 +168,9 @@ public class PrepareOperations { request.setAttribute(STRUTS_ACTION_MAPPING_KEY, mapping); } } catch (Exception ex) { -dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); +if (dispatcher.isHandleException() || dispatcher.isDevMode()) { +dispatcher.sendError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex); +} } }
struts git commit: WW-4679 Handles empty space in path
Repository: struts Updated Branches: refs/heads/master 459e19802 -> c570a2b2b WW-4679 Handles empty space in path Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/c570a2b2 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/c570a2b2 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/c570a2b2 Branch: refs/heads/master Commit: c570a2b2bda34632760f69e84c3877a6004c855b Parents: 459e198 Author: Lukasz Lenart Authored: Fri Sep 16 16:45:27 2016 +0200 Committer: Lukasz Lenart Committed: Fri Sep 16 16:45:27 2016 +0200 -- .../struts2/tiles/StrutsWildcardServletApplicationContext.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/struts/blob/c570a2b2/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java -- diff --git a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java index df6152b..abe90aa 100644 --- a/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java +++ b/plugins/tiles/src/main/java/org/apache/struts2/tiles/StrutsWildcardServletApplicationContext.java @@ -31,7 +31,6 @@ import javax.servlet.ServletContext; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; -import java.net.URI; import java.net.URL; import java.util.Collection; import java.util.Enumeration; @@ -100,9 +99,10 @@ public class StrutsWildcardServletApplicationContext extends ServletApplicationC public ApplicationResource getResource(ApplicationResource base, Locale locale) { String localePath = base.getLocalePath(locale); -if (new File(localePath).exists()) { +File localFile = new File(localePath); +if (localFile.exists()) { try { -return new StrutsApplicationResource(URI.create("file://" + localePath).toURL()); +return new StrutsApplicationResource(localFile.toURI().toURL()); } catch (MalformedURLException e) { LOG.warn("Cannot access [{}]", localePath, e); return null;