Author: asoldano
Date: 2014-05-28 12:37:14 -0400 (Wed, 28 May 2014)
New Revision: 18701
Added:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
stack/cxf/branches/rsearls/modules/server/src/test/java/org/jboss/wsf/stack/cxf/addressRewrite/
stack/cxf/branches/rsearls/modules/server/src/test/java/org/jboss/wsf/stack/cxf/addressRewrite/AddressRewriteTest.java
Removed:
stack/cxf/branches/rsearls/modules/resources/src/main/resources/modules/wildfly800/org/unix4j/
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/unix4j/
Modified:
stack/cxf/branches/rsearls/modules/dist/pom.xml
stack/cxf/branches/rsearls/modules/dist/src/main/scripts/assembly-deploy-artifacts.xml
stack/cxf/branches/rsearls/modules/resources/src/main/resources/modules/wildfly800/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml
stack/cxf/branches/rsearls/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml
stack/cxf/branches/rsearls/modules/server/pom.xml
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java
stack/cxf/branches/rsearls/pom.xml
Log:
- Removing dependency to unix4j and adding custom classes for SED processing
- Adding SED testcase
Modified: stack/cxf/branches/rsearls/modules/dist/pom.xml
===================================================================
--- stack/cxf/branches/rsearls/modules/dist/pom.xml 2014-05-28 01:41:29 UTC (rev 18700)
+++ stack/cxf/branches/rsearls/modules/dist/pom.xml 2014-05-28 16:37:14 UTC (rev 18701)
@@ -128,11 +128,6 @@
<artifactId>opensaml</artifactId>
<scope>provided</scope>
</dependency>
- <!-- Java Sed utilities -->
- <dependency>
- <groupId>org.unix4j</groupId>
- <artifactId>unix4j-base</artifactId>
- </dependency>
<!-- container integration -->
<dependency>
<groupId>org.jboss.ws</groupId>
Modified:
stack/cxf/branches/rsearls/modules/dist/src/main/scripts/assembly-deploy-artifacts.xml
===================================================================
---
stack/cxf/branches/rsearls/modules/dist/src/main/scripts/assembly-deploy-artifacts.xml 2014-05-28
01:41:29 UTC (rev 18700)
+++
stack/cxf/branches/rsearls/modules/dist/src/main/scripts/assembly-deploy-artifacts.xml 2014-05-28
16:37:14 UTC (rev 18701)
@@ -67,8 +67,6 @@
<include>javax.jws:jsr181-api:jar</include>
<include>org.codehaus.woodstox:stax2-api:jar</include>
<include>org.codehaus.woodstox:woodstox-core-asl:jar</include>
- <include>org.unix4j:unix4j-base:jar</include>
- <include>org.unix4j:unix4j-command:jar</include>
</includes>
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
<useProjectArtifact>false</useProjectArtifact>
Modified:
stack/cxf/branches/rsearls/modules/resources/src/main/resources/modules/wildfly800/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml
===================================================================
---
stack/cxf/branches/rsearls/modules/resources/src/main/resources/modules/wildfly800/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml 2014-05-28
01:41:29 UTC (rev 18700)
+++
stack/cxf/branches/rsearls/modules/resources/src/main/resources/modules/wildfly800/org/jboss/ws/cxf/jbossws-cxf-server/main/module.xml 2014-05-28
16:37:14 UTC (rev 18701)
@@ -74,6 +74,5 @@
<include path="META-INF"/>
</imports>
</module>
- <module name="org.unix4j"/>
</dependencies>
</module>
Modified:
stack/cxf/branches/rsearls/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml
===================================================================
---
stack/cxf/branches/rsearls/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml 2014-05-28
01:41:29 UTC (rev 18700)
+++
stack/cxf/branches/rsearls/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml 2014-05-28
16:37:14 UTC (rev 18701)
@@ -130,11 +130,6 @@
<include name="**/jbossws-(a){jbossid}-server-integration.jar"/>
</fileset>
</copy>
- <copy todir="@{targetdir}/org/unix4j/main" flatten="false"
overwrite="true">
- <fileset dir="@{thirdpartydir}/lib">
- <include name="**/unix4j*.jar"/>
- </fileset>
- </copy>
<!-- module.xml files -->
<installModules targetDir="@{targetdir}">
<fileset dir="@{thirdpartydir}/modules/@{modules-jbossid}">
Modified: stack/cxf/branches/rsearls/modules/server/pom.xml
===================================================================
--- stack/cxf/branches/rsearls/modules/server/pom.xml 2014-05-28 01:41:29 UTC (rev 18700)
+++ stack/cxf/branches/rsearls/modules/server/pom.xml 2014-05-28 16:37:14 UTC (rev 18701)
@@ -253,12 +253,6 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.unix4j</groupId>
- <artifactId>unix4j-base</artifactId>
- </dependency>
-
</dependencies>
<!-- Plugins -->
Added:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
(rev 0)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java 2014-05-28
16:37:14 UTC (rev 18701)
@@ -0,0 +1,83 @@
+package org.jboss.wsf.stack.cxf.addressRewrite;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A map from char to char. The mappings for the most common 256 source
+ * characters are simply kept in a char array. For all other more exotic source
+ * characters, a proper hash map is used to store the mapping.
+ */
+class CharMap {
+
+ private final char[] map = new char[256];
+ private final Map<Character, Character> extendedMap = new HashMap<Character,
Character>();
+
+ /**
+ * Creates a char map with the given source and destination characters. If
+ * the strings do not have the same length, subsequent characters in the
+ * longer string are ignored. The first mapping is defined as
+ * {@code source[0] --> destination[0]}, all other mappings in an analogous
+ * way with matching character indices in the two strings.
+ *
+ * @param source
+ * source characters
+ * @param destination
+ * destination characters
+ * @throws IllegalArgumentException
+ * if any of the destination characters is the zero character
+ */
+ public CharMap(String source, String destination) {
+ add(source, destination);
+ }
+
+ /**
+ * Adds the given source and destination characters to this char map.. If
+ * the strings do not have the same length, subsequent characters in the
+ * longer string are ignored. The first mapping is defined as
+ * {@code source[0] --> destination[0]}, all other mappings in an analogous
+ * way with matching character indices in the two strings.
+ *
+ * @param source
+ * source characters
+ * @param destination
+ * destination characters
+ * @throws IllegalArgumentException
+ * if any of the destination characters is the zero character
+ */
+ public void add(String source, String destination) {
+ final int len = Math.min(source.length(), destination.length());
+ for (int i = 0; i < len; i++) {
+ add(source.charAt(i), destination.charAt(i));
+ }
+ }
+
+ /**
+ * Adds the given mapping {@code source --> destination} to this char map.
+ *
+ * @param source
+ * source character
+ * @param destination
+ * destination character
+ * @throws IllegalArgumentException
+ * if the destination character is the zero character
+ */
+ public void add(char source, char destination) {
+ if (destination == 0) {
+ throw new IllegalArgumentException("cannot map to zero character");
+ }
+ if (source < 256) {
+ map[source] = destination;
+ } else {
+ extendedMap.put(source, destination);
+ }
+ }
+
+ public char map(char source) {
+ if (source < 256) {
+ return map[source];
+ }
+ final Character mapped = extendedMap.get(source);
+ return mapped == null ? 0 : mapped.charValue();
+ }
+}
Property changes on:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/CharMap.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
(rev 0)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java 2014-05-28
16:37:14 UTC (rev 18701)
@@ -0,0 +1,414 @@
+package org.jboss.wsf.stack.cxf.addressRewrite;
+
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class SEDProcessor {
+
+ private static enum SEDCommand {
+ SUBSTITUTE, TRANSLATE
+ }
+
+ private static final int[] EMPTY_OCCURRENCE = new int[0];
+
+ private final SEDCommand command;
+ private final String replacement;
+ private final int[] occurrences;
+ private final Pattern regexp;
+ private final SedArguments args;
+ private final CharMap charMap;
+
+ private SEDProcessor(String script, SEDCommand command)
+ {
+ this.command = command;
+ this.args = deriveArgs(script);
+ if (args.isIgnoreCase())
+ {
+ this.regexp = Pattern.compile(getRegexp(args), Pattern.CASE_INSENSITIVE);
+ }
+ else
+ {
+ this.regexp = Pattern.compile(getRegexp(args));
+ }
+ this.replacement = getReplacement(args);
+ this.occurrences = args.isOccurrenceSet() ? args.getOccurrence() :
EMPTY_OCCURRENCE;
+ for (int i = 0; i < occurrences.length; i++)
+ {
+ if (occurrences[i] <= 0)
+ {
+ throw new IllegalArgumentException("invalid occurrence index " +
occurrences[i] + " in sed command");
+ }
+ }
+ Arrays.sort(occurrences);
+ if (command == SEDCommand.TRANSLATE)
+ {
+ this.charMap = new CharMap(args.getString1(), args.getString2());
+ }
+ else
+ {
+ this.charMap = null;
+ }
+ }
+
+ /**
+ * Returns the regexp operand from args, either called "regexp" or
+ * "string1". If none of the two is set, an empty string is returned.
+ *
+ * @param args
+ * the args with operand values
+ * @return the regexp argument from "regexp" or "string1" or an
empty string
+ * of none of the two operands is set
+ */
+ private static String getRegexp(SedArguments args)
+ {
+ if (args.isRegexpSet())
+ {
+ return args.getRegexp();
+ }
+ if (args.isString1Set())
+ {
+ return args.getString1();
+ }
+ return "";
+ }
+
+ /**
+ * Returns the replacement operand from args, either called "replacement"
or
+ * "string2". If none of the two is set, an empty string is returned.
+ *
+ * @param args
+ * the args with operand values
+ * @return the replacement argument from "replacement" or
"string2" or an
+ * empty string of none of the two operands is set
+ */
+ private static String getReplacement(SedArguments args)
+ {
+ if (args.isReplacementSet())
+ {
+ return args.getReplacement();
+ }
+ if (args.isString2Set())
+ {
+ return args.getString2();
+ }
+ return "";
+ }
+
+ private SedArguments deriveArgs(String script)
+ {
+ final int start = findStartTrimWhitespace(script) + 1;
+ final int mid = indexOfNextDelimiter(script, start);
+ final int end = indexOfNextDelimiter(script, mid);
+ if (mid < 0 || end < 0)
+ {
+ throw new IllegalArgumentException("invalid script for sed command: "
+ script);
+ }
+ if (command == SEDCommand.SUBSTITUTE)
+ {
+ SedArguments args = parseSubstituteFlags(script, end + 1);
+ args.setRegexp(script.substring(start + 1, mid));
+ args.setReplacement(script.substring(mid + 1, end));
+ return args;
+ }
+ else if (command == SEDCommand.TRANSLATE)
+ {
+ SedArguments args = new SedArguments();
+ args.setScript(script);
+ args.setTranslate(true);
+ final int scriptEnd = findEndTrimWhitespace(script);
+ if (end + 1 < scriptEnd)
+ {
+ throw new IllegalArgumentException("non-whitespace characters found
after " + command + " command in sed script: " + script);
+ }
+ args.setString1(script.substring(start + 1, mid));
+ args.setString2(script.substring(mid + 1, end));
+ return args;
+ }
+ else
+ {
+ throw new IllegalStateException();
+ }
+ }
+
+ private static SedArguments parseSubstituteFlags(String script, int start)
+ {
+ final int end = findWhitespace(script, start);
+ if (end < findEndTrimWhitespace(script))
+ {
+ throw new IllegalArgumentException("extra non-whitespace characters found
after substitute command in sed script: " + script);
+ }
+ SedArguments args = new SedArguments();
+ args.setScript(script);
+ args.setSubstitute(true);
+ if (start < end)
+ {
+ //g, I flags
+ int index;
+ for (index = end - 1; index >= start; index--)
+ {
+ final char flag = script.charAt(index);
+ if (flag == 'g')
+ {
+ args.setGlobal(true);
+ }
+ else if (flag == 'I')
+ {
+ args.setIgnoreCase(true);
+ }
+ else
+ {
+ break;
+ }
+ }
+ //occurrence index
+ if (index >= start)
+ {
+ final String occurrenceStr = script.substring(start, index + 1);
+ final int occurrence;
+ try
+ {
+ occurrence = Integer.parseInt(occurrenceStr);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException("invalid substitute flags in sed
script: " + script, e);
+ }
+ if (occurrence <= 0)
+ {
+ throw new IllegalArgumentException("invalid occurrence index " +
occurrence + " in sed script: " + script);
+ }
+ args.setOccurrence(occurrence);
+ }
+ }
+ return args;
+ }
+
+ public String processLine(String line)
+ {
+ if (command == SEDCommand.SUBSTITUTE)
+ {
+ final Matcher matcher = regexp.matcher(line);
+ if (matcher.find())
+ {
+ boolean matches = true;
+ final StringBuffer changed = new StringBuffer();//cannot use StringBuilder
here since matcher does not support it
+ if (occurrences.length > 0)
+ {
+ int current = 1;
+ for (int i = 0; i < occurrences.length; i++)
+ {
+ final int occurrence = occurrences[i];
+ while (matches && current < occurrence)
+ {
+ matches = matcher.find();
+ current++;
+ }
+ if (matches)
+ {
+ matcher.appendReplacement(changed, replacement);
+ }
+ else
+ {
+ break;
+ }
+ }
+ if (matches && occurrences.length == 1 &&
args.isGlobal())
+ {
+ matches = matcher.find();
+ while (matches)
+ {
+ matcher.appendReplacement(changed, replacement);
+ matches = matcher.find();
+ }
+ }
+ }
+ else
+ {
+ while (matches)
+ {
+ matcher.appendReplacement(changed, replacement);
+ matches = args.isGlobal() && matcher.find();
+ }
+ }
+ matcher.appendTail(changed);
+ return changed.toString();
+ }
+ else
+ {
+ return line;
+ }
+ }
+ else if (command == SEDCommand.TRANSLATE)
+ {
+ char[] changed = null;
+ final int len = line.length();
+ for (int i = 0; i < len; i++)
+ {
+ final char src = line.charAt(i);
+ final char dst = charMap.map(src);
+ if (dst != 0)
+ {
+ if (changed == null)
+ {
+ changed = new char[len];
+ for (int j = 0; j < i; j++)
+ {
+ changed[j] = line.charAt(j);
+ }
+ }
+ changed[i] = dst;
+ }
+ else
+ {
+ if (changed != null)
+ {
+ changed[i] = src;
+ }
+ }
+ }
+ return changed != null ? String.valueOf(changed) : line;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns the index of the next delimiter in the given sed script. The
+ * character at {@code indexOfPreviousDelimiter} is taken as delimiter. The
+ * method handles escaped delimiters and returns -1 if no further delimiter
+ * is found.
+ *
+ * @param script
+ * the script to analyze
+ * @param indexOfPreviousDelimiter
+ * the index of the previous delimiter
+ * @return the index of the next delimiter after
+ * {@code indexOfPreviousDelimiter}, or -1 if no further delimiter
+ * exists of if {@code indexOfNextDelimiter < 0}
+ */
+ private static int indexOfNextDelimiter(String script, int indexOfPreviousDelimiter)
+ {
+ if (indexOfPreviousDelimiter < 0 || script.length() <=
indexOfPreviousDelimiter)
+ {
+ return -1;
+ }
+ final char delim = script.charAt(indexOfPreviousDelimiter);
+ if (delim == '\\')
+ {
+ throw new IllegalArgumentException("invalid delimiter '\\' in sed
script: " + script);
+ }
+ int index = indexOfPreviousDelimiter;
+ do
+ {
+ index = script.indexOf(delim, index + 1);
+ }
+ while (index >= 0 && isEscaped(script, index));
+ return index;
+ }
+
+ private static boolean isEscaped(String script, int index)
+ {
+ int backslashCount = 0;
+ index--;
+ while (index >= 0 && script.charAt(index) == '\\')
+ {
+ backslashCount++;
+ index--;
+ }
+ // an uneven count of backslashes means that the character at position
+ // index is escaped (an even count of backslashes escapes backslashes)
+ return backslashCount % 2 == 1;
+ }
+
+ /**
+ * Finds and returns the start of the given sequence after trimming
+ * whitespace characters from the left.
+ *
+ * @param s
+ * the character sequence
+ * @return the index containing the first non-whitespace character, or the
+ * length of the character sequence if all characters are blank
+ */
+ private static int findStartTrimWhitespace(CharSequence s)
+ {
+ final int len = s.length();
+ for (int i = 0; i < len; i++)
+ {
+ if (!Character.isWhitespace(s.charAt(i)))
+ {
+ return i;
+ }
+ }
+ return len;
+ }
+
+ /**
+ * Finds and returns the first whitespace character in the given sequence at
+ * or after start. Returns the length of the string if no whitespace is
+ * found.
+ *
+ * @param s
+ * the character sequence
+ * @param start
+ * the first index to consider in the char sequence
+ * @return the index containing the first whitespace character at or after
+ * start, or the length of the character sequence if all characters
+ * are blank
+ */
+ private static int findWhitespace(CharSequence s, int start)
+ {
+ final int len = s.length();
+ for (int i = start; i < len; i++)
+ {
+ if (Character.isWhitespace(s.charAt(i)))
+ {
+ return i;
+ }
+ }
+ return len;
+ }
+
+ /**
+ * Finds and returns the end of the given character sequence after trimming
+ * white space characters from the right. Whitespace characters are defined
+ * by {@link Character#isWhitespace(char)}. .
+ *
+ * @param s
+ * the character sequence
+ * @return the index after the last non-whitespace character, or zero if all
+ * characters are blank
+ */
+ private static int findEndTrimWhitespace(CharSequence s)
+ {
+ for (int i = s.length(); i > 0; i--)
+ {
+ if (!Character.isWhitespace(s.charAt(i - 1)))
+ {
+ return i;
+ }
+ }
+ return 0;
+ }
+
+ public static SEDProcessor newInstance(String script)
+ {
+ final int len = script.length();
+ final int scriptStart = findStartTrimWhitespace(script);
+ if (scriptStart < len)
+ {
+ final char firstChar = script.charAt(scriptStart);
+ if (firstChar == 's')
+ {
+ return new SEDProcessor(script, SEDCommand.SUBSTITUTE);
+ }
+ else if (firstChar == 'y')
+ {
+ return new SEDProcessor(script, SEDCommand.TRANSLATE);
+ }
+ }
+ throw new IllegalArgumentException("invalid script");
+ }
+}
\ No newline at end of file
Property changes on:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SEDProcessor.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Added:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
(rev 0)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java 2014-05-28
16:37:14 UTC (rev 18701)
@@ -0,0 +1,212 @@
+package org.jboss.wsf.stack.cxf.addressRewrite;
+
+public final class SedArguments
+{
+
+ private boolean isGlobal = false;
+
+ private boolean isIgnoreCase = false;
+
+ private boolean isTranslate = false;
+
+ private boolean isSubstitute = false;
+
+ // operand: <script>
+ private String script;
+
+ private boolean scriptIsSet = false;
+
+ // operand: <regexp>
+ private String regexp;
+
+ private boolean regexpIsSet = false;
+
+ // operand: <string1>
+ private String string1;
+
+ private boolean string1IsSet = false;
+
+ // operand: <replacement>
+ private String replacement;
+
+ private boolean replacementIsSet = false;
+
+ // operand: <string2>
+ private String string2;
+
+ private boolean string2IsSet = false;
+
+ // operand: <occurrence>
+ private int[] occurrence;
+
+ private boolean occurrenceIsSet = false;
+
+ /**
+ * Constructor to use if no options are specified.
+ */
+ public SedArguments()
+ {
+
+ }
+
+ public String getScript()
+ {
+ if (scriptIsSet)
+ {
+ return script;
+ }
+ throw new IllegalStateException("operand has not been set: " + script);
+ }
+
+ public boolean isScriptSet()
+ {
+ return scriptIsSet;
+ }
+
+ public void setScript(String script)
+ {
+ this.script = script;
+ this.scriptIsSet = true;
+ }
+
+ public String getRegexp()
+ {
+ if (regexpIsSet)
+ {
+ return regexp;
+ }
+ throw new IllegalStateException("operand has not been set: " + regexp);
+ }
+
+ public boolean isRegexpSet()
+ {
+ return regexpIsSet;
+ }
+
+ public void setRegexp(String regexp)
+ {
+ this.regexp = regexp;
+ this.regexpIsSet = true;
+ }
+
+ public String getString1()
+ {
+ if (string1IsSet)
+ {
+ return string1;
+ }
+ throw new IllegalStateException("operand has not been set: " + string1);
+ }
+
+ public boolean isString1Set()
+ {
+ return string1IsSet;
+ }
+
+ public void setString1(String string1)
+ {
+ this.string1 = string1;
+ this.string1IsSet = true;
+ }
+
+ public String getReplacement()
+ {
+ if (replacementIsSet)
+ {
+ return replacement;
+ }
+ throw new IllegalStateException("operand has not been set: " +
replacement);
+ }
+
+ public boolean isReplacementSet()
+ {
+ return replacementIsSet;
+ }
+
+ public void setReplacement(String replacement)
+ {
+ this.replacement = replacement;
+ this.replacementIsSet = true;
+ }
+
+ public String getString2()
+ {
+ if (string2IsSet)
+ {
+ return string2;
+ }
+ throw new IllegalStateException("operand has not been set: " + string2);
+ }
+
+ public boolean isString2Set()
+ {
+ return string2IsSet;
+ }
+
+ public void setString2(String string2)
+ {
+ this.string2 = string2;
+ this.string2IsSet = true;
+ }
+
+ public int[] getOccurrence()
+ {
+ if (occurrenceIsSet)
+ {
+ return occurrence;
+ }
+ throw new IllegalStateException("operand has not been set: " +
occurrence);
+ }
+
+ public boolean isOccurrenceSet()
+ {
+ return occurrenceIsSet;
+ }
+
+ public void setOccurrence(int... occurrence)
+ {
+ this.occurrence = occurrence;
+ this.occurrenceIsSet = true;
+ }
+
+ public boolean isGlobal()
+ {
+ return isGlobal;
+ }
+
+ public boolean isIgnoreCase()
+ {
+ return isIgnoreCase;
+ }
+
+ public boolean isSubstitute()
+ {
+ return isSubstitute;
+ }
+
+ public boolean isTranslate()
+ {
+ return isTranslate;
+ }
+
+ public void setGlobal(boolean isGlobal)
+ {
+ this.isGlobal = isGlobal;
+ }
+
+ public void setIgnoreCase(boolean isIgnoreCase)
+ {
+ this.isIgnoreCase = isIgnoreCase;
+ }
+
+ public void setTranslate(boolean isTranslate)
+ {
+ this.isTranslate = isTranslate;
+ }
+
+ public void setSubstitute(boolean isSubstitute)
+ {
+ this.isSubstitute = isSubstitute;
+ }
+
+}
Property changes on:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SedArguments.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified:
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java 2014-05-28
01:41:29 UTC (rev 18700)
+++
stack/cxf/branches/rsearls/modules/server/src/main/java/org/jboss/wsf/stack/cxf/addressRewrite/SoapAddressRewriteHelper.java 2014-05-28
16:37:14 UTC (rev 18701)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2014, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -27,7 +27,6 @@
import java.net.URL;
import org.jboss.wsf.spi.management.ServerConfig;
-import org.jboss.wsf.stack.cxf.unix4j.Unix4j;
/**
* Helper for rewriting soap:address in published wsdl
@@ -150,7 +149,7 @@
sb.append(port);
// replace original context-root with replacement context
if (additionalCcontext != null && additionalCcontext.length() > 0) {
- String tmpPath =
Unix4j.builder().echo(path).sed(additionalCcontext).toStringResult();
+ String tmpPath =
SEDProcessor.newInstance(additionalCcontext).processLine(path);
sb.append(tmpPath);
} else
{
@@ -192,7 +191,7 @@
{
final URL url = new URL(address);
final String path = url.getPath();
- final String tmpPath =
Unix4j.builder().echo(path).sed(additionalCcontext).toStringResult();
+ final String tmpPath =
SEDProcessor.newInstance(additionalCcontext).processLine(path);
final String newUrl=url.toString().replace(path, tmpPath);
ADDRESS_REWRITE_LOGGER.addressRewritten(address, newUrl);
@@ -209,5 +208,4 @@
return address;
}
}
-
}
Added:
stack/cxf/branches/rsearls/modules/server/src/test/java/org/jboss/wsf/stack/cxf/addressRewrite/AddressRewriteTest.java
===================================================================
---
stack/cxf/branches/rsearls/modules/server/src/test/java/org/jboss/wsf/stack/cxf/addressRewrite/AddressRewriteTest.java
(rev 0)
+++
stack/cxf/branches/rsearls/modules/server/src/test/java/org/jboss/wsf/stack/cxf/addressRewrite/AddressRewriteTest.java 2014-05-28
16:37:14 UTC (rev 18701)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2014, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.cxf.addressRewrite;
+
+import junit.framework.TestCase;
+
+
+/**
+ * A test case for soap:address rewrite
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 27-May-2014
+ *
+ */
+public class AddressRewriteTest extends TestCase
+{
+ private static String run(String path, String script)
+ {
+ return SEDProcessor.newInstance(script).processLine(path);
+ }
+
+ public void testBasicPathRewrite()
+ {
+ ;
+ assertEquals("/FFF/bar", run("/foo/bar",
"s/foo/FFF/g"));
+ assertEquals("/FFF/bar", run("/foo/bar",
"s/foo/FFF/"));
+ assertEquals("/FFFo/FFFooo/bar", run("/foo/foooo/bar",
"s/fo/FFF/g"));
+ assertEquals("/FFFo/foooo/bar", run("/foo/foooo/bar",
"s/fo/FFF/"));
+ //ignore case...
+ assertEquals("/zzz/zzz/bar", run("/Foo/fOO/bar",
"s/foo/zzz/Ig"));
+ }
+
+ public void testPathRewriteWithSlashes()
+ {
+ //replace all slashes with dashes...
+ assertEquals("foo-bar-abc", run("foo/bar/abc",
"s/\\//-/g")); // "s/\//-/g"
+ //... replace first one only...
+ assertEquals("foo-bar/abc", run("foo/bar/abc",
"s/\\//-/")); // "s/\//-/"
+ //... replace second one only...
+ assertEquals("/foo-bar/abc", run("/foo/bar/abc",
"s/\\//-/2")); // "s/\//-/2"
+ //... replace all except first one...
+ assertEquals("/foo-bar-abc", run("/foo/bar/abc",
"s/\\//-/2g")); // "s/\//-/2g"
+ //... the same using different delimiters
+ assertEquals("/foo-bar-abc", run("/foo/bar/abc",
"s|/|-|2g")); // "s|/|-|2g"
+ assertEquals("/foo-bar-abc", run("/foo/bar/abc",
"s:/:-:2g")); // "s:/:-:2g"
+ }
+
+ public void testPathRewriteAddition()
+ {
+ //add trailing context
+ assertEquals("/abc/foo/bar", run("/foo/bar",
"s|/|/abc/|"));
+ assertEquals("/abc/foo/bar", run("/foo/bar",
"s|^|/abc|"));
+ //add ending path
+ assertEquals("/foo/bar/abc", run("/foo/bar",
"s|$|/abc|"));
+ //add trailing and ending path (use column separators to avoid clashes with path
slashes and "|" logical OR)
+ assertEquals("/abc/foo/bar/abc", run("/foo/bar",
"s:^|$:/abc:g"));
+ }
+
+ public void testPathRewriteReplacement()
+ {
+ //replace context only
+ assertEquals("/abc/bar", run("/foo/bar",
"s|/.+/|/abc/|"));
+ assertEquals("/abc/bar", run("/foo/zzz/bar",
"s|/.+/|/abc/|"));
+ //replace path only
+ assertEquals("/foo/abc", run("/foo/bar",
"s|[a-z]*$|abc|"));
+ assertEquals("/foo/zzz/abc", run("/foo/zzz/bar",
"s|[a-z]*$|abc|"));
+ //... case insensitive...
+ assertEquals("/foo/zzz/abc", run("/foo/zzz/Bar",
"s|[a-zA-Z]*$|abc|"));
+ assertEquals("/foo/zzz/abc", run("/foo/zzz/Bar",
"s|[a-z]*$|abc|I"));
+
+ //replace to upper case
+ assertEquals("/FOO/ZZZ/BAR", run("/foo/zzz/Bar",
"y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/"));
+ }
+
+}
Property changes on:
stack/cxf/branches/rsearls/modules/server/src/test/java/org/jboss/wsf/stack/cxf/addressRewrite/AddressRewriteTest.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date
Added: svn:eol-style
+ native
Modified: stack/cxf/branches/rsearls/pom.xml
===================================================================
--- stack/cxf/branches/rsearls/pom.xml 2014-05-28 01:41:29 UTC (rev 18700)
+++ stack/cxf/branches/rsearls/pom.xml 2014-05-28 16:37:14 UTC (rev 18701)
@@ -111,7 +111,6 @@
<shrinkwrap.version>1.1.3</shrinkwrap.version>
<jaspi.api.version>1.0.0.Alpha1</jaspi.api.version>
<javax.inject.version>1</javax.inject.version>
- <unix4j-version>0.3</unix4j-version>
</properties>
@@ -1270,12 +1269,6 @@
<artifactId>easymockclassextension</artifactId>
<version>2.4</version>
</dependency>
- <!-- Java SED util -->
- <dependency>
- <groupId>org.unix4j</groupId>
- <artifactId>unix4j-base</artifactId>
- <version>${unix4j-version}</version>
- </dependency>
<!-- Other test dependencies -->
<dependency>
<groupId>org.picketlink</groupId>