cvs commit: jakarta-struts/src/share/org/apache/struts/config ActionConfigMatcher.java
martinc 2004/03/22 22:27:06 Modified:src/share/org/apache/struts/config ActionConfigMatcher.java Log: Make ActionConfigMatcher$Mapping serializable. PR: 27376 Submitted by: Fabio Grassi Revision ChangesPath 1.10 +4 -4 jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java Index: ActionConfigMatcher.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- ActionConfigMatcher.java 14 Mar 2004 06:23:47 - 1.9 +++ ActionConfigMatcher.java 23 Mar 2004 06:27:06 - 1.10 @@ -211,7 +211,7 @@ /** * Stores a compiled wildcard pattern and the ActionConfig it came from. */ -private class Mapping { +private class Mapping implements Serializable { /** The compiled pattern. */ private int[] pattern; - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-struts/src/share/org/apache/struts/config ActionConfigMatcher.java
husted 2004/02/14 02:39:31 Modified:src/share/org/apache/struts/config ActionConfigMatcher.java Log: Apply #26192 "[Wildcard] redirect not honored" submitted by Akos Maroy. Revision ChangesPath 1.8 +4 -3 jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java Index: ActionConfigMatcher.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ActionConfigMatcher.java 10 Jan 2004 21:29:12 - 1.7 +++ ActionConfigMatcher.java 14 Feb 2004 10:39:31 - 1.8 @@ -205,6 +205,7 @@ cfg.setContextRelative(fConfigs[x].getContextRelative()); cfg.setName(fConfigs[x].getName()); cfg.setPath(convertParam(fConfigs[x].getPath(), vars)); +cfg.setRedirect(fConfigs[x].getRedirect()); config.removeForwardConfig(fConfigs[x]); config.addForwardConfig(cfg); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-struts/src/share/org/apache/struts/config ActionConfigMatcher.java
dgraham 2004/01/10 13:29:12 Modified:src/share/org/apache/struts/util WildcardHelper.java src/share/org/apache/struts/config ActionConfigMatcher.java Log: Changed WildcardHelper methods from statics to instance methods to allow subclasses to override and customize behavior. Changed WildcardHelper.match() to accept a generic Map parameter rather than HashMap. Revision ChangesPath 1.4 +19 -16 jakarta-struts/src/share/org/apache/struts/util/WildcardHelper.java Index: WildcardHelper.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/WildcardHelper.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- WildcardHelper.java 10 Jan 2004 21:20:48 - 1.3 +++ WildcardHelper.java 10 Jan 2004 21:29:12 - 1.4 @@ -61,25 +61,29 @@ package org.apache.struts.util; -import java.util.HashMap; +import java.util.Map; /** * This class is an utility class that perform wilcard-patterns matching and * isolation taken from Apache Cocoon. * - * (Apache Software Foundation) + * @since Struts 1.2 * @version CVS $Id$ */ public class WildcardHelper { /** The int representing '*' in the pattern int []. */ protected static final int MATCH_FILE = -1; + /** The int representing '**' in the pattern int []. */ protected static final int MATCH_PATH = -2; + /** The int representing begin in the pattern int []. */ protected static final int MATCH_BEGIN = -4; + /** The int representing end in pattern int []. */ protected static final int MATCH_THEEND = -5; + /** The int value that terminates the pattern int []. */ protected static final int MATCH_END = -3; @@ -117,8 +121,7 @@ * value (don't consider the array length). * @exception NullPointerException If data is null. */ -public static int[] compilePattern(String data) -throws NullPointerException { +public int[] compilePattern(String data) { // Prepare the arrays int expr[] = new int[data.length() + 2]; @@ -182,8 +185,7 @@ * @return True if a match * @throws NullPointerException If any parameters are null */ -public static boolean match (HashMap map, String data, -int[] expr) throws NullPointerException { +public boolean match(Map map, String data, int[] expr) { if (map == null) { throw new NullPointerException ("No map provided"); } @@ -315,7 +317,7 @@ } } -/** + /** * Get the offset of a part of an int array within a char array. * * This method return the index in d of the first occurrence after dpos of @@ -330,8 +332,9 @@ * @return The offset in d of the part of r matched in d or -1 if that was * not found. */ -protected static int indexOfArray (int r[], int rpos, int rend, +protected int indexOfArray (int r[], int rpos, int rend, char d[], int dpos) { + // Check if pos and len are legal if (rend < rpos) { throw new IllegalArgumentException ("rend < rpos"); @@ -372,7 +375,7 @@ return (-1); } -/** + /** * Get the offset of a last occurance of an int array within a char array. * * This method return the index in d of the last occurrence after dpos of @@ -387,7 +390,7 @@ * @return The offset in d of the last part of r matched in d or -1 if * that was not found. */ -protected static int lastIndexOfArray (int r[], int rpos, int rend, +protected int lastIndexOfArray (int r[], int rpos, int rend, char d[], int dpos) { // Check if pos and len are legal if (rend < rpos) { @@ -432,7 +435,7 @@ return (-1); } -/** + /** * Matches elements of array r from rpos to rend with array d, starting * from dpos. * @@ -446,7 +449,7 @@ * @param dpos The starting offset in d for the matching. * @return true if array d starts from portion of array r. */ -protected static boolean matchArray (int r[], int rpos, int rend, +protected boolean matchArray (int r[], int rpos, int rend, char d[], int dpos) { if (d.length - dpos < rend - rpos) { return (false); 1.7 +17 -12 jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java Index: ActionConfigMatcher.java === RCS file: /home/cvs/jakarta-struts/src
cvs commit: jakarta-struts/src/share/org/apache/struts/config ActionConfigMatcher.java
mrdon 2004/01/05 10:50:00 Modified:src/share/org/apache/struts/config ActionConfigMatcher.java Log: Better handle case when path attribute is empty PR: 25909 Submitted by: Roberto Tyley Revision ChangesPath 1.5 +4 -4 jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java Index: ActionConfigMatcher.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ActionConfigMatcher.java 25 Oct 2003 01:39:54 - 1.4 +++ ActionConfigMatcher.java 5 Jan 2004 18:49:59 - 1.5 @@ -182,7 +182,7 @@ } config.setName(convertParam(orig.getName(), vars)); -if (path.charAt(0) != '/') { +if (path.length() == 0 || path.charAt(0) != '/') { path = "/" + path; } config.setPath(path); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-struts/src/share/org/apache/struts/config ActionConfigMatcher.java
mrdon 2003/10/24 18:39:54 Modified:src/share/org/apache/struts/config ActionConfigMatcher.java Log: Made serializable as it is sometimes serialized with action forms Revision ChangesPath 1.4 +5 -4 jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java Index: ActionConfigMatcher.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ActionConfigMatcher.java 18 Oct 2003 02:48:16 - 1.3 +++ ActionConfigMatcher.java 25 Oct 2003 01:39:54 - 1.4 @@ -61,6 +61,7 @@ package org.apache.struts.config; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -82,7 +83,7 @@ * * @authorDon Brown */ -public class ActionConfigMatcher { +public class ActionConfigMatcher implements Serializable { /** * The logging instance - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-struts/src/share/org/apache/struts/config ActionConfigMatcher.java
mrdon 2003/10/17 19:48:16 Modified:src/share/org/apache/struts/config ActionConfigMatcher.java Log: Better error checking Revision ChangesPath 1.3 +1 -1 jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java Index: ActionConfigMatcher.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ActionConfigMatcher.java 10 Oct 2003 23:19:57 - 1.2 +++ ActionConfigMatcher.java 18 Oct 2003 02:48:16 - 1.3 @@ -110,7 +110,7 @@ String path; for (int x = 0; x < configs.length; x++) { path = configs[x].getPath(); -if (path.indexOf('*') > -1) { +if (path != null && path.indexOf('*') > -1) { if (path.length() > 0 && path.charAt(0) == '/') { path = path.substring(1); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-struts/src/share/org/apache/struts/config ActionConfigMatcher.java
mrdon 2003/10/10 16:19:57 Modified:src/test/org/apache/struts/config TestActionConfigMatcher.java src/share/org/apache/struts/config ActionConfigMatcher.java Log: Added more unit tests and fixed a bug they discovered (ExceptionConfigs not being copied over) Revision ChangesPath 1.2 +29 -5 jakarta-struts/src/test/org/apache/struts/config/TestActionConfigMatcher.java Index: TestActionConfigMatcher.java === RCS file: /home/cvs/jakarta-struts/src/test/org/apache/struts/config/TestActionConfigMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestActionConfigMatcher.java 10 Oct 2003 22:09:26 - 1.1 +++ TestActionConfigMatcher.java 10 Oct 2003 23:19:57 - 1.2 @@ -167,7 +167,10 @@ configs[0] = mapping; ActionConfigMatcher matcher = new ActionConfigMatcher(configs); -assertNotNull("ActionConfig should be matched", matcher.match("/fooBar")); +ActionConfig matched = matcher.match("/fooBar"); +assertNotNull("ActionConfig should be matched", matched); +assertTrue("ActionConfig should have two action forward", matched.findForwardConfigs().length == 2); +assertTrue("ActionConfig should have two exception forward", matched.findExceptionConfigs().length == 2); } public void testCheckSubstitutionsMatch() { @@ -219,12 +222,33 @@ mapping.setInclude("include,{1}"); mapping.setInput("input,{1}"); -ForwardConfig[] fConfigs = mapping.findForwardConfigs(); ForwardConfig cfg = new ActionForward(); cfg.setContextRelative(true); cfg.setName("name"); cfg.setPath("path,{1}"); mapping.addForwardConfig(cfg); + +cfg = new ActionForward(); +cfg.setContextRelative(true); +cfg.setName("name2"); +cfg.setPath("path2"); +mapping.addForwardConfig(cfg); + +ExceptionConfig excfg = new ExceptionConfig(); +excfg.setKey("foo"); +excfg.setType("foo.Bar"); +excfg.setPath("path"); +mapping.addExceptionConfig(excfg); + +excfg = new ExceptionConfig(); +excfg.setKey("foo2"); +excfg.setType("foo.Bar2"); +excfg.setPath("path2"); +mapping.addExceptionConfig(excfg); + + +mapping.freeze(); + return mapping; } 1.2 +8 -0 jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java Index: ActionConfigMatcher.java === RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ActionConfigMatcher.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ActionConfigMatcher.java 10 Oct 2003 22:03:33 - 1.1 +++ ActionConfigMatcher.java 10 Oct 2003 23:19:57 - 1.2 @@ -203,6 +203,14 @@ config.removeForwardConfig(fConfigs[x]); config.addForwardConfig(cfg); } + +ExceptionConfig[] exConfigs = orig.findExceptionConfigs(); +for (int x = 0; x < exConfigs.length; x++) { +config.addExceptionConfig(exConfigs[x]); +} + +config.freeze(); + return config; } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]