JBoss Portal SVN: r10740 - modules/common/tags.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-05-05 06:48:54 -0400 (Mon, 05 May 2008)
New Revision: 10740
Removed:
modules/common/tags/JBP_COMMON_1_2_0/
Log:
Deleting useless (and unused) tag
16 years, 1 month
JBoss Portal SVN: r10739 - modules/common/branches/JBP_COMMON_BRANCH_1_1.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-05-05 06:25:35 -0400 (Mon, 05 May 2008)
New Revision: 10739
Added:
modules/common/branches/JBP_COMMON_BRANCH_1_1/releaseLibs.sh
Log:
Adding script`
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/releaseLibs.sh
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/releaseLibs.sh (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/releaseLibs.sh 2008-05-05 10:25:35 UTC (rev 10739)
@@ -0,0 +1,27 @@
+repos=$HOME/Dev/portal-modules-respo/common/trunk-SNAPSHOT/lib
+thirdparty=$HOME/Dev/jboss-portal-2.7/thirdparty/jboss-portal/modules/common/lib/
+
+echo "Copies current version of common libraries either to local repository copy or Portal thirdparty to test or release purpose"
+echo "Usage: '$0' to release to Portal thirdparty, '$0 repos' to release to repository local copy"
+echo "Set 'repos' variable to the snapshot lib directory for the common module of your local repository copy"
+echo "Set 'thirdparty' variable to the lib directory for the common module of your local JBoss Portal 2.7 thirparty directory"
+echo ""
+echo "repos currently set at: $repos"
+echo "thirdparty currently set at: $thirdparty"
+echo ""
+
+if [[ $1 == "repos" ]]; then
+ loc=$repos
+ echo "Releasing to repository. Don't forget to update component-info.xml with revision number."
+elif [[ $1 == "usage" ]]; then
+ echo "Usage shown, nothing was done"
+ exit 0
+else
+ loc=$thirdparty
+ echo "Releasing to Portal thirdparty"
+fi
+
+
+cp common/target/common-common-1.1-SNAPSHOT.jar $loc/portal-common-lib.jar
+cp mc/target/common-mc-1.1-SNAPSHOT.jar $loc/portal-common-mc-lib.jar
+cp portal/target/common-portal-1.1-SNAPSHOT.jar $loc/portal-common-portal-lib.jar
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/releaseLibs.sh
___________________________________________________________________
Name: svn:executable
+ *
16 years, 1 month
JBoss Portal SVN: r10738 - in modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src: main/java/org/jboss/portal/common/markup and 3 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-05-05 06:23:36 -0400 (Mon, 05 May 2008)
New Revision: 10738
Modified:
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java
Log:
Applying Chris' changes:
- Fixed CharBuffer.appendNoCheck method which was incorrect for case where offset was not 0.
- Refactored CharEncoder hierachy:
+ Simplified AbstractCharEncoder.
+ Added String encode(String) method on CharEncoder.
+ FastURLDecoder and FastURLEncoder now extends AbstractCharEncoder.
+ JBPORTAL-1970: Improved exception messages by using ParameterValidation where possible.
- Added ParameterValidation.throwIllegalArgExceptionIfRangeInvalid to check range.
- Added test cases.
- Added more test cases for border conditions and error checking.
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -23,6 +23,7 @@
package org.jboss.portal.common.io;
import org.jboss.portal.common.text.CharWriter;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.common.io.UndeclaredIOException;
import java.io.Writer;
@@ -44,10 +45,7 @@
*/
public WriterCharWriter(Writer writer) throws IllegalArgumentException
{
- if (writer == null)
- {
- throw new IllegalArgumentException("No null writer accepted");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(writer, "Writer");
this.writer = writer;
}
@@ -66,22 +64,7 @@
public CharWriter append(char[] chars, int off, int len) throws UndeclaredIOException
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (len < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfRangeInvalid(chars, off, len);
try
{
writer.write(chars, off, len);
@@ -95,10 +78,7 @@
public CharWriter append(char[] chars) throws UndeclaredIOException
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(chars, "char[]");
try
{
writer.write(chars, 0, chars.length);
@@ -112,10 +92,7 @@
public CharWriter append(CharSequence s) throws UndeclaredIOException
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "CharSequence");
try
{
if (s instanceof String)
@@ -124,7 +101,7 @@
}
else
{
- for (int i = 0;i < s.length();i++)
+ for (int i = 0; i < s.length();i++)
{
char c = s.charAt(i);
writer.write(c);
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -156,16 +156,25 @@
// Patches the encoder to let '/' not being encoded
encoder = new AbstractCharEncoder()
{
- protected void safeEncode(char c, CharWriter writer) throws EncodingException
+ protected void safeEncode(char[] chars, int off, int len, CharWriter writer) throws EncodingException
{
- if (c == '/')
+ //
+ int to = off + len;
+
+ // Perform lookup char by char
+ for (int current = off; current < to; current++)
{
- writer.append(SLASH_ARRAY);
+ char c = chars[current];
+ if (c == '/')
+ {
+ writer.append(SLASH_ARRAY);
+ }
+ else
+ {
+ FastURLEncoder.getUTF8Instance().encode(c, writer);
+ }
+
}
- else
- {
- FastURLEncoder.getUTF8Instance().encode(c, writer);
- }
}
};
}
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -22,6 +22,12 @@
******************************************************************************/
package org.jboss.portal.common.text;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.jboss.portal.common.io.WriterCharWriter;
+import org.jboss.portal.common.util.ParameterValidation;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
@@ -31,22 +37,9 @@
public void encode(char[] chars, int off, int len, CharWriter writer) throws EncodingException
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfRangeInvalid(chars, off, len);
+
+ ParameterValidation.throwIllegalArgExceptionIfNull(writer, "CharWriter");
//
safeEncode(chars, off, len, writer);
@@ -54,65 +47,46 @@
public void encode(char[] chars, CharWriter writer) throws EncodingException
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- safeEncode(chars, writer);
+ ParameterValidation.throwIllegalArgExceptionIfNull(chars, "char[]");
+ encode(chars, 0, chars.length, writer);
}
public void encode(CharSequence s, CharWriter writer) throws EncodingException
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
+
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "CharSequence");
//
- safeEncode(s, writer);
- }
-
- public void encode(char c, CharWriter writer) throws EncodingException
- {
- if (writer == null)
+ if (s instanceof String)
{
- throw new IllegalArgumentException();
+ char[] chars = ((String)s).toCharArray();
+ encode(chars, 0, chars.length, writer);
}
-
- //
- safeEncode(c, writer);
- }
-
- protected void safeEncode(char[] chars, int off, int len, CharWriter writer) throws EncodingException
- {
- for (int i = off;i < len;i++)
+ else
{
- safeEncode(chars[i], writer);
+ char[] chars = new char[s.length()];
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ chars[i] = c;
+ }
+ encode(chars, 0, chars.length, writer);
}
}
- protected void safeEncode(char[] chars, CharWriter writer) throws EncodingException
+ public void encode(char c, CharWriter writer) throws EncodingException
{
- safeEncode(chars, 0, chars.length, writer);
+ encode(new char[]{c}, writer);
}
- protected void safeEncode(CharSequence s, CharWriter writer) throws EncodingException
+ public String encode(String string) throws EncodingException
{
- for (int i = 0;i < s.length();i++)
- {
- safeEncode(s.charAt(i), writer);
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(string, "String");
+ Writer sw = new StringWriter();
+ CharWriter charWriter = new WriterCharWriter(sw);
+ safeEncode(string.toCharArray(), 0, string.length(), charWriter);
+ return sw.toString();
}
- protected abstract void safeEncode(char c, CharWriter writer) throws EncodingException;
+ protected abstract void safeEncode(char[] chars, int off, int len, CharWriter writer) throws EncodingException;
}
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.common.text;
+import org.jboss.portal.common.util.ParameterValidation;
+
/**
* A simple char buffer that implements the <code>CharWriter</code> interface
*
@@ -38,7 +40,6 @@
protected int length;
/**
- *
* @param size the initial size
* @throws IllegalArgumentException if the initial size is not a positive value.
*/
@@ -46,7 +47,7 @@
{
if (size < 0)
{
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Size must be positive !");
}
this.buffer = new char[size];
this.length = 0;
@@ -60,42 +61,22 @@
public CharBuffer append(String s, CharEncoder encoder)
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (encoder == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "String");
+ ParameterValidation.throwIllegalArgExceptionIfNull(encoder, "CharEncoder");
encoder.encode(s, this);
return this;
}
public CharWriter append(CharSequence s)
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "CharSequence");
appendNoCheck(s);
return this;
}
public CharWriter append(char[] chars, int off, int len)
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfRangeInvalid(chars, off, len);
//
appendNoCheck(chars, off, len);
@@ -118,10 +99,7 @@
public CharWriter append(char[] chars)
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(chars, "char[]");
//
appendNoCheck(chars, 0, chars.length);
@@ -159,7 +137,7 @@
{
if (length < 0)
{
- throw new IllegalArgumentException();
+ throw new IllegalArgumentException("Length must be positive !");
}
//
@@ -184,7 +162,8 @@
ensureCapacity(length + len);
if (len < 10)
{
- while (off < len)
+ int toCopy = off + len;
+ while (off < toCopy)
{
buffer[length++] = chars[off++];
}
@@ -208,7 +187,7 @@
}
else
{
- for (int i = 0;i < s.length();i++)
+ for (int i = 0; i < s.length();i++)
{
char c = s.charAt(i);
buffer[length++] = c;
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -31,7 +31,6 @@
public interface CharEncoder
{
/**
- *
* @param c the char to encode
* @param writer the writer to use
* @throws IllegalArgumentException if any argument is null
@@ -67,4 +66,11 @@
* @throws EncodingException an encoding exception
*/
void encode(CharSequence s, CharWriter writer) throws IllegalArgumentException, EncodingException;
+
+ /**
+ * @param string the String to encode
+ * @return the encoded String
+ * @throws IllegalArgumentException if the specified String is <code>null</code>
+ */
+ String encode(String string) throws IllegalArgumentException;
}
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.common.text;
+import org.jboss.portal.common.util.ParameterValidation;
+
/**
* This encoder performs lookup for converting a char to its HTML entity representation.
*
@@ -31,8 +33,10 @@
public class EntityEncoder extends AbstractCharEncoder
{
- protected void safeEncode(char c, CharWriter writer) throws EncodingException
+ public void safeEncode(char c, CharWriter writer) throws EncodingException
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(writer, "CharWriter");
+
String s = charToEntity[c];
//
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -31,7 +31,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class FastURLDecoder implements CharEncoder
+public class FastURLDecoder extends AbstractCharEncoder
{
/** . */
@@ -165,98 +165,8 @@
}
}
- public void encode(char c, CharWriter writer)
+ protected void safeEncode(char[] chars, int i, int length, CharWriter tmp)
{
- encode(new char[]{c}, writer);
- }
-
- public void encode(char[] chars, int off, int len, CharWriter writer)
- {
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (len < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- encodeNoCheck(chars, off, len, writer);
- }
-
- public void encode(char[] chars, CharWriter writer)
- {
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- encodeNoCheck(chars, 0, chars.length, writer);
- }
-
- public void encode(CharSequence s, CharWriter writer)
- {
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- if (s instanceof String)
- {
- char[] chars = ((String)s).toCharArray();
- encodeNoCheck(chars, 0, chars.length, writer);
- }
- else
- {
- char[] chars = new char[s.length()];
- for (int i = 0; i < s.length(); i++)
- {
- char c = s.charAt(i);
- chars[i] = c;
- }
- encodeNoCheck(chars, 0, chars.length, writer);
- }
- }
-
- /**
- * @param s
- * @return
- * @throws IllegalArgumentException
- * @since 1.1
- */
- public String encode(String s) throws IllegalArgumentException
- {
- Writer sw = new StringWriter();
- CharWriter charWriter = new WriterCharWriter(sw);
- encodeNoCheck(s.toCharArray(), 0, s.length(), charWriter);
- return sw.toString();
- }
-
- private void encodeNoCheck(char[] chars, int i, int length, CharWriter tmp)
- {
while (i < length)
{
char c = chars[i++];
@@ -326,7 +236,7 @@
case ERROR:
if (strict)
{
- throw new MalformedInputException("Cannot decode char " + c);
+ throw new MalformedInputException("Cannot decode char '" + c + "'");
}
else
{
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -23,6 +23,7 @@
package org.jboss.portal.common.text;
import org.jboss.portal.common.io.UndeclaredIOException;
+import org.jboss.portal.common.util.ParameterValidation;
import java.io.IOException;
import java.io.Writer;
@@ -33,7 +34,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 7228 $
*/
-public class FastURLEncoder implements CharEncoder
+public class FastURLEncoder extends AbstractCharEncoder
{
/** . */
@@ -106,151 +107,45 @@
}
}
- public void encode(CharSequence s, CharWriter out) throws IllegalArgumentException
+ public void encode(char c, CharWriter writer) throws IllegalArgumentException
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (out == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(writer, "CharWriter");
- //
- for (int i = 0; i < s.length(); i++)
- {
- char c = s.charAt(i);
- char[] z = table[c];
- if (z == null)
- {
- throw new MalformedInputException("Wrong");
- }
- out.append(z);
- }
+ char[] z = getEncoding(c);
+ writer.append(z);
}
- public void encode(char c, CharWriter writer)
+ private char[] getEncoding(char c)
{
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
char[] z = table[c];
if (z == null)
{
- throw new MalformedInputException("Wrong");
+ throw new MalformedInputException("Couldn't find appropriate encoding for '" + c + "'");
}
- writer.append(z);
+ return z;
}
- public void encode(char[] chars, int off, int len, CharWriter writer)
+ protected void safeEncode(char[] chars, int off, int len, CharWriter writer)
{
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (off < 0)
- {
- throw new IllegalArgumentException();
- }
- if (len < 0)
- {
- throw new IllegalArgumentException();
- }
- if (off + len > chars.length)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- encodeNoCheck(chars, off, len, writer);
- }
-
- public void encode(char[] chars, CharWriter writer)
- {
- if (chars == null)
- {
- throw new IllegalArgumentException();
- }
- if (writer == null)
- {
- throw new IllegalArgumentException();
- }
-
- //
- encodeNoCheck(chars, 0, chars.length, writer);
- }
-
- private void encodeNoCheck(char[] chars, int off, int len, CharWriter writer)
- {
for (int i = off; i < len; i++)
{
char c = chars[i];
- char[] z = table[c];
- if (z == null)
- {
- throw new IllegalArgumentException("Wrong");
- }
+ char[] z = getEncoding(c);
writer.append(z);
}
}
- public String encode(String s) throws IllegalArgumentException
- {
- StringBuffer tmp = new StringBuffer();
- encode(s, tmp);
- return tmp.toString();
- }
-
- public void encode(String s, StringBuffer out) throws IllegalArgumentException
- {
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (out == null)
- {
- throw new IllegalArgumentException();
- }
- for (int i = 0; i < s.length(); i++)
- {
- char c = s.charAt(i);
- char[] z = table[c];
- if (z == null)
- {
- throw new MalformedInputException("Cannot encode char=" + (int)c);
- }
- out.append(z);
- }
- }
-
public void encode(String s, Writer out) throws IllegalArgumentException, UndeclaredIOException
{
- if (s == null)
- {
- throw new IllegalArgumentException();
- }
- if (out == null)
- {
- throw new IllegalArgumentException();
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(s, "String");
+ ParameterValidation.throwIllegalArgExceptionIfNull(out, "Writer");
+
try
{
for (int i = 0; i < s.length(); i++)
{
char c = s.charAt(i);
- char[] z = table[c];
- if (z == null)
- {
- throw new MalformedInputException("Wrong");
- }
+ char[] z = getEncoding(c);
out.write(z);
}
}
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -37,6 +37,24 @@
}
}
+ public static void throwIllegalArgExceptionIfRangeInvalid(char[] chars, int offset, int length)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(chars, "characters");
+
+ if (offset < 0)
+ {
+ throw new IllegalArgumentException("Offset must be positive!");
+ }
+ if (length < 0)
+ {
+ throw new IllegalArgumentException("Length must be positive!");
+ }
+ if (offset + length > chars.length)
+ {
+ throw new IllegalArgumentException("Specified character range is outside of the given char[]!");
+ }
+ }
+
/** @since 2.6 */
public static boolean isNullOrEmpty(String valueToCheck)
{
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -63,6 +63,60 @@
assertEquals("abc", buffer.asString());
}
+ public void testCharArrayAppendWithOffset()
+ {
+ CharBuffer buffer = new CharBuffer();
+ buffer.append("abcdef".toCharArray(), 1, 5);
+ assertEquals("bcdef", buffer.asString());
+
+ buffer.append("pqrstu".toCharArray(), 3, 3);
+ assertEquals("stu", buffer.asString());
+
+ buffer.append("abc".toCharArray(), 0, 0);
+ assertEquals("", buffer.asString());
+
+ buffer.append("abc".toCharArray(), 3, 0);
+ assertEquals("", buffer.asString());
+
+ buffer.append("abc".toCharArray(), 2, 1);
+ assertEquals("c", buffer.asString());
+ }
+
+ public void testAppendCharArrayRobustness()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+
+ try
+ {
+ buffer.append("abc".toCharArray(), 3, 1);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+
+ try
+ {
+ buffer.append("abc".toCharArray(), -1, 1);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+
+ try
+ {
+ buffer.append("abc".toCharArray(), 0, 4);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+ }
+
public void testReset()
{
CharBuffer buffer = new CharBuffer(0);
Modified: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java 2008-05-05 09:20:20 UTC (rev 10737)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java 2008-05-05 10:23:36 UTC (rev 10738)
@@ -42,6 +42,13 @@
assertEquals("c", buffer.asString(true));
}
+ public void testChars()
+ {
+ CharBuffer buffer = new CharBuffer();
+ EntityEncoder.FULL.encode("&bar".toCharArray(), buffer);
+ assertEquals("&bar", buffer.asString(true));
+ }
+
public void testString()
{
test("&", "&");
16 years, 1 month
JBoss Portal SVN: r10737 - modules/common/tags.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-05-05 05:20:20 -0400 (Mon, 05 May 2008)
New Revision: 10737
Removed:
modules/common/tags/JBP_COMMON_1_1_1/
Log:
Start working on a branch now, there are still at least one patch to apply :-/ Will tag 1.1.1 later
16 years, 1 month
JBoss Portal SVN: r10736 - in modules/common/branches: JBP_COMMON_BRANCH_1_1 and 102 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-05-05 05:09:44 -0400 (Mon, 05 May 2008)
New Revision: 10736
Added:
modules/common/branches/JBP_COMMON_BRANCH_1_1/
modules/common/branches/JBP_COMMON_BRANCH_1_1/.classpath
modules/common/branches/JBP_COMMON_BRANCH_1_1/.project
modules/common/branches/JBP_COMMON_BRANCH_1_1/.settings/
modules/common/branches/JBP_COMMON_BRANCH_1_1/.settings/org.eclipse.jdt.ui.prefs
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.cvsignore
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.project
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/build.bat
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.1/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.1/config/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.1/config/jboss-format.xml
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/team/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/team/anonymous-projectSet.psf
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/team/commiter-projectSet.psf
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/codestyles/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/jboss-portal-common.ipr
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/common/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/common/common.iml
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/mc/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/mc/mc.iml
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/portal/
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/portal/portal.iml
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/readme.txt
modules/common/branches/JBP_COMMON_BRANCH_1_1/build/pom.xml
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.classpath
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.cvsignore
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.project
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.2.working
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-left.r10094
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-left.r10199
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-right.r10095
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-right.r10200
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.working
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/etc/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/etc/portal-common-lib-jar.mf
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/FixMe.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/NotYetImplemented.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcher.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcherFactory.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdaptable.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapted.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/DefaultJavaLangObjectAdapted.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectAdapted.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcher.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcherFactory.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcher.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcherFactory.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/concurrent/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeader.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeaders.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpRequest.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpResponse.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/QueryStringParser.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/I18NTools.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFactory.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleManager.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleFactory.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/AbstractInvocationContext.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/AttributeResolver.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyAttributeResolver.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyInterceptorStackFactory.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStackFactory.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationContext.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationHandler.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Scope.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/AbstractSessionAttributeResolver.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/MapAttributeResolver.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/PrincipalAttributeResolver.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/RequestAttributeResolver.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/SessionAttributeResolver.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/IOTools.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/Serialization.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/SerializationFilter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/UndeclaredIOException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/jar/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/jar/JarEntryInfo.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/jar/JarInfo.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTask.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTest.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableXMLJUnitResultFormatter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameterValue.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupElement.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLFilter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/file/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/jar/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/p3p/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/reflect/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/reflect/Modifier.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/reflect/Reflection.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingRequestWrapper.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingResponseWrapper.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharToByteEncoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharWriter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EncodingException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/MalformedInputException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/TextTools.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/UnsupportedCharsetException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionMap.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CopyOnWriteRegistry.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/IteratorStatus.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ListMap.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MapAccessor.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MapBuilder.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MarkupInfo.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/SimpleMapAccessor.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/NullEntityResolver.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_close.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_close.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_close.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/email.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_close.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/img.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/listitem.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_close.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_close.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_username_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_close.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_close.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_close.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_open.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/url.tpl
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/filters/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/P3PConstantsTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/http/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/SerializationTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractServer.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractSynchronizedServer.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionBuilderTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionMapTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/MapBuilderTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/TypedMapTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/VersionTestCase.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_de_DE.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_fr.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_fr_FR.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_it.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/b.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/c_fr.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/d_fr_FR.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/e.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/e_fr.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/f.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/f_fr_FR.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/g_fr.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/g_fr_FR.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h_fr.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h_fr_FR.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/META-INF/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/META-INF/jboss-service.xml
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/web.xml
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar/bar.txt
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/log4j.properties
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1-/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1.txt
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1/c1.txt
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1/c1/
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1/c1/d1.txt
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b2.txt
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a3.txt
modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test01.code
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.classpath
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.cvsignore
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.project
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/pom.xml
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/etc/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/etc/portal-common-mc-lib-jar.mf
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/ActualBootstrap.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/WebBootstrap.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/pom.xml
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.classpath
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.cvsignore
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.project
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/pom.xml
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/etc/
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/etc/portal-common-portal-lib-jar.mf
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/Mode.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/WindowState.java
modules/common/branches/JBP_COMMON_BRANCH_1_1/svn-commit.tmp
Log:
Importing Branch 1.1
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/.classpath
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/.classpath (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/.classpath 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="mc/src/main/java"/>
+ <classpathentry kind="src" path="portal/src/main/java"/>
+ <classpathentry kind="src" path="common/src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="thirdparty/jboss/microcontainer/lib/jboss-microcontainer.jar"/>
+ <classpathentry kind="lib" path="thirdparty/sun-servlet/lib/servlet-api.jar"/>
+ <classpathentry kind="lib" path="thirdparty/apache-log4j/lib/log4j.jar"/>
+ <classpathentry kind="lib" path="thirdparty/apache-ant/lib/ant.jar"/>
+ <classpathentry kind="lib" path="thirdparty/oswego-concurrent/lib/concurrent.jar"/>
+ <classpathentry kind="lib" path="thirdparty/junit/lib/junit.jar"/>
+ <classpathentry kind="lib" path="thirdparty/jbossas/core-libs/lib/jboss-j2ee.jar"/>
+ <classpathentry kind="lib" path="thirdparty/apache-httpclient/lib/commons-httpclient.jar"/>
+ <classpathentry kind="lib" path="thirdparty/sun-jaf/lib/activation.jar"/>
+ <classpathentry kind="lib" path="/home/theute/.m2/repository/org/codehaus/cargo/cargo-core-uberjar/0.8/cargo-core-uberjar-0.8.jar"/>
+ <classpathentry kind="lib" path="/home/theute/.m2/repository/ant/ant-junit/1.6.5/ant-junit-1.6.5.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/.project
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/.project (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/.project 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>module-common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/.settings/org.eclipse.jdt.ui.prefs (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/.settings/org.eclipse.jdt.ui.prefs 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,3 @@
+#Tue Nov 13 13:01:47 CET 2007
+eclipse.preferences.version=1
+internal.default.compliance=default
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.cvsignore
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.cvsignore (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.cvsignore 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,3 @@
+build.log
+local.properties
+build.iml
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.cvsignore
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.project
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.project (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.project 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>build</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/.project
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/build.bat
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/build.bat (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/build.bat 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,54 @@
+@echo off
+rem
+rem Invokes a script of the same name in the 'tools' module.
+rem
+rem The 'tools' module is expected to be a peer directory of the directory
+rem in which this script lives.
+rem
+rem @author Jason Dillon <jason(a)planet57.com>
+rem
+
+rem $Id: build.bat 2 2005-01-14 23:01:32Z vietj $
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+set MODULE_ROOT=%DIRNAME%
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..\tools
+set TARGET=%TOOLS_ROOT%\bin\build.bat
+set ARGS=%*
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug TARGET=%TARGET%
+
+if exist %TARGET% call :call-script & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target executable does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %TARGET%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools' module
+echo %PROGNAME%: and make sure it is up to date.
+goto :EOF
+
+:call-script
+call :debug Executing %TARGET% %ARGS%
+call %TARGET% %ARGS%
+goto :EOF
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/build.bat
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.1/config/jboss-format.xml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.1/config/jboss-format.xml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.1/config/jboss-format.xml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,244 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles version="8">
+<profile name="JBoss" version="8">
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="52"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="48"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="64"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="64"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_comments" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="3"/>
+</profile>
+</profiles>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.1/config/jboss-format.xml
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/team/anonymous-projectSet.psf
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/team/anonymous-projectSet.psf (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/team/anonymous-projectSet.psf 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<psf version="2.0">
+ <provider id="org.tigris.subversion.subclipse.core.svnnature">
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/api,api"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/bridge,bridge"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/build,build"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/cms,cms"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/common,common"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core,core"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-admin,core-admin"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-cms,core-cms"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-management,core-ma..."/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-samples,core-samples"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-search,core-search"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/faces,faces"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/format,format"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/identity,identity"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/jems,jems"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/portlet,portlet"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/portlet-federation,port..."/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/registration,registration"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/samples,samples"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/search,search"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/security,security"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/server,server"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/test,test"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/testsuite,testsuite"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/theme,theme"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/tools,tools"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/workflow,workflow"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/wsrp,wsrp"/>
+ </provider>
+</psf>
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/team/commiter-projectSet.psf
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/team/commiter-projectSet.psf (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/eclipse/3.2/team/commiter-projectSet.psf 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<psf version="2.0">
+ <provider id="org.tigris.subversion.subclipse.core.svnnature">
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/api,api"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/bridge,bridge"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/build,build"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/cms,cms"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/common,common"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core,core"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-admin,core-admin"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-cms,core-cms"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-management,core-manag..."/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-samples,core-samples"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-search,core-search"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/faces,faces"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/format,format"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/identity,identity"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/jems,jems"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/portlet,portlet"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/portlet-federation,portlet..."/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/registration,registration"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/samples,samples"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/search,search"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/security,security"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/server,server"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/test,test"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/testsuite,testsuite"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/theme,theme"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/tools,tools"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/workflow,workflow"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/wsrp,wsrp"/>
+ </provider>
+</psf>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<code_scheme name="jboss">
+ <option name="JAVA_INDENT_OPTIONS">
+ <value>
+ <option name="INDENT_SIZE" value="3" />
+ <option name="CONTINUATION_INDENT_SIZE" value="3" />
+ <option name="TAB_SIZE" value="3" />
+ <option name="USE_TAB_CHARACTER" value="false" />
+ <option name="SMART_TABS" value="false" />
+ <option name="LABEL_INDENT_SIZE" value="0" />
+ <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+ </value>
+ </option>
+ <option name="BRACE_STYLE" value="2" />
+ <option name="CLASS_BRACE_STYLE" value="2" />
+ <option name="METHOD_BRACE_STYLE" value="2" />
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="FINALLY_ON_NEW_LINE" value="true" />
+ <option name="SPACE_AFTER_TYPE_CAST" value="false" />
+ <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="5000" />
+ <option name="WRAP_COMMENTS" value="true" />
+ <option name="IF_BRACE_FORCE" value="3" />
+ <option name="DOWHILE_BRACE_FORCE" value="3" />
+ <option name="WHILE_BRACE_FORCE" value="3" />
+ <option name="FOR_BRACE_FORCE" value="3" />
+ <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
+ <option name="XML_KEEP_WHITESPACES" value="true" />
+</code_scheme>
+
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,128 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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 ${PACKAGE_NAME};
+
+import org.jboss.portal.test.framework.container.server.result.AssertResult;
+import org.jboss.portal.test.framework.container.server.result.InvokeGetResult;
+import org.jboss.portal.test.framework.container.server.result.FailureResult;
+import org.jboss.portal.test.framework.container.server.result.ServerResult;
+import org.jboss.portal.test.framework.container.server.TestContext;
+import org.jboss.portal.test.portlet.AbstractTestPortlet;
+
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletPreferences;
+import javax.portlet.ValidatorException;
+import javax.portlet.PortletURL;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1951 $
+
+ */
+public class ${NAME} extends AbstractTestPortlet
+{
+
+
+ private AssertResult ares;
+
+ public void doProcessAction(final ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
+ {
+ int requestCount = TestContext.getCurrentRequestCount();
+ if (ares == null)
+ {
+ if (requestCount == 1)
+ {
+ ares = new AssertResult();
+ ares.execute(new AssertResult.Test()
+ {
+ public void run() throws Exception
+ {
+
+ }
+ });
+ }
+ }
+ else if (!ares.isFailed())
+ {
+ if (requestCount == 2)
+ {
+ ares.execute(new AssertResult.Test()
+ {
+ public void run() throws Exception
+ {
+
+ }
+ });
+ }
+ }
+ }
+
+ public void doRender(final RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
+ {
+ ServerResult result = null;
+
+ int requestCount = TestContext.getCurrentRequestCount();
+ if (ares == null)
+ {
+ if (requestCount == 0)
+ {
+ PortletURL url = response.createActionURL();
+ result = new InvokeGetResult(url.toString());
+ AbstractTestPortlet.marshall(result, response, TestContext.getCurrentTestCaseId());
+ }
+ else
+ {
+ AbstractTestPortlet.marshall(new FailureResult("The assert result was expected to be not null"), response, TestContext.getCurrentTestCaseId());
+ }
+ }
+ else if (ares.isFailed())
+ {
+ AbstractTestPortlet.marshall(ares, response, TestContext.getCurrentTestCaseId());
+ }
+ else
+ {
+ if (requestCount == 0)
+ {
+ AbstractTestPortlet.marshall(new FailureResult("The assert result was expected to be not null"), response, TestContext.getCurrentTestCaseId());
+ }
+ else if (requestCount == 1)
+ {
+ PortletURL url = response.createActionURL();
+ result = new InvokeGetResult(url.toString());
+ AbstractTestPortlet.marshall(result, response, TestContext.getCurrentTestCaseId());
+ }
+ else if (requestCount == 2)
+ {
+ AbstractTestPortlet.marshall(ares, response, TestContext.getCurrentTestCaseId());
+ }
+ }
+ }
+
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,4 @@
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,22 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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. *
+ ******************************************************************************/
\ No newline at end of file
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,5 @@
+#parse("File Header.java")
+package ${PACKAGE_NAME};
+#parse("Body Header.java")
+public @interface ${NAME} {
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,5 @@
+#parse("File Header.java")
+package ${PACKAGE_NAME};
+#parse("Body Header.java")
+public class ${NAME} {
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,5 @@
+#parse("File Header.java")
+package ${PACKAGE_NAME};
+#parse("Body Header.java")
+public enum ${NAME} {
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,5 @@
+#parse("File Header.java")
+package ${PACKAGE_NAME};
+#parse("Body Header.java")
+public interface ${NAME} {
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/jboss-portal-common.ipr
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/jboss-portal-common.ipr (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/jboss-portal-common.ipr 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,492 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4" relativePaths="false">
+ <component name="AntConfiguration">
+ <defaultAnt bundledAnt="true" />
+ </component>
+ <component name="BuildJarProjectSettings">
+ <option name="BUILD_JARS_ON_MAKE" value="false" />
+ </component>
+ <component name="CodeStyleProjectProfileManger">
+ <option name="PROJECT_PROFILE" />
+ <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
+ </component>
+ <component name="CodeStyleSettingsManager">
+ <option name="PER_PROJECT_SETTINGS" />
+ <option name="USE_PER_PROJECT_SETTINGS" value="false" />
+ </component>
+ <component name="CompilerConfiguration">
+ <option name="DEFAULT_COMPILER" value="Javac" />
+ <option name="DEPLOY_AFTER_MAKE" value="0" />
+ <resourceExtensions>
+ <entry name=".+\.(properties|xml|html|dtd|tld)" />
+ <entry name=".+\.(gif|png|jpeg|jpg)" />
+ </resourceExtensions>
+ <wildcardResourcePatterns>
+ <entry name="?*.properties" />
+ <entry name="?*.xml" />
+ <entry name="?*.gif" />
+ <entry name="?*.png" />
+ <entry name="?*.jpeg" />
+ <entry name="?*.jpg" />
+ <entry name="?*.html" />
+ <entry name="?*.dtd" />
+ <entry name="?*.tld" />
+ </wildcardResourcePatterns>
+ </component>
+ <component name="DataSourceManagerImpl" />
+ <component name="DependenciesAnalyzeManager">
+ <option name="myForwardDirection" value="false" />
+ </component>
+ <component name="DependencyValidationManager" />
+ <component name="EclipseCompilerSettings">
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="true" />
+ <option name="DEPRECATION" value="false" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
+ </component>
+ <component name="EclipseEmbeddedCompilerSettings">
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="true" />
+ <option name="DEPRECATION" value="false" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
+ </component>
+ <component name="EntryPointsManager">
+ <entry_points />
+ </component>
+ <component name="ExportToHTMLSettings">
+ <option name="PRINT_LINE_NUMBERS" value="false" />
+ <option name="OPEN_IN_BROWSER" value="false" />
+ <option name="OUTPUT_DIRECTORY" />
+ </component>
+ <component name="GUI Designer component loader factory" />
+ <component name="IdProvider" IDEtalkID="E2A438D8B6AE84F43587A2210E562521" />
+ <component name="InspectionProjectProfileManager">
+ <option name="PROJECT_PROFILE" value="Project Default" />
+ <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
+ <scopes />
+ <profiles>
+ <profile version="1.0" is_locked="false">
+ <option name="myName" value="Project Default" />
+ <option name="myLocal" value="false" />
+ <used_levels>
+ <error>
+ <option name="myName" value="ERROR" />
+ <option name="myVal" value="200" />
+ </error>
+ <warning>
+ <option name="myName" value="WARNING" />
+ <option name="myVal" value="100" />
+ </warning>
+ <information>
+ <option name="myName" value="INFO" />
+ <option name="myVal" value="100" />
+ </information>
+ <server>
+ <option name="myName" value="SERVER PROBLEM" />
+ <option name="myVal" value="100" />
+ </server>
+ </used_levels>
+ </profile>
+ </profiles>
+ </component>
+ <component name="JavacSettings">
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="false" />
+ <option name="DEPRECATION" value="true" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
+ </component>
+ <component name="JavadocGenerationManager">
+ <option name="OUTPUT_DIRECTORY" />
+ <option name="OPTION_SCOPE" value="protected" />
+ <option name="OPTION_HIERARCHY" value="true" />
+ <option name="OPTION_NAVIGATOR" value="true" />
+ <option name="OPTION_INDEX" value="true" />
+ <option name="OPTION_SEPARATE_INDEX" value="true" />
+ <option name="OPTION_DOCUMENT_TAG_USE" value="false" />
+ <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
+ <option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
+ <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
+ <option name="OPTION_DEPRECATED_LIST" value="true" />
+ <option name="OTHER_OPTIONS" value="" />
+ <option name="HEAP_SIZE" />
+ <option name="LOCALE" />
+ <option name="OPEN_IN_BROWSER" value="true" />
+ </component>
+ <component name="JikesSettings">
+ <option name="JIKES_PATH" value="" />
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="DEPRECATION" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="false" />
+ <option name="IS_EMACS_ERRORS_MODE" value="true" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ </component>
+ <component name="LogConsolePreferences">
+ <option name="FILTER_ERRORS" value="false" />
+ <option name="FILTER_WARNINGS" value="false" />
+ <option name="FILTER_INFO" value="true" />
+ <option name="CUSTOM_FILTER" />
+ </component>
+ <component name="MavenBuildProjectComponent">
+ <option name="mavenExecutable" value="" />
+ <option name="Settings File" value="" />
+ <option name="mavenCommandLineParams" value="" />
+ <option name="vmOptions" value="" />
+ <option name="useMavenEmbedder" value="false" />
+ <option name="useFilter" value="false" />
+ <option name="Batch Mode" value="false" />
+ <option name="Check Plugin Updates" value="false" />
+ <option name="Debug" value="false" />
+ <option name="Errors" value="false" />
+ <option name="Fail At End" value="false" />
+ <option name="Fail Fast" value="false" />
+ <option name="Fail Never" value="false" />
+ <option name="Lax Checksums" value="false" />
+ <option name="No Plugin Registry" value="false" />
+ <option name="No Plugin Updates" value="false" />
+ <option name="Non Recursive" value="false" />
+ <option name="Offline" value="false" />
+ <option name="Reactor" value="false" />
+ <option name="Strict Checksums" value="false" />
+ <option name="Update Plugins" value="false" />
+ <option name="Update Snapshots" value="false" />
+ <option name="Skip Tests" value="false" />
+ <pom-list />
+ </component>
+ <component name="Palette2">
+ <group name="Swing">
+ <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+ </item>
+ <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+ </item>
+ <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+ <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+ <initial-values>
+ <property name="text" value="Button" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="RadioButton" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="CheckBox" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="Label" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+ <preferred-size width="200" height="200" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+ <preferred-size width="200" height="200" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+ </item>
+ <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+ <preferred-size width="-1" height="20" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+ </item>
+ <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+ </item>
+ </group>
+ </component>
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/common/common.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/common/common.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/mc/mc.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/mc/mc.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/portal/portal.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/portal/portal.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/testsuite/testsuite.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/testsuite/testsuite.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/thirdparty/thirdparty.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/thirdparty/thirdparty.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/tools/tools.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/tools/tools.iml" />
+ </modules>
+ </component>
+ <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="false" project-jdk-name="1.5" project-jdk-type="JavaSDK">
+ <output url="file://$PROJECT_DIR$/output" />
+ </component>
+ <component name="ProjectRunConfigurationManager" />
+ <component name="RmicSettings">
+ <option name="IS_EANABLED" value="false" />
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="false" />
+ <option name="GENERATE_IIOP_STUBS" value="false" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ </component>
+ <component name="StarteamVcsAdapter" />
+ <component name="VssVcs">
+ <SourceSafePersistencyRemovedFolder>$PROJECT_DIR$/wsrp/src/resources/test</SourceSafePersistencyRemovedFolder>
+ </component>
+ <component name="com.intellij.jsf.UserDefinedFacesConfigs">
+ <option name="USER_DEFINED_CONFIGS">
+ <value>
+ <list size="0" />
+ </value>
+ </option>
+ </component>
+ <component name="copyright">
+ <Base>
+ <setting name="state" value="1" />
+ </Base>
+ <LanguageOptions name="$TEMPLATE$">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="true" />
+ <option name="separateAfter" value="true" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="true" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="JBoss, a division of Red Hat Copyright &#36;today.year, Red Hat Middleware, LLC, and individual contributors as indicated by the @authors tag. See the copyright.txt 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 Fr!
anklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="4" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="CSS">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="HTML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JAVA">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JSP">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JavaScript">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="Properties">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="XML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ </component>
+ <component name="libraryTable" />
+ <component name="uidesigner-configuration">
+ <option name="INSTRUMENT_CLASSES" value="true" />
+ <option name="COPY_FORMS_RUNTIME_TO_OUTPUT" value="true" />
+ <option name="DEFAULT_LAYOUT_MANAGER" value="GridLayoutManager" />
+ </component>
+ <UsedPathMacros />
+</project>
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/common/common.iml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/common/common.iml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/common/common.iml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,556 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+ <component name="FacetManager">
+ <facet type="web" name="Web">
+ <configuration>
+ <descriptors>
+ <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/../../../../../../common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/web.xml" optional="false" version="2.4" />
+ </descriptors>
+ <webroots>
+ <root url="file://$MODULE_DIR$/../../../../../../common/src/test/resources/implode/foo.sar/bar.war" relative="/" />
+ </webroots>
+ <building>
+ <setting name="EXPLODED_URL" value="file://" />
+ <setting name="EXPLODED_ENABLED" value="false" />
+ <setting name="JAR_URL" value="file://" />
+ <setting name="JAR_ENABLED" value="false" />
+ <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+ <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+ <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+ <setting name="RUN_JASPER_VALIDATION" value="true" />
+ <setting name="BUILD_ONLY_WEB_RESOURCES" value="false" />
+ </building>
+ <packaging>
+ <containerElement type="module" name="common">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/classes" />
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-launcher.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-launcher.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-nodeps.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-nodeps.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/bsf.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/bsf.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/buildmagic-tasks.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/buildmagic-tasks.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/cargo-core-uberjar-0.8.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/crimson.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/crimson.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/explode.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/explode.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jboss-test.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jboss-test.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jbossbuild.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jbossbuild.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/saxon.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/saxon.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xalan.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xercesImpl.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xercesImpl.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xml-apis.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xml-apis.jar!/</url>
+ </containerElement>
+ </packaging>
+ </configuration>
+ </facet>
+ <facet type="web" name="Web2">
+ <configuration>
+ <descriptors>
+ <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/../../../../../../common/target/test-classes/implode/foo.sar/bar.war/WEB-INF/web.xml" optional="false" version="2.4" />
+ </descriptors>
+ <webroots>
+ <root url="file://$MODULE_DIR$/../../../../../../common/target/test-classes/implode/foo.sar/bar.war" relative="/" />
+ </webroots>
+ <building>
+ <setting name="EXPLODED_URL" value="file://" />
+ <setting name="EXPLODED_ENABLED" value="false" />
+ <setting name="JAR_URL" value="file://" />
+ <setting name="JAR_ENABLED" value="false" />
+ <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+ <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+ <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+ <setting name="RUN_JASPER_VALIDATION" value="true" />
+ <setting name="BUILD_ONLY_WEB_RESOURCES" value="false" />
+ </building>
+ <packaging>
+ <containerElement type="module" name="common">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/classes" />
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-launcher.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-launcher.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-nodeps.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-nodeps.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/bsf.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/bsf.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/buildmagic-tasks.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/buildmagic-tasks.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/cargo-core-uberjar-0.8.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/crimson.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/crimson.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/explode.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/explode.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jboss-test.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jboss-test.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jbossbuild.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jbossbuild.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/saxon.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/saxon.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xalan.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xercesImpl.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xercesImpl.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xml-apis.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xml-apis.jar!/</url>
+ </containerElement>
+ </packaging>
+ </configuration>
+ </facet>
+ </component>
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../../../../../../common/output/idea50/classes" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../../../../../../common">
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/main/resources" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/test/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/test/resources" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../../../../../../common/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/junit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-launcher.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/jboss-test.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/jbossbuild.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/explode.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xml-apis.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xercesImpl.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-nodeps.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/buildmagic-tasks.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/bsf.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/saxon.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/crimson.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntryProperties />
+ </component>
+ <component name="VcsManagerConfiguration">
+ <option name="ACTIVE_VCS_NAME" value="svn" />
+ <option name="USE_PROJECT_VCS" value="false" />
+ </component>
+ <component name="copyright">
+ <Base>
+ <setting name="state" value="1" />
+ </Base>
+ <LanguageOptions name="$TEMPLATE$">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="true" />
+ <option name="separateAfter" value="true" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="true" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="JBoss, a division of Red Hat Copyright &#36;today.year, Red Hat Middleware, LLC, and individual contributors as indicated by the @authors tag. See the copyright.txt 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 Fr!
anklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="4" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="CSS">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="HTML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JAVA">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JSP">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JavaScript">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="Properties">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="XML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ </component>
+</module>
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/mc/mc.iml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/mc/mc.iml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/mc/mc.iml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../../../../../../mc">
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../mc/src/main/java" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../../../../../../mc/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntryProperties />
+ </component>
+</module>
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/portal/portal.iml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/portal/portal.iml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/modules/portal/portal.iml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../../../../../../portal">
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../portal/src/main/java" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../../../../../../portal/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntryProperties />
+ </component>
+ <component name="VcsManagerConfiguration">
+ <option name="ACTIVE_VCS_NAME" value="svn" />
+ <option name="USE_PROJECT_VCS" value="false" />
+ </component>
+</module>
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/readme.txt
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/readme.txt (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/readme.txt 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,10 @@
+- Main project file and modules:
+Copy jboss-portal.ipr to the root of the Portal source directory. You might need to change the JDK to use but
+it should otherwise work out the box. Alternatively, you can create a new project file at the root of your Portal
+installation and import the module files (*.iml) found in the modules directory manually.
+
+- Codestyles and headers:
+The config directory contains standard settings for the JBoss Portal project regarding headers and code style. If
+you intend to commit code to JBoss Portal, you need to update your IDEA installation to use these files. Please
+refer to the IDEA manual on how to precisely do it, the short version being that you can replace the files found
+in your IDEA preference directory by the ones found in the config directory.
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/ide/intellij/idea60/readme.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/build/pom.xml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/build/pom.xml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/build/pom.xml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,144 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal</groupId>
+ <artifactId>jboss-portal-parent</artifactId>
+ <version>1.0.0</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <packaging>pom</packaging>
+ <name>JBoss Portal Modules Common</name>
+ <version>1.1-SNAPSHOT</version>
+ <url>http://labs.jboss.com/jbossportal</url>
+
+ <properties>
+ <version.activation>1.1</version.activation>
+ <version.javax.servlet>2.4</version.javax.servlet>
+ <version.jboss-j2ee>4.2.0.GA</version.jboss-j2ee>
+ <version.jboss-jmx>4.2.0.GA</version.jboss-jmx>
+ <version.log4j>1.2.14</version.log4j>
+ <version.apache.commons-httpclient>3.0.1</version.apache.commons-httpclient>
+ <version.jboss.microcontainer>2.0.0.Beta13</version.jboss.microcontainer>
+ <version.cargo>0.8</version.cargo>
+ <version.junit>3.8.1</version.junit>
+ <version.ant>1.6.5</version.ant>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${version.log4j}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>${version.activation}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <version>${version.jboss-j2ee}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>${version.ant}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ <version>${version.jboss-jmx}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>${version.apache.commons-httpclient}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>${version.javax.servlet}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>${version.ant}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ <version>${version.cargo}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>${version.ant}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>${version.ant}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>${version.jboss.microcontainer}</version>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.classpath
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.classpath (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.classpath 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="/thirdparty/apache-ant/lib/ant.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/oswego-concurrent/lib/concurrent.jar"/>
+ <classpathentry kind="lib" path="/tools/lib/xalan.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/sun-jaf/lib/activation.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-common.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-j2ee.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/apache-log4j/lib/log4j.jar"/>
+ <classpathentry kind="lib" path="/tools/lib/cargo-core-uberjar-0.8.jar"/>
+ <classpathentry kind="lib" path="/tools/lib/ant-junit.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/apache-httpclient/lib/commons-httpclient.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/backport-concurrent/lib/jboss-backport-concurrent.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/sun-servlet/lib/servlet-api.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.classpath
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.cvsignore
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.cvsignore (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.cvsignore 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,2 @@
+output
+bin
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.cvsignore
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.project
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.project (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.project 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/.project
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,126 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-common</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources/format/code</directory>
+ <includes>
+ <include>*.tpl</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- To use in conjonctin with
+ export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
+ -->
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+ <excludes>
+ <exclude>org/jboss/portal/test/common/BundleNameParserTestCase*.java</exclude>
+ <exclude>org/jboss/portal/test/common/net/URLNavigatorTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ </testResource>
+ </testResources>
+ </build>
+
+ <properties/>
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.2.working
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.2.working (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.2.working 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,208 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.1.1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-common</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+
+ <dependency>
+<<<<<<< .working
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4</version>
+ </dependency>
+
+ <dependency>
+=======
+>>>>>>> .merge-right.r10095
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ <version>0.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources/format/code</directory>
+ <includes>
+ <include>*.tpl</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- To use in conjonctin with
+ export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
+ -->
+<!--
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+-->
+ <excludes>
+ <exclude>org/jboss/portal/test/common/BundleNameParserTestCase*.java</exclude>
+ <exclude>org/jboss/portal/test/common/net/URLNavigatorTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ </testResource>
+ </testResources>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-changes-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <linkXref>true</linkXref>
+ <targetJdk>1.5</targetJdk>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <properties/>
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-left.r10094
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-left.r10094 (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-left.r10094 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,150 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-common</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-backport-concurrent</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources/format/code</directory>
+ <includes>
+ <include>*.tpl</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- To use in conjonctin with
+ export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
+ -->
+<!--
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+-->
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+ <excludes>
+ <exclude>org/jboss/portal/test/common/i18n/BundleNameParserTestCase*.java</exclude>
+ <exclude>org/jboss/portal/test/common/net/URLNavigatorTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ </testResource>
+ </testResources>
+ </build>
+
+ <properties/>
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-left.r10199
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-left.r10199 (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-left.r10199 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,138 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-common</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources/format/code</directory>
+ <includes>
+ <include>*.tpl</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- To use in conjonctin with
+ export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
+ -->
+<!--
+-->
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+ <excludes>
+ <exclude>org/jboss/portal/test/common/i18n/BundleNameParserTestCase*.java</exclude>
+ <exclude>org/jboss/portal/test/common/net/URLNavigatorTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ </testResource>
+ </testResources>
+ </build>
+
+ <properties/>
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-right.r10095
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-right.r10095 (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-right.r10095 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,140 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-common</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources/format/code</directory>
+ <includes>
+ <include>*.tpl</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- To use in conjonctin with
+ export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
+ -->
+<!--
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+-->
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+ <excludes>
+ <exclude>org/jboss/portal/test/common/i18n/BundleNameParserTestCase*.java</exclude>
+ <exclude>org/jboss/portal/test/common/net/URLNavigatorTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ </testResource>
+ </testResources>
+ </build>
+
+ <properties/>
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-right.r10200
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-right.r10200 (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.merge-right.r10200 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,136 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-common</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources/format/code</directory>
+ <includes>
+ <include>*.tpl</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- To use in conjonctin with
+ export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
+ -->
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+ <excludes>
+ <exclude>org/jboss/portal/test/common/i18n/BundleNameParserTestCase*.java</exclude>
+ <exclude>org/jboss/portal/test/common/net/URLNavigatorTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ </testResource>
+ </testResources>
+ </build>
+
+ <properties/>
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.working
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.working (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/pom.xml.working 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,211 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.1.1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-common</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+
+ <dependency>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-backport-concurrent</artifactId>
+ <version>2.1.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ <version>0.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources/format/code</directory>
+ <includes>
+ <include>*.tpl</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- To use in conjonctin with
+ export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
+ -->
+<!--
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+-->
+ <excludes>
+ <exclude>org/jboss/portal/test/common/BundleNameParserTestCase*.java</exclude>
+ <exclude>org/jboss/portal/test/common/net/URLNavigatorTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ </testResource>
+ </testResources>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-changes-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <linkXref>true</linkXref>
+ <targetJdk>1.5</targetJdk>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <properties/>
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/etc/portal-common-lib-jar.mf
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/etc/portal-common-lib-jar.mf (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/etc/portal-common-lib-jar.mf 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/etc/portal-common-lib-jar.mf
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/FixMe.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/FixMe.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/FixMe.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class FixMe extends UnsupportedOperationException
+{
+ public FixMe()
+ {
+ super("Fix me");
+ }
+
+ public FixMe(String featureName)
+ {
+ super("Feature: " + featureName + " needs to be fixed");
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/NotYetImplemented.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/NotYetImplemented.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/NotYetImplemented.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common;
+
+/**
+ * Thrown when a code join point is not implemented.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7331 $
+ */
+public class NotYetImplemented extends UnsupportedOperationException
+{
+ public NotYetImplemented()
+ {
+ super("Not yet implemented");
+ }
+
+ /**
+ * Constructor that takes a feature name for formatting the message.
+ *
+ * @param featureName the feature name that is not implemented
+ */
+ public NotYetImplemented(String featureName)
+ {
+ super("Feature: " + featureName + " is not yet implemented");
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcher.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcher.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcher.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class AdaptedMethodDispatcher implements MethodDispatcher
+{
+
+ /** . */
+ private final Method method;
+
+ /** . */
+ private final Object target;
+
+ public AdaptedMethodDispatcher(Method method, Object target)
+ {
+ this.method = method;
+ this.target = target;
+ }
+
+ public Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable
+ {
+ return method.invoke(target, args);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcherFactory.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcherFactory.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcherFactory.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class AdaptedMethodDispatcherFactory implements MethodDispatcherFactory
+{
+
+ /** . */
+ private final Object target;
+
+ public AdaptedMethodDispatcherFactory(Object target)
+ {
+ this.target = target;
+ }
+
+ public MethodDispatcher createDispatcher(Method method)
+ {
+ return new AdaptedMethodDispatcher(method, target);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdaptable.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdaptable.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdaptable.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * Denotes an object that is class adaptable.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface ClassAdaptable
+{
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapted.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapted.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapted.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * A class adapted.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ClassAdapted
+{
+
+ /** . */
+ final Class itf;
+
+ /** . */
+ final Object object;
+
+ public ClassAdapted(Class itf, Object object)
+ {
+ if (itf == null)
+ {
+ throw new IllegalArgumentException("No null adapted interface accepted");
+ }
+ if (!itf.isInterface())
+ {
+ throw new IllegalArgumentException("Adapted interface is not an interface");
+ }
+ if (object == null)
+ {
+ throw new IllegalArgumentException("No null adapted object accepted");
+ }
+
+ //
+ this.itf = itf;
+ this.object = object;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapter.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapter.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Creates a new class adapter.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ClassAdapter
+{
+
+ /** . */
+ private final Map dispatchers;
+
+ /** . */
+ private final Constructor ctor;
+
+ /** . */
+ private final InvocationHandler handler = new InvocationHandler()
+ {
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ MethodDispatcher dispatcher = (MethodDispatcher)dispatchers.get(method);
+
+ //
+ ClassAdaptable adaptable = (ClassAdaptable)proxy;
+
+ //
+ return dispatcher.dispatch(adaptable, args);
+ }
+ };
+
+ /**
+ * Creates a new class adapter. The object adapted implementation used will be an instance of
+ * <code>JavaLangObjectAdapted</code>.
+ *
+ * @param loader the class loader that will contain the dynamic proxy generated class
+ * @param adapteds the array of class adapteds
+ * @throws NoSuchMethodException
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public ClassAdapter(ClassLoader loader, ClassAdapted[] adapteds) throws NoSuchMethodException, IllegalArgumentException
+ {
+ this(loader, adapteds, new DefaultJavaLangObjectAdapted());
+ }
+
+ /**
+ * Create a new class adapter.
+ *
+ * @param loader the class loader that will contain the dynamic proxy generated class
+ * @param adapteds the array of class adapteds
+ * @param objectAdapted the implementation of object adapted
+ * @throws NoSuchMethodException
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public ClassAdapter(ClassLoader loader, ClassAdapted[] adapteds, JavaLangObjectAdapted objectAdapted) throws NoSuchMethodException, IllegalArgumentException
+ {
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("No null class loader accepted");
+ }
+ if (adapteds == null)
+ {
+ throw new IllegalArgumentException("No null adapteds accepted");
+ }
+ if (objectAdapted == null)
+ {
+ throw new IllegalArgumentException("No null object adapted accepted");
+ }
+
+ //
+ dispatchers = new HashMap();
+
+ //
+ addAdapted(Object.class, new JavaLangObjectMethodDispatcherFactory(objectAdapted));
+
+ //
+ Class[] itfs = new Class[adapteds.length + 1];
+ itfs[0] = ClassAdaptable.class;
+
+ //
+ for (int i = 0; i < adapteds.length; i++)
+ {
+ ClassAdapted adapted = adapteds[i];
+
+ //
+ if (adapted == null)
+ {
+ throw new IllegalArgumentException("No null adapted accepted");
+ }
+
+ //
+ itfs[1 + i] = adapted.itf;
+
+ //
+ addAdapted(adapted.itf, new AdaptedMethodDispatcherFactory(adapted.object));
+ }
+
+ //
+ ctor = Proxy.getProxyClass(loader, itfs).getConstructor(new Class[]{InvocationHandler.class});
+ }
+
+ private void addAdapted(Class adaptedClass, MethodDispatcherFactory methodDispatcherFactory)
+ {
+ Method[] methods = adaptedClass.getMethods();
+ for (int j = 0; j < methods.length; j++)
+ {
+ Method method = methods[j];
+ int modifiers = method.getModifiers();
+ if (Modifier.isPublic(modifiers) && !Modifier.isFinal(modifiers) && !Modifier.isStatic(modifiers))
+ {
+ if (!dispatchers.containsKey(method))
+ {
+ dispatchers.put(method, methodDispatcherFactory.createDispatcher(method));
+ }
+ }
+ }
+ }
+
+ /** Returns an instance of the the adaptable object. */
+ public ClassAdaptable getAdaptable() throws IllegalAccessException, InstantiationException, InvocationTargetException
+ {
+ return (ClassAdaptable)ctor.newInstance(new Object[]{handler});
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/DefaultJavaLangObjectAdapted.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/DefaultJavaLangObjectAdapted.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/DefaultJavaLangObjectAdapted.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class DefaultJavaLangObjectAdapted implements JavaLangObjectAdapted
+{
+
+ public String toString(ClassAdaptable adaptable)
+ {
+ return "Adapter[class=" + adaptable.getClass().getName() + ",hashCode=" + System.identityHashCode(adaptable) + "]";
+ }
+
+ public int hashCode(ClassAdaptable adaptable)
+ {
+ return System.identityHashCode(adaptable);
+ }
+
+ public boolean equals(ClassAdaptable adaptable, Object obj)
+ {
+ return adaptable == obj;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectAdapted.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectAdapted.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectAdapted.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * Defines contract for the <code>java.lang.Object</code> adapted.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface JavaLangObjectAdapted
+{
+ /**
+ * Implementation of <code>toString()</code>.
+ *
+ * @param adaptable the adaptable object
+ * @return the string value
+ */
+ String toString(ClassAdaptable adaptable);
+
+ /**
+ * Implementation of <code>hashCode</code>.
+ *
+ * @param adaptable the adaptable object
+ * @return the hash code value
+ */
+ int hashCode(ClassAdaptable adaptable);
+
+ /**
+ * Implementation of <code>equals</code>.
+ *
+ * @param adaptable the adaptable object
+ * @param obj the object to test equality with
+ * @return true the equals value
+ */
+ boolean equals(ClassAdaptable adaptable, Object obj);
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcher.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcher.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcher.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * Implementation of the <code>MethodDispatcher</code> interface for the methods of <code>java.lang.Object</code> which
+ * are delegated by a dynamic proxy to the <code>InvocationHandler</code>.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+abstract class JavaLangObjectMethodDispatcher implements MethodDispatcher
+{
+
+ /** . */
+ protected final JavaLangObjectAdapted target;
+
+ public JavaLangObjectMethodDispatcher(JavaLangObjectAdapted target)
+ {
+ this.target = target;
+ }
+
+ static class ToString extends JavaLangObjectMethodDispatcher
+ {
+
+ public ToString(JavaLangObjectAdapted target)
+ {
+ super(target);
+ }
+
+ public Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable
+ {
+ return target.toString(adaptable);
+ }
+ }
+
+ static class Equals extends JavaLangObjectMethodDispatcher
+ {
+
+ public Equals(JavaLangObjectAdapted target)
+ {
+ super(target);
+ }
+
+ public Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable
+ {
+ return Boolean.valueOf(target.equals(adaptable, args[0]));
+ }
+ }
+
+ static class HashCode extends JavaLangObjectMethodDispatcher
+ {
+
+ public HashCode(JavaLangObjectAdapted target)
+ {
+ super(target);
+ }
+
+ public Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable
+ {
+ return new Integer(target.hashCode(adaptable));
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcherFactory.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcherFactory.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcherFactory.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class JavaLangObjectMethodDispatcherFactory implements MethodDispatcherFactory
+{
+
+ /** . */
+ private final JavaLangObjectAdapted target;
+
+ public JavaLangObjectMethodDispatcherFactory(JavaLangObjectAdapted target)
+ {
+ this.target = target;
+ }
+
+ public MethodDispatcher createDispatcher(Method method)
+ {
+ if ("toString".equals(method.getName()))
+ {
+ return new JavaLangObjectMethodDispatcher.ToString(target);
+ }
+ else if ("equals".equals(method.getName()))
+ {
+ return new JavaLangObjectMethodDispatcher.Equals(target);
+ }
+ else if ("hashCode".equals(method.getName()))
+ {
+ return new JavaLangObjectMethodDispatcher.HashCode(target);
+ }
+ else
+ {
+ throw new AssertionError("Should not be possible");
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcher.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcher.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcher.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+interface MethodDispatcher
+{
+ Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable;
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcherFactory.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcherFactory.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcherFactory.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+interface MethodDispatcherFactory
+{
+ MethodDispatcher createDispatcher(Method method);
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.codehaus.cargo.container.ContainerType;
+import org.codehaus.cargo.container.RemoteContainer;
+import org.codehaus.cargo.container.configuration.Configuration;
+import org.codehaus.cargo.container.configuration.ConfigurationType;
+import org.codehaus.cargo.container.jboss.JBossJMXDeployer;
+import org.codehaus.cargo.container.property.GeneralPropertySet;
+import org.codehaus.cargo.container.property.ServletPropertySet;
+import org.codehaus.cargo.generic.ContainerFactory;
+import org.codehaus.cargo.generic.DefaultContainerFactory;
+import org.codehaus.cargo.generic.configuration.ConfigurationFactory;
+import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory;
+
+import java.io.File;
+
+/**
+ * A deployment task.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public abstract class AbstractDeploymentTask extends Task
+{
+
+ /** The file. */
+ private File file;
+
+ /** The JBoss config. */
+ private String config;
+
+ public AbstractDeploymentTask()
+ {
+ file = null;
+ config = "default";
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public void setFile(File file)
+ {
+ this.file = file;
+ }
+
+ public String getConfig()
+ {
+ return config;
+ }
+
+ public void setConfig(String config)
+ {
+ this.config = config;
+ }
+
+ public void execute() throws BuildException
+ {
+ //
+ ConfigurationFactory cfgFactory = new DefaultConfigurationFactory();
+ Configuration cfg = cfgFactory.createConfiguration("jboss4x", ConfigurationType.RUNTIME);
+
+ // Configure the container
+ if ("default".equals(config))
+ {
+ cfg.setProperty(GeneralPropertySet.PROTOCOL, "http");
+ cfg.setProperty(GeneralPropertySet.HOSTNAME, "localhost");
+ cfg.setProperty(ServletPropertySet.PORT, "8080");
+ }
+ else
+ {
+ throw new BuildException("Unknown configuration " + config);
+ }
+
+ //
+ if (file == null)
+ {
+ throw new BuildException("No specified file to deploy");
+ }
+
+ //
+ ContainerFactory containerFactory = new DefaultContainerFactory();
+ RemoteContainer container = (RemoteContainer)containerFactory.createContainer("jboss4x", ContainerType.REMOTE, cfg);
+
+ //
+ JBossJMXDeployer deployer = new JBossJMXDeployer(container);
+ execute(deployer);
+ }
+
+ protected abstract void execute(JBossJMXDeployer deployer);
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class CannotCreateDirException extends DirException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 4911314548182164515L;
+
+ public CannotCreateDirException(File file)
+ {
+ super(file, "Cannot create directory " + file.getName());
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.codehaus.cargo.container.deployable.Deployable;
+import org.codehaus.cargo.container.deployable.EAR;
+import org.codehaus.cargo.container.jboss.JBossJMXDeployer;
+
+/**
+ * A blocking deploy task.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Deploy extends AbstractDeploymentTask
+{
+
+ public Deploy()
+ {
+ }
+
+ protected void execute(JBossJMXDeployer deployer)
+ {
+ //
+ Deployable deployable = new EAR(getFile().getAbsolutePath());
+
+ //
+ deployer.deploy(deployable);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class DirException extends Exception
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7944765663293180164L;
+ private File file;
+
+ public DirException(File file, String msg)
+ {
+ super(msg);
+ this.file = file;
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,274 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipInputStream;
+
+/**
+ * Ant task that explode an archive.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Explode extends Task
+{
+
+ /** Unzipped extensions. */
+ private static final Set extensions = new HashSet(Arrays.asList(new String[]{"ear", "war", "sar", "har"}));
+
+ /** The exploded file. */
+ private File file;
+
+ /** The target directory. */
+ private File todir;
+
+ /** The target optional name. */
+ private String name;
+
+ /** filename to exclude from decompression * */
+ private String exclude;
+
+ public void setExclude(String exclude)
+ {
+ this.exclude = exclude;
+ }
+
+ public void setFile(File file)
+ {
+ this.file = file;
+ }
+
+ public void setTodir(File todir)
+ {
+ this.todir = todir;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public void execute() throws BuildException
+ {
+ try
+ {
+ explode(file, todir);
+ }
+ catch (DirException e)
+ {
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+ public void explode(File file, File todir) throws BuildException, DirException
+ {
+ if (!file.exists())
+ {
+ throw new BuildException("source file does not exists");
+ }
+ if (!file.isFile())
+ {
+ throw new BuildException("source file is not file");
+ }
+ if (name == null)
+ {
+ name = file.getName();
+ }
+ ZipInputStream zip = null;
+ try
+ {
+ zip = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
+ log("Process archive " + name);
+ explode(this, name, zip, todir, this.exclude);
+ }
+ catch (FileNotFoundException e)
+ {
+ throw new BuildException("Unexpected error " + e.getMessage());
+ }
+ finally
+ {
+ if (zip != null)
+ {
+ try
+ {
+ zip.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+ }
+ }
+
+ /**
+ * Explode a zip stream into a directory.
+ *
+ * @param explode used to log
+ * @param name the name of the created directory
+ * @param zip the zip stream will not be closed
+ * @param todir the parent directory
+ * @throws BuildException
+ * @throws DirException
+ */
+ public static void explode(Explode explode, String name, ZipInputStream zip, File todir, String exclude) throws BuildException, DirException
+ {
+ // First ensure the target directory exists
+ if (!todir.exists())
+ {
+ throw new BuildException("target dir does not exists");
+ }
+ if (!todir.isDirectory())
+ {
+ throw new BuildException("target dir is not a directory");
+ }
+ try
+ {
+ // Buffer
+ byte[] buffer = new byte[512];
+
+ // The real target dir
+ todir = new File(todir, name);
+
+ // Get the directory
+ ensureDirExist(explode, todir);
+
+ // Process each file
+ for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry())
+ {
+ // Next entry
+ File fic = new File(todir, entry.getName());
+ int lastDot = fic.getName().lastIndexOf(".");
+
+ if (entry.isDirectory())
+ {
+ // This is a directory that we must create
+ try
+ {
+ ensureDirExist(explode, fic);
+ }
+ catch (DirException e)
+ {
+ explode.log(e.getMessage());
+ }
+ }
+ else if (lastDot != -1 && extensions.contains(fic.getName().substring(lastDot + 1)))
+ {
+ // This is a nested archive, we explode it
+ try
+ {
+ explode.log("Process nested archive " + fic.getName());
+ if (!fic.getName().equalsIgnoreCase(exclude))
+ {
+ explode(explode, fic.getName(), new ZipInputStream(zip), todir, exclude);
+ }
+ }
+ catch (DirException e)
+ {
+ explode.log(e.getMessage());
+ }
+ }
+ else
+ {
+ // This is a file we write it
+ OutputStream out = null;
+ try
+ {
+ out = new BufferedOutputStream(new FileOutputStream(fic));
+ for (int size = zip.read(buffer); size != -1; size = zip.read(buffer))
+ {
+ out.write(buffer, 0, size);
+ }
+ }
+ catch (IOException e)
+ {
+ explode.log("Problem when writing file " + e.getMessage());
+ }
+ finally
+ {
+ if (out != null)
+ {
+ try
+ {
+ out.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (ZipException e)
+ {
+ throw new BuildException(e);
+ }
+ catch (IOException e)
+ {
+ throw new BuildException(e);
+ }
+ }
+
+ /** When it returns the dir exists otherwise it throws a BuildException */
+ private static void ensureDirExist(Explode explode, File dir) throws FileIsNotDirException, CannotCreateDirException
+ {
+ if (dir.exists())
+ {
+ if (dir.isDirectory())
+ {
+ // explode.log(dir.getName() + " exists and is used");
+ }
+ else
+ {
+ throw new FileIsNotDirException(dir);
+ }
+ }
+ else
+ {
+ if (dir.mkdirs())
+ {
+ // explode.log("Created directory " + dir.getName());
+ }
+ else
+ {
+ throw new CannotCreateDirException(dir);
+ }
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class FileIsNotDirException extends DirException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7596495857634457803L;
+
+ public FileIsNotDirException(File file)
+ {
+ super(file, file.getName() + " exists and is not a directory");
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,207 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Implode extends Task
+{
+
+ /** Unzipped extensions. */
+ private static final Set extensions = new HashSet(Arrays.asList(new String[]{"ear", "war", "sar", "har"}));
+
+ /** The exploded dir. */
+ private File dir;
+
+ /** The target file. */
+ private File tofile;
+
+ public void setDir(File dir)
+ {
+ this.dir = dir;
+ }
+
+ public void setTofile(File tofile)
+ {
+ this.tofile = tofile;
+ }
+
+ public void execute() throws BuildException
+ {
+ if (tofile == null)
+ {
+ throw new BuildException("target file should not be null");
+ }
+ if (dir == null)
+ {
+ throw new BuildException("source dir should not be null");
+ }
+ if (!dir.exists())
+ {
+ throw new BuildException("source dir does not exist");
+ }
+ if (dir.isFile())
+ {
+ throw new BuildException("source dir is a file");
+ }
+ if (tofile.exists() && tofile.isDirectory())
+ {
+ throw new BuildException("target file " + tofile + " designates a directory");
+ }
+ //if (tofile == null || tofile.lastModified() < dir.lastModified())
+
+
+ OutputStream out = null;
+ try
+ {
+ byte[] bytes = implode(dir);
+ out = new BufferedOutputStream(new FileOutputStream(tofile));
+ out.write(bytes);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ throw new BuildException(e.getMessage());
+ }
+ finally
+ {
+ if (out != null)
+ {
+ try
+ {
+ out.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+
+ }
+
+ public byte[] implode(File f) throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ JarOutputStream out = new JarOutputStream(baos);
+ implode(f, "", out);
+ out.close();
+ return baos.toByteArray();
+ }
+
+ public void implode(File f, String path, JarOutputStream out) throws IOException
+ {
+ if (f.isFile())
+ {
+ InputStream in = null;
+ try
+ {
+ in = new BufferedInputStream(new FileInputStream(f));
+ byte[] bytes = new byte[1024];
+
+ //
+ String fileName = path.substring(1);
+ JarEntry fileEntry = new JarEntry(fileName);
+ out.putNextEntry(fileEntry);
+
+ //
+ for (int l = in.read(bytes, 0, bytes.length); l > -0; l = in.read(bytes, 0, bytes.length))
+ {
+ out.write(bytes, 0, l);
+ }
+
+ //
+ out.closeEntry();
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+ }
+ else
+ {
+ if (path.length() > 1)
+ {
+ String dirName = path.substring(1) + '/';
+ JarEntry dirEntry = new JarEntry(dirName);
+ out.putNextEntry(dirEntry);
+ out.closeEntry();
+ }
+
+ //
+ File[] children = f.listFiles();
+ for (int i = 0; i < children.length; i++)
+ {
+ File child = children[i];
+ int lastDot = child.getName().lastIndexOf(".");
+ if (extensions.contains(child.getName().substring(lastDot + 1)))
+ {
+ byte[] bytes = implode(child);
+
+ //
+ String fileName = (path + '/' + child.getName()).substring(1);
+ JarEntry fileEntry = new JarEntry(fileName);
+ out.putNextEntry(fileEntry);
+
+ //
+ out.write(bytes, 0, bytes.length);
+
+ //
+ out.closeEntry();
+ }
+ else
+ {
+ implode(child, path + '/' + child.getName(), out);
+ }
+ }
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.codehaus.cargo.container.deployable.Deployable;
+import org.codehaus.cargo.container.deployable.EAR;
+import org.codehaus.cargo.container.jboss.JBossJMXDeployer;
+
+/**
+ * A blocking undeploy task.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Undeploy extends AbstractDeploymentTask
+{
+
+ protected void execute(JBossJMXDeployer deployer)
+ {
+ //
+ Deployable deployable = new EAR(getFile().getAbsolutePath());
+
+ //
+ deployer.undeploy(deployable);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,273 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.concurrent;
+
+/**
+ * Start in closed mode and adds an open() method to keep the same valve.
+ *
+ * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class Valve
+{
+
+ // Constants -----------------------------------------------------
+
+ /**
+ * The valve is open.
+ */
+ public static final int OPEN = 0;
+
+ /**
+ * The valve is in holding state.
+ */
+ public static final int CLOSING = 1;
+
+ /**
+ * The valve is in hold state.
+ */
+ public static final int CLOSED = 2;
+
+ /**
+ * User friendly names.
+ */
+ private static final String[] STATE_NAMES = {"OPEN","CLOSING","CLOSED"};
+
+ // Attributes ----------------------------------------------------
+
+ /**
+ * The state lock.
+ */
+ protected final Object stateLock = new Object();
+
+ /**
+ * The state.
+ */
+ protected int state;
+
+ /**
+ * The invocation count.
+ */
+ protected int invocations = 0;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Create a valve in the closed state
+ */
+ public Valve()
+ {
+ this(CLOSED);
+ }
+
+ /**
+ * Create a valve with the give initial state
+ *
+ * @param state the initial state
+ */
+ protected Valve(int state)
+ {
+ this.state = state;
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Are we closed?
+ *
+ * @return true when closing or closed, false otherwise
+ */
+ public boolean isClosed()
+ {
+ synchronized (stateLock)
+ {
+ return state != OPEN;
+ }
+ }
+
+ /**
+ * Invoked before an invocation
+ *
+ * @return true if allowed entry, false otherwise
+ */
+ public boolean beforeInvocation()
+ {
+ synchronized (stateLock)
+ {
+ if (state != OPEN)
+ {
+ return false;
+ }
+ ++invocations;
+ }
+ return true;
+ }
+
+ /**
+ * Invoked after an invocation
+ */
+ public void afterInvocation()
+ {
+ synchronized (stateLock)
+ {
+ --invocations;
+ stateLock.notifyAll();
+ }
+ }
+
+ /**
+ * Return the state.
+ */
+ public int getState()
+ {
+ return state;
+ }
+
+ /**
+ * How many invocations are held in the valve.
+ */
+ public int getInvocations()
+ {
+ return invocations;
+ }
+
+ /**
+ * Open the valve.
+ *
+ * @throws IllegalStateException if the valve is not closed
+ */
+ public void open() throws IllegalStateException
+ {
+ synchronized (stateLock)
+ {
+ if (state != CLOSED)
+ {
+ throw new IllegalStateException("Cannot invoke open() valve in state " + STATE_NAMES[state]);
+ }
+ state = OPEN;
+ }
+ }
+
+ /**
+ * Invoked before closing.
+ *
+ * @throws IllegalStateException if the valve is closed
+ */
+ public void closing() throws IllegalStateException
+ {
+ closing(0);
+ }
+
+ /**
+ * Invoked before closing.
+ *
+ * @throws IllegalStateException if the valve is closed
+ */
+ public boolean closing(long millis) throws IllegalStateException
+ {
+ boolean interrupted = false;
+ boolean empty = false;
+ synchronized (stateLock)
+ {
+ if (state == CLOSED)
+ {
+ throw new IllegalStateException("Cannot invoke closing() valve in state " + STATE_NAMES[state]);
+ }
+
+ //
+ state = CLOSING;
+
+ //
+ long finished = -1;
+ if (millis > 0)
+ {
+ finished = System.currentTimeMillis() + millis;
+ }
+
+ while (invocations > 0)
+ {
+ try
+ {
+ if (finished == -1)
+ {
+ stateLock.wait();
+ }
+ else
+ {
+ long time = finished - System.currentTimeMillis();
+ if (time > 0)
+ {
+ stateLock.wait(time);
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ catch (InterruptedException e)
+ {
+ interrupted = true;
+ }
+ }
+
+ empty = invocations == 0;
+ }
+
+ if (interrupted)
+ {
+ Thread.currentThread().interrupt();
+ }
+
+ return empty;
+ }
+
+ /**
+ * Invoked after closing.
+ *
+ * @throws IllegalStateException if the valve is not closing
+ */
+ public void closed() throws IllegalStateException
+ {
+ synchronized (stateLock)
+ {
+ if (state != CLOSING)
+ {
+ throw new IllegalStateException("Cannot invoke close() valve in state " + STATE_NAMES[state]);
+ }
+ state = CLOSED;
+ }
+ }
+
+ // Protected -----------------------------------------------------
+
+ // Package Private -----------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeader.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeader.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeader.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,243 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Modelize an http header structure.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class HttpHeader implements Serializable
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private List elements = new ArrayList();
+
+ public HttpHeader(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Element addElement(String name)
+ {
+ return addElement(new Element(name));
+ }
+
+ public Element addElement(String name, String value)
+ {
+ return addElement(new Element(name, value));
+ }
+
+ public Element addElement(Element element)
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ elements.add(element);
+ return element;
+ }
+
+ public Element getElement()
+ {
+ if (elements.size() > 0)
+ {
+ return (Element)elements.get(0);
+ }
+ return null;
+ }
+
+ public Iterator elements()
+ {
+ return elements.iterator();
+ }
+
+ /** An element of an header */
+ public static class Element implements Serializable
+ {
+ /** The mandatory name. */
+ private String name;
+
+ /** The optional value. */
+ private String value;
+
+ /** The params. */
+ private List params;
+
+ public Element(String name)
+ {
+ this(name, null);
+ }
+
+ public Element(String name, String value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.name = name;
+ this.value = value;
+ this.params = new ArrayList();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public Param addParam(String name)
+ {
+ return addParam(new Param(name));
+ }
+
+ public Param addParam(String name, String value)
+ {
+ return addParam(new Param(name, value));
+ }
+
+ public Param addParam(Param param)
+ {
+ if (param == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ params.add(param);
+ return param;
+ }
+
+ /**
+ * Return the first param of this element or null.
+ *
+ * @return the first param
+ */
+ public Param getParam()
+ {
+ if (params.size() > 0)
+ {
+ return (Param)params.get(0);
+ }
+ return null;
+ }
+
+ /**
+ * Returns an iterator over the params.
+ *
+ * @return a param iterator
+ */
+ public Iterator params()
+ {
+ return params.iterator();
+ }
+
+ /** A param of an element. */
+ public static class Param implements Serializable
+ {
+ /** The mandatory name. */
+ private String name;
+
+ /** The optional value. */
+ private String value;
+
+ public Param(String name)
+ {
+ this(name, null);
+ }
+
+ public Param(String name, String value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+ }
+ }
+
+ public String getValue()
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator j = elements(); j.hasNext();)
+ {
+ HttpHeader.Element elt = (HttpHeader.Element)j.next();
+ buffer.append(elt.getName());
+ if (elt.getValue() != null)
+ {
+ buffer.append("=").append(elt.getValue());
+ }
+ for (Iterator k = elt.params(); k.hasNext();)
+ {
+ HttpHeader.Element.Param param = (HttpHeader.Element.Param)k.next();
+ buffer.append(";").append(param.getName());
+ if (param.getValue() != null)
+ {
+ buffer.append("=").append(param.getValue());
+ }
+ }
+ if (j.hasNext())
+ {
+ buffer.append(",");
+ }
+ }
+ return buffer.toString();
+ }
+
+ public String toString()
+ {
+ return name + ": " + getValue();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeaders.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeaders.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeaders.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class HttpHeaders implements Serializable
+{
+
+ /** . */
+ private List headers = new ArrayList();
+
+ public HttpHeader addHeader(String name)
+ {
+ return addHeader(new HttpHeader(name));
+ }
+
+ public HttpHeader addHeader(HttpHeader header)
+ {
+ if (header == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ headers.add(header);
+ return header;
+ }
+
+ public HttpHeader getHeader(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ for (Iterator i = headers.iterator(); i.hasNext();)
+ {
+ HttpHeader header = (HttpHeader)i.next();
+ if (header.getName().equals(name))
+ {
+ return header;
+ }
+ }
+ return null;
+ }
+
+ public Iterator headers()
+ {
+ return headers.iterator();
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator i = headers.iterator(); i.hasNext();)
+ {
+ HttpHeader header = (HttpHeader)i.next();
+ buffer.append(header.toString());
+ buffer.append("\n");
+ }
+ return buffer.toString();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpRequest.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpRequest.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpRequest.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,112 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Just used to define the request body.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class HttpRequest implements Serializable
+{
+
+ public abstract static class Body implements Serializable
+ {
+ }
+
+ public static class Raw extends Body
+ {
+
+ /** . */
+ private byte[] bytes;
+
+ public byte[] getBytes()
+ {
+ return bytes;
+ }
+
+ public void setBytes(byte[] bytes)
+ {
+ this.bytes = bytes;
+ }
+ }
+
+ public static class Form extends Body
+ {
+
+ /** . */
+ private Map parameters = new HashMap();
+
+ public void addParameter(String name, String[] values)
+ {
+ if (name == null)
+ {
+ throw new IllegalStateException();
+ }
+ if (values == null)
+ {
+ throw new IllegalStateException();
+ }
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (value == null)
+ {
+ throw new IllegalStateException();
+ }
+ }
+ parameters.put(name, values.clone());
+ }
+
+ public void removeParameter(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalStateException();
+ }
+ parameters.remove(name);
+ }
+
+ public Set getParameterNames()
+ {
+ return Collections.unmodifiableSet(parameters.keySet());
+ }
+
+ public String[] getParameterValues(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalStateException();
+ }
+ String[] values = (String[])parameters.get(name);
+ return (String[])values.clone();
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpResponse.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpResponse.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/HttpResponse.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class HttpResponse implements Serializable
+{
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/QueryStringParser.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/QueryStringParser.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/http/QueryStringParser.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,268 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.common.text.CharEncoder;
+import org.jboss.portal.common.text.FastURLDecoder;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.EncodingException;
+import org.jboss.portal.common.util.ParameterMap;
+import org.apache.log4j.Logger;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * A parser for query string for the HTTP protocol. This class is thread safe.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7379 $
+ */
+public class QueryStringParser
+{
+
+ /** . */
+ private static QueryStringParser DEFAULT_PARSER = new QueryStringParser();
+
+ public static QueryStringParser getInstance()
+ {
+ return DEFAULT_PARSER;
+ }
+
+ /** . */
+ private static final Logger log = Logger.getLogger(QueryStringParser.class);
+
+ /** . */
+ private static final int LOOKUP = 0;
+
+ /** . */
+ private static final int INVALID_CHUNK = 1;
+
+ /** . */
+ private static final int PARAM_NAME = 2;
+
+ /** . */
+ private static final int PARAM_VALUE = 3;
+
+ /** . */
+ private CharEncoder parameterDecoder;
+
+ /**
+ * Create a new parser with the specified parameter decoder.
+ *
+ * @param parameterDecoder the parameter decoder
+ * @throws IllegalArgumentException if the decoder is null
+ */
+ public QueryStringParser(CharEncoder parameterDecoder) throws IllegalArgumentException
+ {
+ if (parameterDecoder == null)
+ {
+ throw new IllegalArgumentException("No parameter decoder");
+ }
+ this.parameterDecoder = parameterDecoder;
+ }
+
+ /**
+ * Creates a new parser with a decoder that will decode x-www-formurlencoded parameters with the
+ * UTF-8 charset.
+ */
+ public QueryStringParser()
+ {
+ this(FastURLDecoder.getUTF8Instance());
+ }
+
+ public CharEncoder getParameterDecoder()
+ {
+ return parameterDecoder;
+ }
+
+ private void append(ParameterMap parameterMap, String parameterName, String parameterValue)
+ {
+ String[] values = parameterMap.getValues(parameterName);
+
+ //
+ if (values == null)
+ {
+ values = new String[]{parameterValue};
+ }
+ else
+ {
+ String[] tmp = new String[values.length + 1];
+ System.arraycopy(values, 0, tmp, 0, values.length);
+ values = tmp;
+ values[values.length - 1] = parameterValue;
+ }
+
+ //
+ parameterMap.setValues(parameterName, values);
+ }
+
+ /**
+ * Parse the query string and build an unmodifiable parameter map of it.
+ *
+ * @param queryString the non null query string
+ * @return a <String,String[]> map
+ * @throws IllegalArgumentException if the query string is null
+ */
+ public ParameterMap parseQueryString(String queryString) throws IllegalArgumentException
+ {
+ if (queryString == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ // Map result = Collections.EMPTY_MAP;
+
+ ParameterMap parameterMap = new ParameterMap();
+
+ String encodedName = null;
+ CharBuffer buffer = new CharBuffer(50);
+
+
+ int pos = 0;
+ int len = queryString.length();
+ int state = LOOKUP;
+ while (true)
+ {
+ char c;
+ if (pos < len)
+ {
+ c = queryString.charAt(pos++);
+ }
+ else if (pos == len)
+ {
+ c = '&';
+ pos++;
+ }
+ else
+ {
+ break;
+ }
+
+ //
+ switch(state)
+ {
+ case LOOKUP:
+ if (c == '&')
+ {
+ // Do nothing
+ }
+ else if (c == '=')
+ {
+ state = INVALID_CHUNK;
+ }
+ else
+ {
+ state = PARAM_NAME;
+ buffer.append(c);
+ }
+ break;
+ case PARAM_NAME:
+ if (c == '&')
+ {
+ String tmp = buffer.asString();
+
+ //
+ try
+ {
+ parameterDecoder.encode(tmp, buffer);
+ append(parameterMap, buffer.asString(false), "");
+ }
+ catch (EncodingException e)
+ {
+ log.debug("Could not decode parameter name " + tmp, e);
+ }
+
+ //
+ buffer.reset();
+ state = LOOKUP;
+ }
+ else if (c == '=')
+ {
+ encodedName = buffer.asString();
+ buffer.reset();
+ state = PARAM_VALUE;
+ }
+ else
+ {
+ buffer.append(c);
+ }
+ break;
+ case PARAM_VALUE:
+ if (c == '&')
+ {
+
+ //
+ try
+ {
+ // Save value
+ String encodedValue = buffer.asString();
+
+ // Decode parameter name
+ parameterDecoder.encode(encodedName, buffer);
+ String name = buffer.asString(false);
+
+ // Now decode parameter value
+ try
+ {
+ buffer.reset();
+ parameterDecoder.encode(encodedValue, buffer);
+ String value = buffer.asString();
+ append(parameterMap, name, value);
+ }
+ catch (EncodingException e)
+ {
+ log.debug("Could not decode parameter value " + encodedValue, e);
+ }
+ }
+ catch (EncodingException e)
+ {
+ log.debug("Could not decode parameter name " + encodedName, e);
+ }
+
+ //
+ buffer.reset();
+ state = LOOKUP;
+ }
+ else
+ {
+ buffer.append(c);
+ }
+ break;
+ case INVALID_CHUNK:
+ if (c == '&')
+ {
+ state = LOOKUP;
+ }
+ break;
+ }
+ }
+
+ //
+ return parameterMap;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+import org.jboss.portal.common.util.ConversionException;
+import org.jboss.portal.common.util.NullConversionException;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public abstract class AbstractLocaleFormat implements LocaleFormat
+{
+
+ public Locale getLocale(String value) throws ConversionException
+ {
+ if (value == null)
+ {
+ throw new NullConversionException("No null locale value accepted");
+ }
+ return internalGetLocale(value);
+ }
+
+ public String toString(Locale locale) throws ConversionException
+ {
+ if (locale == null)
+ {
+ throw new NullConversionException("No null locale accepted");
+ }
+ return internalToString(locale);
+ }
+
+ public void write(Locale locale, Writer writer) throws IOException, ConversionException
+ {
+ if (locale == null)
+ {
+ throw new NullConversionException("No null locale accepted");
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("No null writer accepted");
+ }
+ internalWrite(locale, writer);
+ }
+
+ protected abstract Locale internalGetLocale(String value) throws ConversionException;
+
+ protected String internalToString(Locale locale) throws ConversionException
+ {
+ try
+ {
+ StringWriter writer = new StringWriter();
+ internalWrite(locale, writer);
+ return writer.toString();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ protected abstract void internalWrite(Locale locale, Writer writer) throws IOException, ConversionException;
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,310 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+import java.util.NoSuchElementException;
+
+/**
+ * The immutable name of a bundle.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class BundleName
+{
+
+ public BundleName(String baseName)
+ {
+ this(baseName, "", "", "");
+ }
+
+ public BundleName(String baseName, String language)
+ {
+ this(baseName, language, "", "");
+ }
+
+ public BundleName(String baseName, String language, String country)
+ {
+ this(baseName, language, country, "");
+ }
+
+ public BundleName(String baseName, String language, String country, String variant)
+ {
+ if (baseName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (language == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (country == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (variant == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.baseName = baseName;
+ this.language = language;
+ this.country = country;
+ this.variant = variant;
+ }
+
+ /** . */
+ private final String baseName;
+
+ /** Lower-case two-letter codes as defined by ISO-639. */
+ private final String language;
+
+ /** Upper-case two-letter codes as defined by ISO-3166. */
+ private final String country;
+
+ /** . */
+ private final String variant;
+
+ public String getBaseName()
+ {
+ return baseName;
+ }
+
+ public String getLanguage()
+ {
+ return language;
+ }
+
+ public String getCountry()
+ {
+ return country;
+ }
+
+ public String getVariant()
+ {
+ return variant;
+ }
+
+ public static class Iterator implements java.util.Iterator
+ {
+
+ /** . */
+ private final String language;
+
+ /** . */
+ private final String country;
+
+ /** . */
+ private final String variant;
+
+ /** . */
+ private String name;
+
+ /** . */
+ private int status;
+
+ public Iterator(String baseName, Locale locale)
+ {
+ language = locale.getLanguage();
+ country = locale.getCountry();
+ variant = locale.getVariant();
+ status = 8 + (language.length() > 0 ? 4 : 0) + (country.length() > 0 ? 2 : 0) + (variant.length() > 0 ? 1 : 0);
+ switch (status & 0x7)
+ {
+ case 0:
+ name = baseName;
+ break;
+ case 1:
+ name = baseName + "___" + variant;
+ break;
+ case 2:
+ name = baseName + "__" + country;
+ break;
+ case 3:
+ name = baseName + "__" + country + "_" + variant;
+ break;
+ case 4:
+ name = baseName + "_" + language;
+ break;
+ case 5:
+ name = baseName + "_" + language + "__" + variant;
+ break;
+ case 6:
+ name = baseName + "_" + language + "_" + country;
+ break;
+ case 7:
+ name = baseName + "_" + language + "_" + country + "_" + variant;
+ break;
+ default:
+ throw new AssertionError("Should not be here");
+ }
+ }
+
+ public boolean hasNext()
+ {
+ return status != 0;
+ }
+
+ public Object next()
+ {
+ if (status >= 8)
+ {
+ status -= 8;
+ }
+ else
+ {
+ switch (status)
+ {
+ case 0:
+ throw new NoSuchElementException();
+ case 1:
+ name = name.substring(0, name.length() - 3 - variant.length());
+ status = 0;
+ break;
+ case 2:
+ name = name.substring(0, name.length() - 2 - country.length());
+ status = 0;
+ break;
+ case 3:
+ name = name.substring(0, name.length() - 1 - variant.length());
+ status = 2;
+ break;
+ case 4:
+ name = name.substring(0, name.length() - 1 - language.length());
+ status = 0;
+ break;
+ case 5:
+ name = name.substring(0, name.length() - 2 - variant.length());
+ status = 4;
+ break;
+ case 6:
+ name = name.substring(0, name.length() - 1 - country.length());
+ status = 4;
+ break;
+ case 7:
+ name = name.substring(0, name.length() - 1 - variant.length());
+ status = 6;
+ break;
+ default:
+ throw new AssertionError("Should not be here");
+ }
+ }
+ return name;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ *
+ */
+ public static class Parser
+ {
+ /**
+ * @param s
+ * @param from inclusive
+ * @param to exclusive
+ * @return
+ */
+ public BundleName parse(String s, int from, int to)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (from < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (to < s.length())
+ {
+ throw new IllegalArgumentException();
+ }
+ if (to < from)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ int p1 = s.lastIndexOf('_', to - 1);
+ if (p1 < from)
+ {
+ p1 = -1;
+ }
+
+ //
+ if (p1 == -1)
+ {
+ // We have base name
+ return new BundleName(s.substring(from, to));
+ }
+ else if (p1 == to - 1)
+ {
+ // It ends up with _ or __ or ___
+ return null;
+ }
+ String a = s.substring(p1 + 1, to);
+
+ //
+ int p2 = s.lastIndexOf('_', p1 - 1);
+ if (p2 < from)
+ {
+ p2 = -1;
+ }
+
+ //
+ if (p2 == -1)
+ {
+ // We have base name + language
+ return new BundleName(s.substring(from, p1), a);
+ }
+ String b = p2 == p1 - 1 ? "" : s.substring(p2 + 1, p1);
+
+ //
+ int p3 = s.lastIndexOf('_', p2 - 1);
+ if (p3 < from)
+ {
+ p3 = -1;
+ }
+
+ //
+ if (p3 == -1)
+ {
+ // We have (base name + language + country) or (base name + country)
+ return new BundleName(s.substring(from, p2), b, a);
+ }
+
+ //
+ String c = (p3 == p2 - 1) ? "" : s.substring(p3 + 1, p2);
+
+ // We have (base name + variant)
+ // or (base name + country + variant)
+ // or (base name + language + country + variant)
+ // or (base name + language + variant)
+ return new BundleName(s.substring(from, p3), c, b, a);
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.ConversionException;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class CachingLocaleFormat implements LocaleFormat
+{
+
+ /** . */
+ private final LocaleFormat delegate;
+
+ /** . */
+ private final ConcurrentHashMap<String, Locale> localeCache;
+
+ /** . */
+ private final ConcurrentHashMap<Locale, String> stringCache;
+
+ /**
+ * @param delegate the delegate when the cache value has not been found
+ * @throws IllegalArgumentException if the delegate object provided is null
+ */
+ public CachingLocaleFormat(LocaleFormat delegate) throws IllegalArgumentException
+ {
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException("No null delegate is possible");
+ }
+ this.delegate = delegate;
+ this.localeCache = new ConcurrentHashMap<String, Locale>();
+ this.stringCache = new ConcurrentHashMap<Locale, String>();
+ }
+
+ public Locale getLocale(String value) throws ConversionException
+ {
+ Locale locale = localeCache.get(value);
+
+ //
+ if (locale != null)
+ {
+ return locale;
+ }
+ else
+ {
+ locale = delegate.getLocale(value);
+ localeCache.put(value, locale);
+ }
+
+ //
+ return locale;
+ }
+
+ public String toString(Locale locale) throws ConversionException
+ {
+ String string = stringCache.get(locale);
+
+ //
+ if (string != null)
+ {
+ return string;
+ }
+ else
+ {
+ string = delegate.toString(locale);
+ stringCache.put(locale, string);
+ }
+
+ //
+ return string;
+ }
+
+ public void write(Locale locale, Writer writer) throws IOException, ConversionException
+ {
+ delegate.write(locale, writer);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.io.IOTools;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7374 $
+ */
+public class ComplexResourceBundleFactory implements ResourceBundleFactory
+{
+
+ /** . */
+ private final ClassLoader resourceLoader;
+
+ /** . */
+ private final String baseName;
+
+ public ComplexResourceBundleFactory(ClassLoader resourceLoader, String baseName)
+ {
+ this.resourceLoader = resourceLoader;
+ this.baseName = baseName;
+ }
+
+ public ResourceBundle getBundle(Locale locale) throws IllegalArgumentException
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ for (BundleName.Iterator iterator = new BundleName.Iterator(baseName, locale); iterator.hasNext();)
+ {
+ String name = (String)iterator.next();
+
+ // We don't want to process the base name only with the specified locale
+ // in order to respect the sequence of candidate bundle names
+ if (!iterator.hasNext())
+ {
+ break;
+ }
+
+ //
+ ResourceBundle bundle = lookup(name);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+ }
+
+ // Try default locale
+ for (BundleName.Iterator iterator = new BundleName.Iterator(baseName, Locale.getDefault()); iterator.hasNext();)
+ {
+ String name = (String)iterator.next();
+
+ //
+ ResourceBundle bundle = lookup(name);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+ }
+
+ // Nothing was found
+ return null;
+ }
+
+ protected ResourceBundle lookup(String s)
+ {
+ // Try to load class first
+ // we don't do that for now !!!
+
+ // Try to load bundle then
+ String propertyName = s.replace('.', '/') + ".properties";
+ InputStream in = resourceLoader.getResourceAsStream(propertyName);
+ if (in != null)
+ {
+ try
+ {
+ in = IOTools.safeBufferedWrapper(in);
+ return new PropertyResourceBundle(in);
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ //
+ return null;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,120 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.FormatConversionException;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Implementation for the programmatic name of a locale.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class DefaultLocaleFormat extends AbstractLocaleFormat
+{
+
+ /** . */
+ private static final Map CACHE = new HashMap();
+
+ static
+ {
+ for (Iterator i = LocaleManager.getLocales().iterator(); i.hasNext();)
+ {
+ Locale locale = (Locale)i.next();
+
+ //
+ CACHE.put(locale.toString(), locale);
+ }
+ }
+
+ /** . */
+ private LocaleFactory factory;
+
+ public DefaultLocaleFormat(LocaleFactory factory)
+ {
+ this.factory = factory;
+ }
+
+ public DefaultLocaleFormat()
+ {
+ this(LocaleFactory.DEFAULT_FACTORY);
+ }
+
+ protected Locale internalGetLocale(String value) throws FormatConversionException
+ {
+ Locale locale = (Locale)CACHE.get(value);
+ if (locale != null)
+ {
+ return locale;
+ }
+
+ //
+ int p1 = value.lastIndexOf('_');
+ if (p1 < 0)
+ {
+ return factory.createLocale(value);
+ }
+
+ //
+ String a = (p1 == (value.length() - 1)) ? "" : value.substring(p1 + 1, value.length());
+
+ //
+ int p2 = value.lastIndexOf('_', p1 - 1);
+ if (p2 < 0)
+ {
+ if (a.length() == 0)
+ {
+ throw new FormatConversionException();
+ }
+ else
+ {
+ return factory.createLocale(value.substring(0, p1), a);
+ }
+ }
+
+ //
+ boolean emptyLanguage = p2 == p1 - 1;
+ if (p2 == 0 && emptyLanguage)
+ {
+ throw new FormatConversionException();
+ }
+
+ //
+ String b = emptyLanguage ? "" : value.substring(p2 + 1, p1);
+
+ //
+ return factory.createLocale(value.substring(0, p2), b, a);
+ }
+
+ protected void internalWrite(Locale locale, Writer writer) throws IOException
+ {
+ writer.write(locale.toString());
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/I18NTools.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/I18NTools.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/I18NTools.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class I18NTools
+{
+
+ /** Separator. */
+ private static final String RFC3066_SEPARATOR = "-";
+
+ /**
+ * Retrieves the language identification tag associated to the specified Locale as defined by <a
+ * href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter language code per ISO standard
+ * 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes. E.g. "en-US" for American
+ * English, "en-GB" for British English, etc.
+ *
+ * @param locale the locale which language tag is wanted
+ * @return a <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>-compatible language tag.
+ * @throws IllegalArgumentException if the given locale is not valid
+ * @since 2.4
+ */
+ public static String getRFC3066LanguageTagFor(Locale locale)
+ {
+ String country = locale.getCountry(); // country will be empty if no country was specified in the locale
+ return locale.getLanguage() + ((country.length() == 2) ? RFC3066_SEPARATOR + country : country);
+ }
+
+ /**
+ * Compute the trailing name for a given locale.
+ *
+ * @param locale the locale
+ * @return the trailing name
+ * @throws IllegalArgumentException if locale is null
+ */
+ public static String computeTrailingName(Locale locale) throws IllegalArgumentException
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("locale parameter is null");
+ }
+ StringBuffer tmp = new StringBuffer();
+ if (locale.getLanguage() != null && locale.getLanguage().length() > 0)
+ {
+ tmp.append('_').append(locale.getLanguage());
+ if (locale.getCountry() != null && locale.getCountry().length() > 0)
+ {
+ tmp.append('_').append(locale.getCountry());
+ {
+ if (locale.getVariant() != null && locale.getVariant().length() > 0)
+ {
+ tmp.append('_').append(locale.getVariant());
+ }
+ }
+ }
+ }
+ return tmp.toString();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFactory.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFactory.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFactory.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface LocaleFactory
+{
+
+ LocaleFactory DEFAULT_FACTORY = new LocaleFactory()
+ {
+ public Locale createLocale(String language)
+ {
+ return new Locale(language);
+ }
+
+ public Locale createLocale(String language, String country)
+ {
+ return new Locale(language, country);
+ }
+
+ public Locale createLocale(String language, String country, String variant)
+ {
+ return new Locale(language, country, variant);
+ }
+ };
+
+ Locale createLocale(String language);
+
+ Locale createLocale(String language, String country);
+
+ Locale createLocale(String language, String country, String variant);
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.ConversionException;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface LocaleFormat
+{
+
+ /** . */
+ final LocaleFormat RFC3066_LANGUAGE_TAG_NO_CACHE = new RFC3066LanguageTagLocaleFormat();
+
+ /** . */
+ final LocaleFormat DEFAULT_NO_CACHE = new DefaultLocaleFormat();
+
+ /** . */
+ final LocaleFormat RFC3066_LANGUAGE_TAG = new CachingLocaleFormat(new RFC3066LanguageTagLocaleFormat());
+
+ /** . */
+ final LocaleFormat DEFAULT = new CachingLocaleFormat(new DefaultLocaleFormat());
+
+ Locale getLocale(String value) throws ConversionException;
+
+ String toString(Locale locale) throws ConversionException;
+
+ void write(Locale locale, Writer writer) throws IOException, ConversionException;
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleManager.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleManager.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleManager.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.Tools;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class LocaleManager
+{
+
+ /** . */
+ private static final Collection all = Collections.unmodifiableSet(Tools.toSet(Locale.getAvailableLocales()));
+
+ /** Return a collection of all available locale info for the platform. */
+ public static Collection getLocales()
+ {
+ return all;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.PropertyResourceBundle;
+import java.util.Locale;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class LocalizedPropertyResourceBundle extends PropertyResourceBundle
+{
+
+ private final Locale locale;
+
+ /**
+ * Create an instanceof of localized property resource bundle.
+ *
+ * @param stream the stream to decode the property file
+ * @param locale the locale to use
+ * @throws IllegalArgumentException if the locale is null
+ */
+ public LocalizedPropertyResourceBundle(InputStream stream, Locale locale) throws IOException
+ {
+ super(stream);
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("Locale cannot be null");
+ }
+ this.locale = locale;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,442 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.util.ConversionException;
+
+/**
+ * An immutable locale sensitive object that returns strings.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7200 $
+ */
+public final class LocalizedString
+{
+
+ /** The logger. */
+ private static final Logger log = Logger.getLogger(LocalizedString.class);
+
+ /** An unmodifiable <Locale,String>Map. */
+ private final Map values;
+
+ /** The default locale. */
+ private final Locale defaultLocale;
+
+ /** The cached hashCode. */
+ private Integer hashCode;
+
+ /** The cached toString. */
+ private String cachedToString;
+
+ /**
+ * Convenience constructor for simple localized strings with only one value using the <code>Locale.ENGLISH</code> locale.
+ *
+ * @param defaultValue the localized value using the specified default locale
+ * @throws IllegalArgumentException if no default value or locale is provided
+ * @since 2.6
+ */
+ public LocalizedString(String defaultValue) throws IllegalArgumentException
+ {
+ this(defaultValue, Locale.ENGLISH);
+ }
+
+ /**
+ * Convenience constructor for simple localized strings with only one value using the default locale.
+ *
+ * @param defaultValue the localized value using the specified default locale
+ * @param defaultLocale the default locale
+ * @throws IllegalArgumentException if no default value or locale is provided
+ * @since 2.4
+ */
+ public LocalizedString(String defaultValue, Locale defaultLocale) throws IllegalArgumentException
+ {
+ if (defaultValue == null)
+ {
+ throw new IllegalArgumentException("No null default value allowed");
+ }
+ if (defaultLocale == null)
+ {
+ throw new IllegalArgumentException("No null default locale allowed");
+ }
+
+ //
+ Map values = new HashMap(1);
+ addValueForLocale(values, defaultLocale, defaultValue);
+
+ //
+ this.defaultLocale = defaultLocale;
+ this.values = Collections.unmodifiableMap(values);
+ }
+
+ /**
+ * Build an empty localized string.
+ *
+ * @param defaultLocale the default locale
+ * @throws IllegalArgumentException if no default locale is provided
+ */
+ public LocalizedString(Locale defaultLocale) throws IllegalArgumentException
+ {
+ if (defaultLocale == null)
+ {
+ throw new IllegalArgumentException("No null default locale allowed");
+ }
+
+ //
+ this.defaultLocale = defaultLocale;
+ this.values = Collections.EMPTY_MAP;
+ }
+
+ /**
+ * Build a localized string using a <Locale,String>Map object.
+ *
+ * @param values the <Locale,String>Map
+ * @param defaultLocale
+ * @throws IllegalArgumentException if one argument if null or if the map entries are different from <Locale,String>Map.Entry
+ */
+ public LocalizedString(Map values, Locale defaultLocale) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException("No null description map allowed");
+ }
+ if (defaultLocale == null)
+ {
+ throw new IllegalArgumentException("No null default locale allowed");
+ }
+
+ // Convert strings to value
+ Map tmp = new HashMap(values.size());
+ for (Iterator i = values.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ Object key = entry.getKey();
+ if (!(key instanceof Locale))
+ {
+ throw new IllegalArgumentException("Key not a locale " + entry.getKey());
+ }
+ Object value = entry.getValue();
+ if (!(value instanceof String))
+ {
+ throw new IllegalArgumentException("Value not a string " + entry.getValue());
+ }
+ addValueForLocale(tmp, (Locale)key, (String)value);
+ }
+
+ //
+ this.defaultLocale = defaultLocale;
+ this.values = Collections.unmodifiableMap(tmp);
+ }
+
+ /**
+ * Adds a new value for the specified locale to this LocalizedString. Note that if a value existed for this Locale,
+ * it will be overwritten.
+ *
+ * @param locale the locale of the value
+ * @param value the value
+ * @since 2.4
+ */
+ private static void addValueForLocale(Map values, Locale locale, String value)
+ {
+ values.put(locale, new Value(locale, value));
+ }
+
+ /**
+ * Determines if this LocalizedString contains any values.
+ *
+ * @return <code>true</code> if this LocalizedString contains localized values, <code>false</code> otherwise.
+ * @since 2.4
+ */
+ public boolean hasValues()
+ {
+ return values.isEmpty() == false;
+ }
+
+ /**
+ * Return the string for the default locale.
+ *
+ * @return the string for the default locale
+ */
+ public String getDefaultString()
+ {
+ return getString(defaultLocale, false);
+ }
+
+ /**
+ * Returns the value for the default locale.
+ *
+ * @return the value for the default locale
+ */
+ public Value getDefaultValue()
+ {
+ return getValue(defaultLocale, false);
+ }
+
+ /**
+ * Returns a string value.
+ *
+ * @param locale the desired locale
+ * @param resolve true if the locale must be resolved to the most appropriate
+ * @return the description string or null if it is not found
+ */
+ public String getString(Locale locale, boolean resolve)
+ {
+ Value value = getValue(locale, resolve);
+ if (value != null)
+ {
+ return value.getString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns a localized value. The lookup operation can be done without resolution which
+ * means that the locale is just used as a key during the lookup. If the lookup operation is done with
+ * resolution then the different parts of the locale will be used during the operation.
+ *
+ * @param locale the desired locale
+ * @param resolve true if the locale must be resolved to the most appropriate
+ * @return the value or null if it is not found
+ */
+ public Value getValue(Locale locale, boolean resolve)
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("No null locale accepted as argument");
+ }
+
+ // fail fast is there aren't any values
+ if (values.isEmpty())
+ {
+ return null;
+ }
+
+ if (resolve)
+ {
+ Value value = (Value)values.get(locale);
+ if (value == null && !locale.getVariant().equals(""))
+ {
+ value = (Value)values.get(new Locale(locale.getLanguage(), locale.getCountry()));
+ }
+ if (value == null && !locale.getCountry().equals(""))
+ {
+ value = (Value)values.get(new Locale(locale.getLanguage()));
+ }
+ if (value == null)
+ {
+ value = (Value)values.get(defaultLocale);
+ }
+ return value;
+ }
+ else
+ {
+ return (Value)values.get(locale);
+ }
+ }
+
+ public Map getValues()
+ {
+ return Collections.unmodifiableMap(values);
+ }
+
+ /**
+ * Return the default locale of this localized string.
+ *
+ * @return the default locale
+ */
+ public Locale getDefaultLocale()
+ {
+ return defaultLocale;
+ }
+
+ /**
+ * Retrieves the localized value most appropriate based on the given desired locales.
+ *
+ * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
+ * RFC 3066</a>) ordered according to locale preferences.
+ * @return the most appropriate localized value based on locale preferences.
+ * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see
+ * #getLocaleFromRFC3066LanguageTag(String))
+ * @since 2.4
+ */
+ public String getMostAppropriateValueFor(String[] desiredLocales) throws IllegalArgumentException
+ {
+ Value mapping = getPreferredOrBestLocalizedMappingFor(desiredLocales);
+ return (mapping == null) ? null : mapping.getString();
+ }
+
+ /**
+ * Retrieves the Locale-String mapping most appropriate based on the given desired locales, which are ordered
+ * according to locale preferences.
+ *
+ * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
+ * RFC 3066</a>) ordered according to locale preferences.
+ * @return a Map.Entry representing the most appropriate mapping between Locale and localized value, based on locale
+ * preferences.
+ * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see {@link
+ * LocaleFormat#RFC3066_LANGUAGE_TAG#getLocale(String)}
+ * @since 2.4
+ */
+ public Value getPreferredOrBestLocalizedMappingFor(String[] desiredLocales) throws IllegalArgumentException
+ {
+ if (desiredLocales == null)
+ {
+ throw new IllegalArgumentException("No null desired locale array accepted");
+ }
+
+ //
+ if (values.isEmpty())
+ {
+ return null;
+ }
+
+ //
+ Value value = null;
+ if (desiredLocales.length > 0)
+ {
+ for (int i = 0; value == null && i < desiredLocales.length; i++)
+ {
+ String desiredLocale = desiredLocales[i];
+
+ //
+ if (desiredLocale == null)
+ {
+ throw new IllegalArgumentException("Null desired locale not accepted");
+ }
+
+ //
+ try
+ {
+ Locale locale = LocaleFormat.RFC3066_LANGUAGE_TAG.getLocale(desiredLocale);
+ value = getValue(locale, true);
+ }
+ catch (ConversionException e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Invalid desired locale " + desiredLocale);
+ }
+ }
+ }
+
+ // todo julien
+ // We could have a smarter version of this method but this version requires that desiredLocales
+ // are ordered by locale preference. Hence the first found is by definition the best.
+ }
+
+ //
+ if (value == null)
+ {
+ value = getValue(defaultLocale, true);
+ }
+
+ //
+ return value;
+ }
+
+ public String toString()
+ {
+ if (cachedToString == null)
+ {
+ cachedToString = "LocalizedString[value='" + getMostAppropriateValueFor(new String[0]) + "',defaultLocale=" + getDefaultLocale() + "]";
+ }
+ return cachedToString;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || LocalizedString.class != o.getClass())
+ {
+ return false;
+ }
+
+ //
+ LocalizedString that = (LocalizedString)o;
+ return defaultLocale.equals(that.defaultLocale) && getMostAppropriateValueFor(new String[0]).equals(that.getMostAppropriateValueFor(new String[0]));
+ }
+
+ public int hashCode()
+ {
+ if (hashCode == null)
+ {
+ hashCode = new Integer(31 * getMostAppropriateValueFor(new String[0]).hashCode() + defaultLocale.hashCode());
+ }
+ return hashCode.intValue();
+ }
+
+ /**
+ * A localized string value.
+ */
+ public static class Value
+ {
+
+ /** The locale that describes the string. */
+ private final Locale locale;
+
+ /** the string value. */
+ private final String string;
+
+ /**
+ * @param locale the locale
+ * @param string the string
+ * @throws IllegalArgumentException if one argument is null
+ */
+ public Value(Locale locale, String string) throws IllegalArgumentException
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (string == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.locale = locale;
+ this.string = string;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public String getString()
+ {
+ return string;
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.ResourceBundle;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.Collections;
+
+/**
+ * A resource bundle that use a map as content.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class MapResourceBundle extends ResourceBundle
+{
+
+ protected Map content;
+
+ public MapResourceBundle(Map content)
+ {
+ this.content = new HashMap(content);
+ }
+
+ protected Object handleGetObject(String key)
+ {
+ if (key == null)
+ {
+ throw new NullPointerException();
+ }
+ return content.get(key);
+ }
+
+ public Enumeration getKeys()
+ {
+ return Collections.enumeration(content.keySet());
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.Tools;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+/**
+ * This resource bundle takes two resource bundle to make one :
+ * - The locale of this resource bundle is given by the child.
+ * - For a given key present in the child and the parent, the child
+ * value overrides the parent value.
+ *
+ * The locale used for the bundle is the child locale.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 6818 $
+ */
+public class ParentChildResourceBundle extends ResourceBundle
+{
+
+ /** The bundle locale. */
+ private Locale locale;
+
+ /** The bundle values. */
+ private Map values;
+
+ /**
+ * Construct a new resource bundle whose content is based on the child
+ * and parent content.
+ *
+ * @param parent the parent eventually null
+ * @param child the child
+ * @throws IllegalArgumentException if the child is null or its locale is null
+ */
+ public ParentChildResourceBundle(ResourceBundle parent, ResourceBundle child) throws IllegalArgumentException
+ {
+ // Arg check
+ if (child == null)
+ {
+ throw new IllegalArgumentException("Child cannot be null");
+ }
+ if (child.getLocale() == null)
+ {
+ throw new IllegalArgumentException("Child locale must not be null");
+ }
+ this.locale = child.getLocale();
+ this.values = new HashMap();
+
+ // Set the parent content
+ if (parent != null)
+ {
+ for (Enumeration e = parent.getKeys();e.hasMoreElements();)
+ {
+ String key = (String)e.nextElement();
+ Object value = parent.getObject(key);
+ values.put(key, value);
+ }
+ }
+
+ // Set the child content
+ for (Enumeration e = child.getKeys();e.hasMoreElements();)
+ {
+ String key = (String)e.nextElement();
+ Object value = child.getObject(key);
+ values.put(key, value);
+ }
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ protected Object handleGetObject(String key)
+ {
+ return values.get(key);
+ }
+
+ public Enumeration getKeys()
+ {
+ return Tools.toEnumeration(values.keySet().iterator());
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.FormatConversionException;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class RFC3066LanguageTagLocaleFormat extends AbstractLocaleFormat
+{
+
+ /** Separator. */
+ private static final String RFC3066_SEPARATOR = "-";
+
+ /** Valid language tag matcher (see <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>). */
+ private final Pattern RFC3066_COMPOUND_LANG_PATTERN = Pattern.compile("(\\p{Lower}{2})(-(\\p{Upper}{2}))?");
+
+ /** Sorted valid ISO country codes (needed for Arrays.binarySearch). */
+ private final String[] SORTED_ISO_COUNTRIES = Locale.getISOCountries();
+
+ /** Sorted valid ISO language codes (needed for Arrays.binarySearch). */
+ private final String[] SORTED_ISO_LANGUAGES = Locale.getISOLanguages();
+
+ protected Locale internalGetLocale(String value) throws FormatConversionException
+ {
+ Matcher matcher = RFC3066_COMPOUND_LANG_PATTERN.matcher(value);
+ if (matcher.matches())
+ {
+ String language = matcher.group(1);
+ if (Arrays.binarySearch(SORTED_ISO_LANGUAGES, language) < 0)
+ {
+ throw new FormatConversionException("Invalid ISO language code: " + language);
+ }
+ String country = matcher.group(3);
+ if (country == null)
+ {
+ return new Locale(language);
+ }
+ else if (Arrays.binarySearch(SORTED_ISO_COUNTRIES, country) < 0)
+ {
+ throw new FormatConversionException("Invalid ISO country code: " + country);
+ }
+ return new Locale(language, country);
+ }
+ throw new FormatConversionException(value + " is not a valid compound language : accepted " +
+ "format is xx-YY where xx is a valid ISO language code and YY is a valid country code. See " +
+ "java.util.Locale javadoc for more info.");
+ }
+
+ /**
+ * Retrieves the language identification tag associated to the specified Locale as defined by <a
+ * href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter language code per ISO standard
+ * 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes. E.g. "en-US" for American
+ * English, "en-GB" for British English, etc.
+ *
+ * @param locale the locale which language tag is wanted
+ * @return a <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>-compatible language tag.
+ * @throws IllegalArgumentException if the given locale is not valid
+ * @since 2.4
+ */
+ protected void internalWrite(Locale locale, Writer writer) throws IOException
+ {
+ String country = locale.getCountry(); // country will be empty if no country was specified in the locale
+ writer.write(locale.getLanguage());
+ if (country.length() == 2)
+ {
+ writer.write(RFC3066_SEPARATOR);
+ writer.write(country);
+ }
+ else
+ {
+ writer.write(country);
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleFactory.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleFactory.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleFactory.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Definition of a factory for resource bundles.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface ResourceBundleFactory
+{
+ /**
+ * Returns a resource bundle for the specified locale, it may be an expensive operation.
+ *
+ * @param locale the locale for the resource bundle
+ * @return a resource bundle for the locale or null if no such bundle can be obtained
+ * @throws IllegalArgumentException if the locale is null
+ */
+ ResourceBundle getBundle(Locale locale) throws IllegalArgumentException;
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,164 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.apache.log4j.Logger;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * <p>Manage a set of resource bundles. Obtaining bundles is done using a ResourceBundleFactory object. A bundle
+ * obtained successfully is cached in order to avoid the potential expensive cost of bundle retrieval.</p>
+ * <p/>
+ * <p>The manager can also be used to build LocalizedString object from the loaded bundles.</p>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 7228 $
+ */
+public class ResourceBundleManager
+{
+
+ /** . */
+ private Logger log = Logger.getLogger(getClass());
+
+ /** . */
+ private volatile Map localeBundles;
+
+ /** . */
+ private ResourceBundle defaultBundle;
+
+ /** . */
+ private ResourceBundleFactory resourceBundleFactory;
+
+ /**
+ * @param defaultBundle the default bundle returned when no bundle has been obtained for the locale
+ * @param resourceBundleFactory the resource bundle factory
+ * @throws IllegalArgumentException IllegalArgumentException if the resource bundle factory is null
+ */
+ public ResourceBundleManager(ResourceBundle defaultBundle, ResourceBundleFactory resourceBundleFactory) throws IllegalArgumentException
+ {
+ if (resourceBundleFactory == null)
+ {
+ throw new IllegalArgumentException("Need a resource bundle factory");
+ }
+ this.localeBundles = new HashMap();
+ this.defaultBundle = defaultBundle;
+ this.resourceBundleFactory = resourceBundleFactory;
+ }
+
+ /**
+ * Return a localized value constructed from the various resource bundles. The supported locales of the manager are
+ * used in combination with the specified key. The default value is used if no value is found for the
+ * <code>Locale.ENGLISH</code>. Two successive calls to this method may not return identical results since the
+ * returned <code>LocalizedString</code> is built using the bundles known by the manager.
+ *
+ * @param key the key to lookup in the bundles
+ * @param defaultValue the default value
+ * @return the localized string
+ * @throws IllegalArgumentException if the key of the default value is null
+ */
+ public LocalizedString getLocalizedValue(String key, String defaultValue) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (defaultValue == null)
+ {
+ throw new IllegalArgumentException("No null default value accepted");
+ }
+ Map m = new HashMap();
+ for (Iterator j = localeBundles.entrySet().iterator(); j.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)j.next();
+ try
+ {
+ Locale locale = (Locale)entry.getKey();
+ ResourceBundle bundle = (ResourceBundle)entry.getValue();
+ String localizedDisplayName = bundle.getString(key);
+ m.put(locale, localizedDisplayName);
+ }
+ catch (MissingResourceException ignore)
+ {
+ }
+ }
+ if (!m.containsKey(Locale.ENGLISH))
+ {
+ m.put(Locale.ENGLISH, defaultValue);
+ }
+ return new LocalizedString(m, Locale.ENGLISH);
+ }
+
+ /**
+ * Return a bundle for the given locale. If the complete locale (language + country + variant) does not exist then it
+ * falls back to (language + country) or (language) or the default file.
+ * <p/>
+ * When the resource bundle object is found and was not in the global map, it put it in that map with a copy on
+ * write.
+ *
+ * @throws IllegalArgumentException if the locale is null
+ */
+ public ResourceBundle getResourceBundle(Locale locale) throws IllegalArgumentException
+ {
+ // Arg check
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("Locale cannot be null");
+ }
+
+ // Try to get the bundle if the map
+ ResourceBundle bundle = (ResourceBundle)localeBundles.get(locale);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+
+ //
+ log.debug("Want to load bundle for locale " + locale);
+ bundle = resourceBundleFactory.getBundle(locale);
+
+ //
+ if (bundle != null)
+ {
+ log.debug("Obtained bundle " + bundle + " for locale " + locale);
+ }
+ else
+ {
+ log.debug("No bundle obtained for locale " + locale + " will use default bundle " + defaultBundle + " instead");
+ }
+
+ // Cache the bundle
+ Map copy = new HashMap(localeBundles);
+ copy.put(locale, bundle);
+ localeBundles = copy;
+
+ //
+ return bundle;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * An implementation that delegates bundle loading to <code>ResourceBundle.getBundle(String,Locale,ClassLoader)</code>.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class SimpleResourceBundleFactory implements ResourceBundleFactory
+{
+
+ /** The base name of the resource bundles. */
+ private String baseName;
+
+ /** The classloader to load resource from. */
+ private ClassLoader classLoader;
+
+ public SimpleResourceBundleFactory(String baseName, ClassLoader classLoader) throws IllegalArgumentException
+ {
+ if (baseName == null)
+ {
+ throw new IllegalArgumentException("No base name provided");
+ }
+ if (classLoader == null)
+ {
+ throw new IllegalArgumentException("No classloader provided");
+ }
+ this.baseName = baseName;
+ this.classLoader = classLoader;
+ }
+
+ public ResourceBundle getBundle(Locale locale) throws IllegalArgumentException
+ {
+ return ResourceBundle.getBundle(baseName, locale, classLoader);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/AbstractInvocationContext.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/AbstractInvocationContext.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/AbstractInvocationContext.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,163 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class AbstractInvocationContext implements InvocationContext
+{
+
+ /** . */
+ private final Map resolvers;
+
+ public AbstractInvocationContext()
+ {
+ this.resolvers = new HashMap();
+ }
+
+ protected final void addResolver(Scope resolverScope, InvocationContext federatedContext) throws IllegalArgumentException
+ {
+ if (resolverScope == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (federatedContext == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ resolvers.put(resolverScope, new InvocationContextRegistration(federatedContext));
+ }
+
+ protected final void addResolver(Scope resolverScope, AttributeResolver resolver) throws IllegalArgumentException
+ {
+ if (resolverScope == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (resolver == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ resolvers.put(resolverScope, new AttributeResolverRegistration(resolver));
+ }
+
+ public AttributeResolver getAttributeResolver(Scope attrScope) throws IllegalArgumentException
+ {
+ if (attrScope == null)
+ {
+ throw new IllegalArgumentException("Attribute name must not be null");
+ }
+ AttributeResolver resolver = null;
+ Registration registration = (Registration)resolvers.get(attrScope);
+ if (registration instanceof AttributeResolverRegistration)
+ {
+ resolver = ((AttributeResolverRegistration)registration).resolver;
+ }
+ else if (registration instanceof InvocationContextRegistration)
+ {
+ InvocationContext federaredContext = ((InvocationContextRegistration)registration).context;
+ resolver = federaredContext.getAttributeResolver(attrScope);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Scope not recognized " + attrScope);
+ }
+ return resolver;
+ }
+
+ public Object getAttribute(Scope attrScope, Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException("Attribute name must not be null");
+ }
+ if (attrScope == null)
+ {
+ throw new IllegalArgumentException("Attribute scope must not be null");
+ }
+ AttributeResolver resolver = getAttributeResolver(attrScope);
+ if (resolver == null)
+ {
+ throw new IllegalArgumentException("Scope not recognized " + attrScope);
+ }
+ return resolver.getAttribute(attrKey);
+ }
+
+ public void setAttribute(Scope attrScope, Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException("Attribute name must not be null");
+ }
+ if (attrScope == null)
+ {
+ throw new IllegalArgumentException("Attribute scope must not be null");
+ }
+ AttributeResolver resolver = getAttributeResolver(attrScope);
+ if (resolver == null)
+ {
+ throw new IllegalArgumentException("Scope not recognized " + attrScope);
+ }
+ resolver.setAttribute(attrKey, attrValue);
+ }
+
+ public void removeAttribute(Scope attrScope, Object attrKey)
+ {
+ setAttribute(attrScope, attrKey, null);
+ }
+
+ /**
+ * Typed registration to avoid issues classes that implement both interfaces AttributeResolver and
+ * InvocationContext.
+ */
+ private abstract static class Registration
+ {
+ }
+
+ private final static class AttributeResolverRegistration extends Registration
+ {
+ /** . */
+ private final AttributeResolver resolver;
+
+ private AttributeResolverRegistration(AttributeResolver resolver)
+ {
+ this.resolver = resolver;
+ }
+ }
+
+ private final static class InvocationContextRegistration extends Registration
+ {
+ /** . */
+ private final InvocationContext context;
+
+ private InvocationContextRegistration(InvocationContext context)
+ {
+ this.context = context;
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/AttributeResolver.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/AttributeResolver.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/AttributeResolver.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+import java.util.Set;
+
+/**
+ * An attribute resolver.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface AttributeResolver
+{
+ /**
+ * Returns the set of keys of the attributes bound in that resolver.
+ *
+ * @return a set of keys
+ */
+ Set getKeys();
+
+ /**
+ * Return an attribute from this resolver.
+ *
+ * @param attrKey
+ * @return the attribute value or null if it is not found
+ * @throws IllegalArgumentException if the attribute key is not valid
+ */
+ Object getAttribute(Object attrKey) throws IllegalArgumentException;
+
+ /**
+ * Update an attribute value on this resolve. If the attribute value is null the resolver must treat the operation as
+ * a removal of the attribute.
+ *
+ * @param attrKey
+ * @param attrValue the attribute value
+ * @throws IllegalArgumentException if the attribute key is not valid
+ */
+ void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException;
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyAttributeResolver.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyAttributeResolver.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyAttributeResolver.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.portal.common.invocation;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class EmptyAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ private static final EmptyAttributeResolver instance = new EmptyAttributeResolver();
+
+ public static EmptyAttributeResolver getInstance()
+ {
+ return instance;
+ }
+
+ public Set getKeys()
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return null;
+ }
+
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyInterceptorStackFactory.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyInterceptorStackFactory.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyInterceptorStackFactory.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class EmptyInterceptorStackFactory implements InterceptorStackFactory
+{
+
+ /** . */
+ private static final InterceptorStack instance = new InterceptorStack()
+ {
+ public int getLength()
+ {
+ return 0;
+ }
+
+ public Interceptor getInterceptor(int index) throws ArrayIndexOutOfBoundsException
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ };
+
+ public static InterceptorStack getInstance()
+ {
+ return instance;
+ }
+
+ public InterceptorStack getInterceptorStack()
+ {
+ return getInstance();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public interface Interceptor
+{
+ /**
+ * todo
+ */
+ Object invoke(Invocation invocation) throws Exception, InvocationException;
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * A wrapper for a list of interceptors.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public interface InterceptorStack
+{
+ /**
+ * Returns the stack length.
+ *
+ * @return the length
+ */
+ int getLength();
+
+ /**
+ * Return the interceptor at the specified index.
+ *
+ * @param index the interceptor index in the stack
+ * @return the specified interceptor
+ * @throws ArrayIndexOutOfBoundsException if the index is not valid
+ */
+ Interceptor getInterceptor(int index) throws ArrayIndexOutOfBoundsException;
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStackFactory.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStackFactory.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStackFactory.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface InterceptorStackFactory
+{
+ InterceptorStack getInterceptorStack();
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,166 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * A generic invocation object.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5597 $
+ */
+public abstract class Invocation
+{
+
+ /** . */
+ public static final InterceptorStack EMPTY_STACK = new InterceptorStack()
+ {
+ public int getLength()
+ {
+ return 0;
+ }
+ public Interceptor getInterceptor(int index) throws ArrayIndexOutOfBoundsException
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ };
+
+ /** The current index in the chain. */
+ private int currentIndex = 0;
+
+ /** The current interceptor stack. */
+ private InterceptorStack currentStack = Invocation.EMPTY_STACK;
+
+ /** . */
+ private InvocationHandler handler;
+
+ /**
+ * Return the invocation context or throw IllegalStateException.
+ *
+ * @return the invocation context
+ * @throws IllegalStateException if no context is associated with this invocation
+ */
+ public abstract InvocationContext getContext() throws IllegalStateException;
+
+ /**
+ * @see InvocationContext#getAttribute(Scope,Object)
+ */
+ public Object getAttribute(Scope attrScope, Object attrKey) throws IllegalArgumentException
+ {
+ return getContext().getAttribute(attrScope, attrKey);
+ }
+
+ /**
+ * @see InvocationContext#setAttribute(Scope,Object,Object)
+ */
+ public void setAttribute(Scope attrScope, Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ getContext().setAttribute(attrScope, attrKey, attrValue);
+ }
+
+ /**
+ * @see InvocationContext#removeAttribute(Scope,Object)
+ */
+ public void removeAttribute(Scope attrScope, Object attrKey) throws IllegalArgumentException
+ {
+ getContext().removeAttribute(attrScope, attrKey);
+ }
+
+ public InvocationHandler getHandler()
+ {
+ return handler;
+ }
+
+ public void setHandler(InvocationHandler handler)
+ {
+ this.handler = handler;
+ }
+
+ /**
+ * Invoke the next interceptor in the chain. If the end of the chain is reached then the <code>dispatch()</code>
+ * is invoked.
+ */
+ public Object invokeNext() throws Exception, InvocationException
+ {
+ if (currentIndex < currentStack.getLength())
+ {
+ try
+ {
+ Interceptor interceptor = currentStack.getInterceptor(currentIndex++);
+ if (interceptor == null)
+ {
+ throw new InvocationException("Null interceptor at index=" + (currentIndex - 1));
+ }
+ else
+ {
+ return interceptor.invoke(this);
+ }
+ }
+ finally
+ {
+ currentIndex--;
+ }
+ }
+ else
+ {
+ if (handler == null)
+ {
+ throw new InvocationException("No handler");
+ }
+ else
+ {
+ return handler.invoke(this);
+ }
+ }
+ }
+
+ /**
+ * Execute the invocation through the chain of interceptors.
+ */
+ public Object invoke(InterceptorStack newStack) throws Exception, InvocationException
+ {
+ if (newStack == null)
+ {
+ throw new InvocationException("Cannot invoke with a null interceptor[]");
+ }
+
+ // Save the previous context
+ InterceptorStack previousInterceptors = currentStack;
+ int previousIndex = currentIndex;
+
+ try
+ {
+ // Set the new context
+ currentStack = newStack;
+ currentIndex = 0;
+
+ // Perform invoke
+ return invokeNext();
+ }
+ finally
+ {
+ // Restablish the previous context
+ currentStack = previousInterceptors;
+ currentIndex = previousIndex;
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationContext.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationContext.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationContext.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface InvocationContext
+{
+ /**
+ * Return the attribute resolver of this context.
+ *
+ * @param attrScope the attribute resolver scope
+ * @return the attribute resolver or null if not found
+ * @throws IllegalArgumentException if the attribute scope is invalid
+ */
+ AttributeResolver getAttributeResolver(Scope attrScope) throws IllegalArgumentException;
+
+ /**
+ * Returns an attribute value.
+ *
+ * @param attrScope the attribute scope
+ * @param attrKey
+ * @return the attribute value or null if not found
+ * @throws IllegalArgumentException if the attribute key or the attribute scope is not valid
+ */
+ Object getAttribute(Scope attrScope, Object attrKey) throws IllegalArgumentException;
+
+ /**
+ * Update an attribute value.
+ *
+ * @param attrScope the attribute scope
+ * @param attrKey
+ * @param attrValue the attribute value
+ * @throws IllegalArgumentException if the attribute key or the attribute scope is not valid
+ */
+ void setAttribute(Scope attrScope, Object attrKey, Object attrValue) throws IllegalArgumentException;
+
+ /**
+ * Remove an attribute value. If the attribute value is null the resolver must treat the operation as a removal of
+ * the attribute.
+ *
+ * @param attrKey
+ * @throws IllegalArgumentException if the attribute key is null or the attribute scope is not valid
+ */
+ void removeAttribute(Scope attrScope, Object attrKey);
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class InvocationException extends RuntimeException
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7607329736844391861L;
+
+ public InvocationException()
+ {
+ }
+
+ public InvocationException(String message)
+ {
+ super(message);
+ }
+
+ public InvocationException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public InvocationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationHandler.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationHandler.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationHandler.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface InvocationHandler
+{
+ /**
+ *
+ */
+ Object invoke(Invocation invocation) throws Exception, InvocationException;
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Scope.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Scope.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/Scope.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * The scope of an attribute.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Scope
+{
+
+ /** Principal scope. */
+ public static final Scope PRINCIPAL_SCOPE = new Scope("principal");
+
+ /** Request scope. */
+ public static final Scope REQUEST_SCOPE = new Scope("request");
+
+ /** Thread scope. */
+ public static final Scope THREAD_SCOPE = new Scope("thread");
+
+ /** Session scope. */
+ public static final Scope SESSION_SCOPE = new Scope("session");
+
+ /** Invocation scope. */
+ public static final Scope INVOCATION_SCOPE = new Scope("invocation");
+
+ /** The value. */
+ private final String value;
+
+ /**
+ * @param value the scope value
+ * @throws IllegalArgumentException if the value is null
+ */
+ public Scope(String value) throws IllegalArgumentException
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.value = value;
+ }
+
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof Scope)
+ {
+ Scope that = (Scope)obj;
+ return value.equals(that.value);
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ return value;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/AbstractSessionAttributeResolver.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/AbstractSessionAttributeResolver.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/AbstractSessionAttributeResolver.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public abstract class AbstractSessionAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ protected final HttpServletRequest req;
+
+ public AbstractSessionAttributeResolver(HttpServletRequest req)
+ {
+ if (req == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.req = req;
+ }
+
+
+ public Set getKeys()
+ {
+ Map map = getMap(false);
+
+ //
+ if (map != null)
+ {
+ return map.keySet();
+ }
+ else
+ {
+ return Collections.EMPTY_SET;
+ }
+ }
+
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Object value = null;
+ Map map = getMap(false);
+ if (map != null)
+ {
+ value = map.get(attrKey);
+ }
+ return value;
+ }
+
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Map map = getMap(false);
+ if (map != null)
+ {
+ if (attrValue != null)
+ {
+ map.put(attrKey, attrValue);
+ }
+ else
+ {
+ map.remove(attrKey);
+ }
+ }
+ else
+ {
+ if (attrValue != null)
+ {
+ map = getMap(true);
+ map.put(attrKey, attrValue);
+ }
+ }
+ }
+
+ protected abstract String getMapKey();
+
+ protected Map createMap(String mapKey)
+ {
+ return new HashMap();
+ }
+
+ private Map getMap(boolean create)
+ {
+ HttpSession session = req.getSession(create);
+ if (session != null)
+ {
+ String mapKey = getMapKey();
+ Map map = (Map)session.getAttribute(mapKey);
+ if (map == null)
+ {
+ map = createMap(mapKey);
+ session.setAttribute(mapKey, map);
+ }
+ return map;
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/MapAttributeResolver.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/MapAttributeResolver.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/MapAttributeResolver.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MapAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ private final Map attributes;
+
+ public MapAttributeResolver(Map attributes)
+ {
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.attributes = attributes;
+ }
+
+ public MapAttributeResolver()
+ {
+ this(new HashMap());
+ }
+
+
+ public Set getKeys()
+ {
+ return attributes.keySet();
+ }
+
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return attributes.get(attrKey);
+ }
+
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (attrValue != null)
+ {
+ attributes.put(attrKey, attrValue);
+ }
+ else
+ {
+ attributes.remove(attrKey);
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/PrincipalAttributeResolver.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/PrincipalAttributeResolver.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/PrincipalAttributeResolver.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import javax.servlet.http.HttpServletRequest;
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class PrincipalAttributeResolver extends AbstractSessionAttributeResolver
+{
+
+ /** . */
+ private String cachedPrincipalName;
+
+ /** . */
+ private String cachedMapKey;
+
+ public PrincipalAttributeResolver(HttpServletRequest req)
+ {
+ super(req);
+ }
+
+ protected String getMapKey()
+ {
+ Principal principal = req.getUserPrincipal();
+
+ //
+ if (cachedMapKey != null)
+ {
+ if (cachedPrincipalName == null)
+ {
+ if (principal != null)
+ {
+ cachedMapKey = null;
+ }
+ }
+ else
+ {
+ if (principal == null || (cachedPrincipalName.equals(principal.getName()) == false))
+ {
+ cachedMapKey = null;
+ }
+ }
+ }
+
+ //
+ if (cachedMapKey == null)
+ {
+ if (principal == null)
+ {
+ cachedMapKey = "portal.principal";
+ cachedPrincipalName = null;
+ }
+ else
+ {
+ cachedMapKey = "portal.principal." + principal.getName();
+ cachedPrincipalName = principal.getName();
+ }
+ }
+
+ //
+ return cachedMapKey;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/RequestAttributeResolver.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/RequestAttributeResolver.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/RequestAttributeResolver.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.common.util.Tools;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class RequestAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ private final HttpServletRequest req;
+
+ public RequestAttributeResolver(HttpServletRequest req)
+ {
+ if (req == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.req = req;
+ }
+
+
+ public Set getKeys()
+ {
+ return Tools.toSet(req.getAttributeNames());
+ }
+
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException("No null attribute key accepted");
+ }
+ if (attrKey instanceof String == false)
+ {
+ throw new IllegalArgumentException("Attribute key must be a string");
+ }
+
+ //
+ return req.getAttribute((String)attrKey);
+ }
+
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException("No null attribute key accepted");
+ }
+ if (attrKey instanceof String == false)
+ {
+ throw new IllegalArgumentException("Attribute key must be a string");
+ }
+
+ //
+ if (attrValue != null)
+ {
+ req.setAttribute((String)attrKey, attrValue);
+ }
+ else
+ {
+ req.removeAttribute((String)attrKey);
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/SessionAttributeResolver.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/SessionAttributeResolver.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/SessionAttributeResolver.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class SessionAttributeResolver extends AbstractSessionAttributeResolver
+{
+
+ /** . */
+ private final String mapKey;
+
+ public SessionAttributeResolver(HttpServletRequest req, String mapKey)
+ {
+ super(req);
+
+ //
+ if (mapKey == null)
+ {
+ throw new IllegalArgumentException("No null map key allowed");
+ }
+
+ //
+ this.mapKey = mapKey;
+ }
+
+ protected String getMapKey()
+ {
+ return mapKey;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/IOTools.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/IOTools.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/IOTools.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,493 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.io;
+
+import org.jboss.portal.common.util.Tools;
+import org.apache.log4j.Logger;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.InvocationTargetException;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.ByteArrayOutputStream;
+import java.io.Writer;
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.DataOutputStream;
+import java.util.Map;
+
+/**
+ * IO tools.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IOTools
+{
+
+ /** The logger. */
+ public static final Logger log = Logger.getLogger(IOTools.class);
+
+ /** . */
+ private static final Object[] EMPTY_ARGS = new Object[0];
+
+ /** . */
+ private static final Class[] EMPTY_PARAMETER_TYPES = new Class[0];
+
+ /**
+ * <p>Attempt to close an object. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * <p>It will try to obtain a <code>close()</code> method by reflection and it
+ * will be invoked only if the method is public and not static. If the method is called, any <code>Error</code>
+ * or <code>RuntimeException</code> will be rethrown, any other kind of throwable will not be rethrown in any form.</p>
+ *
+ * @param closable the object to close
+ */
+ public static void safeClose(Object closable)
+ {
+ if (closable != null)
+ {
+ try
+ {
+ Method m = closable.getClass().getMethod("close", EMPTY_PARAMETER_TYPES);
+ if (Modifier.isStatic(m.getModifiers()))
+ {
+ log.warn("close() method on closable object is static");
+ return;
+ }
+ m.invoke(closable, EMPTY_ARGS);
+ }
+ catch (NoSuchMethodException e)
+ {
+ log.warn("The closable object does not have a close() method", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ log.warn("Cannot access close() method on closable object", e);
+ }
+ catch (InvocationTargetException e)
+ {
+ Throwable t = e.getCause();
+
+ //
+ if (t instanceof RuntimeException)
+ {
+ log.error("The close() method threw a runtime exception", t);
+ throw (RuntimeException)t;
+ }
+ else if (t instanceof Error)
+ {
+ log.error("The close() method threw an error", t);
+ throw (Error)t;
+ }
+ else if (t instanceof Exception)
+ {
+ log.error("The close() method threw an exception", t);
+ }
+ else
+ {
+ log.error("The close() method threw an unexpected throwable", t);
+ }
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>OutputStream</code>. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param out the stream to close
+ */
+ public static void safeClose(OutputStream out)
+ {
+ if (out != null)
+ {
+ try
+ {
+ out.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing outstream", e);
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>InputStream</code>. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param in the stream to close
+ */
+ public static void safeClose(InputStream in)
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing inputstream", e);
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>Reader</code>. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param reader the stream to close
+ */
+ public static void safeClose(Reader reader)
+ {
+ if (reader != null)
+ {
+ try
+ {
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing reader", e);
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>Writer</code>. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param writer the stream to close
+ */
+ public static void safeClose(Writer writer)
+ {
+ if (writer != null)
+ {
+ try
+ {
+ writer.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing writer", e);
+ }
+ }
+ }
+
+ /**
+ * @see #getBytes(java.io.InputStream, int)
+ * @param in the input stream
+ * @return the bytes read from the stream
+ * @throws java.io.IOException
+ * @throws IllegalArgumentException if the input stream is null
+ */
+ public static byte[] getBytes(InputStream in) throws IOException, IllegalArgumentException
+ {
+ return getBytes(in, Tools.DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Get the bytes from the provided input stream. No attempt will be made to close the stream.
+ *
+ * @param in the input stream
+ * @param bufferSize the buffer size used to copy the bytes
+ * @return the bytes read from the stream
+ * @throws java.io.IOException
+ * @throws IllegalArgumentException if the input stream is null or the buffer size < 1
+ */
+ public static byte[] getBytes(InputStream in, int bufferSize) throws IOException, IllegalArgumentException
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ copy(in, out, bufferSize);
+ return out.toByteArray();
+ }
+
+ /**
+ * @see #copy(java.io.InputStream, java.io.OutputStream, int)
+ * @param in the incoming stream
+ * @param out the outcoming stream
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public static void copy(InputStream in, OutputStream out) throws IOException
+ {
+ copy(in, out, Tools.DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Pipe an incoming stream in an outcoming stream until no bytes is available from the input stream.
+ * No attempts will be made to close the streams.
+ *
+ * @param in the incoming stream
+ * @param out the outcoming stream
+ * @param bufferSize the buffer size
+ * @throws IllegalArgumentException if bufferSize < 1 or an argument is null
+ */
+ public static void copy(InputStream in, OutputStream out, int bufferSize) throws IOException
+ {
+ // arguments check
+ if (in == null)
+ {
+ throw new IllegalArgumentException("null in");
+ }
+ if (out == null)
+ {
+ throw new IllegalArgumentException("null out");
+ }
+ if (bufferSize < 1)
+ {
+ throw new IllegalArgumentException("Buffer size is too small");
+ }
+
+ // do the job
+ byte[] buffer = new byte[bufferSize];
+ while (true)
+ {
+ int i = in.read(buffer);
+ if (i == 0)
+ {
+ continue;
+ }
+ if (i == -1)
+ {
+ break;
+ }
+ out.write(buffer, 0, i);
+ }
+ }
+
+ /**
+ * Pipe an input stream in an output stream.
+ *
+ * @param reader the incoming reader
+ * @param writer the outcoming writer
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public static void copy(Reader reader, Writer writer) throws IOException
+ {
+ copy(reader, writer, Tools.DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Pipe an incoming stream in an outcoming stream.
+ *
+ * @param reader the incoming reader
+ * @param writer the outcoming writer
+ * @param bufferSize the buffer size
+ * @throws IllegalArgumentException if bufferSize < 1 or an argument is null
+ */
+ public static void copy(Reader reader, Writer writer, int bufferSize) throws IOException
+ {
+ // arguments check
+ if (reader == null)
+ {
+ throw new IllegalArgumentException("null in");
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("null out");
+ }
+ if (bufferSize < 1)
+ {
+ throw new IllegalArgumentException("Buffer size is too small");
+ }
+
+ // do the job
+ char[] buffer = new char[bufferSize];
+ while (true)
+ {
+ int i = reader.read(buffer);
+ if (i == 0)
+ {
+ continue;
+ }
+ if (i == -1)
+ {
+ break;
+ }
+ writer.write(buffer, 0, i);
+ }
+ }
+
+ /**
+ * Clone an object implementing the <code>Serializable</code> interface.
+ *
+ * @param serializable
+ * @return
+ * @throws IllegalArgumentException if the serializable object is null
+ * @throws IOException
+ */
+ public static Object clone(Serializable serializable) throws IllegalArgumentException, IOException
+ {
+ try
+ {
+ return unserialize(serialize(serializable));
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new Error("Got a class not found exception for a class that was used", e);
+ }
+ }
+
+ public static byte[] serialize(Serializable serializable) throws IllegalArgumentException, IOException
+ {
+ if (serializable == null)
+ {
+ throw new IllegalArgumentException("No null serializable accepted");
+ }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(serializable);
+ oos.close();
+ return baos.toByteArray();
+ }
+
+ public static Serializable unserialize(byte[] bytes) throws IllegalArgumentException, IOException, ClassNotFoundException
+ {
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("No null serializable accepted");
+ }
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ return (Serializable)ois.readObject();
+ }
+
+ public static <T> byte[] serialize(Serialization<T> serialization, T t)
+ {
+ return serialize(serialization, SerializationFilter.TRIVIAL, t);
+ }
+
+ public static <T> byte[] serialize(Serialization<T> serialization, SerializationFilter filter, T t)
+ {
+ if (serialization == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (t == null)
+ {
+ throw new IllegalArgumentException("No null object to serialize");
+ }
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ filter.serialize(serialization, t, baos);
+ return baos.toByteArray();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public static <T> T unserialize(Serialization<T> serialization, byte[] bytes)
+ {
+ return unserialize(serialization, SerializationFilter.TRIVIAL, bytes);
+ }
+
+ public static <T> T unserialize(Serialization<T> serialization, SerializationFilter filter, byte[] bytes)
+ {
+ if (serialization == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("No null bytes to unserialize");
+ }
+ try
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ return filter.unserialize(serialization, bais);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ /**
+ * Check that the provided input stream is buffered. If the argument is already an instance of <code>BufferedInputStream</code>
+ * no operation will be performed, otherwise a instance of <code>BufferedInputStream</code> will be created and returned.
+ *
+ * If the provided argument is null, the null value is returned.
+ *
+ * @param in the stream
+ * @return a buffered wrapper
+ */
+ public static BufferedInputStream safeBufferedWrapper(InputStream in)
+ {
+ if (in != null)
+ {
+ if (in instanceof BufferedInputStream)
+ {
+ return (BufferedInputStream)in;
+ }
+ else
+ {
+ return new BufferedInputStream(in);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Check that the provided output stream is buffered. If the argument is already an instance of <code>BufferedOutputStream</code>
+ * no operation will be performed, otherwise a instance of <code>BufferedOutputStream</code> will be created and returned.
+ *
+ * If the provided argument is null, the null value is returned.
+ *
+ * @param out the stream
+ * @return a buffered wrapper
+ */
+ public static BufferedOutputStream safeBufferedWrapper(OutputStream out)
+ {
+ if (out != null)
+ {
+ if (out instanceof BufferedOutputStream)
+ {
+ return (BufferedOutputStream)out;
+ }
+ else
+ {
+ return new BufferedOutputStream(out);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/Serialization.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/Serialization.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/Serialization.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.io;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.DataInputStream;
+import java.io.OutputStream;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface Serialization<T>
+{
+
+ Serialization<Map<String, String[]>> PARAMETER_MAP = new Serialization<Map<String, String[]>>()
+ {
+ public void serialize(Map<String, String[]> map, OutputStream out) throws IOException, IllegalArgumentException
+ {
+ if (map == null)
+ {
+ throw new IllegalArgumentException("No null map allowed");
+ }
+
+ //
+ DataOutputStream data = out instanceof DataOutputStream ? (DataOutputStream)out : new DataOutputStream(out);
+
+ //
+ data.writeInt(map.size());
+
+ //
+ for (Map.Entry entry : map.entrySet())
+ {
+ String name = (String)entry.getKey();
+ data.writeUTF(name);
+
+ //
+ String[] values = (String[])entry.getValue();
+ if (values == null)
+ {
+ throw new IllegalArgumentException("No null values are allowed in the map");
+ }
+
+ //
+ int length = values.length;
+ data.writeInt(length);
+
+ //
+ for (String value : values)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException("No null value in the String[] are allowed in the map");
+ }
+ data.writeUTF(value);
+ }
+ }
+
+ //
+ data.flush();
+ }
+
+ public Map<String, String[]> unserialize(InputStream in) throws IOException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException("No null input stream");
+ }
+
+ //
+ DataInputStream data = in instanceof DataInputStream ? (DataInputStream)in : new DataInputStream(in);
+
+ //
+ int size = data.readInt();
+ Map<String, String[]> tmp = new HashMap<String, String[]>(size);
+ while (size-- > 0)
+ {
+ String name = data.readUTF();
+ int length = data.readInt();
+ String[] values = new String[length];
+ for (int i = 0;i < length;i++)
+ {
+ values[i] = data.readUTF();
+ }
+ tmp.put(name, values);
+ }
+
+ //
+ return tmp;
+ }
+ };
+
+ public abstract void serialize(T t, OutputStream out) throws IOException, IllegalArgumentException;
+
+ public abstract T unserialize(InputStream in) throws IOException, IllegalArgumentException;
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/SerializationFilter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/SerializationFilter.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/SerializationFilter.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.io;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPOutputStream;
+import java.util.zip.GZIPInputStream;
+
+/**
+ * Filters a stream for serialize/unserialize operations.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface SerializationFilter
+{
+
+ SerializationFilter TRIVIAL = new SerializationFilter()
+ {
+ public <T> void serialize(Serialization<T> serialization, T t, OutputStream out) throws IllegalArgumentException, IOException
+ {
+ serialization.serialize(t, out);
+ }
+
+ public <T> T unserialize(Serialization<T> serialization, InputStream in) throws IllegalArgumentException, IOException
+ {
+ return serialization.unserialize(in);
+ }
+ };
+
+ /**
+ * Use GZIP streams.
+ */
+ SerializationFilter COMPRESSOR = new SerializationFilter()
+ {
+ public <T> void serialize(Serialization<T> serialization, T t, OutputStream out) throws IllegalArgumentException, IOException
+ {
+ GZIPOutputStream zos = new GZIPOutputStream(out);
+ serialization.serialize(t, zos);
+ zos.finish();
+ }
+
+ public <T> T unserialize(Serialization<T> serialization, InputStream in) throws IllegalArgumentException, IOException
+ {
+ GZIPInputStream zis = new GZIPInputStream(in);
+ return serialization.unserialize(zis);
+ }
+ };
+
+ <T> void serialize(Serialization<T> serialization, T t, OutputStream out) throws IllegalArgumentException, IOException;
+
+ <T> T unserialize(Serialization<T> serialization, InputStream in) throws IllegalArgumentException, IOException;
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/UndeclaredIOException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/UndeclaredIOException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/UndeclaredIOException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.io;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+
+/**
+ * Avoid a method to declare an IOException in its signature when it is not necessary.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class UndeclaredIOException extends UndeclaredThrowableException
+{
+ public UndeclaredIOException(IOException undeclaredIOException)
+ {
+ super(undeclaredIOException);
+ }
+
+ public UndeclaredIOException(IOException undeclaredIOException, String s)
+ {
+ super(undeclaredIOException, s);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,164 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.io;
+
+import org.jboss.portal.common.text.CharWriter;
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WriterCharWriter implements CharWriter
+{
+
+ /** . */
+ private final Writer writer;
+
+ /**
+ * @param writer the target writer
+ * @throws IllegalArgumentException if the writer is null
+ */
+ public WriterCharWriter(Writer writer) throws IllegalArgumentException
+ {
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("No null writer accepted");
+ }
+ this.writer = writer;
+ }
+
+ public CharWriter append(char c) throws UndeclaredIOException
+ {
+ try
+ {
+ writer.write(c);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return this;
+ }
+
+ public CharWriter append(char[] chars, int off, int len) throws UndeclaredIOException
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (len < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off + len > chars.length)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ writer.write(chars, off, len);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return this;
+ }
+
+ public CharWriter append(char[] chars) throws UndeclaredIOException
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ writer.write(chars, 0, chars.length);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return this;
+ }
+
+ public CharWriter append(CharSequence s) throws UndeclaredIOException
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ if (s instanceof String)
+ {
+ writer.write((String)s);
+ }
+ else
+ {
+ for (int i = 0;i < s.length();i++)
+ {
+ char c = s.charAt(i);
+ writer.write(c);
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return this;
+ }
+
+ public void flush() throws UndeclaredIOException
+ {
+ try
+ {
+ writer.flush();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public void close() throws UndeclaredIOException
+ {
+ try
+ {
+ writer.flush();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/jar/JarEntryInfo.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/jar/JarEntryInfo.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/jar/JarEntryInfo.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,234 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.jar;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarEntry;
+
+/**
+ * Enhance jar entry object by adding more info.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7448 $
+ */
+public class JarEntryInfo implements Comparable
+{
+
+ /** The real jar entry. */
+ private final JarEntry entry;
+
+ /** . */
+ private final List names;
+
+ public JarEntryInfo(JarEntry entry)
+ {
+ if (entry == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String entryName = entry.getName();
+ ArrayList atoms = new ArrayList();
+
+ //add the root element since this is not actually included in the jar as a entry
+ atoms.add("/");
+
+ int previous = -1;
+ while (true)
+ {
+ int current = entryName.indexOf('/', previous + 1);
+ if (current == -1)
+ {
+ current = entryName.length();
+ }
+ if (current >= entryName.length() - 1)
+ {
+ if (current - previous > 1)
+ {
+ atoms.add(entryName.substring(previous + 1, current));
+ }
+ break;
+ }
+ if (current - previous > 1)
+ {
+ atoms.add(entryName.substring(previous + 1, current));
+ }
+ previous = current;
+ }
+
+ //
+ this.entry = entry;
+ this.names = Collections.unmodifiableList(atoms);
+ }
+
+ public JarEntry getEntry()
+ {
+ return entry;
+ }
+
+ public boolean isDirectory()
+ {
+ return entry.isDirectory();
+ }
+
+ public int size()
+ {
+ return names.size();
+ }
+
+ public List getNames()
+ {
+ return names;
+ }
+
+ public String getName(int index)
+ {
+ return (String)names.get(index);
+ }
+
+ public boolean isChildOf(JarEntryInfo parent) throws IllegalArgumentException
+ {
+ if (parent == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!parent.isDirectory())
+ {
+ return false;
+ }
+ if (parent.size() + 1 != names.size())
+ {
+ return false;
+ }
+ return parent.names.equals(parent.names.subList(0, names.size() - 1));
+ }
+
+ public boolean isDescendantOf(JarEntryInfo ancestor) throws IllegalArgumentException
+ {
+ if (ancestor == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!ancestor.isDirectory())
+ {
+ return false;
+ }
+ if (ancestor.names.size() >= names.size())
+ {
+ return false;
+ }
+ return ancestor.names.equals(names.subList(0, ancestor.size()));
+ }
+
+ public URL toURL(URL jarURL) throws IllegalArgumentException, IllegalStateException, MalformedURLException
+ {
+ if (jarURL == null)
+ {
+ throw new IllegalArgumentException("No null jarURL");
+ }
+ if (isDirectory())
+ {
+ throw new IllegalStateException("Cannot create dir URL");
+ }
+ StringBuffer tmp = new StringBuffer(jarURL.toString()).append("!/");
+ for (int i = 0; i < names.size(); i++)
+ {
+ String atom = (String)names.get(i);
+ tmp.append(i > 0 ? "/" : "").append(atom);
+ }
+ return new URL("jar", "", tmp.toString());
+ }
+
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer();
+ for (int i = 0; i < names.size(); i++)
+ {
+ String atom = (String)names.get(i);
+ tmp.append(i > 0 ? "/" : "").append(atom);
+ }
+ if (entry.isDirectory())
+ {
+ tmp.append("/");
+ }
+ return tmp.toString();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof JarEntryInfo)
+ {
+ return compareTo(obj) == 0;
+ }
+ return false;
+ }
+
+ public int compareTo(Object obj)
+ {
+ JarEntryInfo that = (JarEntryInfo)obj;
+ Iterator i1 = this.getNames().iterator();
+ Iterator i2 = that.getNames().iterator();
+ while (true)
+ {
+ if (i1.hasNext())
+ {
+ Object o = i1.next();
+ String s1 = (String)o;
+ if (i2.hasNext())
+ {
+ String s2 = (String)i2.next();
+ int res = s1.compareTo(s2);
+ if (res != 0)
+ {
+ return res;
+ }
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ if (i2.hasNext())
+ {
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/jar/JarInfo.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/jar/JarInfo.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/jar/JarInfo.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.jar;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class JarInfo
+{
+
+ /** . */
+ private SortedSet entries;
+
+ public JarInfo(JarFile file)
+ {
+ if (file == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ entries = new TreeSet();
+ for (Enumeration e = file.entries(); e.hasMoreElements();)
+ {
+ JarEntry entry = (JarEntry)e.nextElement();
+ JarEntryInfo info = new JarEntryInfo(entry);
+ entries.add(info);
+ }
+ }
+
+ public JarInfo(JarInputStream in) throws IOException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ entries = new TreeSet();
+ for (JarEntry entry = in.getNextJarEntry(); entry != null; entry = in.getNextJarEntry())
+ {
+ JarEntryInfo info = new JarEntryInfo(entry);
+ entries.add(info);
+ }
+ }
+
+ public Iterator entries()
+ {
+ return entries.iterator();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,221 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit;
+
+import junit.framework.Assert;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Add more assert methods.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7374 $
+ */
+public class ExtendedAssert extends Assert
+{
+
+ /** @see #assertEquals(Object[],Object[]) */
+ public static void assertEquals(Object[] expected, Object[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ /** Test equality as defined by java.util.Array#equals(Object[], Object[]). */
+ public static void assertEquals(String message, Object[] expected, Object[] actual)
+ {
+ if (Arrays.equals(expected, actual))
+ {
+ return;
+ }
+ fail(format(message, expected, actual));
+ }
+
+ /** @see #assertEquals(char[],char[]) */
+ public static void assertEquals(char[] expected, char[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ /** Test equality as defined by java.util.Array#equals(char[], char[]). */
+ public static void assertEquals(String message, char[] expected, char[] actual)
+ {
+ if (Arrays.equals(expected, actual))
+ {
+ return;
+ }
+ fail(format(message, expected, actual));
+ }
+
+ /** @see #assertEquals(byte[],byte[]) */
+ public static void assertEquals(byte[] expected, byte[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ /** Test equality as defined by java.util.Array#equals(char[], char[]). */
+ public static void assertEquals(String message, byte[] expected, byte[] actual)
+ {
+ if (Arrays.equals(expected, actual))
+ {
+ return;
+ }
+ fail(format(message, expected, actual));
+ }
+
+ private static String format(String message, Object expected, Object actual)
+ {
+ String formatted = "";
+ if (message != null)
+ {
+ formatted = message + " ";
+ }
+ return formatted + "expected:<" + format(expected) + "> but was:<" + format(actual) + ">";
+ }
+
+ private static String format(Object o)
+ {
+ if (o instanceof Object[])
+ {
+ Object[] array = (Object[])o;
+ StringBuffer buffer = new StringBuffer("[");
+ for (int i = 0; i < array.length; i++)
+ {
+ buffer.append(i == 0 ? "" : ",").append(String.valueOf(array[i]));
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+ else
+ {
+ return String.valueOf(o);
+ }
+ }
+
+ public static void assertEquals(Object[] expected, Object[] tested, boolean isOrderRelevant, String failMessage)
+ {
+ if (isOrderRelevant)
+ {
+ if (!Arrays.equals(expected, tested))
+ {
+ fail(failMessage);
+ }
+ }
+ else
+ {
+ boolean equals = (expected == tested);
+
+ if (!equals)
+ {
+ if (expected == null || tested == null)
+ {
+ fail(failMessage + " Not both null.");
+ }
+
+ if (expected.getClass().getComponentType() != tested.getClass().getComponentType())
+ {
+ fail(failMessage + " Different classes.");
+ }
+
+ if (expected.length != tested.length)
+ {
+ fail(failMessage + " Different sizes (tested: " + tested.length + ", expected: " + expected.length + ").");
+ }
+
+ List expectedList = Arrays.asList(expected);
+ List testedList = Arrays.asList(tested);
+ if (!expectedList.containsAll(testedList))
+ {
+ fail(failMessage);
+ }
+ }
+ }
+ }
+
+ public static void assertEquals(Object[] expected, Object[] tested, boolean isOrderRelevant, String failMessage, Decorator decorator)
+ {
+ Object[] decoratedExpected = null, decoratedTested = null;
+ if (decorator != null)
+ {
+ decoratedExpected = decorate(expected, decorator);
+ decoratedTested = decorate(tested, decorator);
+ }
+
+ assertEquals(decoratedExpected, decoratedTested, isOrderRelevant, failMessage);
+ }
+
+ public static Object[] decorate(Object[] toBeDecorated, Decorator decorator)
+ {
+ if (toBeDecorated != null)
+ {
+ DecoratedObject[] decorated = new DecoratedObject[toBeDecorated.length];
+ for (int i = 0; i < decorated.length; i++)
+ {
+ decorated[i] = new DecoratedObject(toBeDecorated[i], decorator);
+ }
+ return decorated;
+ }
+ return null;
+
+ }
+
+ public static void assertString1ContainsString2(String string1, String string2)
+ {
+ assertTrue("<" + string1 + "> does not contain <" + string2 + ">", string1.indexOf(string2) >= 0);
+ }
+
+ public static interface Decorator
+ {
+ void decorate(Object decorated);
+ }
+
+ public static class DecoratedObject
+ {
+ private Decorator decorator;
+ private Object decorated;
+
+ public Object getDecorated()
+ {
+ return decorated;
+ }
+
+ public DecoratedObject(Object decorated, Decorator decorator)
+ {
+ this.decorator = decorator;
+ this.decorated = decorated;
+ }
+
+ public boolean equals(Object obj)
+ {
+ decorator.decorate(decorated);
+ return decorator.equals(obj);
+ }
+
+ public String toString()
+ {
+ decorator.decorate(decorated);
+ return decorator.toString();
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,290 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class TransactionAssert extends Assert
+{
+
+ private static final String[] STATUS_NAMES = {
+ "STATUS_ACTIVE",
+ "STATUS_MARKED_ROLLBACK",
+ "STATUS_PREPARED",
+ "STATUS_COMMITTED",
+ "STATUS_ROLLEDBACK",
+ "STATUS_UNKNOWN",
+ "STATUS_NO_TRANSACTION",
+ "STATUS_PREPARING",
+ "STATUS_COMMITTING",
+ "STATUS_ROLLING_BACK"};
+
+ /**
+ * Decode the status name.
+ *
+ * @param status the status value
+ * @return the translated status name or null if it is not valid
+ */
+ public static String decodeStatus(int status)
+ {
+ if (status >= 0 && status <= STATUS_NAMES.length)
+ {
+ return STATUS_NAMES[status];
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /** . */
+ public static final Terminator NONE = new Terminator("NONE");
+
+ /** . */
+ public static final Terminator MARKED_AS_ROLLBACK = new Terminator("MARKED_AS_ROLLBACK");
+
+ /** . */
+ public static final Terminator MUST_COMMIT = new Terminator("MUST_COMMIT");
+
+ /** . */
+ public static final Terminator MUST_ROLLBACK = new Terminator("MUST ROLLBACK");
+
+ /**
+ *
+ */
+ public static final class Terminator
+ {
+
+ /** . */
+ private final String name;
+
+ public Terminator(String name)
+ {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Assert the status of the current transaction.
+ *
+ * @param expectedStatus the expected status
+ */
+ public static void assertStatusEquals(int expectedStatus)
+ {
+ try
+ {
+ UserTransaction ut = getUserTransaction();
+ int status = ut.getStatus();
+ if (status != expectedStatus)
+ {
+ fail("The status of the current transaction is " + status + " was expecting " + expectedStatus);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Unexpected exception");
+ }
+ }
+
+ /** Commit the transaction or fail. */
+ public static void commitTransaction()
+ {
+ try
+ {
+ getUserTransaction().commit();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Cannot commit transaction");
+ }
+ }
+
+ /** Rollback the transaction or fail. */
+ public static void rollbackTransaction()
+ {
+ rollbackTransaction(true);
+ }
+
+ public static void rollbackTransaction(boolean marked)
+ {
+ try
+ {
+ UserTransaction ut = getUserTransaction();
+ int status = ut.getStatus();
+ if (status == Status.STATUS_MARKED_ROLLBACK)
+ {
+ ut.rollback();
+ if (marked == false)
+ {
+ fail("Transaction should have been marked as rollback");
+ }
+ }
+ else if (status == Status.STATUS_ACTIVE)
+ {
+ ut.rollback();
+ if (marked)
+ {
+ fail("Transaction should have been marked as rollback");
+ }
+ }
+ else
+ {
+ if (marked)
+ {
+ fail("Unexpected transaction status " + status);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Cannot end transaction");
+ }
+ }
+
+ /** Begin a transaction or fail. */
+ public static void beginTransaction()
+ {
+ try
+ {
+ getUserTransaction().begin();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Cannot begin transaction");
+ }
+ }
+
+ /** If no transaction do nothing. End the transaction if it is active or marked for rollback otherwise fail. */
+ public static int endTransaction()
+ {
+ try
+ {
+ UserTransaction ut = getUserTransaction();
+ int status = ut.getStatus();
+ if (status == Status.STATUS_MARKED_ROLLBACK)
+ {
+ ut.rollback();
+ }
+ else if (status == Status.STATUS_ACTIVE)
+ {
+ ut.commit();
+ }
+ else if (status == Status.STATUS_NO_TRANSACTION)
+ {
+ // Do nothing
+ }
+ else
+ {
+ fail("Unexpected transaction status " + status);
+ }
+ return status;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new AssertionFailedError("Cannot end transaction");
+ }
+ }
+
+ /** If no transaction do nothing. End the transaction if it is active or marked for rollback otherwise fail. */
+ public static int endTransaction(Terminator expectedTerminator)
+ {
+ if (expectedTerminator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ UserTransaction ut = getUserTransaction();
+ int status = ut.getStatus();
+ if (status == Status.STATUS_MARKED_ROLLBACK)
+ {
+ ut.rollback();
+ if (expectedTerminator != MARKED_AS_ROLLBACK)
+ {
+ fail("Was expecting the transaction to be marked as rollback instead got " + decodeStatus(status));
+ }
+ }
+ else if (status == Status.STATUS_ACTIVE)
+ {
+ if (expectedTerminator == MUST_COMMIT)
+ {
+ ut.commit();
+ }
+ else if (expectedTerminator == MUST_ROLLBACK)
+ {
+ ut.rollback();
+ }
+ else
+ {
+ fail("Was expecting the transaction to be either commiting or rollbacking instead got " + decodeStatus(status));
+ }
+ }
+ else if (status == Status.STATUS_NO_TRANSACTION)
+ {
+ if (expectedTerminator != NONE)
+ {
+ fail("Was expecting no transaction instead got " + decodeStatus(status));
+ }
+ }
+ else
+ {
+ fail("Unexpected transaction status " + decodeStatus(status));
+ }
+ return status;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new AssertionFailedError("Cannot end transaction");
+ }
+ }
+
+ public static UserTransaction getUserTransaction()
+ {
+ try
+ {
+ return (UserTransaction)new InitialContext().lookup("UserTransaction");
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ fail("Cannot obtain user transaction");
+ return null;
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTask.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTask.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTask.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTask;
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+import org.apache.tools.ant.BuildException;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ConfigurableJUnitTask extends JUnitTask
+{
+
+ public ConfigurableJUnitTask() throws Exception
+ {
+ }
+
+ public void addZest(ConfigurableJUnitTest test)
+ {
+ test.setTask(this);
+ addTest(test);
+ }
+
+ protected void execute(JUnitTest test) throws BuildException
+ {
+ // Delete any existing file
+ File tmp = new File(System.getProperty("java.io.tmpdir"), TestParameter.PARAMETRIZATION_FILE_NAME);
+ if (tmp.exists() && tmp.isFile())
+ {
+ if (!tmp.delete())
+ {
+ throw new Error("Cannot delete previous saved parametrization");
+ }
+ }
+
+ //
+ try
+ {
+ // Basically we are only sure at this time of the execution that the nested parameter map is fully initialized
+ if (test instanceof ConfigurableJUnitTest)
+ {
+ ((ConfigurableJUnitTest)test).saveState();
+ }
+
+ // Let the parent class execute the super class
+ super.execute(test);
+ }
+ finally
+ {
+ // Cleanup any save state
+ if (tmp.exists() && tmp.isFile())
+ {
+ if (!tmp.delete())
+ {
+ tmp.deleteOnExit();
+ }
+ }
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTest.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTest.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTest.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,128 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Used by ant to create a representation of the test to run.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ConfigurableJUnitTest extends JUnitTest
+{
+
+ /** . */
+ private final ArrayList nestedParameters;
+
+ /** . */
+ private ConfigurableJUnitTask task;
+
+ /** . */
+ private String id;
+
+ public ConfigurableJUnitTest()
+ {
+ nestedParameters = new ArrayList();
+ }
+
+ public void addParameter(TestParameter parameter)
+ {
+ nestedParameters.add(parameter);
+ }
+
+ public void setTask(ConfigurableJUnitTask task)
+ {
+ this.task = task;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+
+ //
+ TestParameter parameter = new TestParameter();
+ parameter.setName(TestParameter.TEST_ID_PARAM);
+ parameter.setValue(id);
+ addParameter(parameter);
+ }
+
+ /**
+ * Save the state of the junit test on the disk for reuse later in the forked virtual machine.
+ * As there is not clear life cycle of the usage of this class, we need to save the state initially
+ * and on every update.
+ */
+ public void saveState()
+ {
+ try
+ {
+ Map parameters = new HashMap();
+ for (int i = 0; i < nestedParameters.size(); i++)
+ {
+ TestParameter parameter = (TestParameter)nestedParameters.get(i);
+ String[] values = null;
+ if (parameter.value != null)
+ {
+ values = new String[]{parameter.value};
+ }
+ else if (parameter.nestedValues.size() > 0)
+ {
+ values = new String[parameter.nestedValues.size()];
+ for (int j = 0; j < values.length; j++)
+ {
+ values[j] = ((TestParameterValue)parameter.nestedValues.get(j)).text;
+ }
+ }
+ if (values != null)
+ {
+ parameters.put(parameter.name, values);
+ }
+ }
+ File tmp = new File(System.getProperty("java.io.tmpdir"), TestParameter.PARAMETRIZATION_FILE_NAME);
+ tmp.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tmp);
+ ObjectOutputStream oos = new ObjectOutputStream(fos);
+ oos.writeObject(parameters);
+ oos.close();
+
+ }
+ catch (IOException e)
+ {
+ throw new Error(e);
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableXMLJUnitResultFormatter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableXMLJUnitResultFormatter.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableXMLJUnitResultFormatter.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+import org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter;
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+import org.w3c.dom.Element;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConfigurableXMLJUnitResultFormatter extends XMLJUnitResultFormatter
+{
+
+ /** . */
+ private static final Field f;
+
+ static
+ {
+ try
+ {
+ f = XMLJUnitResultFormatter.class.getDeclaredField("rootElement");
+ if (!f.isAccessible())
+ {
+ f.setAccessible(true);
+ }
+ }
+ catch (NoSuchFieldException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ public void startTestSuite(JUnitTest suite)
+ {
+ super.startTestSuite(suite);
+
+ //
+ Map parameters = TestParameter.readExternalParameters();
+ if (parameters != null)
+ {
+ String[] values = (String[])parameters.get(TestParameter.TEST_ID_PARAM);
+ if (values != null && values.length > 0)
+ {
+ try
+ {
+ String id = values[0];
+ Element rootElement = (Element)f.get(this);
+ rootElement.setAttribute("name", id);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new Error(e);
+ }
+ }
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameter.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameter.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class TestParameter
+{
+
+ /** . */
+ static final String TEST_ID_PARAM = "test.param.id";
+
+ /** . */
+ static final String PARAMETRIZATION_FILE_NAME = "junit.parameters";
+
+ /** . */
+ protected String name;
+
+ /** . */
+ protected String value;
+
+ /** . */
+ protected ArrayList nestedValues = new ArrayList();
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public void addValue(TestParameterValue value)
+ {
+ nestedValues.add(value);
+ }
+
+ public static Map readExternalParameters()
+ {
+ try
+ {
+ File tmp = new File(System.getProperty("java.io.tmpdir"), PARAMETRIZATION_FILE_NAME);
+ if (tmp.exists() && tmp.isFile())
+ {
+ FileInputStream fis = new FileInputStream(tmp);
+ ObjectInputStream ois = new ObjectInputStream(fis);
+ Map parameters = (Map)ois.readObject();
+ ois.close();
+ return parameters;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameterValue.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameterValue.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameterValue.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class TestParameterValue
+{
+
+ /** . */
+ protected String text;
+
+ public void addText(String text)
+ {
+ this.text = text;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.logging;
+
+import org.apache.log4j.Hierarchy;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggerRepository;
+import org.apache.log4j.spi.RepositorySelector;
+import org.apache.log4j.spi.RootCategory;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.portal.common.util.ResourceLoader;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.io.IOTools;
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Stan Silvert
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7374 $
+ */
+public class LoaderRepositorySelector implements org.apache.log4j.spi.RepositorySelector
+{
+
+ private static boolean initialized = false;
+
+ // This object is used for the guard because it doesn't get
+ // recycled when the application is redeployed.
+ private static Object guard = LogManager.getRootLogger();
+ private static Map repositories = new HashMap();
+ private static LoggerRepository defaultRepository;
+ private static Logger log = Logger.getLogger(LoaderRepositorySelector.class);
+
+ /**
+ * Register with this repository selector.
+ */
+ public static synchronized void register(ClassLoader classloader, ResourceLoader loader, String pathToLog4jFile)
+ {
+ if (classloader == null)
+ {
+ throw new IllegalArgumentException("No classloader provided");
+ }
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("No loader provided");
+ }
+ if (pathToLog4jFile == null)
+ {
+ throw new IllegalArgumentException("No pathToLog4jFile provided");
+ }
+
+ // Set the global RepositorySelector
+ if (!initialized)
+ {
+ // defaultRepository = LogManager.getLoggerRepository();
+ RepositorySelector theSelector = new LoaderRepositorySelector();
+ LogManager.setRepositorySelector(theSelector, guard);
+ initialized = true;
+ }
+
+ InputStream log4JConfig = null;
+ try
+ {
+ log4JConfig = loader.load(pathToLog4jFile);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(log4JConfig);
+ DOMConfigurator conf = new DOMConfigurator();
+
+ Hierarchy hierarchy = new Hierarchy(new RootCategory(Level.DEBUG));
+ conf.doConfigure(doc.getDocumentElement(), hierarchy);
+ repositories.put(classloader, hierarchy);
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ throw new IllegalArgumentException("Cannot load log4j configuration");
+ }
+ finally
+ {
+ IOTools.safeClose(log4JConfig);
+ }
+ }
+
+ public static synchronized void unregister(ClassLoader classloader)
+ {
+ if (classloader == null)
+ {
+ throw new IllegalArgumentException("No classloader provided");
+ }
+ Hierarchy hierarchy = (Hierarchy)repositories.remove(classloader);
+ if (hierarchy != null)
+ {
+ hierarchy.shutdown();
+ }
+ else
+ {
+ System.out.print("No hierarchy found for classloader : ");
+ Writer writer = new PrintWriter(System.out);
+ Tools.dumpClassLoaderHierarchyInfo(writer, classloader);
+ }
+ }
+
+ private LoaderRepositorySelector()
+ {
+ }
+
+ public LoggerRepository getLoggerRepository()
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ LoggerRepository repository = (LoggerRepository)repositories.get(loader);
+ if (repository == null)
+ {
+ return defaultRepository;
+ }
+ else
+ {
+ return repository;
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.logging;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class Log4JWriter extends Writer
+{
+
+ /** The open/closed status. */
+ private boolean open;
+
+ /** The logger. */
+ private Logger log;
+
+ /** The logging level. */
+ private Level level;
+
+ /**
+ * @throws IllegalArgumentException if log or level is null
+ */
+ public Log4JWriter(Logger log, Level level) throws IllegalArgumentException
+ {
+ if (log == null)
+ {
+ throw new IllegalArgumentException("No logger provided");
+ }
+ if (level == null)
+ {
+ throw new IllegalArgumentException("No level provided");
+ }
+ this.open = false;
+ this.log = log;
+ this.level = level;
+ }
+
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ if (open)
+ {
+ log.log(level, new String(cbuf, off, len));
+ }
+ else
+ {
+ throw new IOException("Stream closed");
+ }
+ }
+
+ public void flush() throws IOException
+ {
+ }
+
+ public void close() throws IOException
+ {
+ open = false;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,194 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.markup;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+import org.jboss.portal.common.io.WriterCharWriter;
+import org.jboss.portal.common.text.AbstractCharEncoder;
+import org.jboss.portal.common.text.CharEncoder;
+import org.jboss.portal.common.text.CharWriter;
+import org.jboss.portal.common.text.EncodingException;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
+/**
+ * A markup attribute.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MarkupAttribute
+{
+
+ /** . */
+ final String name;
+
+ /** . */
+ final String value;
+
+ /** . */
+ final Type type;
+
+ /** . */
+ final String encodedValue;
+
+ /**
+ * @param name the attribute name
+ * @param value the attribute value
+ * @param type the attribute type
+ */
+ public MarkupAttribute(String name, String value, Type type)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name accepted");
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("No null value accepted");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No null type accepted");
+ }
+ this.name = name;
+ this.value = value;
+ this.type = type;
+
+ //
+ StringWriter tmp = new StringWriter();
+ type.encode(value, tmp);
+ this.encodedValue = tmp.toString();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public String getEncodedValue()
+ {
+ return encodedValue;
+ }
+
+ public Type getType()
+ {
+ return type;
+ }
+
+ /** The type of the attribute value. */
+ public abstract static class Type
+ {
+
+ /**
+ * Encode the string in the proper format according to the type.
+ *
+ * @param string the string to encode
+ * @return the encoded string
+ */
+ public abstract void encode(String string, Writer writer) throws UndeclaredIOException;
+
+ private static class CDATAType extends Type
+ {
+ public void encode(String string, Writer writer)
+ {
+ try
+ {
+ writer.write(string);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+ }
+
+ /**
+ * CDATA is a sequence of characters from the document character set and may include character entities. User
+ * agents should interpret attribute values as follows: <ul> <li>Replace character entities with characters,</li>
+ * <li>Ignore line feeds,</li> <li>Replace each carriage return or tab with a single space.</li> </ul>
+ */
+ public static final Type CDATA = new CDATAType();
+
+ /**
+ * NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]),
+ * hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
+ */
+ public static final Type NAME = new CDATAType();
+
+ /** %ContentType required : CDATA -- media type, as per [RFC2045]. */
+ public static final Type CONTENT_TYPE = new CDATAType();
+
+ private static final char[] SLASH_ARRAY = "/".toCharArray();
+
+ /** %URI : CDATA -- a Uniform Resource Identifier, see [URI]. */
+ public static final Type URI = new CDATAType()
+ {
+ {
+ // Patches the encoder to let '/' not being encoded
+ encoder = new AbstractCharEncoder()
+ {
+ protected void safeEncode(char c, CharWriter writer) throws EncodingException
+ {
+ if (c == '/')
+ {
+ writer.append(SLASH_ARRAY);
+ }
+ else
+ {
+ FastURLEncoder.getUTF8Instance().encode(c, writer);
+ }
+ }
+ };
+ }
+
+ /** Our encoder for URI. */
+ final CharEncoder encoder;
+
+ public void encode(String string, Writer writer)
+ {
+ encoder.encode(string, new WriterCharWriter(writer));
+ }
+ };
+
+ /** %LinkTypes : CDATA -- space-separated list of link types. */
+ public static final Type LINK_TYPES = new CDATAType();
+
+ /** %Text : CDATA : CDATA. */
+ public static final Type TEXT = new CDATAType();
+
+ /** %MediaDesc : CDATA -- single or comma-separated list of media descriptors. */
+ public static final Type MEDIA_DESC = new CDATAType();
+
+ /** %URI : CDATA -- a Uniform Resource Identifier, see [URI]. */
+ public static final Type HREF = new CDATAType();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupElement.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupElement.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupElement.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,210 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.markup;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An markup element.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MarkupElement
+{
+
+ /** . */
+ final String name;
+
+ /** . */
+ final String bodyContent;
+
+ /**
+ * If true and the body content is null then output the start tag and the end tag instead of an empty tag. The use
+ * case is for the script element which when it is empty raise issues on IE, so it start element and end element have
+ * to be used.
+ */
+ final boolean neverEmpty;
+
+ /** . */
+ final MarkupAttribute[] attributes;
+
+ /**
+ * @param name the element name
+ * @param bodyContent the optional body content
+ * @param neverEmpty
+ * @param attributes
+ */
+ public MarkupElement(
+ String name,
+ String bodyContent,
+ boolean neverEmpty,
+ MarkupAttribute[] attributes)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name accepted");
+ }
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException("No null attributes accepted");
+ }
+
+ //
+ Set tmp = new HashSet();
+ for (int i = 0; i < attributes.length; i++)
+ {
+ MarkupAttribute attribute = attributes[i];
+ if (attribute == null)
+ {
+ throw new IllegalArgumentException("Cannot have a null attribute");
+ }
+ if (tmp.add(attribute.name) == false)
+ {
+ throw new IllegalArgumentException("Cannot have two identical attributes " + attribute.name);
+ }
+ }
+
+ this.name = name;
+ this.bodyContent = bodyContent;
+ this.neverEmpty = neverEmpty;
+ this.attributes = (MarkupAttribute[])attributes.clone();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getBodyContent()
+ {
+ return bodyContent;
+ }
+
+ public boolean isNeverEmpty()
+ {
+ return neverEmpty;
+ }
+
+ public int getAttributeSize()
+ {
+ return attributes.length;
+ }
+
+ public MarkupAttribute getAttribute(int index)
+ {
+ return attributes[index];
+ }
+
+ public MarkupAttribute getAttribute(String name)
+ {
+ for (int i = 0; i < attributes.length; i++)
+ {
+ MarkupAttribute attribute = attributes[i];
+ if (attribute.name.equals(name))
+ {
+ return attribute;
+ }
+ }
+ return null;
+ }
+
+ public void write(String urlPrefix, Writer writer) throws UndeclaredIOException
+ {
+ if (urlPrefix == null)
+ {
+ throw new IllegalArgumentException("No context path provided");
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("No writer provided");
+ }
+ try
+ {
+ writer.write("<");
+ writer.write(name);
+ for (int i = 0; i < attributes.length; i++)
+ {
+ MarkupAttribute attribute = attributes[i];
+
+ // If it is an URI type we prepend the context path
+ if (attribute.type == MarkupAttribute.Type.URI)
+ {
+ writer.write(" ");
+ writer.write(attribute.name);
+ writer.write("=\"");
+ if (attribute.value.startsWith("/"))
+ {
+ MarkupAttribute.Type.URI.encode(urlPrefix, writer);
+ }
+ writer.write(attribute.encodedValue);
+ writer.write('"');
+ }
+ else
+ {
+ writer.write(" ");
+ writer.write(attribute.name);
+ writer.write("=\"");
+ writer.write(attribute.encodedValue);
+ writer.write('"');
+ }
+ }
+ if (bodyContent != null && bodyContent.length() > 0)
+ {
+ writer.write(">");
+ writer.write(bodyContent);
+ writer.write("</");
+ writer.write(name);
+ writer.write(">\n");
+ }
+ else if (neverEmpty)
+ {
+ writer.write(">");
+ writer.write("</");
+ writer.write(name);
+ writer.write(">\n");
+ }
+ else
+ {
+ writer.write("/>\n");
+ }
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public String toString(String contextPath)
+ {
+ StringWriter buffer = new StringWriter(64);
+ write(contextPath, buffer);
+ return buffer.toString();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,383 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mx;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.Descriptor;
+import javax.management.modelmbean.ModelMBeanAttributeInfo;
+import javax.management.modelmbean.ModelMBeanConstructorInfo;
+import javax.management.modelmbean.ModelMBeanInfo;
+import javax.management.modelmbean.ModelMBeanInfoSupport;
+import javax.management.modelmbean.ModelMBeanNotificationInfo;
+import javax.management.modelmbean.ModelMBeanOperationInfo;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7452 $
+ */
+public class JavaBeanModelMBeanBuilder
+{
+ private final static String CURRENCY_TIME_LIMIT = "currencyTimeLimit";
+ private final static String GET_METHOD = "getMethod";
+ private final static String SET_METHOD = "setMethod";
+ private final static String PERSIST_POLICY = "persistPolicy";
+ private final static String ROLE = "role";
+
+ private ArrayList mmais;
+ private ArrayList mmois;
+ private String className;
+
+ public JavaBeanModelMBeanBuilder(Class from, Class to) throws Exception
+ {
+ if (from == null)
+ {
+ throw new IllegalArgumentException("The from class must not be null");
+ }
+ if (from.isInterface())
+ {
+ throw new IllegalArgumentException("The from class " + from + " must not be an interface");
+ }
+ if (to != null)
+ {
+ if (to.isInterface())
+ {
+ throw new IllegalArgumentException("The to class " + to + " must not be an interface");
+ }
+ if (!to.isAssignableFrom(from))
+ {
+ throw new IllegalArgumentException("The from class " + from + " is not a subclass of " + to);
+ }
+ }
+
+ //
+ Map beanGetters = new HashMap();
+ Map beanSetters = new HashMap();
+ Map beanMethods = new HashMap();
+
+ //
+ for (Class c = from;c != null && !c.equals(to);c = c.getSuperclass())
+ {
+ Map currentClassGetters = new HashMap();
+ Map currentClassSetters = new HashMap();
+
+ Method[] methods = c.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++)
+ {
+ Method method = methods[i];
+ int modifiers = method.getModifiers();
+ if (Modifier.isPublic(modifiers) &&
+ !Modifier.isAbstract(modifiers) &&
+ !Modifier.isStatic(modifiers))
+ {
+ String methodName = method.getName();
+ Class returnType = method.getReturnType();
+ Class[] parameterTypes = method.getParameterTypes();
+ if (methodName.startsWith("get") &&
+ !void.class.equals(returnType) &&
+ parameterTypes.length == 0 &&
+ methodName.length() > 3)
+ {
+ String propertyName = methodName.substring(3);
+
+ // Try to locate an existing setter for the same property
+ Method beanSetter = (Method)currentClassSetters.get(propertyName);
+ if (beanSetter == null)
+ {
+ beanSetter = (Method)beanSetters.get(propertyName);
+ }
+
+ // Check we do not have a setter with a different return type
+ if (beanSetter != null && !beanSetter.getParameterTypes()[0].equals(returnType))
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has a setter" +
+ " type " + beanSetter.getParameterTypes()[0] + " different from the corresponding" +
+ " getter type " + returnType);
+ }
+
+ // Get an existing bean getter
+ Method beanGetter = (Method)currentClassGetters.get(propertyName);
+ if (beanGetter != null)
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has two getters " +
+ beanGetter + " and " + method);
+ }
+
+ //
+ currentClassGetters.put(propertyName, method);
+ }
+ else if (methodName.startsWith("is") &&
+ !void.class.equals(returnType) &&
+ parameterTypes.length == 0 &&
+ methodName.length() > 2)
+ {
+ String propertyName = methodName.substring(2);
+
+ // Try to locate an existing setter for the same property
+ Method beanSetter = (Method)beanSetters.get(propertyName);
+ if (beanSetter != null)
+ {
+ beanSetter = (Method)currentClassSetters.get(propertyName);
+ }
+
+ // Check we do not have a setter with a different return type
+ if (beanSetter != null && !beanSetter.getParameterTypes()[0].equals(returnType))
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has a setter" +
+ " type " + beanSetter.getParameterTypes()[0] + " different from the corresponding" +
+ " getter type " + returnType);
+ }
+
+ // Get an existing getter
+ Method beanGetter = (Method)beanGetters.get(propertyName);
+ if (beanGetter != null)
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has two getters " +
+ beanGetter + " and " + method);
+ }
+
+ //
+ currentClassGetters.put(propertyName, method);
+ }
+ else if (methodName.startsWith("set") &&
+ void.class.equals(returnType) &&
+ parameterTypes.length == 1 &&
+ methodName.length() > 3)
+ {
+ String propertyName = methodName.substring(3);
+
+ // Try to locate an existing getter
+ Method beanGetter = (Method)beanGetters.get(propertyName);
+ if (beanGetter == null)
+ {
+ beanGetter = (Method)currentClassGetters.get(propertyName);
+ }
+
+ // Check we do not have a getter with a different return type
+ if (beanGetter != null && !beanGetter.getReturnType().equals(parameterTypes[0]))
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has a setter" +
+ " type " + parameterTypes[0] + " different from the corresponding" +
+ " getter type " + beanGetter.getReturnType());
+ }
+
+ // Get an existing setter
+ Method beanSetter = (Method)beanSetters.get(propertyName);
+ if (beanSetter != null)
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " cannot have two setters " +
+ beanSetter + " and " + method);
+ }
+
+ //
+ currentClassSetters.put(propertyName, method);
+ }
+
+ //
+ beanMethods.put(new MethodKey(method), method);
+ }
+ }
+ beanGetters.putAll(currentClassGetters);
+ beanSetters.putAll(currentClassSetters);
+ }
+
+ // Keep track of property accessors methods
+ Map roles = new HashMap();
+
+ // Properties->Attributes
+ mmais = new ArrayList();
+ Set allPropertyNames = new HashSet();
+ allPropertyNames.addAll(beanGetters.keySet());
+ allPropertyNames.addAll(beanSetters.keySet());
+ for (Iterator i = allPropertyNames.iterator(); i.hasNext();)
+ {
+ String propertyName = (String)i.next();
+
+ //
+ Method getter = (Method)beanGetters.get(propertyName);
+ Method setter = (Method)beanSetters.get(propertyName);
+
+ // Create the metadata
+ ModelMBeanAttributeInfo mmai = new ModelMBeanAttributeInfo(
+ propertyName,
+ "Javabean introspected attribute",
+ getter,
+ setter);
+
+ // Complete the descriptor
+ Descriptor desc = mmai.getDescriptor();
+ desc.setField(JavaBeanModelMBeanBuilder.CURRENCY_TIME_LIMIT, "-1");
+ desc.setField(JavaBeanModelMBeanBuilder.PERSIST_POLICY, "Never");
+
+ //
+ if (getter != null)
+ {
+ roles.put(getter, "getter");
+ desc.setField(JavaBeanModelMBeanBuilder.GET_METHOD, getter.getName());
+ }
+
+ //
+ if (setter != null)
+ {
+ roles.put(setter, "setter");
+ desc.setField(JavaBeanModelMBeanBuilder.SET_METHOD, setter.getName());
+ }
+
+ //
+ mmai.setDescriptor(desc);
+
+ // Finally add the metadata
+ mmais.add(mmai);
+ }
+
+ //
+ className = from.getName();
+
+ // Methods->Operations
+ mmois = new ArrayList();
+ for (Iterator i = beanMethods.values().iterator(); i.hasNext();)
+ {
+ Method method = (Method)i.next();
+
+ // Create the metadata
+ ModelMBeanOperationInfo mmoi = new ModelMBeanOperationInfo("Javabean introspected method", method);
+
+ // Complete the descriptor
+ Descriptor desc = mmoi.getDescriptor();
+ String role = (String)roles.get(method);
+ desc.setField(JavaBeanModelMBeanBuilder.ROLE, role != null ? role : "operation");
+ mmoi.setDescriptor(desc);
+
+ // Finally add the metadata
+ mmois.add(mmoi);
+ }
+ }
+
+ /**
+ * Remove an interface from the management interface.
+ */
+ public void remove(Class itf)
+ {
+ throw new UnsupportedOperationException("To be implemented if useful, just a placeholder now");
+ }
+
+ /**
+ * Generates and returns the management interface.
+ */
+ public ModelMBeanInfo getInfo()
+ {
+ // Assemble the mbean info
+ ModelMBeanInfoSupport info = new ModelMBeanInfoSupport(
+ className,
+ "Javabean model mbean",
+ (ModelMBeanAttributeInfo[])mmais.toArray(new ModelMBeanAttributeInfo[mmais.size()]),
+ new ModelMBeanConstructorInfo[0],
+ (ModelMBeanOperationInfo[])mmois.toArray(new ModelMBeanOperationInfo[mmois.size()]),
+ new ModelMBeanNotificationInfo[0]);
+
+ //
+ return info;
+ }
+
+ public static ModelMBeanInfo build(Class from, Class to) throws Exception
+ {
+ return new JavaBeanModelMBeanBuilder(from, to).getInfo();
+ }
+
+ public static ModelMBeanInfo build(Object o) throws Exception
+ {
+ return new JavaBeanModelMBeanBuilder(o.getClass(), null).getInfo();
+ }
+
+ /**
+ * Key a method during the lookup operations
+ */
+ private static class MethodKey
+ {
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final Class[] parameterTypes;
+
+ /** . */
+ private final int hashCode;
+
+ public MethodKey(Method method)
+ {
+ this.name = method.getName();
+ this.parameterTypes = method.getParameterTypes();
+
+ // Compute hash code
+ int hashCode = method.getName().hashCode();
+ for (int i = 0;i < parameterTypes.length;i++)
+ {
+ Class parameterType = parameterTypes[i];
+ hashCode = hashCode * 43 + parameterType.hashCode();
+ }
+ this.hashCode = hashCode;
+ }
+
+ public int hashCode()
+ {
+ return hashCode;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof MethodKey)
+ {
+ MethodKey that = (MethodKey)obj;
+
+ //
+ if (that.name.equals(this.name) && that.parameterTypes.length == this.parameterTypes.length)
+ {
+ for (int i = 0;i < that.parameterTypes.length;i++)
+ {
+ if (!that.parameterTypes[i].equals(this.parameterTypes[i]))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mx;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Helper class that filter and listen notifications and help to registration.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class Listener implements NotificationFilter, NotificationListener
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 444957117668223654L;
+ protected final MBeanServer server;
+ protected final Logger log;
+
+ public Listener(MBeanServer server)
+ {
+ if (server == null)
+ {
+ throw new IllegalArgumentException("server must not be null");
+ }
+ this.server = server;
+ this.log = Logger.getLogger(getClass());
+ }
+
+ public void register(ObjectName broadcaster)
+ {
+ register(broadcaster, null);
+ }
+
+ public void register(ObjectName broadcaster, Object handback)
+ {
+ try
+ {
+ if (broadcaster == null)
+ {
+ throw new IllegalArgumentException("Broadcaster is null");
+ }
+
+ log.debug("Register notifications on MBean " + broadcaster.getCanonicalName());
+ server.addNotificationListener(broadcaster, this, this, handback);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ throw new ListenerException(e);
+ }
+ }
+
+ public void unregister(ObjectName broadcaster)
+ {
+ try
+ {
+ if (broadcaster == null)
+ {
+ throw new IllegalArgumentException("Broadcaster is null");
+ }
+
+ log.debug("Unregister notifications on MBean " + broadcaster.getCanonicalName());
+ server.removeNotificationListener(broadcaster, this);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ throw new ListenerException(e);
+ }
+ catch (ListenerNotFoundException e)
+ {
+ throw new ListenerException(e);
+ }
+ }
+
+ /**
+ * Returns true by default.
+ */
+ public boolean isNotificationEnabled(Notification notification)
+ {
+ return true;
+ }
+
+ /**
+ * Does not perform anything by default.
+ */
+ public void handleNotification(Notification notification, Object handback)
+ {
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mx;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ListenerException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 2024301956562398716L;
+
+ public ListenerException()
+ {
+ }
+
+ public ListenerException(String message)
+ {
+ super(message);
+ }
+
+ public ListenerException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ListenerException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLFilter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLFilter.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLFilter.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface URLFilter
+{
+ /** Return true if the filter accepts the url. */
+ boolean acceptFile(URL url);
+
+ /** Return true if the directory should be visited. */
+ boolean acceptDir(URL url);
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import java.net.URL;
+import java.io.IOException;
+
+/**
+ * Defines an interface that provides navigation for URLs.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6834 $
+ */
+public interface URLNavigationProvider
+{
+ /**
+ * Visit all the children recursively.
+ *
+ * @param url the target url
+ * @param visitor the visitor
+ * @param filter the filter
+ * @throws IllegalArgumentException if an argument is null or if the url is not accepted
+ * @throws IOException
+s */
+ void visit(URL url, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException;
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import org.jboss.portal.common.net.file.FileURLNavigationProvider;
+import org.jboss.portal.common.net.jar.JarURLNavigationProvider;
+
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * The URLNavigator class is a registry for various URLNavigationProvider.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6852 $
+ */
+public class URLNavigator
+{
+
+ private static final URLNavigationProvider fileNav = new FileURLNavigationProvider();
+
+ private static final URLNavigationProvider jarNav = new JarURLNavigationProvider();
+
+ private static final URLFilter NULL_FILTER = new URLFilter()
+ {
+ public boolean acceptFile(URL url)
+ {
+ return true;
+ }
+
+ public boolean acceptDir(URL url)
+ {
+ return true;
+ }
+ };
+
+ public static void visit(URL url, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException
+ {
+ URLNavigationProvider provider = getProvider(url);
+
+ if (filter == null)
+ {
+ filter = NULL_FILTER;
+ }
+
+ provider.visit(url, visitor, filter);
+ }
+
+ public static void visit(URL url, URLVisitor visitor) throws IOException
+ {
+ visit(url, visitor, null);
+ }
+
+ /**
+ * Return an URLNavigationProvider for the specified URL.
+ *
+ * @param url the target url
+ * @return the corresponding URL navigator
+ * @throws IllegalArgumentException if the url is null or no provider is found
+ */
+ private static URLNavigationProvider getProvider(URL url) throws IllegalArgumentException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("Null not accepted");
+ }
+ String protocol = url.getProtocol();
+ if ("file".equals(protocol))
+ {
+ return fileNav;
+ }
+ else if ("jar".equals(protocol))
+ {
+ return jarNav;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Not recognized " + protocol);
+ }
+ }
+
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,456 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.text.FastURLDecoder;
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.util.ParameterValidation;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7686 $
+ * @since 2.4 (May 26, 2006)
+ */
+public class URLTools
+{
+ public static final String RE_EMAIL_VALIDATION = "^([a-zA-Z0-9]+(([\\.\\-\\_]?[a-zA-Z0-9]+)+)?)\\(a)(([a-zA-Z0-9]+[\\.\\-\\_])+[a-zA-Z]{2,4})$";
+ private static final Pattern LINK = Pattern.compile("(?:href|action|src|location)\\s*=\\s*('|\")\\s*([^'\"]*)\\s*('|\")",
+ Pattern.CASE_INSENSITIVE);
+
+ public static final String HTTP_PREFIX = "http://";
+ public static final String HTTPS_PREFIX = "https://";
+ public static final String FTP_PREFIX = "ftp://";
+ public static final String FILE_PREFIX = "/";
+
+ private static final Logger log = Logger.getLogger(URLTools.class);
+
+ public static boolean isURLAbsolute(String url)
+ {
+ return isNetworkURL(url) || url.startsWith(FILE_PREFIX);
+ }
+
+ /**
+ * Fetches content from of the URL as a byte array or <code>null</code> if a problem occurred. The timeout values
+ * must not be negative integers, when it is equals to zero it means that it does not setup a timeout and use the
+ * default values.
+ *
+ * @param url the URL the URL of the resource
+ * @param soTimeoutMillis the socket connection timeout in millis
+ * @param connTimeoutMillis the connection timeout in millis
+ * @return the retrieved byte array
+ * @throws IllegalArgumentException if the URL is null or any time out value is negative
+ */
+ public static byte[] getContent(URL url, int soTimeoutMillis, int connTimeoutMillis) throws IllegalArgumentException
+ {
+ InputStream in = null;
+ try
+ {
+ in = getContentAsInputStream(url, soTimeoutMillis, connTimeoutMillis);
+ return IOTools.getBytes(in);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ /**
+ * Fetches content from URL as an InputStream. The timeout values must not be negative integers, when it is equals to
+ * zero it means that it does not setup a timeout and use the default values.
+ *
+ * @param url the URL the URL of the resource
+ * @param soTimeoutMillis the socket connection timeout in millis
+ * @param connTimeoutMillis the connection timeout in millis
+ * @return the buffered content for the URL
+ * @throws IllegalArgumentException if the URL is null or any time out value is negative
+ * @since 1.1
+ */
+ public static InputStream getContentAsInputStream(URL url, int soTimeoutMillis, int connTimeoutMillis) throws IOException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (soTimeoutMillis < 0)
+ {
+ throw new IllegalArgumentException("No negative socket timeout " + soTimeoutMillis);
+ }
+ if (connTimeoutMillis < 0)
+ {
+ throw new IllegalArgumentException("No negative connection timeout" + connTimeoutMillis);
+ }
+
+ //
+ URLConnection conn;
+ try
+ {
+ conn = url.openConnection();
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+
+ // Configure
+ conn.setConnectTimeout(soTimeoutMillis);
+ conn.setReadTimeout(connTimeoutMillis);
+
+ conn.connect();
+ try
+ {
+ return new BufferedInputStream(conn.getInputStream());
+ }
+ catch (SocketTimeoutException e)
+ {
+ log.debug("Time out on: " + url);
+ throw e;
+ }
+ }
+
+ /**
+ * @param url
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean isNetworkURL(String url)
+ {
+ if (url == null || url.length() == 0)
+ {
+ return false;
+ }
+
+ return url.startsWith(HTTP_PREFIX) || url.startsWith(HTTPS_PREFIX) || url.startsWith(FTP_PREFIX);
+ }
+
+ /**
+ * Enforces that the given URL is absolute
+ *
+ * @param url the String representation of the URL to be checked
+ * @throws IllegalArgumentException if the given URL is not absolute
+ */
+ public static void enforceAbsoluteURL(String url) throws IllegalArgumentException
+ {
+ if (!isURLAbsolute(url))
+ {
+ throw new IllegalArgumentException("URL must be absolute. Was: " + url);
+ }
+ }
+
+ public static String encodeXWWWFormURL(String s)
+ {
+ return FastURLEncoder.getUTF8Instance().encode(s);
+ }
+
+ public static String decodeXWWWFormURL(String s)
+ {
+ return FastURLDecoder.getUTF8Instance().encode(s);
+ }
+
+ /** Return true is the address is not null and matches the email validation regular expression. */
+ public static boolean isEmailValid(String address)
+ {
+ return address != null && Pattern.matches(RE_EMAIL_VALIDATION, address);
+ }
+
+ /**
+ * Determines that the specified URL corresponds to an existing resource by trying to open a stream from it. Same as
+ * <code>exists(url, 1000)</code>
+ *
+ * @param url
+ * @return
+ */
+ public static boolean exists(URL url)
+ {
+ return exists(url, 1000);
+ }
+
+ /**
+ * Determines if the specified URL corresponds to an existing resource by trying to open a stream from it.
+ *
+ * @param url the URL to be tested
+ * @param waitForMillis the number of milliseconds to wait before timing out, 0 meaning never timing out.
+ * @return
+ * @throws IllegalArgumentException if the url is null or the time out negative
+ * @since 2.4.2
+ */
+ public static boolean exists(URL url, long waitForMillis) throws IllegalArgumentException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("No null URL accepted");
+ }
+ if (waitForMillis < 0)
+ {
+ throw new IllegalArgumentException("Read time out must be a positive value instead of " + waitForMillis);
+ }
+
+ //
+ URLConnection conn;
+ try
+ {
+ conn = url.openConnection();
+ }
+ catch (IOException e)
+ {
+ log.debug("Could not open connection for " + url, e);
+ return false;
+ }
+
+ // Configure
+ conn.setConnectTimeout((int)waitForMillis);
+ conn.setReadTimeout((int)waitForMillis);
+
+ //
+ InputStream in = null;
+ try
+ {
+ conn.connect();
+ in = conn.getInputStream();
+ return true;
+ }
+ catch (SocketTimeoutException e)
+ {
+ return false;
+ }
+ catch (IOException e)
+ {
+ return false;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ /**
+ * to remove : an API should not try to accomodate the client for that kind of situation, why not also something
+ * like forbidStringLengthToDivisibleBy3 ?
+ *
+ * @param stringURL
+ * @param allowNull <code>true</code> if passing <code>null</code> will be ignored and just return
+ * <code>false</code>, <code>false</code> to throw an {@link IllegalArgumentException} is the given
+ * URL is <code>null</code>.
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean exists(String stringURL, boolean allowNull)
+ {
+ if (!allowNull)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(stringURL, "URL", null);
+ }
+
+ try
+ {
+ URL url = new URL(stringURL);
+ return exists(url);
+ }
+ catch (MalformedURLException e)
+ {
+ return false;
+ }
+ }
+
+ public static URLMatch[] extractURLsFrom(String markup)
+ {
+ // todo: will need to re-write without regex after 2.4
+ int length;
+ if (markup != null && (length = markup.length()) != 0)
+ {
+ Matcher matcher = LINK.matcher(markup);
+ int currentIndex = 0;
+ List links = new ArrayList();
+ while (matcher.find(currentIndex) && currentIndex < length)
+ {
+ links.add(new URLMatch(matcher.start(2), matcher.end(2), matcher.group(2)));
+ currentIndex = matcher.end();
+ }
+
+ return (URLMatch[])links.toArray(new URLMatch[0]);
+ }
+ throw new IllegalArgumentException("Cannot extract URLs from a null or empty markup string!");
+ }
+
+ public static int getURLCountIn(String markup)
+ {
+ int length;
+ if (markup != null && (length = markup.length()) != 0)
+ {
+ Matcher matcher = LINK.matcher(markup);
+ int count = 0;
+ int currentIndex = 0;
+ while (matcher.find(currentIndex) && currentIndex < length)
+ {
+ count++;
+ currentIndex = matcher.end();
+ }
+ return count;
+ }
+ return 0;
+ }
+
+ public static String replaceURLsBy(String markup, final String[] replacements)
+ {
+ if (replacements == null || replacements.length == 0)
+ {
+ return markup;
+ }
+
+ int urlCount = getURLCountIn(markup);
+ if (replacements.length != urlCount)
+ {
+ throw new IllegalArgumentException("Trying to replace " + urlCount + " URLs by " + replacements.length + " replacement(s).");
+ }
+
+ return replaceURLsBy(markup, new URLReplacementGenerator()
+ {
+ public String getReplacementFor(int currentIndex, URLMatch currentMatch)
+ {
+ return replacements[currentIndex];
+ }
+ });
+ }
+
+ public static String replaceURLsBy(String markup, URLReplacementGenerator generator)
+ {
+
+ URLMatch[] urls = extractURLsFrom(markup);
+ if (urls.length > 0)
+ {
+ StringBuffer newMarkup = new StringBuffer(markup.length());
+ int currentIndex = 0;
+ for (int i = 0; i < urls.length; i++)
+ {
+ URLMatch url = urls[i];
+ newMarkup.append(markup.substring(currentIndex, url.getStart())).append(generator.getReplacementFor(i, url));
+ currentIndex = url.getEnd();
+ }
+ newMarkup.append(markup.substring(currentIndex));
+ markup = newMarkup.toString();
+ }
+ return markup;
+ }
+
+ public static class URLMatch
+ {
+ private int start;
+ private int end;
+ private String urlAsString;
+
+ private URLMatch(int start, int end, String urlAsString)
+ {
+ this.start = start;
+ this.end = end;
+ this.urlAsString = urlAsString;
+ }
+
+ public int getStart()
+ {
+ return start;
+ }
+
+ public int getEnd()
+ {
+ return end;
+ }
+
+ public String getURLAsString()
+ {
+ return urlAsString;
+ }
+ }
+
+ /** @since 2.4.2 */
+ public abstract static class URLReplacementGenerator
+ {
+ public abstract String getReplacementFor(int currentIndex, URLMatch currentMatch);
+ }
+
+ public static class PortReplacementGenerator extends URLReplacementGenerator
+ {
+ private int replacementPort;
+
+ public PortReplacementGenerator(int replacementPort)
+ {
+ this.replacementPort = replacementPort;
+ }
+
+ public String getReplacementFor(int currentIndex, URLMatch currentMatch)
+ {
+ return replaceServerPortInURL(currentMatch.getURLAsString(), replacementPort);
+ }
+ }
+
+ /**
+ * @param url
+ * @param newPort
+ * @return
+ * @since 2.4.2
+ */
+ public static String replaceServerPortInURL(String url, int newPort)
+ {
+ if (!isNetworkURL(url))
+ {
+ return url;
+ }
+
+ StringBuffer buf = new StringBuffer(url);
+ int afterProtocol = url.indexOf("://") + 3;
+ int beforePort = url.indexOf(':', afterProtocol);
+ int afterPort;
+
+ if (beforePort != -1)
+ {
+ afterPort = url.indexOf('/', beforePort);
+ buf.delete(beforePort + 1, afterPort);
+ buf.insert(beforePort + 1, newPort);
+ }
+ else
+ {
+ // port number was not present
+ afterPort = url.indexOf('/', afterProtocol);
+ buf.insert(afterPort, ":" + newPort);
+ }
+
+ return buf.toString();
+ }
+
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import java.net.URL;
+
+/**
+ * Visitor pattern interface.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public interface URLVisitor
+{
+ /**
+ * Signal the visitor enters a directory.
+ *
+ * @param url the dir URL
+ * @param name the dir name
+ */
+ void startDir(URL url, String name);
+
+ /**
+ * Signals the visitor leavers a directory.
+ *
+ * @param url the dir URL
+ * @param name the dir name
+ */
+ void endDir(URL url, String name);
+
+ /**
+ * Signals the visitor there is a file.
+ *
+ * @param url the file URL
+ * @param name the file name
+ */
+ void file(URL url, String name);
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net.file;
+
+import org.jboss.portal.common.net.URLNavigationProvider;
+import org.jboss.portal.common.net.URLVisitor;
+import org.jboss.portal.common.net.URLFilter;
+import org.apache.log4j.Logger;
+
+import java.util.Arrays;
+import java.net.URL;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7448 $
+ */
+public class FileURLNavigationProvider implements URLNavigationProvider
+{
+
+ /** The logger. */
+ private Logger log = Logger.getLogger(FileURLNavigationProvider.class);
+
+ /** Trace. */
+ private boolean trace = log.isDebugEnabled();
+
+ public void visit(URL url, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException
+ {
+ File file = new File(url.getFile()).getCanonicalFile();
+ visit(file, visitor, filter);
+ }
+
+ private void visit(File file, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException
+ {
+ if (!file.exists())
+ {
+ throw new FileNotFoundException();
+ }
+ else
+ {
+ String name = file.getName();
+ if (file.isDirectory())
+ {
+ if (trace)
+ {
+ log.debug("entering directory" + file.getAbsolutePath());
+ }
+ URL url = file.toURL();
+ boolean visit = filter == null || filter.acceptDir(url);
+ if (visit)
+ {
+ visitor.startDir(url, name);
+ File[] childrenFiles = file.listFiles();
+ Arrays.sort(childrenFiles);
+ for (int i = 0; i < childrenFiles.length; i++)
+ {
+ File childFile = childrenFiles[i];
+ visit(childFile, visitor, filter);
+ }
+ visitor.endDir(file.toURL(), name);
+ if (trace)
+ {
+ log.debug("leaving directory" + file.getAbsolutePath());
+ }
+ }
+ }
+ else
+ {
+ if (trace)
+ {
+ log.debug("visiting file " + file.getAbsolutePath());
+ }
+ URL url = file.toURL();
+ File file2 = new File(url.getFile());
+ if (file.equals(file2) && filter.acceptFile(url))
+ {
+ visitor.file(url, name);
+ }
+ else if (trace)
+ {
+ log.debug("The file does not respect url format");
+ }
+ }
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,293 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net.jar;
+
+import org.jboss.portal.common.net.URLNavigationProvider;
+import org.jboss.portal.common.net.URLVisitor;
+import org.jboss.portal.common.net.URLFilter;
+import org.jboss.portal.common.jar.JarEntryInfo;
+import org.jboss.portal.common.jar.JarInfo;
+
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7448 $
+ */
+public class JarURLNavigationProvider implements URLNavigationProvider
+{
+
+ public void visit(URL url, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("Null URL not accepted");
+ }
+ if (!"jar".equals(url.getProtocol()))
+ {
+ throw new IllegalArgumentException("Only jar URL are accepted, not " + url.getProtocol());
+ }
+ JarURLConnection conn = (JarURLConnection)url.openConnection();
+ visit(conn, visitor, filter);
+ }
+
+ private void visit(JarURLConnection conn, URLVisitor visitor, URLFilter filter) throws IOException
+ {
+ JarFile jarFile = conn.getJarFile();
+ URL jarURL = conn.getJarFileURL();
+ JarEntry rootEntry = conn.getJarEntry();
+
+ // if the URL specifies a directory without a "/" at the end
+ // the entry will be found, except it won't actually exist.
+ // To get around this issue, we need to check if an entry exists
+ // with a "/" at the end.
+ if (rootEntry != null)
+ {
+ JarEntry testDirEntry = conn.getJarFile().getJarEntry(rootEntry + "/");
+ if (testDirEntry != null)
+ {
+ rootEntry = testDirEntry;
+ }
+ }
+ else
+ {
+ // if rootEntry == null then the url points to the root of the jar. The problem
+ // is that the root of the jar doesn't actually exist in the jar.
+ // We need to create a fake jar entry to mimic this behavior
+ rootEntry = new JarEntry("/");
+ }
+
+ // Get the root entry
+ JarEntryInfo rootEntryInfo = new JarEntryInfo(rootEntry);
+
+ // The entries we will browse
+ JarInfo jarInfo = new JarInfo(jarFile);
+
+ boolean enabled = true;
+
+ //
+ Stack stack = new Stack(jarURL, rootEntryInfo);
+ for (Iterator i = jarInfo.entries(); i.hasNext();)
+ {
+ JarEntryInfo entryInfo = (JarEntryInfo)i.next();
+
+ // Only consider descendant of the root or root itself
+ if (entryInfo.equals(rootEntryInfo) || entryInfo.isDescendantOf(rootEntryInfo))
+ {
+ List relPath;
+ // The relative path from the root
+ if (rootEntryInfo.size() > 1){
+ relPath = entryInfo.getNames().subList(rootEntryInfo.size() - 1, entryInfo.size());
+ }
+ else
+ {
+ relPath = entryInfo.getNames();
+ }
+
+ // Enter intermediate dirs
+ while (stack.size() < relPath.size() - 1 && enabled)
+ {
+ String name = (String)relPath.get(stack.size());
+ stack.push(name, true);
+ URL url = stack.getURL();
+ boolean visit = filter == null || filter.acceptDir(url);
+ if (visit)
+ {
+ visitor.startDir(url, name);
+ }
+ else
+ {
+ enabled = false;
+ }
+ }
+
+ // Leave intermediate dirs
+ while (stack.size() > relPath.size() - 1)
+ {
+ URL url = stack.getURL();
+ Stack.Entry entry = stack.pop();
+ if (enabled)
+ {
+ String name = entry.name;
+ visitor.endDir(url, name);
+ }
+ enabled = true;
+ }
+
+ //
+ if (enabled)
+ {
+ if (entryInfo.isDirectory())
+ {
+ String name = (String)relPath.get(relPath.size() - 1);
+ stack.push(name, true);
+ URL url = stack.getURL();
+ boolean visit = filter == null || filter.acceptDir(url);
+ if (visit)
+ {
+ visitor.startDir(url, name);
+ }
+ else
+ {
+ enabled = false;
+ }
+ }
+ else
+ {
+ String name = (String)relPath.get(relPath.size() - 1);
+ stack.push(name, false);
+ URL url = stack.getURL();
+ if (filter.acceptFile(url))
+ {
+ visitor.file(url, name);
+ }
+ stack.pop();
+ }
+ }
+ }
+ }
+
+ //
+ while (stack.size() > 0)
+ {
+ URL url = stack.getURL();
+ Stack.Entry entry = stack.pop();
+ if (enabled)
+ {
+ String name = entry.name;
+ visitor.endDir(url, name);
+ }
+ enabled = true;
+ }
+ }
+
+ private static class Stack
+ {
+
+ // The jar URL
+ final URL jarURL;
+
+ // The root entry
+ final JarEntryInfo root;
+
+ // The list of names relative to the root entry
+ final LinkedList entries;
+
+ //
+ boolean enabled;
+
+ public Stack(URL jarURL, JarEntryInfo root)
+ {
+ this.jarURL = jarURL;
+ this.root = root;
+ this.entries = new LinkedList();
+ }
+
+ int size()
+ {
+ return entries.size();
+ }
+
+ void push(String name, boolean dir)
+ {
+ entries.addLast(new Entry(name, dir));
+ }
+
+ Entry pop()
+ {
+ return (Entry)entries.removeLast();
+ }
+
+ Entry peek()
+ {
+ return (Entry)entries.getLast();
+ }
+
+ /**
+ * Generate the full URL for the current entry.
+ *
+ * @return
+ * @throws MalformedURLException
+ */
+ URL getURL() throws MalformedURLException
+ {
+ StringBuffer tmp = new StringBuffer(jarURL.toString()).append("!/");
+ for (int i = 0; i < root.size() - 1; i++)
+ {
+ String name = root.getName(i);
+ if (!tmp.toString().endsWith("/"))
+ {
+ tmp.append("/");
+ }
+ // we don't want to add an extra '/' if the actual jar root element
+ if (!name.equals("/"))
+ {
+ tmp.append(name);
+ }
+ }
+ for (int i = 0; i < entries.size(); i++)
+ {
+ Entry entry = (Entry)entries.get(i);
+ String name = entry.name;
+ if (!tmp.toString().endsWith("/"))
+ {
+ tmp.append("/");
+ }
+ if (!name.equals("/"))
+ {
+ tmp.append(name);
+ }
+
+ }
+ Entry entry = peek();
+ if (entry.dir && !entry.name.equals("/") && !(tmp.toString().endsWith("/")))
+ {
+ tmp.append('/');
+ }
+ return new URL("jar", "", tmp.toString());
+ }
+
+ static class Entry
+ {
+ /** The entry name. */
+ final String name;
+
+ /** Whether the name represents a dir or not. */
+ final boolean dir;
+
+ public Entry(String name, boolean dir)
+ {
+ this.name = name;
+ this.dir = dir;
+ }
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,243 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.p3p;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 5451 $
+ */
+public final class P3PConstants
+{
+ public enum TelecomType
+ {
+ TELEPHONE(TELECOM_TELEPHONE),
+ FAX(TELECOM_FAX),
+ MOBILE(TELECOM_MOBILE),
+ PAGER(TELECOM_PAGER);
+
+ private final String prefix;
+
+ TelecomType(String prefix)
+ {
+ this.prefix = prefix;
+ }
+
+ public String getPrefix()
+ {
+ return prefix;
+ }
+ }
+
+ public enum TelecomInfo
+ {
+ INTCODE(TELECOM_INTCODE),
+ LOCCODE(TELECOM_LOCCODE),
+ NUMBER(TELECOM_NUMBER),
+ EXT(TELECOM_EXT),
+ COMMENT(TELECOM_COMMENT);
+
+ private final String name;
+
+ TelecomInfo(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+
+ public enum PostalInfo
+ {
+ NAME(POSTAL_NAME),
+ STREET(POSTAL_STREET),
+ CITY(POSTAL_CITY),
+ STATEPROV(POSTAL_STATEPROV),
+ POSTALCODE(POSTAL_POSTALCODE),
+ COUNTRY(POSTAL_COUNTRY),
+ ORGANIZATION(POSTAL_ORGANIZATION);
+
+ private final String name;
+
+ PostalInfo(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+
+ public enum OnlineInfo
+ {
+ EMAIL(ONLINE_EMAIL),
+ URI(ONLINE_URI);
+
+ private final String name;
+
+ OnlineInfo(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+
+
+ // Postal
+ private static final String POSTAL_NAME = "postal.name";
+ private static final String POSTAL_STREET = "postal.street";
+ private static final String POSTAL_CITY = "postal.city";
+ private static final String POSTAL_STATEPROV = "postal.stateprov";
+ private static final String POSTAL_POSTALCODE = "postal.postalcode";
+ private static final String POSTAL_COUNTRY = "postal.country";
+ private static final String POSTAL_ORGANIZATION = "postal.organization";
+
+ // Telecom
+ private static final String TELECOM_TELEPHONE = "telecom.telephone.";
+ private static final String TELECOM_FAX = "telecom.fax.";
+ private static final String TELECOM_MOBILE = "telecom.mobile.";
+ private static final String TELECOM_PAGER = "telecom.pager.";
+ private static final String TELECOM_INTCODE = "intcode";
+ private static final String TELECOM_LOCCODE = "loccode";
+ private static final String TELECOM_NUMBER = "number";
+ private static final String TELECOM_EXT = "ext";
+ private static final String TELECOM_COMMENT = "comment";
+
+ // Online
+ private static final String ONLINE_URI = "online.uri";
+ private static final String ONLINE_EMAIL = "online.email";
+
+ /*
+ * User information attribute names (PLT.D in the portlet spec) that are defined in P3P spec.
+ */
+
+ //
+ public static final String INFO_USER_BDATE = "user.bdate";
+ public static final String INFO_USER_GENDER = "user.gender";
+ public static final String INFO_USER_EMPLOYER = "user.employer";
+ public static final String INFO_USER_DEPARTMENT = "user.department";
+ public static final String INFO_USER_JOB_TITLE = "user.jobtitle";
+ public static final String INFO_USER_NAME_PREFIX = "user.name.prefix";
+ public static final String INFO_USER_NAME_GIVEN = "user.name.given";
+ public static final String INFO_USER_NAME_FAMILY = "user.name.family";
+ public static final String INFO_USER_NAME_MIDDLE = "user.name.middle";
+ public static final String INFO_USER_NAME_SUFFIX = "user.name.suffix";
+ public static final String INFO_USER_NAME_NICKNAME = "user.name.nickName";
+
+ // User home
+ private static final String INFO_USER_HOME_PREFIX = "user.home-info.";
+ public static final String INFO_USER_HOME_INFO_POSTAL_NAME = INFO_USER_HOME_PREFIX + POSTAL_NAME;
+ public static final String INFO_USER_HOME_INFO_POSTAL_STREET = INFO_USER_HOME_PREFIX + POSTAL_STREET;
+ public static final String INFO_USER_HOME_INFO_POSTAL_CITY = INFO_USER_HOME_PREFIX + POSTAL_CITY;
+ public static final String INFO_USER_HOME_INFO_POSTAL_STATEPROV = INFO_USER_HOME_PREFIX + POSTAL_STATEPROV;
+ public static final String INFO_USER_HOME_INFO_POSTAL_POSTALCODE = INFO_USER_HOME_PREFIX + POSTAL_POSTALCODE;
+ public static final String INFO_USER_HOME_INFO_POSTAL_COUNTRY = INFO_USER_HOME_PREFIX + POSTAL_COUNTRY;
+ public static final String INFO_USER_HOME_INFO_POSTAL_ORGANIZATION = INFO_USER_HOME_PREFIX + POSTAL_ORGANIZATION;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_INTCODE = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_INTCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_LOCCODE = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_LOCCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_NUMBER = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_NUMBER;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_EXT = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_EXT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_COMMENT = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_COMMENT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_INTCODE = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_INTCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_LOCCODE = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_LOCCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_NUMBER = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_NUMBER;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_EXT = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_EXT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_COMMENT = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_COMMENT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_INTCODE = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_INTCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_LOCCODE = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_LOCCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_NUMBER = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_NUMBER;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_EXT = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_EXT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_COMMENT = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_COMMENT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_INTCODE = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_INTCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_LOCCODE = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_LOCCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_NUMBER = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_NUMBER;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_EXT = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_EXT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_COMMENT = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_COMMENT;
+ public static final String INFO_USER_HOME_INFO_ONLINE_EMAIL = INFO_USER_HOME_PREFIX + ONLINE_EMAIL;
+ public static final String INFO_USER_HOME_INFO_ONLINE_URI = INFO_USER_HOME_PREFIX + ONLINE_URI;
+
+ // User Business
+ private static final String INFO_USER_BUSINESS_PREFIX = "user.business-info.";
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_NAME = INFO_USER_BUSINESS_PREFIX + POSTAL_NAME;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_STREET = INFO_USER_BUSINESS_PREFIX + POSTAL_STREET;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_CITY = INFO_USER_BUSINESS_PREFIX + POSTAL_CITY;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_STATEPROV = INFO_USER_BUSINESS_PREFIX + POSTAL_STATEPROV;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_POSTALCODE = INFO_USER_BUSINESS_PREFIX + POSTAL_POSTALCODE;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_COUNTRY = INFO_USER_BUSINESS_PREFIX + POSTAL_COUNTRY;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_ORGANIZATION = INFO_USER_BUSINESS_PREFIX + POSTAL_ORGANIZATION;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_INTCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_INTCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_LOCCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_LOCCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_NUMBER = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_NUMBER;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_EXT = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_EXT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_COMMENT = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_COMMENT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_INTCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_INTCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_LOCCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_LOCCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_NUMBER = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_NUMBER;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_EXT = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_EXT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_COMMENT = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_COMMENT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_INTCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_INTCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_LOCCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_LOCCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_NUMBER;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_EXT = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_EXT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_COMMENT = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_COMMENT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_INTCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_INTCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_LOCCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_LOCCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_NUMBER = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_NUMBER;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_EXT = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_EXT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_COMMENT = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_COMMENT;
+ public static final String INFO_USER_BUSINESS_INFO_ONLINE_EMAIL = INFO_USER_BUSINESS_PREFIX + ONLINE_EMAIL;
+ public static final String INFO_USER_BUSINESS_INFO_ONLINE_URI = INFO_USER_BUSINESS_PREFIX + ONLINE_URI;
+
+ private P3PConstants()
+ {
+ }
+
+ private static String getHomeOrBusinessPrefix(boolean isBusiness)
+ {
+ return isBusiness ? P3PConstants.INFO_USER_BUSINESS_PREFIX : P3PConstants.INFO_USER_HOME_PREFIX;
+ }
+
+ public static String getPostalUserInfoKey(PostalInfo info, boolean isBusiness)
+ {
+ return getHomeOrBusinessPrefix(isBusiness) + info.getName();
+ }
+
+ public static String getTelecomInfoKey(TelecomType type, TelecomInfo info, boolean isBusiness)
+ {
+ return getHomeOrBusinessPrefix(isBusiness) + type.getPrefix() + info.getName();
+ }
+
+ public static String getOnlineUserInfoKey(OnlineInfo info, boolean isBusiness)
+ {
+ return getHomeOrBusinessPrefix(isBusiness) + info.getName();
+ }
+}
\ No newline at end of file
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * Map request uri path to portal object.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public interface PathMapper
+{
+
+ /**
+ * Map a path to a result.
+ *
+ * @param pathMapperContext the context of the mapping
+ * @param path the path to map
+ * @return returns a path mapper result
+ */
+ public PathMapperResult map(PathMapperContext pathMapperContext, String path);
+
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * Interface that provide access to objects that are mapped to pathes.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public interface PathMapperContext
+{
+ /**
+ * Returns the object graph root.
+ *
+ * @return the root object
+ */
+ Object getRoot();
+
+ /**
+ * Return the child object having the specified name or null if it does not exists.
+ *
+ * @return the child of the parent object matching the specifed name
+ */
+ Object getChild(Object parent, String name);
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * The result of a request to a mapper.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class PathMapperResult
+{
+
+ /** . */
+ private final Object target;
+
+ /** . */
+ private final String targetPath;
+
+ /** . */
+ private final String targetPathInfo;
+
+ public PathMapperResult(Object target, String targetPath, String targetPathInfo)
+ {
+ this.target = target;
+ this.targetPath = targetPath;
+ this.targetPathInfo = targetPathInfo;
+ }
+
+ public Object getTarget()
+ {
+ return target;
+ }
+
+ public String getTargetPathInfo()
+ {
+ return targetPathInfo;
+ }
+
+ public int hashCode()
+ {
+ int hashCode = (target != null ? target.hashCode() : 0) +
+ (targetPath != null ? targetPath.hashCode() : 0) +
+ (targetPathInfo != null ? targetPathInfo.hashCode() : 0);
+ return hashCode;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof PathMapperResult)
+ {
+ PathMapperResult other = (PathMapperResult)obj;
+ return (target == null ? (other.target == null) : target.equals(other.target)) &&
+ (targetPath == null ? (other.targetPath == null) : targetPath.equals(other.targetPath)) &&
+ (targetPathInfo == null ? (other.targetPathInfo == null) : targetPathInfo.equals(other.targetPathInfo));
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer("MappingResult[");
+ buffer.append(target == null ? "-" : target.toString());
+ buffer.append(',');
+ buffer.append(targetPath == null ? "-" : targetPath);
+ buffer.append(',');
+ buffer.append(targetPathInfo == null ? "-" : targetPathInfo);
+ buffer.append("]");
+ return buffer.toString();
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,202 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * Utility class to pull parse a relative path.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class RelativePathParser
+{
+
+ // Constants ********************************************************************************************************
+
+ private static final int STATE_BEGIN = 0;
+ private static final int STATE_DOT = 1;
+ private static final int STATE_DOT_DOT = 2;
+ private static final int STATE_CHAR = 3;
+
+ /**
+ * The parser has reached the end of the stream. The values returned by <code>getOffset()</code> and
+ * <code>getLength()</code> is undertermined.
+ */
+ public static final int NONE = 0;
+
+ /**
+ * The recognized token is up. The values returned by <code>getOffset()</code> and
+ * <code>getLength()</code> is undertermined.
+ */
+ public static final int UP = 1;
+
+ /**
+ * The recognized token is down. The values returned by <code>getOffset()</code> and
+ * <code>getLength()</code> determine the token string value.
+ */
+ public static final int DOWN = 2;
+
+ // Variables ********************************************************************************************************
+
+ /**
+ * The path being parsed.
+ */
+ private final String path;
+
+ /**
+ * The current index of parsing.
+ */
+ private int current;
+
+ /**
+ * The current internal offset.
+ */
+ private int previous;
+
+ /**
+ * The offset value when a down token is recognized.
+ */
+ private int offset;
+
+ /**
+ * The length value when a down token is recognized.
+ */
+ private int length;
+
+ public RelativePathParser(String path)
+ {
+ if (path == null)
+ {
+ throw new IllegalArgumentException("No path");
+ }
+ this.path = path;
+ this.previous = 0;
+ this.current = 0;
+ }
+
+ /**
+ * Read the next token available.
+ *
+ * @return the token type recognized which can be NONE, UP or DOWN.
+ */
+ public int next()
+ {
+ //
+ previous = current;
+ int state = STATE_BEGIN;
+
+ //
+ while (current < path.length())
+ {
+ char c = path.charAt(current++);
+ switch (c)
+ {
+ case '.':
+ {
+ switch (state)
+ {
+ case STATE_BEGIN:
+ state = STATE_DOT;
+ break;
+ case STATE_DOT:
+ state = STATE_DOT_DOT;
+ break;
+ case STATE_CHAR:
+ break;
+ default:
+ case STATE_DOT_DOT:
+ throw new IllegalArgumentException();
+ }
+ break;
+ }
+ case '/':
+ {
+ switch (state)
+ {
+ default:
+ case STATE_BEGIN:
+ throw new IllegalStateException("");
+ case STATE_DOT:
+ previous = current;
+ state = STATE_BEGIN;
+ break;
+ case STATE_DOT_DOT:
+ length = -1;
+ offset = -1;
+ return UP;
+ case STATE_CHAR:
+ length = current - previous - 1;
+ offset = previous;
+ return DOWN;
+ }
+ break;
+ }
+ default:
+ {
+ switch (state)
+ {
+ case STATE_BEGIN:
+ state = STATE_CHAR;
+ break;
+ case STATE_CHAR:
+ break;
+ case STATE_DOT:
+ case STATE_DOT_DOT:
+ default:
+ throw new IllegalStateException("");
+ }
+ }
+ }
+ }
+
+ //
+ switch (state)
+ {
+ case STATE_DOT:
+ case STATE_BEGIN:
+ length = -1;
+ offset = -1;
+ return NONE;
+ case STATE_CHAR:
+ offset = previous;
+ length = current - previous;
+ return DOWN;
+ case STATE_DOT_DOT:
+ length = -1;
+ offset = -1;
+ return UP;
+ default:
+ throw new IllegalStateException("");
+ }
+ }
+
+ public int getOffset()
+ {
+ return offset;
+ }
+
+ public int getLength()
+ {
+ return length;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * A simple mapper implementation. The limitations is that only the root and its children can have children
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class SimplePathMapper implements PathMapper
+{
+ public PathMapperResult map(PathMapperContext ctx, String path)
+ {
+ Object root = ctx.getRoot();
+ Object target = null;
+ String targetPath = null;
+ String targetPathInfo = null;
+
+ if (path == null || path.length() == 0)
+ {
+ targetPath = null;
+ targetPathInfo = null;
+ }
+ else if ("/".equals(path))
+ {
+ targetPath = null;
+ targetPathInfo = "/";
+ }
+ else
+ {
+ int firstSlashPos = path.indexOf('/', 1);
+ if (firstSlashPos == -1)
+ {
+ String firstChunk = path.substring(1);
+ target = ctx.getChild(root, firstChunk);
+ if (target != null)
+ {
+ targetPath = path;
+ targetPathInfo = null;
+ }
+ else
+ {
+ targetPath = null;
+ targetPathInfo = path;
+ }
+ }
+ else if (firstSlashPos == 1)
+ {
+ targetPath = null;
+ targetPathInfo = "/";
+ }
+ else
+ {
+ String firstChunk = path.substring(1, firstSlashPos);
+ target = ctx.getChild(root, firstChunk);
+ if (target != null)
+ {
+ int secondSlashPos = path.indexOf('/', firstSlashPos + 1);
+ if (secondSlashPos == -1)
+ {
+ String secondChunck = path.substring(firstSlashPos + 1);
+ if (secondChunck.length() == 0)
+ {
+ targetPath = "/" + firstChunk;
+ targetPathInfo = "/";
+ }
+ else
+ {
+ Object child = ctx.getChild(target, secondChunck);
+ if (child != null)
+ {
+ target = child;
+ targetPath = path;
+ targetPathInfo = null;
+ }
+ else
+ {
+ targetPath = "/" + firstChunk;
+ targetPathInfo = "/" + secondChunck;
+ }
+ }
+ }
+ else
+ {
+ targetPath = "/" + firstChunk;
+ targetPathInfo = path.substring(firstSlashPos);
+ }
+ }
+ else
+ {
+ targetPath = null;
+ targetPathInfo = path;
+ }
+ }
+ }
+ return new PathMapperResult(target, targetPath, targetPathInfo);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/reflect/Modifier.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/reflect/Modifier.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/reflect/Modifier.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.reflect;
+
+import java.lang.reflect.Field;
+
+/**
+ * Extends the java Modifier object in order to add more utility methods.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Modifier extends java.lang.reflect.Modifier
+{
+
+ /**
+ * Return true if the field is considered as a readable property which means that it is public and non static.
+ *
+ * @param f the field to test
+ * @return true if the field is a readable property
+ * @throws IllegalArgumentException if the field argument is null
+ */
+ public static boolean isReadableProperty(Field f) throws IllegalArgumentException
+ {
+ if (f == null)
+ {
+ throw new IllegalArgumentException("No field provided");
+ }
+
+ //
+ int modifiers = f.getModifiers();
+ return (modifiers & STATIC) == 0 && (modifiers & PUBLIC) != 0;
+ }
+
+ /**
+ * Return true if the field is considered as a writable property which means that it is public, non static and non
+ * final.
+ *
+ * @param f the field to test
+ * @return true if the field is a writable property
+ * @throws IllegalArgumentException if the field argument is null
+ */
+ public static boolean isWritableProperty(Field f)
+ {
+ if (f == null)
+ {
+ throw new IllegalArgumentException("No field provided");
+ }
+
+ //
+ int modifiers = f.getModifiers();
+ return (modifiers & (STATIC | FINAL)) == 0 && (modifiers & PUBLIC) != 0;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/reflect/Reflection.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/reflect/Reflection.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/reflect/Reflection.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.reflect;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Reflection
+{
+
+ /**
+ * Search a method on the specified class. The search will try find methods with any scope and will
+ * start with the provided class. First it will inspect the public method on the class, if one is found
+ * then this method is returned. If no public method is found then it will inspect the declared methods
+ * of the provided class and its super classes.
+ *
+ * @param clazz the class to inspect
+ * @param methodName the method name
+ * @param parameterTypes the parameter types
+ * @return the matched method or null
+ * @throws IllegalArgumentException if one argument is null
+ */
+ public static Method findMethod(
+ Class clazz,
+ String methodName,
+ Class[] parameterTypes) throws IllegalArgumentException
+ {
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException("No class provided");
+ }
+ if (methodName == null)
+ {
+ throw new IllegalArgumentException("No method name provided");
+ }
+ if (parameterTypes == null)
+ {
+ throw new IllegalArgumentException("No parameter types provided");
+ }
+ for (int i = 0; i < parameterTypes.length; i++)
+ {
+ if (parameterTypes[i] == null)
+ {
+ throw new IllegalArgumentException("Null parameter type at element=" + i);
+ }
+ }
+
+ // First try a public method, which could be an implemented from an interface
+ try
+ {
+ return clazz.getMethod(methodName, parameterTypes);
+ }
+ catch (NoSuchMethodException ignore)
+ {
+ }
+
+ //
+ return findDeclaredMethod(clazz, methodName, parameterTypes);
+ }
+
+ /**
+ * Search a declared method on the specified class and its super classes.
+ *
+ * @param clazz the class to inspect
+ * @param methodName the method name
+ * @param parameterTypes the parameter types
+ * @return the matched method or null
+ * @throws IllegalArgumentException if one argument is null
+ */
+ private static Method findDeclaredMethod(
+ Class clazz,
+ String methodName,
+ Class[] parameterTypes) throws IllegalArgumentException
+ {
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException("No class provided");
+ }
+ if (methodName == null)
+ {
+ throw new IllegalArgumentException("No method name provided");
+ }
+ if (parameterTypes == null)
+ {
+ throw new IllegalArgumentException("No parameter types provided");
+ }
+ for (int i = 0; i < parameterTypes.length; i++)
+ {
+ if (parameterTypes[i] == null)
+ {
+ throw new IllegalArgumentException("Null parameter type at element=" + i);
+ }
+ }
+
+ //
+ try
+ {
+ return clazz.getDeclaredMethod(methodName, parameterTypes);
+ }
+ catch (NoSuchMethodException ignore)
+ {
+ }
+
+ //
+ Class parentClass = clazz.getSuperclass();
+ if (parentClass != null)
+ {
+ Method method = findDeclaredMethod(parentClass, methodName, parameterTypes);
+ if (method != null)
+ {
+ return method;
+ }
+ }
+
+ // Nothing found
+ return null;
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingRequestWrapper.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingRequestWrapper.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingRequestWrapper.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.servlet;
+
+import org.jboss.portal.common.util.Tools;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper around a HTTPServletRequest to add attributes without affecting the actual request.
+ *
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 7228 $
+ */
+public class BufferingRequestWrapper extends HttpServletRequestWrapper
+{
+
+ /** . */
+ private static final Object REMOVED_ATTRIBUTE = new Object();
+
+ /** . */
+ private Map attributes;
+
+ /** . */
+ private Locale[] locales;
+
+ /** . */
+ private String contextPath;
+
+ public BufferingRequestWrapper(HttpServletRequest servletRequest, String contextPath, Locale[] locales)
+ {
+ super(servletRequest);
+
+ //
+ this.contextPath = contextPath;
+ this.locales = locales;
+ this.attributes = new HashMap();
+ }
+
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+
+ public Locale getLocale()
+ {
+ return locales.length > 0 ? locales[0] : null;
+ }
+
+ public Enumeration getLocales()
+ {
+ return Tools.toEnumeration(locales);
+ }
+
+ public String getMethod()
+ {
+ return "GET";
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ if (value == null)
+ {
+ value = REMOVED_ATTRIBUTE;
+ }
+
+ //
+ attributes.put(name, value);
+ }
+
+ public Object getAttribute(String name)
+ {
+ Object value = attributes.get(name);
+
+ //
+ if (value == REMOVED_ATTRIBUTE)
+ {
+ value = null;
+ }
+ else if (value == null)
+ {
+ value = getRequest().getAttribute(name);
+ }
+
+ //
+ return value;
+ }
+
+ public void removeAttribute(String name)
+ {
+ setAttribute(name, null);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ Set names = new HashSet();
+
+ //
+ for (Enumeration e = getRequest().getAttributeNames(); e.hasMoreElements();)
+ {
+ names.add(e.nextElement());
+ }
+
+ //
+ for (Iterator i = attributes.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ Object value = entry.getValue();
+ if (value == REMOVED_ATTRIBUTE)
+ {
+ names.remove(name);
+ }
+ else
+ {
+ names.add(name);
+ }
+ }
+
+ //
+ return Tools.toEnumeration(names.iterator());
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingResponseWrapper.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingResponseWrapper.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingResponseWrapper.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,225 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.servlet;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Locale;
+
+/**
+ * Redirection of the Writer
+ *
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 7228 $
+ */
+public class BufferingResponseWrapper extends HttpServletResponseWrapper
+{
+
+ /** . */
+ private ServletOutputStreamBuffer outputStream;
+
+ /** . */
+ private PrintWriter writer;
+
+ /** . */
+ private StringWriter chars;
+
+ /** . */
+ private String characterEncoding;
+
+ /** Not really used but we need it to memorize what the client set optionally. */
+ protected int bufferSize;
+
+ public BufferingResponseWrapper(HttpServletResponse response)
+ {
+ super(response);
+
+ // By default inherit the character encoding of the wrapped response
+ this.characterEncoding = response.getCharacterEncoding();
+
+ // 0 means no buffering - we say no buffering
+ this.bufferSize = 0;
+ }
+
+ public String getContent()
+ {
+ if (outputStream != null)
+ {
+ try
+ {
+ outputStream.flush();
+ return outputStream.getContent(characterEncoding);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+ else if (chars != null)
+ {
+ writer.flush();
+ return chars.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void addCookie(Cookie arg0)
+ {
+ }
+
+ public void addDateHeader(String arg0, long arg1)
+ {
+ }
+
+ public void addHeader(String arg0, String arg1)
+ {
+ }
+
+ public void addIntHeader(String arg0, int arg1)
+ {
+ }
+
+ public void sendError(int arg0) throws IOException
+ {
+ }
+
+ public void sendError(int arg0, String arg1) throws IOException
+ {
+ }
+
+ public void sendRedirect(String arg0) throws IOException
+ {
+ }
+
+ public void setDateHeader(String arg0, long arg1)
+ {
+ }
+
+ public void setHeader(String arg0, String arg1)
+ {
+ }
+
+ public void setIntHeader(String arg0, int arg1)
+ {
+ }
+
+ public void setStatus(int arg0)
+ {
+ }
+
+ public void setStatus(int arg0, String arg1)
+ {
+ }
+
+ public int getBufferSize()
+ {
+ return bufferSize;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return characterEncoding;
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ if (writer != null)
+ {
+ throw new IllegalStateException("Already obtained a PrintWriter");
+ }
+ if (outputStream == null)
+ {
+ outputStream = new ServletOutputStreamBuffer(500);
+ }
+ return outputStream;
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ if (outputStream != null)
+ {
+ throw new IllegalStateException("Already obtained a ServletOutputStream");
+ }
+ if (writer == null)
+ {
+ chars = new StringWriter();
+ writer = new PrintWriter(chars, false);
+ }
+ return writer;
+ }
+
+ public boolean isCommitted()
+ {
+ return false;
+ }
+
+ public void reset()
+ {
+ resetBuffer();
+ }
+
+ public void resetBuffer()
+ {
+ if (outputStream != null)
+ {
+ outputStream.reset();
+ }
+ else if (chars != null)
+ {
+ writer.flush();
+ chars.getBuffer().setLength(0);
+ }
+ }
+
+ public void setBufferSize(int bufferSize)
+ {
+ this.bufferSize = bufferSize;
+ }
+
+ public void setCharacterEncoding(String characterEncoding)
+ {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public void setContentLength(int arg0)
+ {
+ }
+
+ public void setContentType(String arg0)
+ {
+ }
+
+ public void setLocale(Locale arg0)
+ {
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.servlet;
+
+import javax.servlet.ServletOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ServletOutputStreamBuffer extends ServletOutputStream
+{
+
+ /** . */
+ private ByteArrayOutputStream buffer;
+
+ public ServletOutputStreamBuffer(int size)
+ {
+ buffer = new ByteArrayOutputStream(size);
+ }
+
+ public void write(int value) throws IOException
+ {
+ buffer.write(value);
+ }
+
+ public String getContent(String encoding) throws IOException
+ {
+ buffer.flush();
+
+ //
+ return buffer.toString(encoding);
+ }
+
+ public byte[] getBinaryContent() throws IOException
+ {
+ buffer.flush();
+
+ //
+ return buffer.toByteArray();
+ }
+
+ public void reset()
+ {
+ buffer.reset();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractCharEncoder implements CharEncoder
+{
+
+ public void encode(char[] chars, int off, int len, CharWriter writer) throws EncodingException
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off + len > chars.length)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ safeEncode(chars, off, len, writer);
+ }
+
+ public void encode(char[] chars, CharWriter writer) throws EncodingException
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ safeEncode(chars, writer);
+ }
+
+ public void encode(CharSequence s, CharWriter writer) throws EncodingException
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ safeEncode(s, writer);
+ }
+
+ public void encode(char c, CharWriter writer) throws EncodingException
+ {
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ safeEncode(c, writer);
+ }
+
+ protected void safeEncode(char[] chars, int off, int len, CharWriter writer) throws EncodingException
+ {
+ for (int i = off;i < len;i++)
+ {
+ safeEncode(chars[i], writer);
+ }
+ }
+
+ protected void safeEncode(char[] chars, CharWriter writer) throws EncodingException
+ {
+ safeEncode(chars, 0, chars.length, writer);
+ }
+
+ protected void safeEncode(CharSequence s, CharWriter writer) throws EncodingException
+ {
+ for (int i = 0;i < s.length();i++)
+ {
+ safeEncode(s.charAt(i), writer);
+ }
+ }
+
+ protected abstract void safeEncode(char c, CharWriter writer) throws EncodingException;
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,234 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * A simple char buffer that implements the <code>CharWriter</code> interface
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class CharBuffer implements CharWriter
+{
+
+ /** . */
+ protected char[] buffer;
+
+ /** . */
+ protected int length;
+
+ /**
+ *
+ * @param size the initial size
+ * @throws IllegalArgumentException if the initial size is not a positive value.
+ */
+ public CharBuffer(int size) throws IllegalArgumentException
+ {
+ if (size < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.buffer = new char[size];
+ this.length = 0;
+ }
+
+ public CharBuffer()
+ {
+ this.buffer = new char[512];
+ this.length = 0;
+ }
+
+ public CharBuffer append(String s, CharEncoder encoder)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (encoder == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ encoder.encode(s, this);
+ return this;
+ }
+
+ public CharWriter append(CharSequence s)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ appendNoCheck(s);
+ return this;
+ }
+
+ public CharWriter append(char[] chars, int off, int len)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off + len > chars.length)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ appendNoCheck(chars, off, len);
+
+ //
+ return this;
+ }
+
+
+ public CharWriter append(char c)
+ {
+ ensureCapacity(length + 1);
+
+ //
+ buffer[length++] = c;
+
+ //
+ return this;
+ }
+
+ public CharWriter append(char[] chars)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ appendNoCheck(chars, 0, chars.length);
+
+ //
+ return this;
+ }
+
+ public String asString()
+ {
+ return asString(true);
+ }
+
+ public String asString(boolean reset)
+ {
+ String s = new String(buffer, 0, length);
+ if (reset)
+ {
+ reset();
+ }
+ return s;
+ }
+
+ public int getCapacity()
+ {
+ return buffer.length;
+ }
+
+ public int getLength()
+ {
+ return length;
+ }
+
+ public void setLength(int length)
+ {
+ if (length < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.length = length;
+
+ //
+ if (length > buffer.length)
+ {
+ char[] tmp = new char[length];
+ System.arraycopy(buffer, 0, tmp, 0, buffer.length);
+ buffer = tmp;
+ }
+ }
+
+ public void reset()
+ {
+ this.length = 0;
+ }
+
+ protected final void appendNoCheck(char[] chars, int off, int len)
+ {
+ ensureCapacity(length + len);
+ if (len < 10)
+ {
+ while (off < len)
+ {
+ buffer[length++] = chars[off++];
+ }
+ }
+ else
+ {
+ System.arraycopy(chars, off, buffer, length, len);
+ length += len;
+ }
+ }
+
+ protected final void appendNoCheck(CharSequence s)
+ {
+ ensureCapacity(length + s.length());
+
+ //
+ if (s instanceof String)
+ {
+ ((String)s).getChars(0, s.length(), buffer, length);
+ length += s.length();
+ }
+ else
+ {
+ for (int i = 0;i < s.length();i++)
+ {
+ char c = s.charAt(i);
+ buffer[length++] = c;
+ }
+ }
+ }
+
+ protected final void ensureCapacity(int minimumCapacity)
+ {
+ int capacity = buffer.length;
+ if (capacity < minimumCapacity)
+ {
+ while (capacity < minimumCapacity)
+ {
+ capacity = capacity * 2 + 1;
+ }
+ char[] tmp = new char[capacity];
+ System.arraycopy(buffer, 0, tmp, 0, length);
+ buffer = tmp;
+ }
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * Defines an interface for encoding chars.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CharEncoder
+{
+ /**
+ *
+ * @param c the char to encode
+ * @param writer the writer to use
+ * @throws IllegalArgumentException if any argument is null
+ * @throws EncodingException an encoding exception
+ */
+ void encode(char c, CharWriter writer) throws IllegalArgumentException, EncodingException;
+
+ /**
+ *
+ * @param chars the chars to encode
+ * @param off the offset in the char array
+ * @param len the lenght of chars to encode
+ * @param writer the writer to use
+ * @throws IllegalArgumentException if any argument is null or if the bounds not valid in the provided array
+ * @throws EncodingException an encoding exception
+ */
+ void encode(char[] chars, int off, int len, CharWriter writer) throws IllegalArgumentException, EncodingException;
+
+ /**
+ *
+ * @param chars the chars to encode
+ * @param writer the writer to use
+ * @throws IllegalArgumentException if any argument is null
+ * @throws EncodingException an encoding exception
+ */
+ void encode(char[] chars, CharWriter writer) throws IllegalArgumentException, EncodingException;
+
+ /**
+ *
+ * @param s the sequence to encode
+ * @param writer the writer to use
+ * @throws IllegalArgumentException if any argument is null
+ * @throws EncodingException an encoding exception
+ */
+ void encode(CharSequence s, CharWriter writer) throws IllegalArgumentException, EncodingException;
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharToByteEncoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharToByteEncoder.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharToByteEncoder.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.Charset;
+import java.nio.CharBuffer;
+import java.nio.ByteBuffer;
+
+/**
+ * Defines an interface for encoding a char to a sequence of bytes.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CharToByteEncoder
+{
+
+ /**
+ * Encode the specified char. The returned byte array can be used safely until a new invocation to the same
+ * object is done. If the returned array has a length of zero it means that the char cannot be encoded.
+ *
+ * @param c the char to encode
+ * @return the encoded char as a byte array
+ * @throws EncodingException
+ */
+ byte[] encode(char c) throws EncodingException;
+
+ /** . */
+ final byte[] EMPTY = new byte[0];
+
+ /**
+ * Generic implementation that works for any charset, based on NIO.
+ */
+ public static class Generic implements CharToByteEncoder
+ {
+
+ /** . */
+ public static final Generic UTF8 = new Generic("UTF8");
+
+ /** . */
+ private final CharsetEncoder encoder;
+
+ /** . */
+ private final java.nio.CharBuffer in;
+
+ /** . */
+ private final ByteBuffer out;
+
+ /** . */
+ private final byte[][] arrays = {new byte[0],new byte[1],new byte[2],new byte[3],new byte[4], new byte[5]};
+
+ public Generic(Charset charset)
+ {
+ encoder = charset.newEncoder();
+ in = CharBuffer.allocate(1);
+ out = ByteBuffer.allocate(100);
+ }
+
+ public Generic(String encoding)
+ {
+ this(Charset.forName(encoding));
+ }
+
+ public byte[] encode(char c) throws EncodingException
+ {
+ switch(Character.getType(c))
+ {
+ case Character.SURROGATE:
+ case Character.PRIVATE_USE:
+ return EMPTY;
+ default:
+ if (encoder.canEncode(c))
+ {
+ in.rewind();
+ out.rewind();
+ in.put(0, c);
+ encoder.reset();
+ encoder.encode(in, out, true);
+ encoder.flush(out);
+ int length = out.position();
+ byte[] bytes = arrays[length];
+ System.arraycopy(out.array(), 0, bytes, 0, length);
+ return bytes;
+ }
+ else
+ {
+ return EMPTY;
+ }
+ }
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharWriter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharWriter.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/CharWriter.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CharWriter
+{
+ CharWriter append(char c);
+ CharWriter append(char[] chars, int off, int len);
+ CharWriter append(char[] chars);
+ CharWriter append(CharSequence s);
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EncodingException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EncodingException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EncodingException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class EncodingException extends RuntimeException
+{
+ public EncodingException()
+ {
+ }
+
+ public EncodingException(String string)
+ {
+ super(string);
+ }
+
+ public EncodingException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public EncodingException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/EntityEncoder.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,381 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * This encoder performs lookup for converting a char to its HTML entity representation.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EntityEncoder extends AbstractCharEncoder
+{
+
+ protected void safeEncode(char c, CharWriter writer) throws EncodingException
+ {
+ String s = charToEntity[c];
+
+ //
+ if (s != null)
+ {
+ writer.append('&');
+ writer.append(s);
+ writer.append(';');
+ }
+ else
+ {
+ writer.append(c);
+ }
+ }
+
+ public void safeEncode(char[] chars, int off, int len, CharWriter writer) throws EncodingException
+ {
+ // The index of the last copied char
+ int previous = off;
+
+ //
+ int to = off + len;
+
+ // Perform lookup char by char
+ for (int current = off; current < to; current++)
+ {
+ // Lookup
+ String replacement = lookup(chars[current]);
+
+ // Do we have a replacement
+ if (replacement != null)
+ {
+ // We lazy create the result
+
+ // Append the previous chars if any
+ writer.append(chars, previous, current - previous);
+
+ // Append the replaced entity
+ writer.append('&').append(replacement).append(';');
+
+ // Update the previous pointer
+ previous = current + 1;
+ }
+ }
+
+ //
+ writer.append(chars, previous, chars.length - previous);
+ }
+
+ /** All HTML entities. */
+ public static final EntityEncoder FULL = new EntityEncoder();
+
+ /** All HTML entities except the HTML chars which are used to do HTML itself. */
+ public static final EntityEncoder BASIC = new BasicEntityTable();
+
+ private static class BasicEntityTable extends EntityEncoder
+ {
+ public BasicEntityTable()
+ {
+ remove('<');
+ remove('>');
+ remove('"');
+ remove('&');
+ }
+ }
+
+ /** . */
+ private String[] charToEntity = new String[65536];
+
+ protected EntityEncoder()
+ {
+ put(160, "nbsp");
+ put(161, "iexcl");
+ put(162, "cent");
+ put(163, "pound");
+ put(164, "curren");
+ put(165, "yen");
+ put(166, "brvbar");
+ put(167, "sect");
+ put(168, "uml");
+ put(169, "copy");
+ put(170, "ordf");
+ put(171, "laquo");
+ put(172, "not");
+ put(173, "shy");
+ put(174, "reg");
+ put(175, "macr");
+ put(176, "deg");
+ put(177, "plusmn");
+ put(178, "sup2");
+ put(179, "sup3");
+ put(180, "acute");
+ put(181, "micro");
+ put(182, "para");
+ put(183, "middot");
+ put(184, "cedil");
+ put(185, "sup1");
+ put(186, "ordm");
+ put(187, "raquo");
+ put(188, "frac14");
+ put(189, "frac12");
+ put(190, "frac34");
+ put(191, "iquest");
+ put(192, "Agrave");
+ put(193, "Aacute");
+ put(194, "Acirc");
+ put(195, "Atilde");
+ put(196, "Auml");
+ put(197, "Aring");
+ put(198, "AElig");
+ put(199, "Ccedil");
+ put(200, "Egrave");
+ put(201, "Eacute");
+ put(202, "Ecirc");
+ put(203, "Euml");
+ put(204, "Igrave");
+ put(205, "Iacute");
+ put(206, "Icirc");
+ put(207, "Iuml");
+ put(208, "ETH");
+ put(209, "Ntilde");
+ put(210, "Ograve");
+ put(211, "Oacute");
+ put(212, "Ocirc");
+ put(213, "Otilde");
+ put(214, "Ouml");
+ put(215, "times");
+ put(216, "Oslash");
+ put(217, "Ugrave");
+ put(218, "Uacute");
+ put(219, "Ucirc");
+ put(220, "Uuml");
+ put(221, "Yacute");
+ put(222, "THORN");
+ put(223, "szlig");
+ put(224, "agrave");
+ put(225, "aacute");
+ put(226, "acirc");
+ put(227, "atilde");
+ put(228, "auml");
+ put(229, "aring");
+ put(230, "aelig");
+ put(231, "ccedil");
+ put(232, "egrave");
+ put(233, "eacute");
+ put(234, "ecirc");
+ put(235, "euml");
+ put(236, "igrave");
+ put(237, "iacute");
+ put(238, "icirc");
+ put(239, "iuml");
+ put(240, "eth");
+ put(241, "ntilde");
+ put(242, "ograve");
+ put(243, "oacute");
+ put(244, "ocirc");
+ put(245, "otilde");
+ put(246, "ouml");
+ put(247, "divide");
+ put(248, "oslash");
+ put(249, "ugrave");
+ put(250, "uacute");
+ put(251, "ucirc");
+ put(252, "uuml");
+ put(253, "yacute");
+ put(254, "thorn");
+ put(255, "yuml");
+ put(402, "fnof");
+ put(913, "Alpha");
+ put(914, "Beta");
+ put(915, "Gamma");
+ put(916, "Delta");
+ put(917, "Epsilon");
+ put(918, "Zeta");
+ put(919, "Eta");
+ put(920, "Theta");
+ put(921, "Iota");
+ put(922, "Kappa");
+ put(923, "Lambda");
+ put(924, "Mu");
+ put(925, "Nu");
+ put(926, "Xi");
+ put(927, "Omicron");
+ put(928, "Pi");
+ put(929, "Rho");
+ put(931, "Sigma");
+ put(932, "Tau");
+ put(933, "Upsilon");
+ put(934, "Phi");
+ put(935, "Chi");
+ put(936, "Psi");
+ put(937, "Omega");
+ put(945, "alpha");
+ put(946, "beta");
+ put(947, "gamma");
+ put(948, "delta");
+ put(949, "epsilon");
+ put(950, "zeta");
+ put(951, "eta");
+ put(952, "theta");
+ put(953, "iota");
+ put(954, "kappa");
+ put(955, "lambda");
+ put(956, "mu");
+ put(957, "nu");
+ put(958, "xi");
+ put(959, "omicron");
+ put(960, "pi");
+ put(961, "rho");
+ put(962, "sigmaf");
+ put(963, "sigma");
+ put(964, "tau");
+ put(965, "upsilon");
+ put(966, "phi");
+ put(967, "chi");
+ put(968, "psi");
+ put(969, "omega");
+ put(977, "thetasym");
+ put(978, "upsih");
+ put(982, "piv");
+ put(8226, "bull");
+ put(8230, "hellip");
+ put(8242, "prime");
+ put(8243, "Prime");
+ put(8254, "oline");
+ put(8260, "frasl");
+ put(8472, "weierp");
+ put(8465, "image");
+ put(8476, "real");
+ put(8482, "trade");
+ put(8501, "alefsym");
+ put(8592, "larr");
+ put(8593, "uarr");
+ put(8594, "rarr");
+ put(8595, "darr");
+ put(8596, "harr");
+ put(8629, "crarr");
+ put(8656, "lArr");
+ put(8657, "uArr");
+ put(8658, "rArr");
+ put(8659, "dArr");
+ put(8660, "hArr");
+ put(8704, "forall");
+ put(8706, "part");
+ put(8707, "exist");
+ put(8709, "empty");
+ put(8711, "nabla");
+ put(8712, "isin");
+ put(8713, "notin");
+ put(8715, "ni");
+ put(8719, "prod");
+ put(8721, "sum");
+ put(8722, "minus");
+ put(8727, "lowast");
+ put(8730, "radic");
+ put(8733, "prop");
+ put(8734, "infin");
+ put(8736, "ang");
+ put(8743, "and");
+ put(8744, "or");
+ put(8745, "cap");
+ put(8746, "cup");
+ put(8747, "int");
+ put(8756, "there4");
+ put(8764, "sim");
+ put(8773, "cong");
+ put(8776, "asymp");
+ put(8800, "ne");
+ put(8801, "equiv");
+ put(8804, "le");
+ put(8805, "ge");
+ put(8834, "sub");
+ put(8835, "sup");
+ put(8836, "nsub");
+ put(8838, "sube");
+ put(8839, "supe");
+ put(8853, "oplus");
+ put(8855, "otimes");
+ put(8869, "perp");
+ put(8901, "sdot");
+ put(8968, "lceil");
+ put(8969, "rceil");
+ put(8970, "lfloor");
+ put(8971, "rfloor");
+ put(9001, "lang");
+ put(9002, "rang");
+ put(9674, "loz");
+ put(9824, "spades");
+ put(9827, "clubs");
+ put(9829, "hearts");
+ put(9830, "diams");
+ put(34, "quot");
+ put(38, "amp");
+ put(60, "lt");
+ put(62, "gt");
+ put(338, "OElig");
+ put(339, "oelig");
+ put(352, "Scaron");
+ put(353, "scaron");
+ put(376, "Yuml");
+ put(710, "circ");
+ put(732, "tilde");
+ put(8194, "ensp");
+ put(8195, "emsp");
+ put(8201, "thinsp");
+ put(8204, "zwnj");
+ put(8205, "zwj");
+ put(8206, "lrm");
+ put(8207, "rlm");
+ put(8211, "ndash");
+ put(8212, "mdash");
+ put(8216, "lsquo");
+ put(8217, "rsquo");
+ put(8218, "sbquo");
+ put(8220, "ldquo");
+ put(8221, "rdquo");
+ put(8222, "bdquo");
+ put(8224, "dagger");
+ put(8225, "Dagger");
+ put(8240, "permil");
+ put(8249, "lsaquo");
+ put(8250, "rsaquo");
+ put(8364, "euro");
+ }
+
+ protected final void put(int c, String entity)
+ {
+ charToEntity[c] = entity;
+ }
+
+ protected final void remove(int c)
+ {
+ charToEntity[c] = null;
+ }
+
+ /**
+ * Returns null if no entity is found or return the converted entity.
+ *
+ * @param c the char to encode
+ * @return the corresponding encoded string or null
+ */
+ public final String lookup(char c)
+ {
+ return charToEntity[c];
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,388 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.jboss.portal.common.io.WriterCharWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FastURLDecoder implements CharEncoder
+{
+
+ /** . */
+ private static final FastURLDecoder UTF8 = new FastURLDecoder(CharToByteEncoder.Generic.UTF8);
+
+ /** . */
+ private static final FastURLDecoder UTF8_STRICT = new FastURLDecoder(CharToByteEncoder.Generic.UTF8, true);
+
+ public static FastURLDecoder getUTF8Instance()
+ {
+ return UTF8;
+ }
+
+ public static FastURLDecoder getUTF8StrictInstance()
+ {
+ return UTF8_STRICT;
+ }
+
+ /** . */
+ private static final char FROM = 0;
+
+ /** . */
+ private static final char TO = (char)0x10FFFD;
+
+ /** . */
+ private static final int AS_IS = 0;
+
+ /** . */
+ private static final int PLUS = 1;
+
+ /** . */
+ private static final int ESCAPE = 2;
+
+ /** . */
+ private static final int ERROR = 3;
+
+ /** . */
+ private final LookupNonTerm root;
+
+ /** . */
+ private final int[] decisions;
+
+ /** . */
+ private final int[][] conversions;
+
+ /** . */
+ private final boolean strict;
+
+ public FastURLDecoder(CharToByteEncoder encoder)
+ {
+ this(encoder, false);
+ }
+
+ public FastURLDecoder(CharToByteEncoder encoder, boolean strict)
+ {
+ this.strict = strict;
+
+ //
+ root = new LookupNonTerm();
+ for (char c = FROM; c <= TO; c++)
+ {
+ byte[] v = encoder.encode(c);
+ LookupNonTerm node = root;
+ int k = v.length;
+ for (int i = 0; i < k; i++)
+ {
+ int index = (int)v[i] & 0xFF;
+ if (i == k - 1)
+ {
+ node.children[index] = new LookupTerm(c);
+ }
+ else
+ {
+ if (node.children[index] == null)
+ {
+ node.children[index] = new LookupNonTerm();
+ }
+ node = (LookupNonTerm)node.children[index];
+ }
+ }
+ }
+
+ //
+ conversions = new int[256][256];
+ for (char i = 0; i < 256; i++)
+ {
+ int x = hexValue(i);
+ for (char j = 0; j < 256; j++)
+ {
+ int y = hexValue(j);
+ if (x != -1 && y != -1)
+ {
+ conversions[i][j] = (x << 4) + y;
+ }
+ else
+ {
+ conversions[i][j] = -1;
+ }
+ }
+ }
+
+ //
+ decisions = new int[256];
+ for (int i = 0; i < decisions.length; i++)
+ {
+ if (TextTools.isAlphaNumeric((char)i))
+ {
+ decisions[i] = AS_IS;
+ }
+ else
+ {
+ switch (i)
+ {
+ case '+':
+ decisions[i] = PLUS;
+ break;
+ case '.':
+ case '-':
+ case '*':
+ case '_':
+ decisions[i] = AS_IS;
+ break;
+ case '%':
+ decisions[i] = ESCAPE;
+ break;
+ default:
+ decisions[i] = ERROR;
+ break;
+ }
+ }
+ }
+ }
+
+ public void encode(char c, CharWriter writer)
+ {
+ encode(new char[]{c}, writer);
+ }
+
+ public void encode(char[] chars, int off, int len, CharWriter writer)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (len < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off + len > chars.length)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ encodeNoCheck(chars, off, len, writer);
+ }
+
+ public void encode(char[] chars, CharWriter writer)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ encodeNoCheck(chars, 0, chars.length, writer);
+ }
+
+ public void encode(CharSequence s, CharWriter writer)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (s instanceof String)
+ {
+ char[] chars = ((String)s).toCharArray();
+ encodeNoCheck(chars, 0, chars.length, writer);
+ }
+ else
+ {
+ char[] chars = new char[s.length()];
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ chars[i] = c;
+ }
+ encodeNoCheck(chars, 0, chars.length, writer);
+ }
+ }
+
+ /**
+ * @param s
+ * @return
+ * @throws IllegalArgumentException
+ * @since 1.1
+ */
+ public String encode(String s) throws IllegalArgumentException
+ {
+ Writer sw = new StringWriter();
+ CharWriter charWriter = new WriterCharWriter(sw);
+ encodeNoCheck(s.toCharArray(), 0, s.length(), charWriter);
+ return sw.toString();
+ }
+
+ private void encodeNoCheck(char[] chars, int i, int length, CharWriter tmp)
+ {
+ while (i < length)
+ {
+ char c = chars[i++];
+ int decision = c < 256 ? decisions[c] : ERROR;
+ switch (decision)
+ {
+ case AS_IS:
+ tmp.append(c);
+ break;
+ case PLUS:
+ tmp.append(' ');
+ break;
+ case ESCAPE:
+ int j = i;
+
+ //
+ LookupNonTerm current = root;
+ while (true)
+ {
+ if (j + 2 > length)
+ {
+ throw new MalformedInputException("Not enough chars to decode an escaped value length should have been" +
+ (j + 2) + " but is " + length);
+ }
+
+ //
+ char c1 = chars[j++];
+ char c2 = chars[j++];
+
+ //
+ if (c1 > 255)
+ {
+ throw new MalformedInputException("Input out of the lookup range (" + c1 + "," + c2 + ")");
+ }
+ if (c2 > 255)
+ {
+ throw new MalformedInputException("Input out of the lookup range (" + c1 + "," + c2 + ")");
+ }
+
+
+ int z = conversions[c1][c2];
+
+ //
+ if (z == -1)
+ {
+ throw new MalformedInputException("Input out of the lookup range (" + c1 + "," + c2 + ")");
+ }
+
+ //
+ LookupNode child = current.children[z];
+ if (child instanceof LookupTerm)
+ {
+ LookupTerm term = (LookupTerm)child;
+ tmp.append(term.c);
+ i = j;
+ break;
+ }
+ else
+ {
+ current = (LookupNonTerm)child;
+ }
+
+ //
+ j++;
+ }
+ break;
+ case ERROR:
+ if (strict)
+ {
+ throw new MalformedInputException("Cannot decode char " + c);
+ }
+ else
+ {
+ tmp.append(c);
+ }
+ break;
+ }
+ }
+ }
+
+ public boolean isStrict()
+ {
+ return strict;
+ }
+
+ private static class LookupNode
+ {
+ }
+
+ private static class LookupTerm extends LookupNode
+ {
+
+ /** . */
+ private final char c;
+
+ public LookupTerm(char c)
+ {
+ this.c = c;
+ }
+ }
+
+ private static class LookupNonTerm extends LookupNode
+ {
+ private final LookupNode[] children = new LookupNode[256];
+ }
+
+ /**
+ * Returns the hex value of the char c. If the char cannot be converted then -1 is returned.
+ *
+ * @param c the char to convert
+ * @return the converted hex value
+ */
+ private static int hexValue(char c)
+ {
+ if (c >= 'A' && c <= 'F')
+ {
+ return c - 'A' + 10;
+ }
+ if (c >= 'a' && c <= 'f')
+ {
+ return c - 'a' + 10;
+ }
+ if (c >= '0' && c <= '9')
+ {
+ return c - '0';
+ }
+ return -1;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,267 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * An implementation based on a table for lookups.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class FastURLEncoder implements CharEncoder
+{
+
+ /** . */
+ private static final FastURLEncoder DEFAULT_ENCODER = new FastURLEncoder(CharToByteEncoder.Generic.UTF8);
+
+ public static FastURLEncoder getUTF8Instance()
+ {
+ return DEFAULT_ENCODER;
+ }
+
+ /** . */
+ private final char[][] table;
+
+ /** . */
+ private static final char MAX = (char)0x10FFFD;
+
+ public FastURLEncoder(CharToByteEncoder encoder) throws IllegalArgumentException
+ {
+ if (encoder == null)
+ {
+ throw new IllegalArgumentException("No encoding provided");
+ }
+
+ //
+ this.table = new char[MAX + 1][];
+
+ //
+ for (char c = 0; c <= MAX; c++)
+ {
+ char[] z;
+ if (TextTools.isAlphaNumeric(c))
+ {
+ z = new char[]{c};
+ }
+ else
+ {
+ switch (c)
+ {
+ case ' ':
+ z = new char[]{'+'};
+ break;
+ case '.':
+ case '-':
+ case '*':
+ case '_':
+ z = new char[]{c};
+ break;
+ default:
+ byte[] v = encoder.encode(c);
+ if (v.length > 0)
+ {
+ z = new char[v.length * 3];
+ int index = 0;
+ for (int i = 0; i < v.length; i++)
+ {
+ byte b = v[i];
+ z[index++] = '%';
+ z[index++] = TextTools.toHex((b & 0xF0) >> 4);
+ z[index++] = TextTools.toHex(b & 0x0F);
+ }
+ }
+ else
+ {
+ z = null;
+ }
+ break;
+ }
+ }
+ table[c] = z;
+ }
+ }
+
+ public void encode(CharSequence s, CharWriter out) throws IllegalArgumentException
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (out == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new MalformedInputException("Wrong");
+ }
+ out.append(z);
+ }
+ }
+
+ public void encode(char c, CharWriter writer)
+ {
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new MalformedInputException("Wrong");
+ }
+ writer.append(z);
+ }
+
+ public void encode(char[] chars, int off, int len, CharWriter writer)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (len < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off + len > chars.length)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ encodeNoCheck(chars, off, len, writer);
+ }
+
+ public void encode(char[] chars, CharWriter writer)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ encodeNoCheck(chars, 0, chars.length, writer);
+ }
+
+ private void encodeNoCheck(char[] chars, int off, int len, CharWriter writer)
+ {
+ for (int i = off; i < len; i++)
+ {
+ char c = chars[i];
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new IllegalArgumentException("Wrong");
+ }
+ writer.append(z);
+ }
+ }
+
+ public String encode(String s) throws IllegalArgumentException
+ {
+ StringBuffer tmp = new StringBuffer();
+ encode(s, tmp);
+ return tmp.toString();
+ }
+
+ public void encode(String s, StringBuffer out) throws IllegalArgumentException
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (out == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new MalformedInputException("Cannot encode char=" + (int)c);
+ }
+ out.append(z);
+ }
+ }
+
+ public void encode(String s, Writer out) throws IllegalArgumentException, UndeclaredIOException
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (out == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new MalformedInputException("Wrong");
+ }
+ out.write(z);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public String toString()
+ {
+ return "FastURLEncoder[" + "" + ",[" + 0 + "," + MAX + "]]";
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/MalformedInputException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/MalformedInputException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/MalformedInputException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MalformedInputException extends EncodingException
+{
+ public MalformedInputException()
+ {
+ }
+
+ public MalformedInputException(String string)
+ {
+ super(string);
+ }
+
+ public MalformedInputException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public MalformedInputException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/TextTools.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/TextTools.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/TextTools.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TextTools
+{
+
+ /**
+ * Returns true if the char c is alpha numeric i.e it belongs to one of the following ranges [0,9], [A,Z] or
+ * [a,z]
+ * @param c the char to test
+ * @return true if c is alpha numeric
+ */
+ public static boolean isAlphaNumeric(char c)
+ {
+ return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
+ }
+
+ /**
+ * Returns the hexadecimal value of the provided numeric value.
+ * @param z the numeric value to convert
+ * @return the hexadecimal char
+ * @throws IllegalArgumentException if the value is not between 0 and 15
+ */
+ public static char toHex(int z) throws IllegalArgumentException
+ {
+ if (z >= 0 && z < 10)
+ {
+ return (char)('0' + z);
+ }
+ else if (z >= 10 && z < 16)
+ {
+ return (char)('A' - 10 + z);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Wrong character");
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/UnsupportedCharsetException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/UnsupportedCharsetException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/text/UnsupportedCharsetException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UnsupportedCharsetException extends EncodingException
+{
+ public UnsupportedCharsetException()
+ {
+ }
+
+ public UnsupportedCharsetException(String string)
+ {
+ super(string);
+ }
+
+ public UnsupportedCharsetException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public UnsupportedCharsetException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.transaction;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class NestedException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 8546585764241990455L;
+
+ public NestedException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.transaction;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class TransactionException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 8968893103336776336L;
+ public TransactionException()
+ {
+ }
+ public TransactionException(Throwable cause)
+ {
+ super(cause);
+ }
+ public TransactionException(String message)
+ {
+ super(message);
+ }
+ public TransactionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.transaction;
+
+import javax.transaction.TransactionManager;
+import javax.naming.InitialContext;
+
+/**
+ * Implementations provides access to a transaction manager.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public interface TransactionManagerProvider
+{
+ /**
+ * Provide access to the transaction manager.
+ *
+ * @return return the transaction manager.
+ * @throws Exception any exception that prevent to get the transaction manager
+ */
+ TransactionManager getTransactionManager() throws Exception;
+
+ /**
+ * JBoss transaction manager provider implementation.
+ */
+ TransactionManagerProvider JBOSS_PROVIDER = new TransactionManagerProvider()
+ {
+ public TransactionManager getTransactionManager() throws Exception
+ {
+ return (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
+ }
+ };
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,704 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.transaction;
+
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.NotSupportedException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.RollbackException;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Utility class for managing transactions.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class Transactions
+{
+
+ /** . */
+ private static Logger log = Logger.getLogger(Transactions.class);
+
+ /** . */
+ private static final String[] STATUS_NAMES = {
+ "STATUS_ACTIVE",
+ "STATUS_MARKED_ROLLBACK",
+ "STATUS_PREPARED",
+ "STATUS_COMMITTED",
+ "STATUS_ROLLEDBACK",
+ "STATUS_UNKNOWN",
+ "STATUS_NO_TRANSACTION",
+ "STATUS_PREPARING",
+ "STATUS_COMMITTING",
+ "STATUS_ROLLING_BACK"};
+
+ /**
+ * Decode the status name.
+ *
+ * @param status the status value
+ * @return the translated status name or null if it is not valid
+ */
+ public static String decodeStatus(int status)
+ {
+ if (status >= 0 && status <= STATUS_NAMES.length)
+ {
+ return STATUS_NAMES[status];
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Apply the transaction type before the unit of work.
+ *
+ * @param type the transaction type
+ * @param tm the transaction manager
+ * @return the new transaction if one has been started.
+ * @throws TransactionException
+ * @throws IllegalArgumentException if the type or the transaction manager is null
+ */
+ public static Transaction applyBefore(Type type, TransactionManager tm) throws TransactionException, IllegalArgumentException
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager provided");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No type");
+ }
+
+ // Suspend the incoming transaction
+ Transaction oldTx = suspend(tm);
+
+ if (oldTx != null)
+ {
+ type.txBefore(tm, oldTx);
+ }
+ else
+ {
+ type.noTxBefore(tm);
+ }
+
+ return oldTx;
+ }
+
+ /**
+ * Apply the transaction type after the unit of work has been done.
+ *
+ * @param type the transaction type
+ * @param tm the transaction manager
+ * @param oldTx the old transaction if it is not null
+ * @throws TransactionException
+ * @throws IllegalArgumentException if the type of the transaction manager is null
+ */
+ public static void applyAfter(Type type, TransactionManager tm, Transaction oldTx) throws TransactionException, IllegalArgumentException
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager provided");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No type");
+ }
+
+ try
+ {
+ if (oldTx != null)
+ {
+ type.txAfter(tm, oldTx);
+ }
+ else
+ {
+ type.noTxAfter(tm);
+ }
+ }
+ finally
+ {
+ if (oldTx != null)
+ {
+ try
+ {
+ resume(tm, oldTx);
+ }
+ catch (TransactionException ignore)
+ {
+ log.error("Was not capable to resume the incoming transaction", ignore);
+ }
+ }
+ }
+ }
+
+ /**
+ * Apply the transaction type around the unit of work.
+ *
+ * @param type the transaction type
+ * @param tm the transaction manager
+ * @param runnable the unit of work
+ * @return the object returned by the runnable object
+ * @throws NestedException wraps any exception throws by the runnable object
+ * @throws TransactionException
+ * @throws IllegalArgumentException if any method argument is null
+ */
+ public static Object apply(Type type, TransactionManager tm, final Runnable runnable) throws NestedException, TransactionException, IllegalArgumentException
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager provided");
+ }
+ if (runnable == null)
+ {
+ throw new IllegalArgumentException("No code to execute");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No type");
+ }
+
+ // Any throwable thrown by the wrapped code
+ Throwable throwable = null;
+
+ // Any object returned by the wrapped code
+ Object ret = null;
+
+ // Suspend the incoming transaction
+ Transaction oldTx = suspend(tm);
+
+ try
+ {
+ if (oldTx != null)
+ {
+ type.txBefore(tm, oldTx);
+ try
+ {
+ ret = runnable.run();
+ }
+ catch (Throwable t)
+ {
+ throwable = t;
+ }
+ finally
+ {
+ type.txAfter(tm, oldTx);
+ }
+ }
+ else
+ {
+ type.noTxBefore(tm);
+ try
+ {
+ ret = runnable.run();
+ }
+ catch (Throwable t)
+ {
+ throwable = t;
+ }
+ finally
+ {
+ type.noTxAfter(tm);
+ }
+ }
+ }
+ finally
+ {
+ if (oldTx != null)
+ {
+ try
+ {
+ resume(tm, oldTx);
+ }
+ catch (TransactionException ignore)
+ {
+ log.error("Was not capable to resume the incoming transaction", ignore);
+ }
+ }
+ }
+ if (throwable != null)
+ {
+ if (throwable instanceof Error)
+ {
+ throw (Error)throwable;
+ }
+ else
+ {
+ throw new NestedException(throwable);
+ }
+ }
+ else
+ {
+ return ret;
+ }
+ }
+
+ public static Object notSupported(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_NOT_SUPPORTED, tm, runnable);
+ }
+
+ public static Object never(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_NEVER, tm, runnable);
+ }
+
+ public static Object mandatory(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_MANDATORY, tm, runnable);
+ }
+
+ public static Object supports(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_SUPPORTS, tm, runnable);
+ }
+
+ public static Object required(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_REQUIRED, tm, runnable);
+ }
+
+ public static Object requiresNew(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_REQUIRES_NEW, tm, runnable);
+ }
+
+ /**
+ * Begin a new transaction.
+ *
+ * @param tm the transaction manager
+ * @throws IllegalArgumentException if the tm is null
+ */
+ public static void begin(TransactionManager tm) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ tm.begin();
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when beginning transaction", e);
+ throw new TransactionException(e);
+ }
+ catch (NotSupportedException e)
+ {
+ log.error("Problem when beginning transaction", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ /**
+ * Mark the transaction as rollback only.
+ *
+ * @param tx the transaction to mark as rollback only
+ * @throws IllegalArgumentException if the transaction is null
+ * @throws TransactionException
+ */
+ private static void setRollbackOnly(Transaction tx) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tx == null)
+ {
+ throw new IllegalArgumentException("No transaction to set rollback only");
+ }
+ tx.setRollbackOnly();
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when setting transaction as rollback only", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ /**
+ * Mark the active transaction for this thread as rollback only
+ *
+ * @see #setRollbackOnly(javax.transaction.Transaction)
+ * @param tm the transaction manager
+ * @throws IllegalArgumentException if the tm is null
+ */
+ public static void setRollbackOnly(TransactionManager tm) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ Transaction tx = tm.getTransaction();
+ if (tx == null)
+ {
+ throw new TransactionException("No active transaction to set rollback only");
+ }
+ setRollbackOnly(tx);
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when setting transaction as rollback only", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ public void safeSetRollbackOnly(TransactionManager tm)
+ {
+ try
+ {
+ setRollbackOnly(tm);
+ }
+ catch (IllegalArgumentException e)
+ {
+ log.error("", e);
+ }
+ catch (TransactionException e)
+ {
+ log.error("", e);
+ }
+ }
+
+ public static void safeEnd(TransactionManager tm)
+ {
+ try
+ {
+ end(tm);
+ }
+ catch (IllegalArgumentException e)
+ {
+ log.error("", e);
+ }
+ catch (TransactionException e)
+ {
+ log.error("", e);
+ }
+ }
+
+ /**
+ * Terminate the active transaction for this thread. If the transaction is marked for rollback
+ * then it is rollbacked otherwise it is commited.
+ *
+ * @param tm the transaction manager
+ * @return true if commit happened, false otherwise
+ * @throws IllegalArgumentException if the tm is null
+ */
+ public static boolean end(TransactionManager tm) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ int status = tm.getStatus();
+ switch (status)
+ {
+ case Status.STATUS_MARKED_ROLLBACK:
+ tm.rollback();
+ return false;
+ case Status.STATUS_ACTIVE:
+ tm.commit();
+ return true;
+ default:
+ throw new TransactionException("Abnormal status for ending a tx " + STATUS_NAMES[status]);
+ }
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when ending transaction", e);
+ throw new TransactionException(e);
+ }
+ catch (HeuristicMixedException e)
+ {
+ log.error("Problem when ending transaction", e);
+ throw new TransactionException(e);
+ }
+ catch (HeuristicRollbackException e)
+ {
+ log.error("Problem when ending transaction", e);
+ throw new TransactionException(e);
+ }
+ catch (RollbackException e)
+ {
+ log.error("Problem when ending transaction", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ /**
+ * Associate the thread with a transaction
+ *
+ * @param tm the transaction manager
+ * @param tx the transaction to associate with the this thread
+ * @throws IllegalArgumentException if any argument is null
+ * @throws TransactionException
+ */
+ public static void resume(TransactionManager tm, Transaction tx) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ if (tx == null)
+ {
+ throw new IllegalArgumentException("No transaction to resume");
+ }
+ tm.resume(tx);
+ }
+ catch (Exception e)
+ {
+ log.error("Problem when resuming transaction", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ /**
+ * Disassociate the current thread with the active transaction.
+ *
+ * @param tm the transaction manager
+ * @return the transaction previously associated with this thread
+ * @throws IllegalArgumentException if the transaction manager is null
+ * @throws TransactionException
+ */
+ public static Transaction suspend(TransactionManager tm) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ return tm.suspend();
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when suspending transaction", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ public interface Runnable
+ {
+ Object run() throws Exception;
+ }
+
+ public abstract static class Type
+ {
+ private final String name;
+
+ private Type(String name)
+ {
+ this.name = name;
+ }
+
+ public Transaction before(TransactionManager tm)
+ {
+ return applyBefore(this, tm);
+ }
+
+ public void after(TransactionManager tm, Transaction oldTx)
+ {
+ applyAfter(this, tm, oldTx);
+ }
+
+ abstract void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException;
+
+ abstract void txAfter(TransactionManager tm, Transaction oldTx);
+
+ abstract void noTxBefore(TransactionManager tm) throws TransactionException;
+
+ abstract void noTxAfter(TransactionManager tm);
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+ }
+
+ public static final Type TYPE_NOT_SUPPORTED = new Type("NOT_SUPPORTED")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx)
+ {
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ }
+ void noTxBefore(TransactionManager tm)
+ {
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ }
+ };
+
+ public static final Type TYPE_SUPPORTS = new Type("SUPPORTS")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException
+ {
+ resume(tm, oldTx);
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ try
+ {
+ suspend(tm);
+ }
+ catch (IllegalStateException ignore)
+ {
+ log.error("Problem when suspending transaction", ignore);
+ }
+ }
+ void noTxBefore(TransactionManager tm)
+ {
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ }
+ };
+
+ public static final Type TYPE_REQUIRED = new Type("REQUIRED")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx)
+ {
+ resume(tm, oldTx);
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ try
+ {
+ suspend(tm);
+ }
+ catch (TransactionException ignore)
+ {
+ log.error("Problem when suspending transaction", ignore);
+ }
+ }
+ void noTxBefore(TransactionManager tm) throws TransactionException
+ {
+ begin(tm);
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ try
+ {
+ end(tm);
+ }
+ catch (IllegalStateException ignore)
+ {
+ log.error("Problem when ending transaction", ignore);
+ }
+ }
+ };
+
+ public static final Type TYPE_REQUIRES_NEW = new Type("REQUIRES_NEW")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException
+ {
+ begin(tm);
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ try
+ {
+ end(tm);
+ }
+ catch (IllegalStateException ignore)
+ {
+ log.error("Problem when ending transaction", ignore);
+ }
+ }
+ void noTxBefore(TransactionManager tm) throws TransactionException
+ {
+ begin(tm);
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ try
+ {
+ end(tm);
+ }
+ catch (IllegalStateException ignore)
+ {
+ log.error("Problem when ending transaction", ignore);
+ }
+ }
+ };
+
+ public static final Type TYPE_MANDATORY = new Type("MANDATORY")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException
+ {
+ resume(tm, oldTx);
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ }
+ void noTxBefore(TransactionManager tm) throws TransactionException
+ {
+ throw new TransactionException("No incoming transaction");
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ throw new UnsupportedOperationException("Should never ne called");
+ }
+ };
+
+ public static final Type TYPE_NEVER = new Type("NEVER")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException
+ {
+ throw new TransactionException("Need no incoming transaction");
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ throw new UnsupportedOperationException("Should never ne called");
+ }
+ void noTxBefore(TransactionManager tm)
+ {
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ }
+ };
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,560 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * <p>Encodes and decodes to and from Base64 and URL-safe Base64 encodings. URL-safe Base64 encoding being defined here
+ * as standard Base64 encoding with the following modifications:</p>
+ * <ul>
+ * <li>use '-' and '_' instead of '+' and '/'</li>
+ * <li>no line feeds</li>
+ * <li>padding character is '*' instead of '='</li>
+ * </ul>
+ * <p/>
+ * <p>Based on version 2.1 of the Base64 class developed by Robert Harder (public domain).
+ * Please visit <a href="http://iharder.net/base64">http://iharder.net/base64</a>
+ * periodically to check for updates or to contribute improvements.
+ * </p>
+ *
+ * @author <a href="mailto:rob@iharder.net">Robert Harder</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @since 2.4 (Apr 30, 2006)
+ */
+public class Base64
+{
+
+/* ******** P R I V A T E F I E L D S ******** */
+
+
+ /** Maximum line length (76) of Base64 output. */
+ private final static int MAX_LINE_LENGTH = 76;
+
+
+ /** The equals sign (=) as a byte. */
+ private final static byte EQUALS_SIGN = (byte)'=';
+
+ /** '*' as a byte */
+ private final static byte STAR = (byte)'*';
+
+ /** The character to be used as a padding character in the encoded Strings. */
+ private byte PADDING_CHAR;
+
+
+ /** The new line character (\n) as a byte. */
+ private final static byte NEW_LINE = (byte)'\n';
+
+
+ /** Preferred encoding. */
+ private final static String PREFERRED_ENCODING = "UTF-8";
+
+
+ /** The 64 valid Base64 values. */
+ private byte[] ALPHABET;
+ private final static byte[] NATIVE_ALPHABET = /* May be something funny like EBCDIC */
+ {
+ (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G',
+ (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N',
+ (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U',
+ (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z',
+ (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g',
+ (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n',
+ (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u',
+ (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z',
+ (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5',
+ (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/'
+ };
+ private final static byte[] NATIVE_URL_SAFE_ALPHABET =
+ {
+ (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G',
+ (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N',
+ (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U',
+ (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z',
+ (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g',
+ (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n',
+ (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u',
+ (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z',
+ (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5',
+ (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'-', (byte)'_'
+ };
+
+ private static final int IGNORE = -9; // Indicates ignored characters
+ private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
+ private final static byte PADDING_CHAR_ENC = -1; // Indicates equals sign in encoding
+
+ /**
+ * Translates a value to either its 6-bit reconstruction value
+ * or a negative number indicating some other meaning.
+ */
+ private byte[] DECODABET;
+
+ /**
+ * Translates a Base64 value to either its 6-bit reconstruction value
+ * or a negative number indicating some other meaning.
+ */
+ private final static byte[] BASE64_DECODABET =
+ {
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 0 - 8
+ WHITE_SPACE_ENC, WHITE_SPACE_ENC, // Whitespace: Tab and Linefeed
+ IGNORE, IGNORE, // Decimal 11 - 12
+ WHITE_SPACE_ENC, // Whitespace: Carriage Return
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 14 - 26
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 27 - 31
+ WHITE_SPACE_ENC, // Whitespace: Space
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 33 - 42
+ 62, // Plus sign at decimal 43
+ IGNORE, IGNORE, IGNORE, // Decimal 44 - 46
+ 63, // Slash at decimal 47
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine
+ IGNORE, IGNORE, IGNORE, // Decimal 58 - 60
+ PADDING_CHAR_ENC, // Equals sign at decimal 61 (padding character)
+ IGNORE, IGNORE, IGNORE, // Decimal 62 - 64
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 91 - 96
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'
+ IGNORE, IGNORE, IGNORE, IGNORE // Decimal 123 - 126
+ };
+
+ /**
+ * Translates a URL-modified Base64 value to either its 6-bit reconstruction value
+ * or a negative number indicating some other meaning.
+ */
+ private final static byte[] URL_SAFE_DECODABET =
+ {
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 0 - 8
+ WHITE_SPACE_ENC, WHITE_SPACE_ENC, // Whitespace: Tab and Linefeed
+ IGNORE, IGNORE, // Decimal 11 - 12
+ WHITE_SPACE_ENC, // Whitespace: Carriage Return
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 14 - 26
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 27 - 31
+ WHITE_SPACE_ENC, // Whitespace: Space
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 33 - 41
+ PADDING_CHAR_ENC, // Star sign at decimal 42 (padding character)
+ IGNORE, IGNORE, // Decimal 43 - 44
+ 62, // Minus sign at decimal 45
+ IGNORE, IGNORE, // Decimal 46 - 47
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 58 - 64
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'
+ IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 91 - 94
+ 63, // Underscore at decimal 95
+ IGNORE, // Decimal 96
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'
+ IGNORE, IGNORE, IGNORE, IGNORE // Decimal 123 - 126
+ };
+
+ /** Determine which ALPHABET to use. */
+ public void initAlphabets(boolean useURLSafeEncoding)
+ {
+ byte[] __bytes;
+ String alphabetString;
+ byte[] nativeAlphabet;
+
+ if (useURLSafeEncoding)
+ {
+ alphabetString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
+ nativeAlphabet = NATIVE_URL_SAFE_ALPHABET;
+ PADDING_CHAR = STAR;
+ DECODABET = URL_SAFE_DECODABET;
+ }
+ else
+ {
+ alphabetString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ nativeAlphabet = NATIVE_ALPHABET;
+ PADDING_CHAR = EQUALS_SIGN;
+ DECODABET = BASE64_DECODABET;
+ }
+
+ try
+ {
+ __bytes = alphabetString.getBytes(PREFERRED_ENCODING);
+ } // end try
+ catch (java.io.UnsupportedEncodingException use)
+ {
+ __bytes = nativeAlphabet; // Fall back to native encoding
+ } // end catch
+ ALPHABET = __bytes;
+ } // end initAlphabets
+
+ private static final Base64 STANDARD_BASE64 = new Base64();
+ private static final Base64 URL_SAFE_BASE64 = new Base64(true);
+
+ private Base64()
+ {
+ this(false);
+ }
+
+ private Base64(boolean useURLSafeEncoding)
+ {
+ initAlphabets(useURLSafeEncoding);
+ }
+
+ private static Base64 getBase64(boolean useURLSafeEncoding)
+ {
+ return useURLSafeEncoding ? URL_SAFE_BASE64 : STANDARD_BASE64;
+ }
+
+/* ******** E N C O D I N G M E T H O D S ******** */
+
+
+ /**
+ * Encodes up to three bytes of the array <var>source</var>
+ * and writes the resulting four Base64 bytes to <var>destination</var>.
+ * The source and destination arrays can be manipulated
+ * anywhere along their length by specifying
+ * <var>srcOffset</var> and <var>destOffset</var>.
+ * This method does not check to make sure your arrays
+ * are large enough to accomodate <var>srcOffset</var> + 3 for
+ * the <var>source</var> array or <var>destOffset</var> + 4 for
+ * the <var>destination</var> array.
+ * The actual number of significant bytes in your array is
+ * given by <var>numSigBytes</var>.
+ *
+ * @param source the array to convert
+ * @param srcOffset the index where conversion begins
+ * @param numSigBytes the number of significant bytes in your array
+ * @param destination the array to hold the conversion
+ * @param destOffset the index where output will be put
+ * @return the <var>destination</var> array
+ */
+ private byte[] encode3to4(byte[] source, int srcOffset, int numSigBytes,
+ byte[] destination, int destOffset)
+ {
+ // 1 2 3
+ // 01234567890123456789012345678901 Bit position
+ // --------000000001111111122222222 Array position from threeBytes
+ // --------| || || || | Six bit groups to index ALPHABET
+ // >>18 >>12 >> 6 >> 0 Right shift necessary
+ // 0x3f 0x3f 0x3f Additional AND
+
+ // Create buffer with zero-padding if there are only one or two
+ // significant bytes passed in the array.
+ // We have to shift left 24 in order to flush out the 1's that appear
+ // when Java treats a value as negative that is cast from a byte to an int.
+ int inBuff = (numSigBytes > 0 ? ((source[srcOffset] << 24) >>> 8) : 0)
+ | (numSigBytes > 1 ? ((source[srcOffset + 1] << 24) >>> 16) : 0)
+ | (numSigBytes > 2 ? ((source[srcOffset + 2] << 24) >>> 24) : 0);
+
+ switch (numSigBytes)
+ {
+ case 3:
+ destination[destOffset] = ALPHABET[(inBuff >>> 18)];
+ destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f];
+ destination[destOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3f];
+ destination[destOffset + 3] = ALPHABET[(inBuff) & 0x3f];
+ return destination;
+
+ case 2:
+ destination[destOffset] = ALPHABET[(inBuff >>> 18)];
+ destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f];
+ destination[destOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3f];
+ destination[destOffset + 3] = PADDING_CHAR;
+ return destination;
+
+ case 1:
+ destination[destOffset] = ALPHABET[(inBuff >>> 18)];
+ destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f];
+ destination[destOffset + 2] = PADDING_CHAR;
+ destination[destOffset + 3] = PADDING_CHAR;
+ return destination;
+
+ default:
+ return destination;
+ } // end switch
+ } // end encode3to4
+
+ /**
+ * Encodes a byte array into Base64 notation using the standard Base64 encoding.
+ *
+ * @param source The data to convert
+ */
+ public static String encodeBytes(byte[] source)
+ {
+ return encodeBytes(source, 0, source.length, false);
+ } // end encodeBytes
+
+
+ /**
+ * Encodes a byte array into Base64 notation.
+ *
+ * @param source The data to convert
+ * @param useURLSafeEncoding <code>true</code> to use '-', '_' instead of '+', '/' in the alphabet and '*' instead
+ * of '=' for padding to generate a URL-safe encoding. <i>Note: Technically, this makes
+ * your encoding non-compliant.</i>
+ */
+ public static String encodeBytes(byte[] source, boolean useURLSafeEncoding)
+ {
+ return encodeBytes(source, 0, source.length, useURLSafeEncoding);
+ } // end encodeBytes
+
+ /**
+ * Encodes a byte array into Base64 notation.
+ *
+ * @param source The data to convert
+ * @param off Offset in array where conversion should begin
+ * @param len Length of data to convert
+ * @param useURLSafeEncoding <code>true</code> to use '-', '_' instead of '+', '/' in the alphabet and '*' instead
+ * of '=' for padding to generate a URL-safe encoding. <i>Note: Technically, this makes
+ * your encoding non-compliant.</i>
+ */
+ public static String encodeBytes(byte[] source, int off, int len, boolean useURLSafeEncoding)
+ {
+ Base64 b64 = getBase64(useURLSafeEncoding);
+
+ int len43 = len * 4 / 3;
+ byte[] outBuff = new byte[(len43) // Main 4:3
+ + ((len % 3) > 0 ? 4 : 0) // Account for padding
+ + ((!useURLSafeEncoding) ? (len43 / MAX_LINE_LENGTH) : 0)]; // New lines
+ int d = 0;
+ int e = 0;
+ int len2 = len - 2;
+ int lineLength = 0;
+ for (; d < len2; d += 3, e += 4)
+ {
+ b64.encode3to4(source, d + off, 3, outBuff, e);
+
+ lineLength += 4;
+ if (!useURLSafeEncoding && lineLength == MAX_LINE_LENGTH)
+ {
+ outBuff[e + 4] = NEW_LINE;
+ e++;
+ lineLength = 0;
+ } // end if: end of line
+ } // en dfor: each piece of array
+
+ if (d < len)
+ {
+ b64.encode3to4(source, d + off, len - d, outBuff, e);
+ e += 4;
+ } // end if: some padding needed
+
+ // Return value according to relevant encoding.
+ try
+ {
+ return new String(outBuff, 0, e, PREFERRED_ENCODING);
+ } // end try
+ catch (java.io.UnsupportedEncodingException uue)
+ {
+ return new String(outBuff, 0, e);
+ } // end catch
+
+ } // end encodeBytes
+
+/* ******** D E C O D I N G M E T H O D S ******** */
+
+ /**
+ * Decodes four bytes from array <var>source</var>
+ * and writes the resulting bytes (up to three of them)
+ * to <var>destination</var>.
+ * The source and destination arrays can be manipulated
+ * anywhere along their length by specifying
+ * <var>srcOffset</var> and <var>destOffset</var>.
+ * This method does not check to make sure your arrays
+ * are large enough to accomodate <var>srcOffset</var> + 4 for
+ * the <var>source</var> array or <var>destOffset</var> + 3 for
+ * the <var>destination</var> array.
+ * This method returns the actual number of bytes that
+ * were converted from the Base64 encoding.
+ *
+ * @param source the array to convert
+ * @param srcOffset the index where conversion begins
+ * @param destination the array to hold the conversion
+ * @param destOffset the index where output will be put
+ * @return the number of decoded bytes converted
+ */
+ private int decode4to3(byte[] source, int srcOffset, byte[] destination, int destOffset)
+ {
+ // Example: Dk==
+ if (source[srcOffset + 2] == PADDING_CHAR)
+ {
+ // Two ways to do the same thing. Don't know which way I like best.
+ //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
+ // | ( ( DECODABET[ source[ srcOffset + 1] ] << 24 ) >>> 12 );
+ int outBuff = ((DECODABET[source[srcOffset]] & 0xFF) << 18)
+ | ((DECODABET[source[srcOffset + 1]] & 0xFF) << 12);
+
+ destination[destOffset] = (byte)(outBuff >>> 16);
+ return 1;
+ }
+
+ // Example: DkL=
+ else if (source[srcOffset + 3] == PADDING_CHAR)
+ {
+ // Two ways to do the same thing. Don't know which way I like best.
+ //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
+ // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
+ // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 );
+ int outBuff = ((DECODABET[source[srcOffset]] & 0xFF) << 18)
+ | ((DECODABET[source[srcOffset + 1]] & 0xFF) << 12)
+ | ((DECODABET[source[srcOffset + 2]] & 0xFF) << 6);
+
+ destination[destOffset] = (byte)(outBuff >>> 16);
+ destination[destOffset + 1] = (byte)(outBuff >>> 8);
+ return 2;
+ }
+
+ // Example: DkLE
+ else
+ {
+ try
+ {
+ // Two ways to do the same thing. Don't know which way I like best.
+ //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
+ // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
+ // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 )
+ // | ( ( DECODABET[ source[ srcOffset + 3 ] ] << 24 ) >>> 24 );
+ int outBuff = ((DECODABET[source[srcOffset]] & 0xFF) << 18)
+ | ((DECODABET[source[srcOffset + 1]] & 0xFF) << 12)
+ | ((DECODABET[source[srcOffset + 2]] & 0xFF) << 6)
+ | ((DECODABET[source[srcOffset + 3]] & 0xFF));
+
+
+ destination[destOffset] = (byte)(outBuff >> 16);
+ destination[destOffset + 1] = (byte)(outBuff >> 8);
+ destination[destOffset + 2] = (byte)(outBuff);
+
+ return 3;
+ }
+ catch (Exception e)
+ {
+ System.out.println("" + source[srcOffset] + ": " + (DECODABET[source[srcOffset]]));
+ System.out.println("" + source[srcOffset + 1] + ": " + (DECODABET[source[srcOffset + 1]]));
+ System.out.println("" + source[srcOffset + 2] + ": " + (DECODABET[source[srcOffset + 2]]));
+ System.out.println("" + source[srcOffset + 3] + ": " + (DECODABET[source[srcOffset + 3]]));
+ return -1;
+ } //e nd catch
+ }
+ } // end decodeToBytes
+
+ /**
+ * Very low-level access to decoding ASCII characters in
+ * the form of a byte array.
+ *
+ * @param source The Base64 encoded data
+ * @param off The offset of where to begin decoding
+ * @param len The length of characters to decode
+ * @return decoded data
+ */
+ private byte[] decode(int len, int off, byte[] source)
+ {
+ int len34 = len * 3 / 4;
+ byte[] outBuff = new byte[len34]; // Upper limit on size of output
+ int outBuffPosn = 0;
+
+ byte[] b4 = new byte[4];
+ int b4Posn = 0;
+ int i = 0;
+ byte sbiCrop = 0;
+ byte sbiDecode = 0;
+ for (i = off; i < off + len; i++)
+ {
+ sbiCrop = (byte)(source[i] & 0x7f); // Only the low seven bits
+ sbiDecode = DECODABET[sbiCrop];
+
+ if (sbiDecode >= WHITE_SPACE_ENC) // White space, padding character or better
+ {
+ if (sbiDecode >= PADDING_CHAR_ENC)
+ {
+ b4[b4Posn++] = sbiCrop;
+ if (b4Posn > 3)
+ {
+ outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn);
+ b4Posn = 0;
+
+ // If that was the padding char, break out of 'for' loop
+ if (sbiCrop == PADDING_CHAR)
+ {
+ break;
+ }
+ } // end if: quartet built
+
+ } // end if: padding character or better
+
+ } // end if: white space, padding character or better
+ else
+ {
+ System.err.println("Bad Base64 input character at " + i + ": " + source[i] + "(decimal)");
+ return null;
+ } // end else:
+ } // each input character
+
+ byte[] out = new byte[outBuffPosn];
+ System.arraycopy(outBuff, 0, out, 0, outBuffPosn);
+ return out;
+ }
+
+ /**
+ * Very low-level access to decoding ASCII characters in
+ * the form of a byte array.
+ *
+ * @param source The Base64 encoded data
+ * @param off The offset of where to begin decoding
+ * @param len The length of characters to decode
+ * @param urlSafeEncodingWasUsed <code>true</code> if the URL-safe was used to encode the data to be decoded
+ * @return decoded data
+ */
+ public static byte[] decode(byte[] source, int off, int len, boolean urlSafeEncodingWasUsed)
+ {
+ return getBase64(urlSafeEncodingWasUsed).decode(len, off, source);
+ } // end decode
+
+ /**
+ * Decodes data from Base64 notation
+ *
+ * @param s the string to decode
+ * @param urlSafeEncodingWasUsed <code>true</code> if the URL-safe was used to encode the data to be decoded
+ * @return the decoded data
+ */
+ public static byte[] decode(String s, boolean urlSafeEncodingWasUsed)
+ {
+ byte[] bytes;
+ try
+ {
+ bytes = s.getBytes(PREFERRED_ENCODING);
+ } // end try
+ catch (java.io.UnsupportedEncodingException uee)
+ {
+ bytes = s.getBytes();
+ } // end catch
+
+ // Decode
+ bytes = decode(bytes, 0, bytes.length, urlSafeEncodingWasUsed);
+
+ return bytes;
+ } // end decode
+
+ /**
+ * Decodes data from Base64 notation
+ *
+ * @param s the string to decode
+ * @return the decoded data
+ */
+ public static byte[] decode(String s)
+ {
+ return decode(s, false);
+ } // end decode
+
+} // end class Base64
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import org.jboss.portal.common.net.URLTools;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7379 $
+ */
+public class CLResourceLoader implements ResourceLoader
+{
+
+ private final ClassLoader loader;
+
+ public CLResourceLoader(ClassLoader loader)
+ {
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("No classloader provided");
+ }
+ this.loader = loader;
+ }
+
+ public CLResourceLoader()
+ {
+ this(Thread.currentThread().getContextClassLoader());
+ }
+
+ public InputStream load(String location)
+ {
+ return loader.getResourceAsStream(location);
+ }
+
+ public LoaderResource getResource(String location)
+ {
+ if (location == null)
+ {
+ throw new IllegalArgumentException("Location is null");
+ }
+ URL url = loader.getResource(location);
+ return new URLResource(location, url);
+ }
+
+ private static class URLResource extends LoaderResource
+ {
+
+ private final URL url;
+
+ public URLResource(String location, URL url)
+ {
+ super(location);
+ this.url = url;
+ }
+
+ public boolean exists()
+ {
+ return URLTools.exists(url);
+ }
+
+ public InputStream asInputStream() throws IllegalStateException
+ {
+ if (!exists())
+ {
+ throw new IllegalStateException("Resource " + location + " does not exist");
+ }
+ try
+ {
+ return url.openStream();
+ }
+ catch (IOException e)
+ {
+ throw new IllegalStateException("Cannot open resource stream " + location);
+ }
+ }
+
+ public String toString()
+ {
+ return "Resource[" + location + "," + url + "]";
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Collection;
+
+/**
+ * An helper to build collection of object in a simple manner.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7234 $
+ */
+public class CollectionBuilder<C extends Collection<V>, V>
+{
+
+ /** . */
+ private C collection;
+
+ private CollectionBuilder(C collection)
+ {
+ this.collection = collection;
+ }
+
+ public static <C extends Collection<V>, V> CollectionBuilder<C, V> create(C collection)
+ {
+ return new CollectionBuilder<C, V>(collection);
+ }
+
+ public static <V> CollectionBuilder<ArrayList<V>, V> arrayList()
+ {
+ return new CollectionBuilder<ArrayList<V>, V>(new ArrayList<V>());
+ }
+
+ public static <V> CollectionBuilder<ArrayList<V>, V> arrayList(V v)
+ {
+ CollectionBuilder<ArrayList<V>, V> builder = new CollectionBuilder<ArrayList<V>, V>(new ArrayList<V>());
+ builder.add(v);
+ return builder;
+ }
+
+ public static <V> CollectionBuilder<LinkedList<V>, V> linkedList()
+ {
+ return new CollectionBuilder<LinkedList<V>, V>(new LinkedList<V>());
+ }
+
+ public static <V> CollectionBuilder<LinkedList<V>, V> linkedList(V v)
+ {
+ CollectionBuilder<LinkedList<V>, V> builder = new CollectionBuilder<LinkedList<V>, V>(new LinkedList<V>());
+ builder.add(v);
+ return builder;
+ }
+
+ public static <V> CollectionBuilder<HashSet<V>, V> hashSet()
+ {
+ return new CollectionBuilder<HashSet<V>, V>(new HashSet<V>());
+ }
+
+ public static <V> CollectionBuilder<HashSet<V>, V> hashSet(V v)
+ {
+ CollectionBuilder<HashSet<V>, V> builder = new CollectionBuilder<HashSet<V>, V>(new HashSet<V>());
+ builder.add(v);
+ return builder;
+ }
+
+ /**
+ * Add the object to the collection.
+ *
+ * @param o the object to add
+ * @return the builder
+ */
+ public CollectionBuilder<C, V> add(V o)
+ {
+ collection.add(o);
+ return this;
+ }
+
+ /**
+ * Add all the objects to the collection.
+ *
+ * @param all the objects to add
+ * @return the builder
+ */
+ public CollectionBuilder<C, V> addAll(Collection<V> all)
+ {
+ collection.addAll(all);
+ return this;
+ }
+
+ public C get()
+ {
+ return collection;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionMap.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionMap.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionMap.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,272 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A map of collections.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class CollectionMap<K, V> implements Serializable
+{
+
+ /** The underlying map. */
+ private final Map<K, Collection<V>> map;
+ /** An optional comparator. */
+ protected Comparator<V> comparator;
+
+ public CollectionMap()
+ {
+ map = init(null);
+ }
+
+ public CollectionMap(CollectionMap<K, V> other) throws IllegalArgumentException
+ {
+ if (other == null)
+ {
+ throw new IllegalArgumentException("Cannot copy null argument");
+ }
+ map = init(other);
+ }
+
+ public CollectionMap(CollectionMap<K, V> other, Comparator<V> comparator) throws IllegalArgumentException
+ {
+ this(other);
+ initComparator(comparator);
+ }
+
+ public CollectionMap(Comparator<V> comparator)
+ {
+ this();
+
+ initComparator(comparator);
+ }
+
+ private void initComparator(Comparator<V> comparator)
+ {
+ //
+ if (comparator == null)
+ {
+ throw new IllegalArgumentException("No null comparator allowed");
+ }
+
+ //
+ this.comparator = comparator;
+ }
+
+ /**
+ * Add an object in the set keyed under the specified key.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final void put(K key, V o) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ Collection<V> collection = map.get(key);
+ if (collection == null)
+ {
+ collection = newCollection();
+ map.put(key, collection);
+ }
+ add(collection, o);
+ }
+
+ /** Return the set of keys. */
+ public final Set<K> keySet()
+ {
+ return map.keySet();
+ }
+
+ /**
+ * Remove the entire set of objects specified by the key.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final void remove(K key) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ map.remove(key);
+ }
+
+ /**
+ * Remove an object in the set keyed under the specified key.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final void remove(K key, Object o) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ Collection<V> collection = map.get(key);
+
+ //
+ if (collection != null)
+ {
+ remove(collection, o);
+
+ //
+ if (collection.isEmpty())
+ {
+ map.remove(key);
+ }
+ }
+ }
+
+ /**
+ * Return true if the specified set contains the object o.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final boolean contains(K key, Object o) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ Collection<V> collection = map.get(key);
+
+ //
+ if (collection == null)
+ {
+ return false;
+ }
+ else
+ {
+ return collection.contains(o);
+ }
+ }
+
+ /** Return the collection specified by the key. */
+ public Collection<V> get(K key)
+ {
+ return map.get(key);
+ }
+
+ /**
+ * Return an iterator over the values in the set specified by the key.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final Iterator<V> iterator(final K key)
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ Collection<V> set = map.get(key);
+
+ //
+ if (set == null)
+ {
+ Set<V> tmp = Collections.emptySet();
+ return tmp.iterator();
+ }
+ else
+ {
+ final Iterator<V> iterator = set.iterator();
+ return new Iterator<V>()
+ {
+ public boolean hasNext()
+ {
+ return iterator.hasNext();
+ }
+
+ public V next()
+ {
+ return iterator.next();
+ }
+
+ public void remove()
+ {
+ iterator.remove();
+ if (!iterator.hasNext())
+ {
+ map.remove(key);
+ }
+ }
+ };
+ }
+ }
+
+ private Map<K, Collection<V>> init(CollectionMap<K, V> other)
+ {
+ Map<K, Collection<V>> map = new HashMap<K, Collection<V>>();
+
+ //
+ if (other != null)
+ {
+ for (Map.Entry<K, Collection<V>> entry : other.map.entrySet())
+ {
+ K key = entry.getKey();
+ Collection<V> value = entry.getValue();
+ map.put(key, newCollection(value));
+ }
+ }
+
+ //
+ return map;
+ }
+
+ protected abstract void add(Collection<V> c, V o);
+
+ /**
+ * Removes an object from the collection. The type of the object to remove is intentionnally <code>Object</code> and
+ * not the parameterized type <code><V></code> because the Collection<V> interface is designed that way.
+ *
+ * @param c the collection to remove from
+ * @param o the object to remove
+ */
+ protected abstract void remove(Collection<V> c, Object o);
+
+ protected abstract Collection<V> newCollection();
+
+ protected abstract Collection<V> newCollection(Collection<V> other);
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * Describe how content should be interpreted.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6704 $
+ */
+public class ContentInfo
+{
+
+ /** The content type. */
+ private final MediaType contentType;
+
+ public ContentInfo(MediaType contentType)
+ {
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException("Content type cannot be null");
+ }
+ this.contentType = contentType;
+ }
+
+ public MediaType getContentType()
+ {
+ return contentType;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * Signals that an error occured during a conversion.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public class ConversionException extends Exception
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 4647584036804084315L;
+
+ public ConversionException()
+ {
+ }
+
+ public ConversionException(String message)
+ {
+ super(message);
+ }
+
+ public ConversionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ConversionException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CopyOnWriteRegistry.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CopyOnWriteRegistry.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/CopyOnWriteRegistry.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,134 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Implementation of a registry that implements copy on write semantics.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class CopyOnWriteRegistry
+{
+
+ /** . */
+ private volatile Map content;
+
+ public CopyOnWriteRegistry()
+ {
+ content = new HashMap();
+ }
+
+ /**
+ * Register an object.
+ *
+ * @param key the registration key
+ * @param object the registered object
+ * @return true if the registration was made
+ * @throws IllegalArgumentException if the one argument is null
+ */
+ public synchronized boolean register(Object key, Object object) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (object == null)
+ {
+ throw new IllegalArgumentException("No null value accepted");
+ }
+ if (content.containsKey(key))
+ {
+ return false;
+ }
+ Map tmp = new HashMap(content);
+ tmp.put(key, object);
+ content = tmp;
+ return true;
+ }
+
+ /**
+ * Unregister an object.
+ *
+ * @param key the registration key
+ * @return true if the unregistration was made
+ * @throws IllegalArgumentException if the key is null
+ */
+ public synchronized Object unregister(Object key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (content.containsKey(key))
+ {
+ Map tmp = new HashMap(content);
+ Object registration = tmp.remove(key);
+ content = tmp;
+ return registration;
+ }
+ return null;
+ }
+
+ /**
+ * Return an unmodifiable set containing the keys.
+ *
+ * @return the keys
+ */
+ public Set getKeys()
+ {
+ return Collections.unmodifiableSet(content.keySet());
+ }
+
+ /**
+ * Return an unmodifable collection containing the registrations.
+ *
+ * @return the registrations
+ */
+ public Collection getRegistrations()
+ {
+ return Collections.unmodifiableCollection(content.values());
+ }
+
+ /**
+ * Return a registration or null if it does not exist.
+ *
+ * @param key the registration key
+ * @return the registeted object
+ * @throws IllegalArgumentException if the key is null
+ */
+ public Object getRegistration(Object key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ return content.get(key);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.ResourceBundle;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6817 $
+ */
+public class EmptyResourceBundle extends ResourceBundle
+{
+
+ /** . */
+ public static final EmptyResourceBundle INSTANCE = new EmptyResourceBundle();
+
+ protected Object handleGetObject(String key)
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key accepted");
+ }
+ return null;
+ }
+
+ public Enumeration getKeys()
+ {
+ return Tools.EMPTY_ENUMERATION;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7395 $
+ */
+public class Exceptions
+{
+
+ public static Throwable unwrap(Throwable throwable) throws IllegalArgumentException
+ {
+ if (throwable == null)
+ {
+ throw new IllegalArgumentException("Cannot unwrap null throwable");
+ }
+ for (Throwable current = throwable;current != null;current = current.getCause())
+ {
+ throwable = current;
+ }
+ return throwable;
+ }
+
+ public static String toHTML(Throwable throwable)
+ {
+ return toHTML(throwable, false);
+ }
+
+ public static String toHTML(Throwable throwable, boolean deep)
+ {
+ StringBuffer tmp = new StringBuffer();
+ appendHTMLTo(tmp, throwable, deep);
+ return tmp.toString();
+ }
+
+ public static void appendHTMLTo(StringBuffer buffer, Throwable throwable)
+ {
+ appendHTMLTo(buffer, throwable, false);
+ }
+
+ public static void appendHTMLTo(StringBuffer buffer, Throwable throwable, boolean deep)
+ {
+ buffer.append("<div><pre style=\"text-align:left;\"><code>");
+ while (throwable != null)
+ {
+ buffer.append(throwable.toString()).append('\n');
+ StackTraceElement[] elts = throwable.getStackTrace();
+ for (int j = 0; j < elts.length; j++)
+ {
+ StackTraceElement elt = elts[j];
+ buffer.append("\tat ").append(elt).append("\n");
+ }
+ throwable = throwable.getCause();
+ }
+ buffer.append("</code></pre></div>");
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * A non expected format prevents a conversion to happen.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public class FormatConversionException extends ConversionException
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6642578306452728356L;
+
+ public FormatConversionException()
+ {
+ }
+
+ public FormatConversionException(String message)
+ {
+ super(message);
+ }
+
+ public FormatConversionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public FormatConversionException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/IteratorStatus.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/IteratorStatus.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/IteratorStatus.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * An java.util.Iterator wrapper which keep additional state associated with the wrapped iterator. The implementation of
+ * the Iterator interface delegates all operations to the wrapped iterator.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class IteratorStatus implements Iterator
+{
+
+ /** The real iterator. */
+ private final Iterator delegate;
+
+ /** The iterator index. */
+ private int index;
+
+ /**
+ * @param delegate the wrapped iterator
+ * @throws IllegalArgumentException if the wrapped iterator is null
+ */
+ public IteratorStatus(Iterator delegate) throws IllegalArgumentException
+ {
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException("No iterator is provided");
+ }
+ this.delegate = delegate;
+ this.index = -1;
+ }
+
+ /**
+ * @param c the collection to iterate
+ * @throws IllegalArgumentException if the collection is null
+ */
+ public IteratorStatus(Collection c) throws IllegalArgumentException
+ {
+ if (c == null)
+ {
+ throw new IllegalArgumentException("No collection is provided");
+ }
+ this.delegate = c.iterator();
+ this.index = -1;
+ }
+
+ /**
+ * Returns the index of the last element obtained or -1 if no element has been returned yet.
+ *
+ * @return the index of the last element obtained
+ */
+ public int getIndex()
+ {
+ return index;
+ }
+
+ /**
+ * Returns true if one element has been iterated.
+ *
+ * @return true if one element has been iterated.
+ * @throws IllegalStateException if no element has been iterated yet
+ */
+ public boolean isFirst() throws IllegalStateException
+ {
+ if (index == -1)
+ {
+ throw new IllegalStateException("No element has been iterated so far");
+ }
+ return index == 0;
+ }
+
+ public boolean hasNext()
+ {
+ return delegate.hasNext();
+ }
+
+ public Object next()
+ {
+ Object o = delegate.next();
+
+ // Increment after getting the next object since the call to the next() method
+ // can throw a NoSuchElementException
+ index++;
+ return o;
+ }
+
+ public void remove()
+ {
+ delegate.remove();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,391 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public abstract class LazyMap implements Map
+{
+
+ /** . */
+ private Map delegate;
+
+ /** . */
+ private boolean modified;
+
+ /**
+ * Create the delegate. There are no guarantees that this method will be called only once.
+ */
+ protected abstract Map createDelegate();
+
+ public boolean isModified()
+ {
+ return modified;
+ }
+
+ private Map getDelegate()
+ {
+ if (delegate == null)
+ {
+ delegate = createDelegate();
+ }
+ if (delegate == null)
+ {
+ throw new IllegalStateException("No delegate obtained");
+ }
+ return delegate;
+ }
+
+ public int size()
+ {
+ return getDelegate().size();
+ }
+
+ public boolean isEmpty()
+ {
+ return getDelegate().isEmpty();
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return getDelegate().containsKey(key);
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return getDelegate().containsValue(value);
+ }
+
+ public Object get(Object key)
+ {
+ return getDelegate().get(key);
+ }
+
+ public Object put(Object key, Object value)
+ {
+ modified = true;
+ return getDelegate().put(key, value);
+ }
+
+ public Object remove(Object key)
+ {
+ modified = true;
+ return getDelegate().remove(key);
+ }
+
+ public void putAll(Map t)
+ {
+ modified = true;
+ getDelegate().putAll(t);
+ }
+
+ public void clear()
+ {
+ modified = true;
+ getDelegate().clear();
+ }
+
+ public Set keySet()
+ {
+ return new Set()
+ {
+ Set keySet = getDelegate().keySet();
+
+ public int size()
+ {
+ return keySet.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return keySet.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ return keySet.contains(o);
+ }
+
+ public Iterator iterator()
+ {
+ return keySet.iterator();
+ }
+
+ public Object[] toArray()
+ {
+ return keySet.toArray();
+ }
+
+ public Object[] toArray(Object[] a)
+ {
+ return keySet.toArray(a);
+ }
+
+ public boolean add(Object o)
+ {
+ modified = true;
+ return keySet.add(o);
+ }
+
+ public boolean remove(Object o)
+ {
+ modified = true;
+ return keySet.remove(o);
+ }
+
+ public boolean containsAll(Collection c)
+ {
+ return keySet.containsAll(c);
+ }
+
+ public boolean addAll(Collection c)
+ {
+ modified = true;
+ return keySet.addAll(c);
+ }
+
+ public boolean retainAll(Collection c)
+ {
+ return keySet.retainAll(c);
+ }
+
+ public boolean removeAll(Collection c)
+ {
+ modified = true;
+ return keySet.removeAll(c);
+ }
+
+ public void clear()
+ {
+ modified = true;
+ keySet.clear();
+ }
+
+ public boolean equals(Object o)
+ {
+ return keySet.equals(o);
+ }
+
+ public int hashCode()
+ {
+ return keySet.hashCode();
+ }
+ };
+ }
+
+ public Collection values()
+ {
+ return new Collection()
+ {
+ /** . */
+ Collection values = getDelegate().values();
+
+ public int size()
+ {
+ return values.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return values.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ return values.contains(o);
+ }
+
+ public Iterator iterator()
+ {
+ return values.iterator();
+ }
+
+ public Object[] toArray()
+ {
+ return values.toArray();
+ }
+
+ public Object[] toArray(Object[] a)
+ {
+ return values.toArray(a);
+ }
+
+ public boolean add(Object o)
+ {
+ modified = true;
+ return values.add(o);
+ }
+
+ public boolean remove(Object o)
+ {
+ modified = true;
+ return values.remove(o);
+ }
+
+ public boolean containsAll(Collection c)
+ {
+ return values.containsAll(c);
+ }
+
+ public boolean addAll(Collection c)
+ {
+ modified = true;
+ return values.addAll(c);
+ }
+
+ public boolean removeAll(Collection c)
+ {
+ modified = true;
+ return values.removeAll(c);
+ }
+
+ public boolean retainAll(Collection c)
+ {
+ return values.retainAll(c);
+ }
+
+ public void clear()
+ {
+ modified = true;
+ values.clear();
+ }
+
+ public boolean equals(Object o)
+ {
+ return values.equals(o);
+ }
+
+ public int hashCode()
+ {
+ return values.hashCode();
+ }
+ };
+ }
+
+ public Set entrySet()
+ {
+ return new Set()
+ {
+ /** . */
+ Set entrySet = getDelegate().entrySet();
+
+ public int size()
+ {
+ return entrySet.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return entrySet.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ return entrySet.contains(o);
+ }
+
+ public Iterator iterator()
+ {
+ return entrySet.iterator();
+ }
+
+ public Object[] toArray()
+ {
+ return entrySet.toArray();
+ }
+
+ public Object[] toArray(Object[] a)
+ {
+ return entrySet.toArray(a);
+ }
+
+ public boolean add(Object o)
+ {
+ modified = true;
+ return entrySet.add(o);
+ }
+
+ public boolean remove(Object o)
+ {
+ modified = true;
+ return entrySet.remove(o);
+ }
+
+ public boolean containsAll(Collection c)
+ {
+ return entrySet.containsAll(c);
+ }
+
+ public boolean addAll(Collection c)
+ {
+ modified = true;
+ return entrySet.addAll(c);
+ }
+
+ public boolean retainAll(Collection c)
+ {
+ modified = true;
+ return entrySet.retainAll(c);
+ }
+
+ public boolean removeAll(Collection c)
+ {
+ modified = true;
+ return entrySet.removeAll(c);
+ }
+
+ public void clear()
+ {
+ modified = true;
+ entrySet.clear();
+ }
+
+ public boolean equals(Object o)
+ {
+ return entrySet.equals(o);
+ }
+
+ public int hashCode()
+ {
+ return entrySet.hashCode();
+ }
+ };
+ }
+
+ public boolean equals(Object o)
+ {
+ return getDelegate().equals(o);
+ }
+
+ public int hashCode()
+ {
+ return getDelegate().hashCode();
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ListMap.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ListMap.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ListMap.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,94 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ListMap<K, V> extends CollectionMap<K, V>
+{
+
+ public ListMap()
+ {
+ }
+
+ public ListMap(SetMap<K, V> other) throws IllegalArgumentException
+ {
+ super(other);
+ }
+
+ public ListMap(SetMap<K, V> other, Comparator<V> comparator) throws IllegalArgumentException
+ {
+ super(other, comparator);
+ }
+
+ public ListMap(Comparator<V> comparator)
+ {
+ super(comparator);
+ }
+
+ /** Return the list specified by the key. */
+ public List<V> get(K key)
+ {
+ return (List<V>)super.get(key);
+ }
+
+ protected void add(Collection<V> c, V o)
+ {
+ c.add(o);
+
+ //
+ if (comparator != null)
+ {
+ Collections.sort((List<V>)c, comparator);
+ }
+ }
+
+ protected void remove(Collection<V> c, Object o)
+ {
+ c.remove(o);
+
+ //
+ if (comparator != null)
+ {
+ Collections.sort((List<V>)c, comparator);
+ }
+ }
+
+ protected Collection<V> newCollection()
+ {
+ return new ArrayList<V>();
+ }
+
+ protected Collection<V> newCollection(Collection<V> other)
+ {
+ return new ArrayList<V>(other);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,194 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.xml.XMLTools;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Represent a resource that may or not exist.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7380 $
+ */
+public abstract class LoaderResource
+{
+
+ protected final String location;
+
+ private final Logger log = Logger.getLogger(getClass());
+
+ public LoaderResource(String location)
+ {
+ if (location == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.location = location;
+ }
+
+ public abstract boolean exists();
+
+ public abstract InputStream asInputStream() throws IllegalStateException;
+
+ public String getLocation()
+ {
+ return location;
+ }
+
+ public Document asDocument(DocumentBuilder builder) throws IllegalStateException
+ {
+ if (!exists())
+ {
+ throw new IllegalStateException("Resource " + location + " does not exist");
+ }
+ InputStream in = null;
+ try
+ {
+ in = IOTools.safeBufferedWrapper(asInputStream());
+ return builder.parse(in);
+ }
+ catch (SAXException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot parse stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ catch (IOException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot access stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ public Properties asProperties() throws IllegalStateException
+ {
+ return asProperties(false);
+ }
+
+ public Properties asProperties(boolean xml) throws IllegalStateException
+ {
+ if (!exists())
+ {
+ throw new IllegalStateException("Resource " + location + " does not exist");
+ }
+ InputStream in = null;
+
+ log.debug("Loading resource: " + location);
+
+ try
+ {
+ in = IOTools.safeBufferedWrapper(asInputStream());
+ Properties props;
+ if (xml)
+ {
+ DocumentBuilder builder = XMLTools.getDocumentBuilderFactory().newDocumentBuilder();
+ Document doc = asDocument(builder);
+ props = XMLTools.loadXMLProperties(doc);
+ }
+ else
+ {
+ props = new Properties();
+ props.load(in);
+ }
+ log.debug("Finished loading resource: " + location);
+ return props;
+ }
+ catch (ParserConfigurationException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot parse xml stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ catch (IOException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot access stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ public String asString() throws IllegalStateException
+ {
+ return asString(null);
+ }
+
+ public String asString(String enc) throws IllegalStateException
+ {
+ if (!exists())
+ {
+ throw new IllegalStateException("Resource " + location + " does not exist");
+ }
+ InputStream in = null;
+
+ log.debug("Loading resource: " + location);
+
+ try
+ {
+ in = IOTools.safeBufferedWrapper(asInputStream());
+ ByteArrayOutputStream out = new ByteArrayOutputStream(in.available());
+ IOTools.copy(in, out);
+ String result;
+ if (enc == null)
+ {
+ result = out.toString();
+ }
+ else
+ {
+ result = out.toString(enc);
+ }
+
+ log.debug("Finished loading resource: " + location);
+ return result;
+ }
+ catch (IOException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot access stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MapAccessor.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MapAccessor.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MapAccessor.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Map;
+
+/**
+ * An interface which defines how a map can be accessed.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface MapAccessor<K, V>
+{
+ /**
+ * Return the accessed map.
+ *
+ * @param writable whether or not the Map will be accessed for a write-type (e.g., put, remove...) operation.
+ * This allows for lazy initialization via a create-on-write mechanism.
+ * @return a non null map
+ */
+ Map<K, V> getMap(boolean writable);
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MapBuilder.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MapBuilder.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MapBuilder.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * An helper to build map in a simple manner.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MapBuilder<M extends Map<K, V>, K, V>
+{
+
+ /** . */
+ private final M map;
+
+ private MapBuilder(M map)
+ {
+ if (map == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.map = map;
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<HashMap<K, V>, K, V> hashMap()
+ {
+ return new MapBuilder<HashMap<K, V>, K, V>(new HashMap<K, V>());
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<HashMap<K, V>, K, V> hashMap(K k, V v)
+ {
+ MapBuilder<HashMap<K, V>, K, V> builder = new MapBuilder<HashMap<K, V>, K, V>(new HashMap<K, V>());
+ builder.put(k, v);
+ return builder;
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<TreeMap<K, V>, K, V> treeMap()
+ {
+ return new MapBuilder<TreeMap<K, V>, K, V>(new TreeMap<K, V>());
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<TreeMap<K, V>, K, V> treeMap(K k, V v)
+ {
+ MapBuilder<TreeMap<K, V>, K, V> builder = new MapBuilder<TreeMap<K, V>, K, V>(new TreeMap<K, V>());
+ builder.put(k, v);
+ return builder;
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<LinkedHashMap<K, V>, K, V> linkedHashMap()
+ {
+ return new MapBuilder<LinkedHashMap<K, V>, K, V>(new LinkedHashMap<K, V>());
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<LinkedHashMap<K, V>, K, V> linkedHashMap(K k, V v)
+ {
+ MapBuilder<LinkedHashMap<K, V>, K, V> builder = new MapBuilder<LinkedHashMap<K, V>, K, V>(new LinkedHashMap<K, V>());
+ builder.put(k, v);
+ return builder;
+ }
+
+ public static <M extends Map<K, V>, K, V> MapBuilder<M, K, V> create(M m)
+ {
+ return new MapBuilder<M, K, V>(m);
+ }
+
+ /**
+ * Add the object to the collection.
+ *
+ * @param key the key
+ * @param value the value
+ * @return the builder
+ */
+ public MapBuilder<M, K, V> put(K key, V value)
+ {
+ map.put(key, value);
+ return this;
+ }
+
+ /**
+ * Add all the objects to the collection.
+ *
+ * @param all the entries to add
+ * @return the builder
+ */
+ public MapBuilder<M, K, V> putAll(M all)
+ {
+ map.putAll(all);
+ return this;
+ }
+
+ public M get()
+ {
+ return map;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MarkupInfo.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MarkupInfo.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MarkupInfo.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * Extends content to describe markup content.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MarkupInfo extends ContentInfo
+{
+
+ /** The charset. */
+ private final String charset;
+
+ public MarkupInfo(MediaType contentType, String charset)
+ {
+ super(contentType);
+
+ //
+ if (charset == null)
+ {
+ throw new IllegalArgumentException("Charset cannot be null");
+ }
+
+ //
+ this.charset = charset;
+ }
+
+ public String getCharset()
+ {
+ return charset;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,342 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This is a immutable wrapper to the activation MimeTpye.
+ * <p>This class contains some extensions to the activation MimeType, such as the typesafe enum
+ * pattern, and allows for a mime type to specify allowed sub types.</p>
+ *
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @version $LastChangedRevision: 6704 $, $LastChangedDate: 2007-03-15 23:36:31 +0100 (Thu, 15 Mar 2007) $
+ * @see javax.activation.MimeType
+ * see also ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/
+ */
+public final class MediaType
+{
+ private static Map allowedTypes = new HashMap();
+ private static Map supportedExtensions = new HashMap();
+
+ /**
+ * Mime type 'Any' maps to an accept mime type of '*.*' (used by IE for css, images, etc.)
+ */
+ public static final MediaType ANY =
+ new MediaType("*", "*", new String[]{});
+
+ /**
+ * Mime type xhtml
+ */
+ public static final MediaType XHTML = new MediaType("application", "xhtml+xml",
+ new String[]{"xhtml"});
+
+ /**
+ * Mime type html
+ */
+ public static final MediaType HTML = new MediaType("text", "html",
+ new String[]{"html", "htm"},
+ new MediaType[]{XHTML});
+
+ /**
+ * Mime type form (application/x-www-form-urlencoded)
+ */
+ public static final MediaType FORM =
+ new MediaType("application", "x-www-form-urlencoded", new String[]{});
+
+ /**
+ * Mime type xml
+ */
+ public static final MediaType XML = new MediaType("text", "xml", new String[]{"xml"},
+ new MediaType[]{XHTML});
+
+ /**
+ * Mime type wml
+ */
+ public static final MediaType WML = new MediaType("text", "vnd.wap.wml",
+ new String[]{"wml"});
+
+ /**
+ * Mime type css
+ */
+ public static final MediaType CSS = new MediaType("text", "css",
+ new String[]{"css"});
+
+ /**
+ * Mime type text
+ */
+ public static final MediaType TEXT = new MediaType("text", "plain",
+ new String[]{"txt"});
+
+ /**
+ * Mime type js
+ */
+ public static final MediaType JS = new MediaType("text", "javascript",
+ new String[]{"js"});
+
+ /**
+ * Mime type svg
+ */
+ public static final MediaType SVG = new MediaType("image", "svg+xml",
+ new String[]{"svg"});
+
+ /**
+ * Mime type jpeg
+ */
+ public static final MediaType JPEG = new MediaType("image", "jpeg",
+ new String[]{"jpeg", "jpg"});
+
+ /**
+ * Mime type gif
+ */
+ public static final MediaType GIF = new MediaType("image", "gif",
+ new String[]{"gif"});
+
+ /**
+ * Mime type png
+ */
+ public static final MediaType PNG = new MediaType("image", "png",
+ new String[]{"png"});
+
+ /**
+ * Mime type wbmp
+ */
+ public static final MediaType WBMP = new MediaType("image", "vnd.wap.wbmp",
+ new String[]{"wbpm"});
+
+ /**
+ * Mime type rss
+ */
+ public static final MediaType RSS = new MediaType("application", "rss+xml",
+ new String[]{});
+
+ /**
+ * Mime type ico (see http://filext.com/detaillist.php?extdetail=ICO)
+ */
+ public static final MediaType ICO = new MediaType("application", "octet-stream",
+ new String[]{"ico"});
+ private MimeType m_mimeType = null;
+ private MediaType[] m_allowedSubTypes;
+ private Set allowSubTypeSet;
+
+ /**
+ * Construct a mime type instance without any allowed subtypes.
+ *
+ * @param primaryType the primary type of the mime type (i.e. 'text')
+ * @param subType the sub type of the mime type (i.e. 'html')
+ */
+ private MediaType(String primaryType, String subType, String[] extensions)
+ {
+ try
+ {
+ m_mimeType = new MimeType(primaryType, subType);
+ m_allowedSubTypes = null;
+ allowSubTypeSet = null;
+ allowedTypes.put(m_mimeType.getBaseType(), this);
+ for (int i = 0; i < extensions.length; i++)
+ {
+ supportedExtensions.put(extensions[i], this);
+ }
+ }
+ catch (MimeTypeParseException e)
+ {
+ // +++TODO handle this , but where ?
+ System.out.println(e.getMessage());
+ }
+ }
+
+ /**
+ * Construct a mime type with the provided allowed subtypes.
+ *
+ * @param primaryType the primary type of the mime type (i.e. 'text')
+ * @param subType the sub type of the mime type (i.e. 'html')
+ * @param allowedSubTypes an array of <code>MediaType</code>s to allow as valid subtypes of this type
+ */
+ private MediaType(String primaryType, String subType, String[] extensions, MediaType[] allowedSubTypes)
+ {
+ this(primaryType, subType, extensions);
+ // only if the mime type was sucessfully created
+ if (m_mimeType != null)
+ {
+ m_allowedSubTypes = allowedSubTypes;
+ allowSubTypeSet = new HashSet(Arrays.asList(allowedSubTypes));
+ }
+ }
+
+ /**
+ * Get the mime type for the presented string, if the string contains a valid mime type.
+ *
+ * @param mimeType the <code>java.lang.String</code> to parse into a <code>RegistryMimeTpye</code>
+ * @return the <code>RegistryMimeTpye</code> that matches with the presented string
+ * @throws MimeTypeParseException if the presented mimetype is not supported
+ * @throws IllegalArgumentException if the presented string is null or empty
+ */
+ public static MediaType parseMimeType(String mimeType) throws MimeTypeParseException
+ {
+ if (mimeType == null || "".equals(mimeType))
+ {
+ throw new IllegalArgumentException("no valid mime type provided");
+ }
+
+ String type = mimeType.trim().toLowerCase();
+ if (allowedTypes.keySet().contains(type))
+ {
+ return (MediaType)allowedTypes.get(type);
+ }
+
+ throw new MimeTypeParseException("Type [" + mimeType + "] not supported");
+ }
+
+ /**
+ * Get the mime type for the presented string.
+ * <p>The string is handles as a file name extension. example: 'xml' returns MediaType.XML</p>
+ *
+ * @param extension the <code>java.lang.String</code> to parse into a <code>RegistryMimeTpye</code>
+ * @return the <code>RegistryMimeTpye</code> that matches with the presented string
+ * @throws MimeTypeParseException if the presented mimetype is not supported
+ * @throws IllegalArgumentException if the presented string is null or empty
+ */
+ public static MediaType parseMimeTypeByExtension(String extension)
+ throws MimeTypeParseException
+ {
+ if (extension == null || "".equals(extension))
+ {
+ throw new IllegalArgumentException("no valid mime type provided [" + extension + "]");
+ }
+
+ String ext = extension.trim().toLowerCase();
+ if (supportedExtensions.keySet().contains(ext))
+ {
+ return (MediaType)supportedExtensions.get(ext);
+ }
+
+ throw new MimeTypeParseException("Extension [" + extension + "] not supported");
+ }
+
+ /**
+ * Get a list of allowed sub types for the passed mime type.
+ *
+ * @param mimeType the <code>RegistryMimeTpye</code> to get the list of allowed subtypes for
+ * @return a <code>java.util.List</code> of <code>PortalMimeTpye</code>s
+ */
+ public static List getAllowedSubTypes(MediaType mimeType)
+ {
+ if (mimeType.m_allowedSubTypes == null)
+ {
+ return Collections.EMPTY_LIST;
+ }
+ else
+ {
+ return Collections.unmodifiableList(Arrays.asList(mimeType.m_allowedSubTypes));
+ }
+ }
+
+ /**
+ * Get a list of allowed sub types for for this mime type.
+ *
+ * @return a <code>java.util.List</code> of <code>RegistryMimeTpye</code>s
+ */
+ public List getAllowedSubTypes()
+ {
+ if (m_allowedSubTypes == null)
+ {
+ return Collections.EMPTY_LIST;
+ }
+ else
+ {
+ return Collections.unmodifiableList(Arrays.asList(m_allowedSubTypes));
+ }
+ }
+
+ /**
+ * Return true if the allowed sub types contains the specified media type.
+ *
+ * @param other the sub type to test
+ * @return true if it is an allowed sub type
+ */
+ public boolean isAllowedSubType(MediaType other)
+ {
+ if (equals(other))
+ {
+ return true;
+ }
+ if (allowSubTypeSet == null)
+ {
+ return false;
+ }
+ return allowSubTypeSet.contains(other);
+ }
+
+ /**
+ * Get the String representation of the mime type (i.e. 'text/html').
+ *
+ * @return the mime type as a <code>java.lang.String</code>
+ * @see java.lang.Object#toString
+ */
+ public String toString()
+ {
+ return m_mimeType.getBaseType();
+ }
+
+ /**
+ * compare the parameter with this instance and see if they are equals.
+ *
+ * @param o the Object to compare this instance to
+ * @return true if this and the paramters o are equal
+ * @see java.lang.Object#equals
+ */
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (!(o instanceof MediaType))
+ {
+ return false;
+ }
+
+ final MediaType type = (MediaType)o;
+
+ return m_mimeType.equals(type.m_mimeType);
+ }
+
+ /**
+ * Get the hascode for this mime type.
+ *
+ * @return an int value representing this instance
+ * @see java.lang.Object#hashCode
+ */
+ public int hashCode()
+ {
+ return m_mimeType.hashCode();
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * A null pointer prevents a conversion to happen.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public class NullConversionException extends ConversionException
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 5948866940278003857L;
+
+ public NullConversionException()
+ {
+ }
+
+ public NullConversionException(String message)
+ {
+ super(message);
+ }
+
+ public NullConversionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public NullConversionException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,274 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * A decorator that enforce the map content to be <String,String[]>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6671 $
+ */
+public class ParameterMap extends TypedMap<String, String[], String, String[]>
+{
+
+ /** . */
+ private static final KeyConverter keyConv = new KeyConverter();
+
+ /** . */
+ private static final ValueConverter valueConv1 = new ValueConverter(false, false);
+
+ /** . */
+ private static final ValueConverter valueConv2 = new ValueConverter(false, true);
+
+ /** . */
+ private static final ValueConverter valueConv3 = new ValueConverter(true, false);
+
+ /** . */
+ private static final ValueConverter valueConv4 = new ValueConverter(true, true);
+
+ private static ValueConverter getValueConverter(boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ if (cloneInternalValue)
+ {
+ if (cloneExternalValue)
+ {
+ return valueConv4;
+ }
+ else
+ {
+ return valueConv3;
+ }
+ }
+ else
+ {
+ if (cloneExternalValue)
+ {
+ return valueConv2;
+ }
+ else
+ {
+ return valueConv1;
+ }
+ }
+ }
+
+ /** . */
+ private final boolean cloneInternalValue;
+
+ /** . */
+ private final boolean cloneExternalValue;
+
+ public ParameterMap(boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ this(new HashMap<String, String[]>(), cloneInternalValue, cloneExternalValue);
+ }
+
+ public ParameterMap(MapAccessor<String, String[]> accessor)
+ {
+ this(accessor, false, false);
+ }
+
+ public ParameterMap(Map<String, String[]> delegate)
+ {
+ this(delegate, false, false);
+ }
+
+ public ParameterMap()
+ {
+ this(false, false);
+ }
+
+ public ParameterMap(MapAccessor<String, String[]> accessor, boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ super(accessor, keyConv, getValueConverter(cloneInternalValue, cloneExternalValue));
+
+ //
+ this.cloneInternalValue = cloneInternalValue;
+ this.cloneExternalValue = cloneExternalValue;
+ }
+
+ public ParameterMap(Map<String, String[]> delegate, boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ super(delegate, keyConv, getValueConverter(cloneInternalValue, cloneExternalValue));
+
+ //
+ this.cloneInternalValue = cloneInternalValue;
+ this.cloneExternalValue = cloneExternalValue;
+ }
+
+ /**
+ * Return true if values returned by the map are cloned.
+ *
+ * @return true if returned values are cloned
+ */
+ public boolean isCloneInternalValue()
+ {
+ return cloneInternalValue;
+ }
+
+ public boolean isCloneExternalValue()
+ {
+ return cloneExternalValue;
+ }
+
+ private static class KeyConverter extends Converter<String, String>
+ {
+ protected String getInternal(String external) throws IllegalArgumentException, ClassCastException
+ {
+ return external;
+ }
+ protected String getExternal(String internal)
+ {
+ return internal;
+ }
+ protected boolean equals(String left, String right)
+ {
+ return left.equals(right);
+ }
+ }
+
+ private static class ValueConverter extends Converter<String[], String[]>
+ {
+
+ /** . */
+ private final boolean cloneInternalValue;
+
+ /** . */
+ private final boolean cloneExternalValue;
+
+ private ValueConverter(boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ this.cloneInternalValue = cloneInternalValue;
+ this.cloneExternalValue = cloneExternalValue;
+ }
+
+ /**
+ * Only check are made to the value. The only valid values accepted
+ * are string arrays with non zero length and containing non null
+ * values.
+ *
+ * @param external
+ * @return
+ * @throws NullPointerException if the value is null
+ * @throws ClassCastException if the value type is not an array of string
+ * @throws IllegalArgumentException if the array length is zero or one of the array value is null
+ */
+ protected String[] getInternal(String[] external) throws IllegalArgumentException, ClassCastException, NullPointerException
+ {
+ if (external.length == 0)
+ {
+ throw new IllegalArgumentException("Array must not be zero length");
+ }
+
+ //
+ for (int i = external.length - 1;i >= 0;i--)
+ {
+ if (external[i] == null)
+ {
+ throw new IllegalArgumentException("No null entries allowed in String[]");
+ }
+ }
+
+ //
+ if (cloneExternalValue)
+ {
+ external = external.clone();
+ }
+
+ //
+ return external;
+ }
+
+ protected String[] getExternal(String[] internal)
+ {
+ if (cloneInternalValue)
+ {
+ internal = internal.clone();
+ }
+ return internal;
+ }
+
+ protected boolean equals(String[] left, String[] right)
+ {
+ return Arrays.equals(left, right);
+ }
+ }
+
+ /**
+ * Return the parameter value or null if it does not exist.
+ *
+ * @param name the parameter name
+ * @return the parameter value or null if it does not exist
+ * @throws NullPointerException if the name is null
+ */
+ public String getValue(String name) throws IllegalArgumentException
+ {
+ String[] value = get(name);
+ return value == null ? null : value[0];
+ }
+
+ /**
+ * Return the parameter values or null if it does not exist.
+ *
+ * @param name the value to get
+ * @return the parameter values
+ * @throws NullPointerException if the name is null
+ */
+ public String[] getValues(String name) throws IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name");
+ }
+ return get(name);
+ }
+
+ /**
+ * Set the a parameter value.
+ *
+ * @param name the parameter name
+ * @param value the parameter value
+ * @throws NullPointerException if the name or the value is null
+ */
+ public void setValue(String name, String value)
+ {
+ put(name, new String[]{value});
+ }
+
+ /**
+ * Set the parameter values. This method does not make a defensive copy of the values.
+ *
+ * @param name the parameter name
+ * @param values the parameter values
+ * @throws NullPointerException if the name or the value is null
+ * @throws IllegalArgumentException if the values length is zero or contains a null element
+ */
+ public void setValues(String name, String[] values) throws NullPointerException, IllegalArgumentException
+ {
+ put(name, values);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 5757 $
+ * @since 2.4 (May 31, 2006)
+ */
+public class ParameterValidation
+{
+ public static void throwIllegalArgExceptionIfNullOrEmpty(String valueToCheck, String valueName, String contextName)
+ {
+ if (isNullOrEmpty(valueToCheck))
+ {
+ throw new IllegalArgumentException((contextName != null ? contextName + " r" : "R") + "equires a non-null, non-empty " + valueName);
+ }
+ }
+
+ /** @since 2.6 */
+ public static boolean isNullOrEmpty(String valueToCheck)
+ {
+ return valueToCheck == null || valueToCheck.length() == 0;
+ }
+
+ public static void throwIllegalArgExceptionIfNull(Object objectToTest, String name)
+ {
+ if (objectToTest == null)
+ {
+ throw new IllegalArgumentException("Must pass a non null " + name);
+ }
+ }
+
+ /** @since 2.4.1 */
+ public static void throwIllegalArgExceptionIfNullOrEmpty(Object[] array, String name)
+ {
+ if (array == null)
+ {
+ throw new IllegalArgumentException("Must pass a non-null " + name);
+ }
+ if (array.length == 0)
+ {
+ throw new IllegalArgumentException("Must pass a non-empty " + name);
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Encapsulate info about a proxy and provide a way to instantiate it.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ProxyInfo
+{
+
+ private static final Class[] EMPTY_SIGNATURE = new Class[0];
+ private static final Class[] EQUALS_SIGNATURE = new Class[]{Object.class};
+ private static final Class[] INVOCATION_HANDLER_SIGNATURE = new Class[]{InvocationHandler.class};
+
+ /** The proxy constructor. */
+ private final Constructor ctor;
+
+ /** The proxy toString method. */
+ private final Method toString;
+
+ /** The proxy hashCode method. */
+ private final Method hashCode;
+
+ /** The proxy equals method. */
+ private final Method equals;
+
+ public ProxyInfo(Class clazz) throws Exception
+ {
+ this.ctor = clazz.getConstructor(INVOCATION_HANDLER_SIGNATURE);
+
+ //
+ toString = Object.class.getMethod("toString", EMPTY_SIGNATURE);
+ hashCode = Object.class.getMethod("hashCode", EMPTY_SIGNATURE);
+ equals = Object.class.getMethod("equals", EQUALS_SIGNATURE);
+ }
+
+ /**
+ * Instantiate a proxy.
+ *
+ * @param handler the invocation handler
+ * @return the proxy
+ */
+ public Object instantiate(InvocationHandler handler) throws IllegalAccessException, InvocationTargetException, InstantiationException
+ {
+ return ctor.newInstance(new Object[]{handler});
+ }
+
+ public Method getToString()
+ {
+ return toString;
+ }
+
+ public Method getHashCode()
+ {
+ return hashCode;
+ }
+
+ public Method getEquals()
+ {
+ return equals;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.io.InputStream;
+
+/**
+ * A generic interface which define loading capabilities of resources.
+ * The name format must follow the regular expression : ^(/[-a-zA-Z0-9_\.]+)+$
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6653 $
+ */
+public interface ResourceLoader
+{
+
+ /** Helper to validate name. */
+ String REGEX_NAME_VALIDATOR = "^(/[-a-zA-Z0-9_\\.]+)+$";
+
+ /**
+ * Returns an InputStream or null if not found.
+ */
+ InputStream load(String location);
+
+ /**
+ *
+ */
+ LoaderResource getResource(String location);
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+/**
+ * A map of set. This object does not handle synchronization and use HashMap and HashSet as underlying data structures;
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7322 $
+ */
+public class SetMap<K, V> extends CollectionMap<K, V>
+{
+
+ /** Version. */
+ static final long serialVersionUID = -7239767000556095977L;
+
+ public SetMap()
+ {
+ }
+
+ public SetMap(SetMap<K, V> other) throws IllegalArgumentException
+ {
+ super(other);
+ }
+
+ public SetMap(SetMap<K, V> other, Comparator<V> comparator) throws IllegalArgumentException
+ {
+ super(other);
+
+ //
+ if (comparator == null)
+ {
+ throw new IllegalArgumentException("No null comparator allowed");
+ }
+
+ //
+ this.comparator = comparator;
+ }
+
+ public SetMap(Comparator<V> comparator)
+ {
+ super();
+
+ //
+ if (comparator == null)
+ {
+ throw new IllegalArgumentException("No null comparator allowed");
+ }
+
+ //
+ this.comparator = comparator;
+ }
+
+ /** Return the set specified by the key. */
+ public Set<V> get(K key)
+ {
+ return (Set<V>)super.get(key);
+ }
+
+ protected void add(Collection<V> c, V o)
+ {
+ c.add(o);
+ }
+
+ protected void remove(Collection<V> c, Object o)
+ {
+ c.remove(o);
+ }
+
+ protected Collection<V> newCollection()
+ {
+ if (comparator == null)
+ {
+ return new HashSet<V>();
+ }
+ else
+ {
+ return new TreeSet<V>(comparator);
+ }
+ }
+
+ protected Collection<V> newCollection(Collection<V> other)
+ {
+ if (comparator == null)
+ {
+ return new HashSet<V>(other);
+ }
+ else
+ {
+ SortedSet<V> set = new TreeSet<V>(comparator);
+ set.addAll(other);
+ return set;
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/SimpleMapAccessor.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/SimpleMapAccessor.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/SimpleMapAccessor.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleMapAccessor<K, V> implements MapAccessor<K, V>
+{
+
+ /** . */
+ private Map<K, V> delegate;
+
+ public SimpleMapAccessor(Map<K, V> delegate)
+ {
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.delegate = delegate;
+ }
+
+ public Map<K, V> getMap(boolean writable)
+ {
+ return delegate;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,929 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.logging.Log4JWriter;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.Array;
+import java.math.BigInteger;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.UnknownHostException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7377 $
+ */
+public class Tools
+{
+
+ public static final int DEFAULT_BUFFER_SIZE = 512;
+
+ public static final Logger log = Logger.getLogger(Tools.class);
+
+ /** 16 chars long VMID. */
+ public static final String VMID = VMID();
+
+ private static String VMID()
+ {
+ try
+ {
+ BigInteger bi = BigInteger.valueOf(0);
+ byte[] address = java.net.InetAddress.getLocalHost().getAddress();
+ for (int i = 0; i < 4; i++)
+ {
+ bi = bi.shiftLeft(8);
+ bi = bi.add(BigInteger.valueOf(address[i]));
+ }
+ bi = bi.shiftLeft(32);
+ int code = System.identityHashCode(new Object());
+ bi = bi.add(BigInteger.valueOf(code));
+ byte[] bytes = bi.toByteArray();
+ StringBuffer buffer = new StringBuffer();
+ char[] chars = "0123456789ABCDEF".toCharArray();
+ for (int i = 0; i < bytes.length; i++)
+ {
+ buffer.append(chars[(bytes[i] & 0xF0) >> 4]).append(chars[bytes[i] & 0xF]);
+ }
+ return buffer.toString();
+ }
+ catch (UnknownHostException e)
+ {
+ e.printStackTrace(System.err);
+ throw new Error("Cannot create VMID");
+ }
+ }
+
+ public static final Enumeration EMPTY_ENUMERATION = new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ return false;
+ }
+
+ public Object nextElement()
+ {
+ throw new NoSuchElementException();
+ }
+ };
+
+ public static final Iterator EMPTY_ITERATOR = new Iterator()
+ {
+ public boolean hasNext()
+ {
+ return false;
+ }
+
+ public Object next()
+ {
+ throw new NoSuchElementException();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ public static final ResourceBundle EMPTY_BUNDLE = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ return null;
+ }
+
+ public Enumeration getKeys()
+ {
+ return EMPTY_ENUMERATION;
+ }
+ };
+
+ public static <E> Enumeration<E> toEnumeration(final Iterator<E> iterator)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return new Enumeration<E>()
+ {
+ public boolean hasMoreElements()
+ {
+ return iterator.hasNext();
+ }
+
+ public E nextElement()
+ {
+ return iterator.next();
+ }
+ };
+ }
+
+ public static <E> Enumeration<E> toEnumeration(final E[] objects)
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return new Enumeration<E>()
+ {
+ int index = 0;
+
+ public boolean hasMoreElements()
+ {
+ return index < objects.length;
+ }
+
+ public E nextElement()
+ {
+ if (index < objects.length)
+ {
+ return objects[index++];
+ }
+ else
+ {
+ throw new NoSuchElementException();
+ }
+ }
+ };
+ }
+
+ public static <E> Enumeration<E> toEnumeration(final E o)
+ {
+ return new Enumeration<E>()
+ {
+ boolean hasMore = true;
+
+ public boolean hasMoreElements()
+ {
+ return hasMore;
+ }
+
+ public E nextElement()
+ {
+ if (hasMore)
+ {
+ hasMore = false;
+ }
+ else
+ {
+ throw new NoSuchElementException();
+ }
+ return o;
+ }
+ };
+ }
+
+ public static <E> Set<E> toSet(Enumeration<E> e)
+ {
+ if (e == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ HashSet<E> set = new HashSet<E>();
+ while (e.hasMoreElements())
+ {
+ set.add(e.nextElement());
+ }
+ return set;
+ }
+
+ public static <E> Set<E> toSet(E... objects)
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ HashSet<E> set = new HashSet<E>();
+ for (E object : objects)
+ {
+ set.add(object);
+ }
+ return set;
+ }
+
+ /**
+ * Transforms an iterator into an unordered Set
+ *
+ * @param iterator The iterator to transform
+ * @return A HashSet
+ */
+ public static <E> Set<E> toSet(Iterator<E> iterator)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return toSet(iterator, false);
+ }
+
+ /**
+ * Transforms an iterator into a Set
+ *
+ * @param iterator The iterator to transform
+ * @param preserveOrder true if the set must respect the ordering of the iterator
+ * @return a LinkedHashSet if ordered is true, a HashSet otherwise
+ */
+ public static <E> Set<E> toSet(Iterator<E> iterator, boolean preserveOrder)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Set<E> set;
+ if (preserveOrder)
+ {
+ set = new LinkedHashSet<E>();
+ }
+ else
+ {
+ set = new HashSet<E>();
+ }
+ while (iterator.hasNext())
+ {
+ set.add(iterator.next());
+ }
+ return set;
+ }
+
+ public static <E> List<E> toList(Enumeration<E> e)
+ {
+ if (e == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<E> list = new ArrayList<E>();
+ while (e.hasMoreElements())
+ {
+ list.add(e.nextElement());
+ }
+ return list;
+ }
+
+ public static <E> List<E> toList(Iterator<E> iterator)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<E> list = new ArrayList<E>();
+ while (iterator.hasNext())
+ {
+ list.add(iterator.next());
+ }
+ return list;
+ }
+
+ public static <E> List<E> toList(E... objects)
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<E> list = new ArrayList<E>(objects.length);
+ for (E object : objects)
+ {
+ list.add(object);
+ }
+ return list;
+ }
+
+ /**
+ * Consider remove this method as it cannot be generified.
+ *
+ * @param i
+ * @return
+ */
+ @Deprecated
+ public static Object[] toArray(Iterator i)
+ {
+ // This method cannot be generified.
+ return toList(i).toArray();
+ }
+
+ /**
+ * Returns a singleton iterator.
+ *
+ * @param o the singleton object
+ * @return the iterator
+ */
+ public static <E> Iterator<E> iterator(final E o)
+ {
+ return new Iterator<E>()
+ {
+ /** The status of the iterator. */
+ boolean done = false;
+
+ public boolean hasNext()
+ {
+ return !done;
+ }
+
+ public E next()
+ {
+ if (done)
+ {
+ throw new NoSuchElementException("Already iterated");
+ }
+ done = true;
+ return o;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("read only");
+ }
+ };
+ }
+
+ /**
+ * Returns an iterator over the array elements.
+ *
+ * @param objects the array containing the objects to iterate on
+ * @return the iterator
+ * @throws IllegalArgumentException if the object array is null or the specified range is not valid
+ */
+ public static <E> Iterator<E> iterator(final E... objects) throws IllegalArgumentException
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException("No null object array");
+ }
+ return iterator(objects, 0, objects.length);
+ }
+
+ /**
+ * Returns an iterator over the array elements within the specified range. The range is considered as valid
+ * if the from argument is greater or equals than zero, the to argument is lesser or equals than array size
+ * and the from argument is lesser or equals to the to argument.
+ *
+ * @param objects the array containing the objects to iterate on
+ * @param from the inclusive start index
+ * @param to the exclusive stop index
+ * @return the iterator
+ * @throws IllegalArgumentException if the object array is null or the specified range is not valid or if the range is not valid
+ */
+ public static <E> Iterator<E> iterator(final E[] objects, final int from, final int to) throws IllegalArgumentException
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException("No null object array");
+ }
+ if (from > to || from < 0 || to > objects.length)
+ {
+ throw new IllegalArgumentException("Invalid range [" + from + "," + to + "] for array of length " + objects.length);
+ }
+ return new Iterator<E>()
+ {
+ /** . */
+ int index = from;
+
+ public boolean hasNext()
+ {
+ return index < to;
+ }
+
+ public E next()
+ {
+ if (index >= to)
+ {
+ throw new NoSuchElementException("Index is greater than the array length");
+ }
+ return objects[index++];
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("read only");
+ }
+ };
+ }
+
+ public static int computeStringHash(int hash, String s)
+ {
+ char[] chars = s.toCharArray();
+ int length = chars.length;
+ for (int i = 0; i < length; i++)
+ {
+ char c = chars[i];
+ hash = 31 * hash + c;
+ }
+ return hash;
+ }
+
+ /**
+ * Computes an md5 hash of a string.
+ *
+ * @param text the hashed string
+ * @return the string hash
+ * @throws NullPointerException if text is null
+ */
+ public static byte[] md5(String text)
+ {
+ // arguments check
+ if (text == null)
+ {
+ throw new NullPointerException("null text");
+ }
+
+ try
+ {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(text.getBytes());
+ return md.digest();
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ log.error("Cannot find MD5 algorithm", e);
+ throw new RuntimeException("Cannot find MD5 algorithm");
+ }
+ }
+
+ /**
+ * Computes an md5 hash and returns the result as a string in hexadecimal format.
+ *
+ * @param text the hashed string
+ * @return the string hash
+ * @throws NullPointerException if text is null
+ */
+ public static String md5AsHexString(String text)
+ {
+ return toHexString(md5(text));
+ }
+
+ /**
+ * Computes a hash with specified algorighm and returns the result as a string in hexadecimal format
+ *
+ * @param text
+ * @param algorithm
+ * @param encoding
+ * @return
+ * @throws NoSuchAlgorithmException
+ */
+ public static String hashAndEncodeString(String text, String algorithm, String encoding) throws NoSuchAlgorithmException
+ {
+ // arguments check
+ if (text == null)
+ {
+ throw new NullPointerException("null text");
+ }
+ if (algorithm == null)
+ {
+ throw new NullPointerException("null algorithm");
+ }
+ if (encoding == null)
+ {
+ throw new NullPointerException("null encoding");
+ }
+
+ MessageDigest md = MessageDigest.getInstance(algorithm);
+ md.update(text.getBytes());
+ byte[] encoded = md.digest();
+
+ if ("HEX".equalsIgnoreCase(encoding))
+ {
+ return toHexString(encoded);
+ }
+ //TODO: add base64 support here
+ else
+ {
+ throw new IllegalArgumentException("Not supported encoding: " + encoding);
+ }
+
+ }
+
+
+ /**
+ * Returns a string in the hexadecimal format.
+ *
+ * @param bytes the converted bytes
+ * @return the hexadecimal string representing the bytes data
+ * @throws IllegalArgumentException if the byte array is null
+ */
+ public static String toHexString(byte[] bytes)
+ {
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("byte array must not be null");
+ }
+ StringBuffer hex = new StringBuffer(bytes.length * 2);
+ for (int i = 0; i < bytes.length; i++)
+ {
+ hex.append(Character.forDigit((bytes[i] & 0XF0) >> 4, 16));
+ hex.append(Character.forDigit((bytes[i] & 0X0F), 16));
+ }
+ return hex.toString();
+ }
+
+ /**
+ * Returns a byte array converted from the hexadecimal format.
+ *
+ * @param hex the string to convert
+ * @return the byte array corresponding
+ * @throws IllegalArgumentException if the string is null or does not have the good format
+ */
+ public static byte[] fromHexString(String hex)
+ {
+ if (hex == null)
+ {
+ throw new IllegalArgumentException("Hex string must not be null");
+ }
+ if (hex.length() % 2 == 1)
+ {
+ throw new IllegalArgumentException("Hex string length is not even : " + hex.length());
+ }
+ int index = 0;
+ byte[] bytes = new byte[hex.length() / 2];
+ for (int i = 0; i < bytes.length; i++)
+ {
+ char chigh = hex.charAt(index++);
+ int high = Character.digit(chigh, 16);
+ if (high == -1)
+ {
+ throw new IllegalArgumentException("Hex string contains a bad char : " + chigh);
+ }
+ char clow = hex.charAt(index++);
+ int low = Character.digit(clow, 16);
+ if (low == -1)
+ {
+ throw new IllegalArgumentException("Hex string contains a bad char : " + clow);
+ }
+ byte value = (byte)((high << 4) + low);
+ bytes[i] = value;
+ }
+ return bytes;
+ }
+
+ /**
+ *
+ */
+ public static String generateTemporaryHash(String value, long time)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException("id must not be null");
+ }
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(time);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ return md5AsHexString(value + calendar.getTimeInMillis());
+ }
+
+ /**
+ *
+ */
+ public static boolean confirmTemporaryHash(String hash, String value, long time)
+ {
+ if (hash == null)
+ {
+ return false;
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("value must not be null");
+ }
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(time);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ String expected = md5AsHexString(value + calendar.getTimeInMillis());
+ if (expected.equals(hash))
+ {
+ return true;
+ }
+ calendar.add(Calendar.HOUR_OF_DAY, -1);
+ expected = md5AsHexString(value + calendar.getTimeInMillis());
+ return expected.equals(hash);
+ }
+
+ public static String getShortNameOf(Class clazz)
+ {
+ return clazz.getSimpleName();
+ }
+
+ public static String getPackageOf(Class clazz)
+ {
+ String name = clazz.getName();
+ int index = name.lastIndexOf('.');
+ if (index != -1)
+ {
+ name = name.substring(0, index);
+ }
+ else
+ {
+ name = "";
+ }
+ return name;
+ }
+
+ public static String buildClassLoaderInfo(ClassLoader loader)
+ {
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("no loader");
+ }
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("ClassLoader[Name=").append(loader.getClass().getName());
+ buffer.append(",HashCode=").append(loader.hashCode());
+ buffer.append(",IdentityHashCode=").append(System.identityHashCode(loader));
+ if (loader instanceof URLClassLoader)
+ {
+ URLClassLoader urlLoader = (URLClassLoader)loader;
+ URL[] urls = urlLoader.getURLs();
+ for (int i = 0; i < urls.length; i++)
+ {
+ URL url = urls[i];
+ buffer.append(",URL(").append(i).append(")=").append(url);
+ }
+ }
+ try
+ {
+ Class uclClass = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.mx.loading.UnifiedClassLoader");
+ Class loaderClass = loader.getClass();
+ if (uclClass.isAssignableFrom(loaderClass))
+ {
+ URL url = (URL)loaderClass.getMethod("getURL", new Class[0]).invoke(loader, new Object[0]);
+ buffer.append(",GetURL=").append(url);
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot get UCL infos", e);
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ public static String dumpClassLoaderHierarchyInfo(ClassLoader loader)
+ {
+ StringWriter writer = new StringWriter();
+ dumpClassLoaderHierarchyInfo(writer, loader);
+ return writer.toString();
+ }
+
+ public static void dumpClassLoaderHierarchyInfo(Writer writer, ClassLoader loader)
+ {
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("no writer");
+ }
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("no loader");
+ }
+
+ //
+ PrintWriter pw = null;
+ if (writer instanceof PrintWriter)
+ {
+ pw = (PrintWriter)writer;
+ }
+ else
+ {
+ pw = new PrintWriter(writer);
+ }
+
+ pw.println("<classloader-dump>");
+ while (loader != null)
+ {
+ pw.println(buildClassLoaderInfo(loader));
+ loader = loader.getParent();
+ }
+ pw.print("</classloader-dump>");
+ pw.flush();
+ }
+
+ public static void dumpClassLoaderHierarchyInfo(Logger log, ClassLoader loader)
+ {
+ Writer writer = new Log4JWriter(log, Level.DEBUG);
+ dumpClassLoaderHierarchyInfo(writer, loader);
+ }
+
+ public static void dumpClassLoaderHierarchyInfo(Logger log, Level level, ClassLoader loader)
+ {
+ Writer writer = new Log4JWriter(log, level);
+ dumpClassLoaderHierarchyInfo(writer, loader);
+ }
+
+ /**
+ * Replace occurence in a string.
+ *
+ * @param string the source string
+ * @param pattern the replaced pattern
+ * @param replacement the replacement text
+ * @return the new string
+ */
+ public static String replace(String string, String pattern, String replacement)
+ {
+ StringBuffer buffer = new StringBuffer(string.length());
+ int previous = 0;
+ int current = string.indexOf(pattern);
+ while (current != -1)
+ {
+ buffer.append(string.substring(previous, current));
+ buffer.append(replacement);
+ previous = current + pattern.length();
+ current = string.indexOf(pattern, previous);
+ }
+ buffer.append(string.substring(previous));
+ return buffer.toString();
+ }
+
+ /**
+ * Append an object to an array of objects. The original array is not modified. The returned array
+ * will be of the same component type of the provided array and its first n elements where n is the size
+ * of the provided array will be the elements of the provided array. The last element of the array will be
+ * the provided object to append.
+ *
+ * @param array the array to augment
+ * @param o the object to append
+ * @return a new array
+ * @throws IllegalArgumentException if the array is null
+ * @throws ClassCastException if the appended object class prevents it from being added to the array
+ */
+ public static <E> E[] appendTo(E[] array, E o) throws IllegalArgumentException, ClassCastException
+ {
+ if (array == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Class componentType = array.getClass().getComponentType();
+ if (o != null && !componentType.isAssignableFrom(o.getClass()))
+ {
+ throw new ClassCastException("Object with class " + o.getClass().getName() + " cannot be casted to class " + componentType.getName());
+ }
+
+ //
+ E[] copy = (E[])Array.newInstance(componentType, array.length + 1);
+ System.arraycopy(array, 0, copy, 0, array.length);
+ copy[array.length] = o;
+
+ //
+ return copy;
+ }
+
+ /**
+ * Return true if
+ * <ul>
+ * <li>o1 is null and o2 is null</li<
+ * <li>o1 is not null and the invocation of <code>equals(Object o)</code> on o1 wit o2 as argument returns true</li>
+ * </ul>
+ *
+ * @param o1 the first argument
+ * @param o2 the second argument
+ * @return if arguments are equals according to the semantic defined by the method contract
+ */
+ public static boolean safeEquals(Object o1, Object o2)
+ {
+ if (o1 == null)
+ {
+ return o2 == null;
+ }
+ else
+ {
+ return o1.equals(o2);
+ }
+ }
+
+ public static String replaceAllInstancesOfBoundedString(String initial, String prefix, String suffix, String replacement)
+ {
+ return replaceBoundedString(initial, prefix, suffix, replacement, true, false);
+ }
+
+ /**
+ * Todo : define what "bounded" means.
+ *
+ * @param initial
+ * @param prefix
+ * @param suffix
+ * @param replacement
+ * @param replaceIfBoundedStringEmpty
+ * @param keepBoundaries
+ * @return
+ */
+ public static String replaceBoundedString(String initial, String prefix, String suffix, String replacement,
+ boolean replaceIfBoundedStringEmpty, boolean keepBoundaries)
+ {
+ if (initial == null || initial.length() == 0)
+ {
+ return initial;
+ }
+
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(prefix, "prefix", "Tools.replaceBoundedString");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(suffix, "suffix", "Tools.replaceBoundedString");
+ ParameterValidation.throwIllegalArgExceptionIfNull(replacement, "replacement");
+
+ StringBuffer tmp = new StringBuffer(initial);
+ int prefixIndex = tmp.indexOf(prefix);
+ int suffixLength = suffix.length();
+ int prefixLength = prefix.length();
+
+ while (prefixIndex != -1)
+ {
+ int suffixIndex = tmp.indexOf(suffix, prefixIndex);
+
+ if (suffixIndex != -1)
+ {
+ // we don't care about empty bounded strings or prefix and suffix don't delimit an empty String => replace!
+ if (replaceIfBoundedStringEmpty || suffixIndex != prefixIndex + prefixLength)
+ {
+ if (keepBoundaries)
+ {
+ tmp.delete(prefixIndex + prefixLength, suffixIndex);
+ tmp.insert(prefixIndex + prefixLength, replacement);
+ }
+ else
+ {
+ tmp.delete(prefixIndex, suffixIndex + suffixLength);
+ tmp.insert(prefixIndex, replacement);
+ }
+ }
+ }
+
+ prefixIndex = tmp.indexOf(prefix, prefixIndex + prefixLength);
+ }
+
+ return tmp.toString();
+ }
+
+ /**
+ * Determines if value is contained in array.
+ *
+ * todo: correct this method contract in order to make it more reusable, it looks like for now like a method
+ * which has a contract convenient only for some kind of callers.
+ *
+ * 1/ null value should be accepted (or the method should be called isContainedInButNotForNullValue ?)
+ * 2/ null array should not be accepted (or the method should be called isContainedInExceptIfThePassedArrayIsNull ?)
+ *
+ * @param value
+ * @param array
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean isContainedIn(Object value, Object[] array)
+ {
+ if (value == null)
+ {
+ return false;
+ }
+
+ //
+ if (array != null)
+ {
+ for (Object anArray : array)
+ {
+ if (value.equals(anArray))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,783 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import org.jboss.portal.common.NotYetImplemented;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TypedMap<EK, EV, IK, IV> implements Map<EK, EV>
+{
+
+ public abstract static class Converter<E, I>
+ {
+
+ /**
+ * Unwraps the key to the the internal key that will be stored in the map. This method calls the
+ * <code>assertKeyValidity(Object key)</code> and returns the same key. It can be overriden to provide a customized
+ * key that will be used instead of the external key.
+ *
+ * @param external the key to unwrap
+ * @return the unwrapped key
+ * @throws ClassCastException if the class of the specified key prevents it from being stored in this map
+ * @throws IllegalArgumentException if some aspect of this key prevents it from being stored in this map
+ */
+ protected abstract I getInternal(E external) throws IllegalArgumentException, ClassCastException;
+
+ /**
+ * Wrap the internal key into its external representation, by default returns the same key. It can be overriden to
+ * provide a customized key that will be used instead of the internal key.
+ */
+ protected abstract E getExternal(I internal);
+
+ public I unwrap(E external) throws IllegalArgumentException, ClassCastException, NullPointerException
+ {
+ if (external == null)
+ {
+ throw new NullPointerException("No null key accepted");
+ }
+
+ //
+ I internal = getInternal(external);
+
+ //
+ if (internal == null)
+ {
+ throw new IllegalArgumentException("The provided key " + external + " was converted to a null key");
+ }
+
+ //
+ return internal;
+ }
+
+ public E wrap(I internal) throws IllegalStateException
+ {
+ if (internal == null)
+ {
+ throw new IllegalStateException("Got an internal null key");
+ }
+
+ //
+ E external = getExternal(internal);
+
+ //
+ if (external == null)
+ {
+ throw new IllegalStateException("Converted an internal key to a null key " + internal);
+ }
+
+ //
+ return external;
+ }
+
+ public boolean safeEquals(I left, I right)
+ {
+ // Check the internal value, it should not be null
+ return !(left == null || right == null) && equals(left, right);
+ }
+
+ /**
+ * Compare internal values, the passed argument are never null.
+ *
+ * @param left the left value
+ * @param right the right value
+ * @return true if the values are equals
+ */
+ protected abstract boolean equals(I left, I right);
+ }
+
+ /** The map accessor. */
+ private final MapAccessor<IK, IV> accessor;
+
+ /** The key converter. */
+ private final Converter<EK, IK> keyConverter;
+
+ /** The value converter. */
+ private final Converter<EV, IV> valueConverter;
+
+ public TypedMap(MapAccessor<IK, IV> accessor, Converter<EK, IK> keyConverter, Converter<EV, IV> valueConverter)
+ {
+ if (accessor == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (keyConverter == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (valueConverter == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+
+ this.accessor = accessor;
+ this.keyConverter = keyConverter;
+ this.valueConverter = valueConverter;
+ }
+
+ public TypedMap(Map<IK, IV> delegate, Converter<EK, IK> keyConv, Converter<EV, IV> valueConv)
+ {
+ this(new SimpleMapAccessor<IK, IV>(delegate), keyConv, valueConv);
+ }
+
+ public Converter<EK, IK> getKeyConverter()
+ {
+ return keyConverter;
+ }
+
+ public Converter<EV, IV> getValueConverter()
+ {
+ return valueConverter;
+ }
+
+ public final int size()
+ {
+ return accessor.getMap(false).size();
+ }
+
+ public final void clear()
+ {
+ if (!isEmpty())
+ {
+ accessor.getMap(true).clear();
+ }
+ }
+
+ public final boolean isEmpty()
+ {
+ return accessor.getMap(false).isEmpty();
+ }
+
+ public final boolean containsKey(Object key)
+ {
+ EK ek = (EK)key;
+ IK ik = keyConverter.unwrap(ek);
+ return accessor.getMap(false).containsKey(ik);
+ }
+
+ public final Set<EK> keySet()
+ {
+ return new KeySet();
+ }
+
+ public EV put(EK ek, EV ev)
+ {
+ IK ik = keyConverter.unwrap(ek);
+ IV iv = valueConverter.unwrap(ev);
+ iv = accessor.getMap(true).put(ik, iv);
+ return iv == null ? null : valueConverter.wrap(iv);
+ }
+
+ public final EV get(Object key)
+ {
+ EK ek = (EK)key;
+ IK ik = keyConverter.unwrap(ek);
+ IV iv = accessor.getMap(false).get(ik);
+ return iv == null ? null : valueConverter.wrap(iv);
+ }
+
+ public final EV remove(Object key)
+ {
+ EK ek = (EK)key;
+ IK ik = keyConverter.unwrap(ek);
+ IV iv = null;
+ if (!isEmpty())
+ {
+ iv = accessor.getMap(true).remove(ik);
+ }
+ return iv == null ? null : valueConverter.wrap(iv);
+ }
+
+ public final boolean containsValue(Object value)
+ {
+ EV ev = (EV)value;
+ IV iv = valueConverter.unwrap(ev);
+ return accessor.getMap(false).containsValue(iv);
+ }
+
+ public final Set<Entry<EK, EV>> entrySet()
+ {
+ return new TypedEntrySet();
+ }
+
+ public void putAll(Map<? extends EK, ? extends EV> em)
+ {
+ Map<IK, IV> im = convert(em);
+ accessor.getMap(true).putAll(im);
+ }
+
+ public Collection<EV> values()
+ {
+ return new ValueCollection();
+ }
+
+ /** Compare to parameters objects. */
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof Map)
+ {
+ Map<EK, EV> that = (Map<EK,EV>)o;
+ Map<IK, IV> delegate = this.accessor.getMap(false);
+
+ // Must have same sizes
+ if (that.size() != delegate.size())
+ {
+ return false;
+ }
+
+ //
+ for (Entry<EK, EV> thatEntry : that.entrySet())
+ {
+
+ EK thatKey = thatEntry.getKey();
+ EV thatValue = thatEntry.getValue();
+
+ //
+ try
+ {
+ // Unwrap key, mostly for checking its type is correct
+ keyConverter.unwrap(thatKey);
+
+ // Unwrap value
+ IV iv = valueConverter.unwrap(thatValue);
+
+ // Get the internal value
+ IV internalValue = delegate.get(thatKey);
+
+ // Perform value comparison
+ if (!valueConverter.safeEquals(internalValue, iv))
+ {
+ return false;
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ catch (ClassCastException e)
+ {
+ return false;
+ }
+ catch (NullPointerException e)
+ {
+ return false;
+ }
+ }
+
+ //
+ return true;
+ }
+
+ //
+ return false;
+ }
+
+ public String toString()
+ {
+ return accessor.getMap(false).toString();
+ }
+
+ /**
+ * Validates and unwraps the map.
+ *
+ * @param t
+ * @return
+ * @throws IllegalArgumentException
+ * @throws NullPointerException
+ * @throws ClassCastException
+ */
+ protected final Map<IK, IV> convert(Map<? extends EK, ? extends EV> t) throws IllegalArgumentException, NullPointerException, ClassCastException
+ {
+ if (t == null)
+ {
+ throw new NullPointerException("No null map can be accepted");
+ }
+ Map<IK, IV> u = new HashMap<IK, IV>(t.size());
+ for (Entry<? extends EK, ? extends EV> entry : t.entrySet())
+ {
+ IK ik = keyConverter.unwrap(entry.getKey());
+ IV iv = valueConverter.unwrap(entry.getValue());
+ u.put(ik, iv);
+ }
+ return u;
+ }
+
+ /**
+ * Replace the content with the new map which is validated before replacement.
+ *
+ * @param map the replacement map
+ * @throws ClassCastException
+ * @throws NullPointerException
+ * @throws IllegalArgumentException
+ */
+ public void replace(Map<EK, EV> map) throws ClassCastException, NullPointerException, IllegalArgumentException
+ {
+ if (!map.isEmpty())
+ {
+ Map<IK, IV> tmp = convert(map);
+
+ //
+ Map<IK, IV> delegate = accessor.getMap(true);
+ delegate.clear();
+ delegate.putAll(tmp);
+ }
+ }
+
+ /**
+ * Validate the content.
+ *
+ * @throws ClassCastException
+ * @throws NullPointerException
+ * @throws IllegalArgumentException
+ */
+ public void validate() throws ClassCastException, NullPointerException, IllegalArgumentException
+ {
+ for (Entry<IK, IV> entry : accessor.getMap(false).entrySet())
+ {
+ keyConverter.wrap(entry.getKey());
+ valueConverter.wrap(entry.getValue());
+ }
+ }
+
+ public class KeySet implements Set<EK>
+ {
+
+ /** . */
+ private final Set<IK> delegate;
+
+ public KeySet()
+ {
+ this.delegate = TypedMap.this.accessor.getMap(false).keySet();
+ }
+
+ public int size()
+ {
+ return delegate.size();
+ }
+
+ public void clear()
+ {
+ if (!isEmpty())
+ {
+ delegate.clear();
+ }
+ }
+
+ public boolean isEmpty()
+ {
+ return delegate.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ EK ek;
+ try
+ {
+ ek = (EK)o;
+ }
+ catch (ClassCastException e)
+ {
+ return false;
+ }
+ try
+ {
+ IK ik = keyConverter.getInternal(ek);
+ return TypedMap.this.accessor.getMap(false).containsKey(ik);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ catch (ClassCastException e)
+ {
+ return false;
+ }
+ catch (NullPointerException e)
+ {
+ return false;
+ }
+ }
+
+ public Object[] toArray()
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray()");
+ }
+
+ public boolean add(EK ek)
+ {
+ throw new NotYetImplemented("TypedEntrySet.add(Object o)");
+ }
+
+ public boolean remove(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.remove(Object o)");
+ }
+
+ public boolean containsAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.addAll(Collection c)");
+ }
+
+ public boolean addAll(Collection<? extends EK> eks)
+ {
+ throw new NotYetImplemented("TypedEntrySet.containsAll(Collection c)");
+ }
+
+ public boolean removeAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.removeAll(Collection c)");
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ if (c == null)
+ {
+ throw new NullPointerException();
+ }
+
+ //
+ boolean changed = false;
+ for (Iterator i = iterator(); i.hasNext();)
+ {
+ Object key = i.next();
+ if (!c.contains(key))
+ {
+ i.remove();
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ public Iterator<EK> iterator()
+ {
+ return new KeyIterator();
+ }
+
+ public <EK> EK[] toArray(EK a[])
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray(Object a[])");
+ }
+
+ public class KeyIterator implements Iterator<EK>
+ {
+
+ /** . */
+ private final Iterator<IK> delegate;
+
+ public KeyIterator()
+ {
+ this.delegate = KeySet.this.delegate.iterator();
+ }
+
+ public void remove()
+ {
+ delegate.remove();
+ }
+
+ public boolean hasNext()
+ {
+ return delegate.hasNext();
+ }
+
+ public EK next()
+ {
+ IK ik = delegate.next();
+ return keyConverter.wrap(ik);
+ }
+ }
+ }
+
+ public class ValueCollection implements Collection<EV>
+ {
+
+ /** . */
+ private final Collection<IV> delegate;
+
+ public ValueCollection()
+ {
+ this.delegate = TypedMap.this.accessor.getMap(false).values();
+ }
+
+ public int size()
+ {
+ return delegate.size();
+ }
+
+ public void clear()
+ {
+ delegate.clear();
+ }
+
+ public boolean isEmpty()
+ {
+ return delegate.isEmpty();
+ }
+
+ public Object[] toArray()
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray()");
+ }
+
+ public boolean add(EV ev)
+ {
+ throw new NotYetImplemented("TypedEntrySet.add(Object o)");
+ }
+
+ public boolean contains(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.contains(Object o)");
+ }
+
+ public boolean remove(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.remove(Object o)");
+ }
+
+ public boolean addAll(Collection<? extends EV> evs)
+ {
+ throw new NotYetImplemented("TypedEntrySet.addAll(Collection c)");
+ }
+
+ public boolean containsAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.containsAll(Collection c)");
+ }
+
+ public boolean removeAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.removeAll(Collection c)");
+ }
+
+ public boolean retainAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.retainAll(Collection c)");
+ }
+
+ public <T> T[] toArray(T[] ts)
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray(Object a[])");
+ }
+
+ public Iterator<EV> iterator()
+ {
+ return new ValueIterator();
+ }
+
+ public class ValueIterator implements Iterator<EV>
+ {
+
+ /** . */
+ private final Iterator<IV> delegate;
+
+ public ValueIterator()
+ {
+ this.delegate = ValueCollection.this.delegate.iterator();
+ }
+
+ public void remove()
+ {
+ delegate.remove();
+ }
+
+ public boolean hasNext()
+ {
+ return delegate.hasNext();
+ }
+
+ public EV next()
+ {
+ IV iv = delegate.next();
+ return valueConverter.wrap(iv);
+ }
+ }
+ }
+
+ public class TypedEntrySet implements Set<Entry<EK, EV>>
+ {
+
+ /** . */
+ private final Set<Entry<IK, IV>> delegate;
+
+ public TypedEntrySet()
+ {
+ this.delegate = TypedMap.this.accessor.getMap(false).entrySet();
+ }
+
+ public int size()
+ {
+ return delegate.size();
+ }
+
+ public void clear()
+ {
+ if (!isEmpty())
+ {
+ delegate.clear();
+ }
+ }
+
+ public boolean isEmpty()
+ {
+ return delegate.isEmpty();
+ }
+
+ public Object[] toArray()
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray()");
+ }
+
+ public boolean add(Entry<EK, EV> ekevEntry)
+ {
+ throw new NotYetImplemented("TypedEntrySet.add(Object o)");
+ }
+
+ public boolean contains(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.contains(Object o)");
+ }
+
+ public boolean remove(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.remove(Object o)");
+ }
+
+ public boolean addAll(Collection<? extends Entry<EK, EV>> entries)
+ {
+ throw new NotYetImplemented("TypedEntrySet.addAll(Collection c)");
+ }
+
+ public boolean containsAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.containsAll(Collection c)");
+ }
+
+ public boolean removeAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.removeAll(Collection c)");
+ }
+
+ public boolean retainAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.retainAll(Collection c)");
+ }
+
+ public <T> T[] toArray(T[] ts)
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray(Object a[])");
+ }
+
+ public Iterator<Entry<EK, EV>> iterator()
+ {
+ return new TypedEntryIterator();
+ }
+
+ public class TypedEntryIterator implements Iterator<Entry<EK, EV>>
+ {
+
+ /** . */
+ private final Iterator<Entry<IK, IV>> delegate;
+
+ public TypedEntryIterator()
+ {
+ this.delegate = TypedEntrySet.this.delegate.iterator();
+ }
+
+ public void remove()
+ {
+ delegate.remove();
+ }
+
+ public boolean hasNext()
+ {
+ return delegate.hasNext();
+ }
+
+ public Entry<EK, EV> next()
+ {
+ Entry<IK, IV> entry = delegate.next();
+ return new TypedEntry(entry);
+ }
+ }
+
+ public class TypedEntry implements Entry<EK, EV>
+ {
+
+ /** . */
+ private final Entry<IK, IV> delegate;
+
+ public TypedEntry(Entry<IK, IV> delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public int hashCode()
+ {
+ return delegate.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ return delegate.equals(obj);
+ }
+
+ public String toString()
+ {
+ return delegate.toString();
+ }
+
+ public EK getKey()
+ {
+ IK ik = delegate.getKey();
+ return keyConverter.wrap(ik);
+ }
+
+ public EV getValue()
+ {
+ IV iv = delegate.getValue();
+ return valueConverter.wrap(iv);
+ }
+
+ public EV setValue(Object value)
+ {
+ EV ev = (EV)value;
+ IV iv = valueConverter.unwrap(ev);
+ iv = delegate.setValue(iv);
+ return valueConverter.wrap(iv);
+ }
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.net.InetAddress;
+import java.security.SecureRandom;
+
+/**
+ * Adapted from ejb plugin key generated.
+ *
+ * The implementation of UUID key generator
+ * based on the algorithm from Floyd Marinescu's EJB Design Patterns.
+ *
+ * @author <a href="mailto:alex.loubyansky@jboss.org">Alex Loubyansky</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class UUIDGenerator
+{
+
+ // Attributes ---------------------------------------------------
+
+ /** Hex digits */
+ private static final char[] hexDigits = "0123456789ABCDEF".toCharArray();
+
+ // Static --------------------------------------------------------
+
+ /** secure random to provide nonrepeating seed */
+ private SecureRandom seeder;
+
+ /** cached middle value */
+ private String midValue;
+
+ // Constructor --------------------------------------------------
+
+ public UUIDGenerator()
+ {
+ try
+ {
+ // Cache the middle part for UUID
+ StringBuffer buffer = new StringBuffer( 16 );
+
+ // Construct host part of the uuid (8 hex digits)
+ byte[] addr = InetAddress.getLocalHost().getAddress();
+ buffer.append( toHex( toInt(addr), 8 ) );
+
+ // Append the hash code for this object (8 hex digits)
+ buffer.append( toHex( System.identityHashCode(this), 8 ) );
+
+ // Set up midValue
+ midValue = buffer.toString();
+
+ // Load up the randomizer
+ seeder = new SecureRandom();
+ int node = seeder.nextInt();
+ }
+ catch (Exception e)
+ {
+ throw new Error("Not possible");
+ }
+ }
+
+ public String generateKey()
+ {
+ StringBuffer buffer = new StringBuffer(32);
+
+ // Append current time as unsigned int value
+ buffer.append(toHex((int)(System.currentTimeMillis() & 0xFFFFFFFF), 8));
+
+ // Append cached midValue
+ buffer.append( midValue );
+
+ // Append the next random int
+ buffer.append( toHex( seeder.nextInt(), 8 ) );
+
+ // Return the result
+ return buffer.toString();
+ }
+
+ // Private ------------------------------------------------------
+
+ /**
+ * Converts int value to string hex representation
+ */
+ private String toHex(int value, int length)
+ {
+ StringBuffer buffer = new StringBuffer(length);
+ int shift = (length - 1) << 2;
+ int i = -1;
+ while(++i < length)
+ {
+ buffer.append(hexDigits[(value >> shift) & 0x0000000F]);
+ value <<= 4;
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Constructs int value from byte array
+ */
+ private static int toInt( byte[] bytes )
+ {
+ int value = 0;
+ int i = -1;
+ while (++i < bytes.length)
+ {
+ value <<= 8;
+ int b = bytes[ i ] & 0xff;
+ value |= b;
+ }
+ return value;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,287 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * Version class conforming to JBoss Product Version Conventions post 2006-03-01. See
+ * http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProductVersioning.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7165 $
+ */
+public class Version
+{
+
+ /** . */
+ private final String codeName;
+
+ /** . */
+ private final String toString;
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final int major;
+
+ /** . */
+ private final int minor;
+
+ /** . */
+ private final int patch;
+
+ /** . */
+ private final Qualifier qualifier;
+
+ public Version(String name, int major, int minor, int patch, Qualifier qualifier, String codeName)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No name provided");
+ }
+ if (major < 0)
+ {
+ throw new IllegalArgumentException("Major cannot be negative");
+ }
+ if (minor < 0)
+ {
+ throw new IllegalArgumentException("Minor cannot be negative");
+ }
+ if (patch < 0)
+ {
+ throw new IllegalArgumentException("Patch cannot be negative");
+ }
+ if (qualifier == null)
+ {
+ throw new IllegalArgumentException("Qualifier cannot be null");
+ }
+ if (codeName == null)
+ {
+ throw new IllegalArgumentException("No code name provided");
+ }
+ this.name = name;
+ this.major = major;
+ this.minor = minor;
+ this.patch = patch;
+ this.qualifier = qualifier;
+ this.codeName = codeName;
+ this.toString = Format.JBOSS_PRODUCT_CONVENTION.toString(this);
+ }
+
+ public String getCodeName()
+ {
+ return codeName;
+ }
+
+ /** Return the name; */
+ public String getName()
+ {
+ return name;
+ }
+
+ /** Return the major. */
+ public int getMajor()
+ {
+ return major;
+ }
+
+ /** Return the minor. */
+ public int getMinor()
+ {
+ return minor;
+ }
+
+ /** Return the patch. */
+ public int getPatch()
+ {
+ return patch;
+ }
+
+ /** Return the intermediate major. */
+ public Qualifier getQualifier()
+ {
+ return qualifier;
+ }
+
+ public String toString()
+ {
+ return toString;
+ }
+
+ public String toString(Format format) throws IllegalArgumentException
+ {
+ if (format == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return format.toString(this);
+ }
+
+ /** Type safe enum for intermediate major. */
+ public static class Qualifier
+ {
+
+ public enum Prefix
+ {
+
+ SNAPSHOT("SNAPSHOT", false, "Snapshot"),
+ ALPHA("ALPHA", true, "Alpha"),
+ BETA("BETA", true, "Beta"),
+ CR("CR", true, "Candidate for release"),
+ GA("GA", false, "General Availability"),
+ SP("SP", true, "Service pack");
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final String description;
+
+ /** . */
+ private final boolean suffixable;
+
+ private Prefix(String name, boolean suffixable, String description)
+ {
+ this.name = name;
+ this.suffixable = suffixable;
+ this.description = description;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean isSuffixable()
+ {
+ return suffixable;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+ }
+
+ public enum Suffix
+ {
+
+ EMPTY(""),
+ SUFFIX_1("1"),
+ SUFFIX_2("2"),
+ SUFFIX_3("3"),
+ SUFFIX_4("4"),
+ SUFFIX_5("5"),
+ SUFFIX_6("6");
+
+ /** . */
+ private final String value;
+
+ private Suffix(String value)
+ {
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ return value;
+ }
+ }
+
+ /** . */
+ private final String toString;
+
+ /** . */
+ private final Prefix prefix;
+
+ /** . */
+ private final Suffix suffix;
+
+ public Qualifier(Prefix prefix)
+ {
+ this(prefix, Suffix.EMPTY);
+ }
+
+ public Qualifier(Prefix prefix, Suffix suffix)
+ {
+ if (prefix == null)
+ {
+ throw new IllegalArgumentException("No prefix provided");
+ }
+ if (suffix == null)
+ {
+ suffix = Suffix.EMPTY;
+ }
+ if (prefix.isSuffixable() == false && suffix.value.length() > 0)
+ {
+ throw new IllegalArgumentException("The prefix " + prefix + " is not suffixable");
+ }
+ this.toString = "" + prefix + suffix;
+ this.prefix = prefix;
+ this.suffix = suffix;
+ }
+
+ public Prefix getPrefix()
+ {
+ return prefix;
+ }
+
+ public Suffix getSuffix()
+ {
+ return suffix;
+ }
+
+ public String toString()
+ {
+ return toString;
+ }
+ }
+
+ public interface Format
+ {
+
+ /**
+ * Implement formatting as defined <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProductVersioning">here</a>
+ */
+ Format JBOSS_PRODUCT_CONVENTION = new Format()
+ {
+ public String toString(Version version)
+ {
+ StringBuffer buffer = new StringBuffer(version.getName());
+ buffer.append(" ")
+ .append(version.getMajor()).append('.')
+ .append(version.getMinor()).append('.')
+ .append(version.getPatch()).append('-')
+ .append(version.getQualifier());
+ return buffer.toString();
+ }
+ };
+
+ String toString(Version version);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class BooleanValue extends Value
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1478457007976203260L;
+
+ /** The Boolean array. */
+ private Boolean[] values;
+
+ public BooleanValue()
+ {
+ this((Boolean)null);
+ }
+
+ public BooleanValue(Boolean value)
+ {
+ this(new Boolean[]{value});
+ }
+
+ public BooleanValue(boolean value)
+ {
+ this(new boolean[]{value});
+ }
+
+ public BooleanValue(String value)
+ {
+ this(new String[]{value});
+ }
+
+ public BooleanValue(Boolean[] values)
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = values;
+ }
+
+ public BooleanValue(boolean[] _values)
+ {
+ if (_values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ values = new Boolean[_values.length];
+ for (int i = 0;i < _values.length;i++)
+ {
+ values[i] = Boolean.valueOf(_values[i]);
+ }
+ }
+
+ public BooleanValue(String[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = new Boolean[values.length];
+ for (int i = 0;i < values.length;i++)
+ {
+ String value = values[i];
+ if (value == null)
+ {
+ this.values[i] = null;
+ }
+ else if ("true".equals(value))
+ {
+ this.values[i] = Boolean.TRUE;
+ }
+ else if ("false".equals(value))
+ {
+ this.values[i] = Boolean.FALSE;
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ public boolean isInstanceOf(Class clazz)
+ {
+ return clazz != null && clazz.isAssignableFrom(Boolean.class);
+ }
+
+ protected Object[] getObjectArray()
+ {
+ return values;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.util.NullConversionException;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public interface Converter
+{
+ /**
+ * Return true if the converter accepts the class for conversion.
+ *
+ * @throws IllegalArgumentException if the class object is null
+ */
+ boolean accept(Class clazz);
+
+ /**
+ * String to object conversion.
+ *
+ * @throws NullConversionException if the value nullity prevent the conversion
+ * @throws org.jboss.portal.common.util.FormatConversionException if the value cannot be converted
+ */
+ Object toObject(String value) throws NullConversionException, FormatConversionException;
+
+ /**
+ * Convert the object to the stored value.
+ *
+ * @throws NullConversionException if the value nullity prevent the conversion
+ * @throws FormatConversionException if the value cannot be converted
+ */
+ String toString(Object value) throws NullConversionException, FormatConversionException;
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class FloatValue extends Value
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -3069055353952983120L;
+
+ /** The Float array. */
+ private Float[] values;
+
+ public FloatValue()
+ {
+ this((Float)null);
+ }
+
+ public FloatValue(Float integer)
+ {
+ this(new Float[]{integer});
+ }
+
+ public FloatValue(float _value)
+ {
+ this(new float[]{_value});
+ }
+
+ public FloatValue(String value)
+ {
+ this(new String[]{value});
+ }
+
+ public FloatValue(Float[] values)
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = values;
+ }
+
+ public FloatValue(float[] _values)
+ {
+ if (_values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ values = new Float[_values.length];
+ for (int i = 0;i < _values.length;i++)
+ {
+ values[i] = new Float(_values[i]);
+ }
+ }
+
+ public FloatValue(String[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ this.values = new Float[values.length];
+ for (int i = 0;i < values.length;i++)
+ {
+ String value = values[i];
+ if (value != null)
+ {
+ this.values[i] = new Float(value);
+ }
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public boolean isInstanceOf(Class clazz)
+ {
+ return clazz != null && clazz.isAssignableFrom(Integer.class);
+ }
+
+ protected Object[] getObjectArray()
+ {
+ return values;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,243 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.util.NullConversionException;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public class Helper
+{
+
+ public static final int[] EMPTY_INT_ARRAY = new int[0];
+ public static final boolean[] EMPTY_BOOLEAN_ARRAY = new boolean[0];
+ public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+ public static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ public static final Converter FLOAT_CONVERTER = new Converter()
+ {
+ public boolean accept(Class clazz)
+ {
+ return Float.class.equals(clazz);
+ }
+ public Object toObject(String value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ try
+ {
+ return Float.valueOf(value);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new FormatConversionException();
+ }
+ }
+ public String toString(Object value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ if (!(value instanceof Float))
+ {
+ throw new FormatConversionException();
+ }
+ return value.toString();
+ }
+ };
+
+ public static final Converter INTEGER_CONVERTER = new Converter()
+ {
+ public boolean accept(Class clazz)
+ {
+ return Integer.class.equals(clazz);
+ }
+ public Object toObject(String value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ try
+ {
+ return Integer.valueOf(value);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new FormatConversionException();
+ }
+ }
+ public String toString(Object value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ if (!(value instanceof Integer))
+ {
+ throw new FormatConversionException();
+ }
+ return value.toString();
+ }
+ };
+
+ public static final Converter BOOLEAN_CONVERTER = new Converter()
+ {
+ public boolean accept(Class clazz)
+ {
+ return Boolean.class.equals(clazz);
+ }
+ public Object toObject(String value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ return Boolean.valueOf(Helper.toBoolean(value));
+ }
+ public String toString(Object value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ if (!(value instanceof Boolean))
+ {
+ throw new FormatConversionException();
+ }
+ return value.toString();
+ }
+ };
+
+ public static int toInt(String value) throws NullConversionException, FormatConversionException
+ {
+ try
+ {
+ if (value == null)
+ {
+ throw new NullConversionException();
+ }
+ return Integer.parseInt(value);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new FormatConversionException();
+ }
+ }
+
+ public static boolean toBoolean(String value) throws NullConversionException, FormatConversionException
+ {
+ if ("true".equals(value))
+ {
+ return true;
+ }
+ else if ("false".equals(value))
+ {
+ return false;
+ }
+ else if (value == null)
+ {
+ throw new NullConversionException();
+ }
+ else
+ {
+ throw new FormatConversionException();
+ }
+ }
+
+ public static String toString(int value)
+ {
+ return Integer.toString(value);
+ }
+
+ public static String toString(boolean value)
+ {
+ return Boolean.toString(value);
+ }
+
+ public static String toString(Object value, Converter converter) throws NullConversionException, FormatConversionException, IllegalArgumentException
+ {
+ if (converter == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return converter.toString(value);
+ }
+
+ public static String[] toStringArray(int[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ String[] strings = new String[values.length];
+ for (int i = 0;i < strings.length;i++)
+ {
+ strings[i] = Integer.toString(values[i]);
+ }
+ return strings;
+ }
+
+ public static String[] toStringArray(boolean[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ String[] strings = new String[values.length];
+ for (int i = 0;i < strings.length;i++)
+ {
+ strings[i] = Boolean.toString(values[i]);
+ }
+ return strings;
+ }
+
+ public static String[] toStringArray(Object[] values, Converter converter) throws NullConversionException, FormatConversionException, IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (converter == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ String[] strings = new String[values.length];
+ for (int i = 0;i < strings.length;i++)
+ {
+ Object value = values[i];
+ if (value != null)
+ {
+ strings[i] = converter.toString(values[i]);
+ }
+ }
+ return strings;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,114 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class IntegerValue extends Value
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -3396982952223096067L;
+
+ /** The Integer array. */
+ private Integer[] values;
+
+ public IntegerValue()
+ {
+ this((Integer)null);
+ }
+
+ public IntegerValue(Integer integer)
+ {
+ this(new Integer[]{integer});
+ }
+
+ public IntegerValue(int _value)
+ {
+ this(new int[]{_value});
+ }
+
+ public IntegerValue(String value)
+ {
+ this(new String[]{value});
+ }
+
+ public IntegerValue(Integer[] values)
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = values;
+ }
+
+ public IntegerValue(int[] _values)
+ {
+ if (_values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ values = new Integer[_values.length];
+ for (int i = 0;i < _values.length;i++)
+ {
+ values[i] = new Integer(_values[i]);
+ }
+ }
+
+ public IntegerValue(String[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ this.values = new Integer[values.length];
+ for (int i = 0;i < values.length;i++)
+ {
+ String value = values[i];
+ if (value != null)
+ {
+ this.values[i] = new Integer(value);
+ }
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public boolean isInstanceOf(Class clazz)
+ {
+ return clazz != null && clazz.isAssignableFrom(Integer.class);
+ }
+
+ protected Object[] getObjectArray()
+ {
+ return values;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class StringValue extends Value
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 4280801691629359883L;
+
+ /** The String array. */
+ private String[] values;
+
+ public StringValue()
+ {
+ this((String)null);
+ }
+
+ public StringValue(String value)
+ {
+ this(new String[]{value});
+ }
+
+ public StringValue(String[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = values;
+ }
+
+ public boolean isInstanceOf(Class clazz)
+ {
+ return clazz != null && clazz.isAssignableFrom(String.class);
+ }
+
+ protected Object[] getObjectArray()
+ {
+ return values;
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,314 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+import java.util.AbstractList;
+import java.util.RandomAccess;
+
+/**
+ * A read only interface used to retrieve data. It represents both for
+ * mono value and multi values. It must implement equals and hashCode.
+ * <p/>
+ * The semantics :
+ * <p/>
+ * <table border="1">
+ * <tr>
+ * <th>storage</th><th>mono</th><th>multi</th>
+ * </tr>
+ * <tr>
+ * <td>xxx</td><td>xxx</td><td>[xxx]</td>
+ * </tr>
+ * <tr>
+ * <td>null</td><td>null</td><td>[null]</td>
+ * </tr>
+ * <tr>
+ * <td colspan="3"></td>
+ * </tr>
+ * <tr>
+ * <td>[]</td><td>null</td><td>[]</td>
+ * </tr>
+ * <tr>
+ * <td>[null,..]</td><td>null</td><td>[null,..]</td>
+ * </tr>
+ * <tr>
+ * <td>["1",..]</td><td>"1"</td><td>["1",..]</td>
+ * </tr>
+ * </table>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public abstract class Value implements Serializable, Cloneable
+{
+
+ /**
+ * The cached hashCode.
+ */
+ private transient int hashCode = 0;
+
+ /**
+ * The object list representation.
+ */
+ private transient List objectList;
+
+ /**
+ * The string list representation.
+ */
+ private transient List stringList;
+
+ // ******************************
+
+ /**
+ *
+ */
+ public abstract boolean isInstanceOf(Class clazz);
+
+ public final int hashCode()
+ {
+ if (isNull())
+ {
+ return 0;
+ }
+ else
+ {
+ if (hashCode == 0)
+ {
+ Object[] objects = getObjectArray();
+ for (int i = 0; i < objects.length; i++)
+ {
+ Object o = objects[i];
+ if (o != null)
+ {
+ hashCode *= 43 + o.hashCode();
+ }
+ }
+ }
+ else
+ {
+ return hashCode;
+ }
+ }
+ return hashCode;
+ }
+
+ public final boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj.getClass().equals(getClass()))
+ {
+ Value other = (Value)obj;
+ switch ((other.isNull() ? 2 : 0) + (isNull() ? 1 : 0))
+ {
+ case 1:
+ case 2:
+ return false;
+ case 3:
+ return true;
+ }
+ return Arrays.equals(getObjectArray(), other.getObjectArray());
+ }
+ return false;
+ }
+
+ public final String toString()
+ {
+ StringBuffer buffer = new StringBuffer("[");
+ String[] strings = asStringArray();
+ for (int i = 0; i < strings.length; i++)
+ {
+ String s = strings[i];
+ buffer.append(i > 0 ? "," : "").
+ append(String.valueOf(s));
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ /**
+ * Clone this object.
+ *
+ * @return a clone of this object
+ */
+ public final Value clone()
+ {
+ try
+ {
+ return (Value)super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ // ***********************
+ // * Mono valued methods *
+ // ***********************
+
+ /**
+ * Return true if the value is null.
+ */
+ public final boolean isNull()
+ {
+ return getObjectArray().length == 0 || getObjectArray()[0] == null;
+ }
+
+ /**
+ * Return the value as a string or null if the value is null.
+ */
+ public final String asString()
+ {
+ String string = null;
+ Object object = asObject();
+ if (object != null)
+ {
+ string = object.toString();
+ }
+ return string;
+ }
+
+ /**
+ * Return the value.
+ */
+ public final Object asObject()
+ {
+ if (isNull())
+ {
+ return null;
+ }
+ return getObjectArray()[0];
+ }
+
+ // ************************
+ // * Multi valued methods *
+ // ************************
+
+ /**
+ * Return true if it contains more than one value.
+ */
+ public final boolean isMultiValued()
+ {
+ return size() > 1;
+ }
+
+ /**
+ * Return true if it contains zero value.
+ */
+ public final boolean isEmpty()
+ {
+ return size() == 0;
+ }
+
+ /**
+ * Return the size.
+ */
+ public final int size()
+ {
+ return getObjectArray().length;
+ }
+
+ /**
+ * Creates a new array and fill it with the string values.
+ */
+ public final String[] asStringArray()
+ {
+ Object[] objects = getObjectArray();
+ String[] strings = new String[objects.length];
+ for (int i = 0; i < objects.length; i++)
+ {
+ Object object = objects[i];
+ if (object != null)
+ {
+ strings[i] = object.toString();
+ }
+ }
+ return strings;
+ }
+
+ /**
+ * Create a new array and fill it with the values.
+ */
+ public final Object[] asObjectArray()
+ {
+ return (Object[])getObjectArray().clone();
+ }
+
+ /**
+ * Return an immutable list of strings.
+ */
+ public final List asStringList()
+ {
+ if (stringList == null)
+ {
+ stringList = new ValueList(asStringArray());
+ }
+ return stringList;
+ }
+
+ /**
+ * Return an immutable list of objects.
+ */
+ public final List asObjectList()
+ {
+ if (objectList == null)
+ {
+ // Avoid to make a copy as the list is not mutable
+ objectList = new ValueList(getObjectArray());
+ }
+ return objectList;
+ }
+
+ /**
+ * Return the values as an array of converted object. It must always return a non null array.
+ */
+ protected abstract Object[] getObjectArray();
+
+ private static class ValueList extends AbstractList implements List, RandomAccess
+ {
+
+ /** . */
+ private final Object[] array;
+
+ private ValueList(Object[] array)
+ {
+ this.array = array;
+ }
+
+ public int size()
+ {
+ return array.length;
+ }
+
+ public Object get(int index)
+ {
+ return array[index];
+ }
+ }
+
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.xml;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7380 $
+ */
+public class NoSuchElementException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -393378187931491442L;
+
+ public NoSuchElementException()
+ {
+ }
+
+ public NoSuchElementException(String message)
+ {
+ super(message);
+ }
+
+ public NoSuchElementException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public NoSuchElementException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/NullEntityResolver.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/NullEntityResolver.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/NullEntityResolver.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.xml;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class NullEntityResolver implements EntityResolver
+{
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ return null;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.xml;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7380 $
+ */
+public class TooManyElementException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -2381186243988987102L;
+
+ public TooManyElementException()
+ {
+ }
+
+ public TooManyElementException(String message)
+ {
+ super(message);
+ }
+
+ public TooManyElementException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public TooManyElementException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,468 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.xml;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Utilities for dealing with XML.
+ *
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7686 $
+ */
+public class XMLTools
+{
+
+ /** Namespace URI for XML lang. */
+ public static final String XML_LANG_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
+
+ /** Document builder factory. */
+ private static final DocumentBuilderFactory buildFactory = DocumentBuilderFactory.newInstance();
+
+ /** Transformer factory. */
+ private static final TransformerFactory transformerFactory = TransformerFactory.newInstance();
+
+ /** Default output format which is : no xml declaration, no document type, indent. */
+ private static Properties DEFAULT_FORMAT = createFormat(true, false, true, "utf-8");
+
+ /** . */
+ public static final String PARAM_YES = "yes";
+
+ /** . */
+ public static final String PARAM_NO = "no";
+
+ /** . */
+ public static final String ATTRIB_OMIT_XML_DECLARATION = "omit-xml-declaration";
+
+ /** . */
+ public static final String ATTRIB_CDATA_SECTION_ELEMENTS = "cdata-section-elements";
+
+ /** . */
+ public static final String ATTRIB_METHOD = "method";
+
+ /** . */
+ public static final String ATTRIB_INDENT = "indent";
+
+ /** . */
+ public static final String ATTRIB_HREF = "href";
+
+ /** . */
+ public static final String DIRECTIVE_IMPORT = "xsl:import";
+
+ /** . */
+ public static final String DIRECTIVE_INCLUDE = "xsl:include";
+
+ /** . */
+ public static final boolean DEFAULT_NAMESPACE_AWARE = true;
+
+ /** . */
+ public static final boolean DEFAULT_VALIDATION = false;
+
+ /** prevent instantiation */
+ private XMLTools()
+ {
+ }
+
+ /** Return the builder factory. */
+ public static DocumentBuilderFactory getDocumentBuilderFactory()
+ {
+ return buildFactory;
+ }
+
+ /**
+ *
+ */
+ private static Properties createFormat(boolean omitXMLDeclaration, boolean standalone, boolean indented, String encoding)
+ {
+ Properties format = new Properties();
+ format.setProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration ? "yes" : "no");
+ format.setProperty(OutputKeys.STANDALONE, standalone ? "yes" : "no");
+ format.setProperty(OutputKeys.INDENT, indented ? "yes" : "no");
+ format.setProperty(OutputKeys.ENCODING, encoding);
+ return format;
+ }
+
+ /**
+ *
+ */
+ public static String toString(Document doc, boolean omitXMLDeclaration, boolean standalone, boolean indented, String encoding) throws TransformerException
+ {
+ Properties format = createFormat(omitXMLDeclaration, standalone, indented, encoding);
+ return toString(doc, format);
+ }
+
+ /**
+ * Serialize the document with the default format : - No XML declaration - Indented - Encoding is UTF-8
+ *
+ * @see #toString(Document,Properties)
+ */
+ public static String toString(Document doc) throws TransformerException
+ {
+ return toString(doc, DEFAULT_FORMAT);
+ }
+
+ /** @see #toString(Document) */
+ public static String toString(Element element) throws ParserConfigurationException, TransformerException
+ {
+ return toString(element, DEFAULT_FORMAT);
+ }
+
+ /** Converts an element to a String representation. */
+ private static String toString(Element element, Properties properties) throws ParserConfigurationException, TransformerException
+ {
+ Document doc = buildFactory.newDocumentBuilder().newDocument();
+ element = (Element)doc.importNode(element, true);
+ doc.appendChild(element);
+ return toString(doc, properties);
+ }
+
+ /** Converts an document to a String representation. */
+ private static String toString(Document doc, Properties format) throws TransformerException
+ {
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setOutputProperties(format);
+ StringWriter writer = new StringWriter();
+ Source source = new DOMSource(doc);
+ Result result = new StreamResult(writer);
+ transformer.transform(source, result);
+ return writer.toString();
+ }
+
+ /** Parse a string into a document. */
+ public static Document toDocument(String text) throws ParserConfigurationException, SAXException, IOException
+ {
+ DocumentBuilder builder = buildFactory.newDocumentBuilder();
+ StringReader reader = new StringReader(text);
+ InputSource source = new InputSource();
+ source.setCharacterStream(reader);
+ return builder.parse(source);
+ }
+
+ /** Parse a string into an element. */
+ public static Element toElement(String text) throws ParserConfigurationException, SAXException, IOException
+ {
+ Document doc = toDocument(text);
+ return doc.getDocumentElement();
+ }
+
+ public static Document toDocument(Element element) throws ParserConfigurationException, SAXException, IOException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Document doc = buildFactory.newDocumentBuilder().newDocument();
+ element = (Element)doc.importNode(element, true);
+ doc.appendChild(element);
+ return doc;
+ }
+
+ /**
+ * Perform trimming by default
+ *
+ * @param element
+ * @return
+ * @throws IllegalArgumentException
+ * @see #asString(org.w3c.dom.Element,boolean)
+ */
+ public static String asString(Element element) throws IllegalArgumentException
+ {
+ return asString(element, true);
+ }
+
+ /**
+ * Get the element's content as a string.
+ *
+ * @param element the container
+ * @param trim true if text should be trimmed before returning result
+ * @throws IllegalArgumentException if the element content is mixed or null
+ */
+ public static String asString(Element element, boolean trim) throws IllegalArgumentException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No null element allowed");
+ }
+
+ //
+ StringBuffer buffer = new StringBuffer();
+ NodeList children = element.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+ switch (child.getNodeType())
+ {
+ case Node.CDATA_SECTION_NODE:
+ case Node.TEXT_NODE:
+ buffer.append(((Text)child).getData());
+ break;
+ case Node.ELEMENT_NODE:
+ throw new IllegalArgumentException("Mixed content not allowed");
+ default:
+ break;
+ }
+ }
+ String result = buffer.toString();
+ if (trim)
+ {
+ result = result.trim();
+ }
+ return result;
+ }
+
+ /**
+ * Return the optional unique child of an element.
+ *
+ * @param element the parent element
+ * @param strict true if the element must be present
+ * @return the child element or null if it does not exist and strict is false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, boolean strict) throws IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No element specified");
+ }
+ Element childElt = null;
+ NodeList list = element.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node childNode = list.item(i);
+ if (childNode instanceof Element)
+ {
+ if (childElt == null)
+ {
+ childElt = (Element)childNode;
+ }
+ else
+ {
+ throw new TooManyElementException("More than one child element for element " + element.getNodeName());
+ }
+ }
+ }
+ if (strict && childElt == null)
+ {
+ throw new NoSuchElementException("No child element for element " + element.getNodeName());
+ }
+ return childElt;
+ }
+
+ /**
+ * Return an optional child of an element with the specified name.
+ *
+ * @param element the parent element
+ * @param name the child name
+ * @param strict if the child must be present
+ * @return the child element or null if it does not exist and strict is set to false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, String name, boolean strict) throws IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ return getUniqueChild(element, null, name, strict);
+ }
+
+ /**
+ * Return an optional child of an element with the specified name and the optionally specified namespace uri.
+ *
+ * @param element the parent element
+ * @param name the child name
+ * @param uri the child uri
+ * @param strict if the child must be present
+ * @return the child element or null if it does not exist and strict is set to false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, String uri, String name, boolean strict) throws IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ List list = getChildren(element, uri, name);
+ switch (list.size())
+ {
+ case 0:
+ if (strict)
+ {
+ throw new NoSuchElementException("Missing child " + name + " of element " + element.getNodeName());
+ }
+ else
+ {
+ return null;
+ }
+ case 1:
+ return (Element)list.get(0);
+ default:
+ throw new TooManyElementException("Too many children for element " + element.getNodeName());
+ }
+ }
+
+ /**
+ * Return an iterator for all the children of the given element having the specified name.
+ *
+ * @param element the parent element
+ * @param name the child names
+ * @return an iterator for the designated elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static Iterator<Element> getChildrenIterator(Element element, String name) throws IllegalArgumentException
+ {
+ return getChildren(element, name).iterator();
+ }
+
+ /**
+ * Return an iterator for all the children of the given element having the specified name and the optionally
+ * specified namesspace uri.
+ *
+ * @param element the parent element
+ * @param uri the children uri
+ * @param name the children name
+ * @return an iterator for the designated elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static Iterator<Element> getChildrenIterator(Element element, String uri, String name) throws IllegalArgumentException
+ {
+ return getChildren(element, uri, name).iterator();
+ }
+
+ /**
+ * Return all the children of the given element having the specified name. The collection object can be modified.
+ *
+ * @param element the parent element
+ * @param name the child names
+ * @return a list of elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static List<Element> getChildren(Element element, String name) throws IllegalArgumentException
+ {
+ return getChildren(element, null, name);
+ }
+
+ /**
+ * Return all the children of the given element having the specified name and the optionally specified namespace URI.
+ * The collection object can be modified.
+ *
+ * @param element the parent element
+ * @param uri the children uri
+ * @param name the children name
+ * @return a list of elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static List<Element> getChildren(Element element, String uri, String name) throws IllegalArgumentException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No element found");
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No name specified");
+ }
+ ArrayList<Element> result = new ArrayList<Element>();
+ NodeList list = element.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ Element childElt = (Element)node;
+
+ //
+ if (uri == null)
+ {
+ if (childElt.getTagName().equals(name))
+ {
+ result.add(childElt);
+ }
+ }
+ else if (uri.equals(childElt.getNamespaceURI()))
+ {
+ if (childElt.getLocalName().equals(name))
+ {
+ result.add(childElt);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static Properties loadXMLProperties(Element propertiesElt)
+ {
+ if (propertiesElt == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Properties props = new Properties();
+ for (Element entryElt : getChildren(propertiesElt, "entry"))
+ {
+ String key = entryElt.getAttribute("key");
+ String value = asString(entryElt);
+ props.put(key, value);
+ }
+ return props;
+ }
+
+ public static Properties loadXMLProperties(Document doc)
+ {
+ if (doc == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return loadXMLProperties(doc.getDocumentElement());
+ }
+
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_close.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_close.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_close.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<span style="font-weight: bold">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/b_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_close.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_close.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_close.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,3 @@
+ </pre></td></tr>
+</table>
+<span class="pn-text">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,7 @@
+</span>
+<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
+<tr>
+ <td><span class="pn-title"><b>{L_CODE}:</b></span></td>
+ </tr>
+ <tr>
+ <td class="pn-code"><pre>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/code_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_close.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_close.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_close.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<span style="color: {COLOR}">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/color_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/email.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/email.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/email.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<a href="mailto:{EMAIL}">{EMAIL}</a>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/email.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_close.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_close.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_close.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<span style="font-style: italic">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/i_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/img.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/img.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/img.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<img src="{URL}" border="0" />
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/img.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/listitem.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/listitem.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/listitem.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<li>
\ No newline at end of file
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/listitem.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_close.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_close.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_close.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+</ol>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<ol type="{LIST_TYPE}">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/olist_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_close.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_close.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_close.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,4 @@
+</td>
+ </tr>
+</table>
+<span class="pn-text">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,7 @@
+</span>
+<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
+<tr>
+ <td><span class="pn-title"><b>{L_QUOTE}:</b></span></td>
+ </tr>
+ <tr>
+ <td class="pn-quote">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_username_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_username_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_username_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,7 @@
+</span>
+<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
+<tr>
+ <td><span class="pn-title"><b>{USERNAME} {L_WROTE}:</b></span></td>
+ </tr>
+ <tr>
+ <td class="pn-quote">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/quote_username_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_close.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_close.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_close.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<span style="font-size: {SIZE}px; line-height: normal">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/size_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_close.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_close.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_close.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<span style="text-decoration: underline">
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/u_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_close.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_close.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_close.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+</ul>
\ No newline at end of file
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_open.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_open.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_open.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<ul>
\ No newline at end of file
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/ulist_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/url.tpl
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/url.tpl (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/url.tpl 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<a href="{URL}" target="_blank">{DESCRIPTION}</a>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/main/resources/format/code/url.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,252 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.invocation.AbstractInvocationContext;
+import org.jboss.portal.common.invocation.Scope;
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractInvocationContextTestCase extends TestCase
+{
+
+ /** . */
+ private static final Scope TEST_SCOPE = new Scope("test");
+
+ public void testNonExistingScope()
+ {
+ AbstractInvocationContext ctx = new AbstractInvocationContext();
+ try
+ {
+ ctx.getAttribute(TEST_SCOPE, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ try
+ {
+ ctx.setAttribute(TEST_SCOPE, "foo", "bar");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ try
+ {
+ ctx.removeAttribute(TEST_SCOPE, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ try
+ {
+ ctx.getAttributeResolver(TEST_SCOPE);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ }
+
+ public void testExistingScopeWithResolver()
+ {
+ final MapResolver resolver = new MapResolver();
+ AbstractInvocationContext ctx = new AbstractInvocationContext()
+ {
+ {
+ addResolver(TEST_SCOPE, resolver);
+ }
+ };
+ testExistingScope(ctx, resolver);
+ }
+
+ public void testExistingScopeDelegation()
+ {
+ final MapResolver resolver = new MapResolver();
+ final AbstractInvocationContext parent = new AbstractInvocationContext()
+ {
+ {
+ addResolver(TEST_SCOPE, resolver);
+ }
+ };
+ AbstractInvocationContext child = new AbstractInvocationContext()
+ {
+ {
+ addResolver(TEST_SCOPE, parent);
+ }
+ };
+ testExistingScope(child, resolver);
+ }
+
+
+ private void testExistingScope(AbstractInvocationContext ctx, MapResolver resolver)
+ {
+ // Assert empty does not exist
+ assertNull(ctx.getAttribute(TEST_SCOPE, "foo"));
+ assertEquals(0, resolver.size());
+
+ // Remove non existing
+ ctx.removeAttribute(TEST_SCOPE, "foo");
+ assertNull(ctx.getAttribute(TEST_SCOPE, "foo"));
+ assertEquals(0, resolver.size());
+
+ // Set non existing
+ ctx.setAttribute(TEST_SCOPE, "foo", "bar");
+ assertEquals("bar", resolver.getAttribute("foo"));
+ assertEquals(1, resolver.size());
+
+ // Overwrite existing
+ ctx.setAttribute(TEST_SCOPE, "foo", "bar2");
+ assertEquals("bar2", resolver.getAttribute("foo"));
+ assertEquals(1, resolver.size());
+
+ // Remove existing
+ ctx.removeAttribute(TEST_SCOPE, "foo");
+ assertNull(ctx.getAttribute(TEST_SCOPE, "foo"));
+ assertEquals(0, resolver.size());
+
+ // Get resolver
+ assertEquals(resolver, ctx.getAttributeResolver(TEST_SCOPE));
+ }
+
+ public void testAPI()
+ {
+ AbstractInvocationContext ctx = new AbstractInvocationContext();
+ try
+ {
+ ctx.getAttribute(null, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.getAttribute(TEST_SCOPE, null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(null, "foo", "bar");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(TEST_SCOPE, null, "bar");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(null, "foo", null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(TEST_SCOPE, null, null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.removeAttribute(null, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.removeAttribute(TEST_SCOPE, null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.getAttributeResolver(null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ private static class MapResolver extends HashMap implements AttributeResolver
+ {
+ public Set getKeys()
+ {
+ return keySet();
+ }
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return get(attrKey);
+ }
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (attrValue != null)
+ {
+ put(attrKey, attrValue);
+ }
+ else
+ {
+ remove(attrKey);
+ }
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.io.IOTools;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.BufferedInputStream;
+import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.BufferedOutputStream;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BufferedStreamTestCase extends TestCase
+{
+
+ public BufferedStreamTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testInputStream() throws Exception
+ {
+ assertNull(IOTools.safeBufferedWrapper((InputStream)null));
+ BufferedInputStream in = IOTools.safeBufferedWrapper(new ByteArrayInputStream("abc".getBytes("UTF8")));
+ assertEquals(System.identityHashCode(in), System.identityHashCode(IOTools.safeBufferedWrapper(in)));
+ assertNotNull(in);
+ byte[] bytes = "abc".getBytes("UTF8");
+ Arrays.fill(bytes, (byte)0);
+ assertEquals(bytes.length, in.read(bytes));
+ assertEquals(-1, in.read());
+ assertEquals("abc", new String(bytes, "UTF8"));
+ }
+
+ public void testOutputputStream() throws Exception
+ {
+ assertNull(IOTools.safeBufferedWrapper((OutputStream)null));
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ BufferedOutputStream buffered = IOTools.safeBufferedWrapper(out);
+ assertNotNull(buffered);
+ assertEquals(System.identityHashCode(buffered), System.identityHashCode(IOTools.safeBufferedWrapper(buffered)));
+ buffered.write("abc".getBytes("UTF8"));
+ buffered.close();
+ assertEquals("abc", out.toString("UTF8"));
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,206 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.NoSuchElementException;
+
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameIteratorTestCase extends TestCase
+{
+
+ private final String A = new Locale("a", "b", "c").getLanguage();
+ private final String B = new Locale("a", "b", "c").getCountry();
+ private final String C = new Locale("a", "b", "c").getVariant();
+
+ public void testNameLookup1()
+ {
+ Locale l = new Locale("a", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B + "_" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup2()
+ {
+ Locale l = new Locale("a", "b");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup4()
+ {
+ Locale l = new Locale("a", "b", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup3()
+ {
+ Locale l = new Locale("a");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup5()
+ {
+ Locale l = new Locale("a", "", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup6()
+ {
+ Locale l = new Locale("a", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "__" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup7()
+ {
+ Locale l = new Locale("", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B + "_" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup8()
+ {
+ Locale l = new Locale("", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base___" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameParserTestCase extends TestCase
+{
+
+ /** . */
+ private final BundleName.Parser parser = new BundleName.Parser();
+
+
+ private static final Test[] tests = {
+ new Test("_", null),
+ new Test("__", null),
+ new Test("___", null),
+
+ //
+ new Test("a", new BundleName("a")),
+ new Test("a_b", new BundleName("a", "b")),
+ new Test("a_b_c", new BundleName("a", "b", "c")),
+ new Test("a__b", new BundleName("a", "", "b")),
+ new Test("a___b", new BundleName("a", "", "", "b")),
+ new Test("a__b_c", new BundleName("a", "", "b", "c")),
+ new Test("a_b__c", new BundleName("a", "b", "", "c")),
+ new Test("a_b_c_d", new BundleName("a", "b", "c", "d")),
+
+ //
+ new Test("", new BundleName("")),
+ new Test("_b", new BundleName("", "b")),
+ new Test("_b_c", new BundleName("", "b", "c")),
+ new Test("__b", new BundleName("", "", "b")),
+ new Test("___b", new BundleName("", "", "", "b")),
+ new Test("__b_c", new BundleName("", "", "b", "c")),
+ new Test("_b__c", new BundleName("", "b", "", "c")),
+ new Test("_b_c_d", new BundleName("", "b", "c", "d")),
+ };
+
+ public void testA()
+ {
+ for (int i = 0; i < tests.length; i++)
+ {
+ Test test = tests[i];
+ BundleName name = parser.parse(test.input, 0, test.input.length());
+ if (name == null)
+ {
+ assertNull(test.input, test.expectedName);
+ }
+ else
+ {
+ assertNotNull(test.input, test.expectedName);
+ assertEquals(test.input, test.expectedName.getBaseName(), name.getBaseName());
+ assertEquals(test.input, test.expectedName.getLanguage(), name.getLanguage());
+ assertEquals(test.input, test.expectedName.getCountry(), name.getCountry());
+ assertEquals(test.input, test.expectedName.getVariant(), name.getVariant());
+ }
+ }
+ }
+
+
+ private static class Test
+ {
+
+ /** . */
+ private String input;
+
+ /** . */
+ private BundleName expectedName;
+
+ public Test(String input, BundleName expectedName)
+ {
+ this.input = input;
+ this.expectedName = expectedName;
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,303 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.jboss.portal.common.i18n.ComplexResourceBundleFactory;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ComplexResourceBundleFactoryTestCase extends TestCase
+{
+
+ /** . */
+ private ClassLoader cl;
+
+ protected void setUp() throws Exception
+ {
+ URL bundleURL = Thread.currentThread().getContextClassLoader().getResource("bundle");
+ assertNotNull(bundleURL);
+ File f = new File(bundleURL.getFile());
+ assertTrue(f.exists());
+ assertTrue(f.isDirectory());
+ cl = new URLClassLoader(new URL[]{f.toURL()}, ClassLoader.getSystemClassLoader());
+ }
+
+ public void testExactMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "a");
+
+ //
+ ResourceBundle a_de_DE = factory.getBundle(new Locale("de", "DE"));
+ assertNotNull(a_de_DE);
+ assertEquals("a_de_DE", a_de_DE.getString("value"));
+
+ //
+ ResourceBundle a_fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(a_fr);
+ assertEquals("a_fr", a_fr.getString("value"));
+
+ //
+ ResourceBundle a_fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(a_fr_FR);
+ assertEquals("a_fr_FR", a_fr_FR.getString("value"));
+
+ //
+ ResourceBundle a_it = factory.getBundle(new Locale("it"));
+ assertNotNull(a_it);
+ assertEquals("a_it", a_it.getString("value"));
+ }
+
+ public void testNoMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "a");
+
+ //
+ ResourceBundle a_de = factory.getBundle(new Locale("de"));
+ assertNull(a_de);
+
+ //
+ ResourceBundle a_en = factory.getBundle(new Locale("en"));
+ assertNull(a_en);
+
+ //
+ ResourceBundle a_en_EN = factory.getBundle(new Locale("en", "EN"));
+ assertNull(a_en_EN);
+ }
+
+ public void testFallbackOnDefaultLocale1() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "b");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale2() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "c");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale3() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "d");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNull(de);
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNull(fr);
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("d_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("d_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale4() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "e");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale5() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "f");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale6() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "g");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale7() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "h");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,187 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CopyOnWriteRegistry;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CopyOnWriteRegistryTestCase extends TestCase
+{
+
+ private CopyOnWriteRegistry registry;
+ Object key;
+ Object registered1;
+ Object registered2;
+
+
+ protected void setUp() throws Exception
+ {
+ registry = new CopyOnWriteRegistry();
+ key = new Object();
+ registered1 = new Object();
+ registered2 = new Object();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ registry = null;
+ key = null;
+ registered1 = null;
+ registered2 = null;
+ }
+
+ public void testRegisterThrowsIAE()
+ {
+ try
+ {
+ registry.register(null, registered1);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ registry.register(registered1, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ registry.register(null, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testUnregisterThrowsIAE()
+ {
+ try
+ {
+ registry.unregister(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testGetThrowsIAE()
+ {
+ try
+ {
+ registry.getRegistration(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testDualRegistration()
+ {
+ assertTrue(registry.register(key, registered1));
+ assertFalse(registry.register(key, registered2));
+ assertEquals(registered1, registry.getRegistration(key));
+ }
+
+ public void testUnregisterNonRegistered()
+ {
+ assertNull(registry.unregister(key));
+ }
+
+ public void testNormal()
+ {
+ assertEquals(Collections.EMPTY_SET, registry.getKeys());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(registry.getRegistrations()));
+ assertTrue(registry.register(key, registered1));
+ assertEquals(Collections.singleton(key), registry.getKeys());
+ assertEquals(Collections.singletonList(registered1), new ArrayList(registry.getRegistrations()));
+ assertEquals(registered1, registry.getRegistration(key));
+ assertEquals(registered1, registry.unregister(key));
+ assertEquals(null, registry.getRegistration(key));
+ assertEquals(Collections.EMPTY_SET, registry.getKeys());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(registry.getRegistrations()));
+ }
+
+ public void testCopyOnWrite()
+ {
+ Set keys = registry.getKeys();
+ List registrations = new ArrayList(registry.getRegistrations());
+ assertEquals(Collections.EMPTY_SET, keys);
+ assertEquals(Collections.EMPTY_LIST, registrations);
+ assertTrue(registry.register(key, registered1));
+ assertEquals(Collections.EMPTY_SET, keys);
+ assertEquals(Collections.EMPTY_LIST, registrations);
+ keys = registry.getKeys();
+ registrations = new ArrayList(registry.getRegistrations());
+ assertEquals(Collections.singleton(key), keys);
+ assertEquals(Collections.singletonList(registered1), registrations);
+ assertEquals(registered1, registry.unregister(key));
+ assertEquals(Collections.singleton(key), keys);
+ assertEquals(Collections.singletonList(registered1), registrations);
+ keys = registry.getKeys();
+ registrations = new ArrayList(registry.getRegistrations());
+ assertEquals(Collections.EMPTY_SET, keys);
+ assertEquals(Collections.EMPTY_LIST, registrations);
+ }
+
+ public void testKeysAreNotModifiable()
+ {
+ registry.register(key, registered1);
+ try
+ {
+ registry.getKeys().clear();
+ fail("Was expecting UnsupportedOperationException");
+ }
+ catch (UnsupportedOperationException expected)
+ {
+ }
+ }
+
+ public void testRegistrationsAreNotModifiable()
+ {
+ registry.register(key, registered1);
+ try
+ {
+ registry.getRegistrations().clear();
+ fail("Was expecting UnsupportedOperationException");
+ }
+ catch (UnsupportedOperationException expected)
+ {
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class DescriptionTestCase extends TestCase
+{
+
+ public DescriptionTestCase(String name)
+ {
+ super(name);
+ }
+
+ private Locale deflt = Locale.ENGLISH;
+ private Locale abc = new Locale("a", "b", "c");
+ private Locale ab = new Locale("a", "b");
+ private Locale a = new Locale("a");
+
+ public void testA()
+ {
+ Map map = new HashMap();
+ map.put(abc, "abc");
+ map.put(ab, "ab");
+ map.put(a, "a");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("abc", desc.getString(abc, true));
+ assertEquals("ab", desc.getString(ab, true));
+ assertEquals("a", desc.getString(a, true));
+ }
+
+ public void testB()
+ {
+ Map map = new HashMap();
+ map.put(abc, "abc");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("abc", desc.getString(abc, true));
+ assertEquals("deflt", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+
+ public void testC()
+ {
+ Map map = new HashMap();
+ map.put(ab, "ab");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("ab", desc.getString(abc, true));
+ assertEquals("ab", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+
+ public void testD()
+ {
+ Map map = new HashMap();
+ map.put(a, "a");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("a", desc.getString(abc, true));
+ assertEquals("a", desc.getString(ab, true));
+ assertEquals("a", desc.getString(a, true));
+ }
+
+ public void testE()
+ {
+ Map map = new HashMap();
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("deflt", desc.getString(abc, true));
+ assertEquals("deflt", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Tools;
+
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class HexTestCase extends TestCase
+{
+ public HexTestCase(String s)
+ {
+ super(s);
+ System.out.println("BUILD");
+ System.out.println("BUILD");
+ System.out.println("BUILD");
+ }
+
+ public void testBasic()
+ {
+ byte[] original = new byte[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
+ String hex = Tools.toHexString(original);
+// assertEquals((String)"000102030405060708090a0b0c0d0e0f1011121314", (String)hex);
+ assertEquals("a", "a");
+ byte[] copy = Tools.fromHexString(hex);
+ assertTrue(Arrays.equals(original, copy));
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.ant.Implode;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6289 $
+ */
+public class ImplodeTestCase extends TestCase
+{
+
+ public ImplodeTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testA() throws Exception
+ {
+ URL foo_sarURL = Thread.currentThread().getContextClassLoader().getResource("implode/foo.sar");
+ assertNotNull(foo_sarURL);
+ File foo_sarDir = new File(foo_sarURL.getFile());
+ assertTrue(foo_sarDir.exists());
+ assertTrue(foo_sarDir.isDirectory());
+
+ File tmp = File.createTempFile("foo", ".sar");
+ tmp.deleteOnExit();
+ tmp.setLastModified(foo_sarDir.lastModified() - 1);
+ assertTrue(foo_sarDir.lastModified() > tmp.lastModified());
+ Implode implode = new Implode();
+ implode.setDir(foo_sarDir);
+ implode.setTofile(tmp);
+ implode.execute();
+
+ // Test that the structure is correct
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.NoSuchElementException;
+
+import org.jboss.portal.common.util.IteratorStatus;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IteratorStatusTestCase extends TestCase
+{
+
+ public void testA()
+ {
+ ArrayList list = new ArrayList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+
+ //
+ test(new IteratorStatus(list));
+ test(new IteratorStatus(list.iterator()));
+ }
+
+ private void test(IteratorStatus iterator)
+ {
+ assertTrue(iterator.hasNext());
+ assertEquals(-1, iterator.getIndex());
+
+ //
+ assertEquals("a", iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals(0, iterator.getIndex());
+
+ //
+ assertEquals("b", iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals(1, iterator.getIndex());
+
+ //
+ assertEquals("c", iterator.next());
+ assertFalse(iterator.hasNext());
+ assertEquals(2, iterator.getIndex());
+
+ //
+ try
+ {
+ iterator.next();
+ fail("Was expecting a NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ assertFalse(iterator.hasNext());
+ assertEquals(2, iterator.getIndex());
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,126 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Iterator;
+import java.util.Arrays;
+import java.util.jar.JarOutputStream;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+
+import org.jboss.portal.common.jar.JarEntryInfo;
+import org.jboss.portal.common.jar.JarInfo;
+import org.jboss.portal.common.io.IOTools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7425 $
+ */
+public class JarTestCase extends TestCase
+{
+
+ public JarTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testJarEntryInfo()
+ {
+ JarEntryInfo info1 = new JarEntryInfo(new JarEntry("a"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info1.getNames());
+
+ JarEntryInfo info2 = new JarEntryInfo(new JarEntry("a/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info2.getNames());
+
+ JarEntryInfo info3 = new JarEntryInfo(new JarEntry("/"));
+ assertEquals(Arrays.asList(new String[]{"/"}), info3.getNames());
+
+ JarEntryInfo info4 = new JarEntryInfo(new JarEntry("a/b"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info4.getNames());
+
+ JarEntryInfo info5 = new JarEntryInfo(new JarEntry("a/b/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info5.getNames());
+
+ JarEntryInfo info6 = new JarEntryInfo(new JarEntry("/a"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info6.getNames());
+
+ JarEntryInfo info7 = new JarEntryInfo(new JarEntry("/a/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info7.getNames());
+
+ JarEntryInfo info8 = new JarEntryInfo(new JarEntry("/a/b"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info8.getNames());
+
+ JarEntryInfo info9 = new JarEntryInfo(new JarEntry("/a/b/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info9.getNames());
+ }
+
+ public void testEntryComparator() throws IOException
+ {
+ File jarFile = File.createTempFile("test", ".jar");
+
+ OutputStream out = IOTools.safeBufferedWrapper(new FileOutputStream(jarFile));
+ JarOutputStream jarOut = new JarOutputStream(out);
+ jarOut.putNextEntry(new JarEntry("a/c"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("c/d"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("a"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("b"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("a/b"));
+ jarOut.closeEntry();
+ jarOut.close();
+
+ jarFile.deleteOnExit();
+
+ JarInputStream jarIn = new JarInputStream(IOTools.safeBufferedWrapper(new FileInputStream(jarFile)));
+ Iterator i = new JarInfo(jarIn).entries();
+ while (i.hasNext())
+ {
+ Object o = i.next();
+ System.out.println("o = " + o);
+ }
+ jarIn.close();
+ }
+
+ public void testIsChildOf()
+ {
+ assertFalse(new JarEntryInfo(new JarEntry("a")).isChildOf(new JarEntryInfo(new JarEntry(""))));
+ assertFalse(new JarEntryInfo(new JarEntry("/a")).isChildOf(new JarEntryInfo(new JarEntry(""))));
+ assertTrue(new JarEntryInfo(new JarEntry("a")).isChildOf(new JarEntryInfo(new JarEntry("/"))));
+ assertTrue(new JarEntryInfo(new JarEntry("/a")).isChildOf(new JarEntryInfo(new JarEntry("/"))));
+ assertFalse(new JarEntryInfo(new JarEntry("a/b")).isChildOf(new JarEntryInfo(new JarEntry("a"))));
+ assertFalse(new JarEntryInfo(new JarEntry("/a/b")).isChildOf(new JarEntryInfo(new JarEntry("a"))));
+ assertTrue(new JarEntryInfo(new JarEntry("a/b")).isChildOf(new JarEntryInfo(new JarEntry("a/"))));
+ assertTrue(new JarEntryInfo(new JarEntry("/a/b")).isChildOf(new JarEntryInfo(new JarEntry("a/"))));
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,496 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.mx.JavaBeanModelMBeanBuilder;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.management.Attribute;
+import javax.management.Descriptor;
+import javax.management.modelmbean.ModelMBeanInfo;
+import javax.management.modelmbean.RequiredModelMBean;
+import javax.management.modelmbean.ModelMBeanOperationInfo;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7452 $
+ */
+public class JavaBeanModelMBeanBuilderTestCase extends TestCase
+{
+
+ public void testEmpty() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(Empty.class, Object.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ MBeanAttributeInfo[] attrs = info.getAttributes();
+ assertNotNull(attrs);
+ assertEquals(0, attrs.length);
+
+ //
+ MBeanOperationInfo[] ops = info.getOperations();
+ assertNotNull(ops);
+ assertEquals(0, ops.length);
+ }
+
+ public void testSimpleClass() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(TestClass.class, Object.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ assertNotNull(info.getAttributes());
+ Set attrs = getAttributes(info);
+
+ //
+ Set expectedAttrs = new HashSet();
+ expectedAttrs.add(new TestAttribute("java.lang.String", "String"));
+ expectedAttrs.add(new TestAttribute("boolean", "Boolean"));
+ assertEquals(expectedAttrs, attrs);
+
+ //
+ assertNotNull(info.getOperations());
+ Set ops = getOperations(info);
+
+ //
+ Set expectedOps = new HashSet();
+ expectedOps.add(TestOperation.newOperation("void", "operation", new String[]{}));
+ expectedOps.add(TestOperation.newOperation("void", "operation", new String[]{"java.lang.String"}));
+ expectedOps.add(TestOperation.newSetter("setString", "java.lang.String"));
+ expectedOps.add(TestOperation.newGetter("getString", "java.lang.String"));
+ expectedOps.add(TestOperation.newSetter("setBoolean", "boolean"));
+ expectedOps.add(TestOperation.newGetter("isBoolean", "boolean"));
+ assertEquals(expectedOps, ops);
+ }
+
+ public void testOperationOverride() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(Child.class, Parent.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ assertNotNull(info.getOperations());
+ Set ops = getOperations(info);
+
+ //
+ Set expectedOps = new HashSet();
+ expectedOps.add(TestOperation.newOperation("void", "overridenOperation", new String[]{}));
+ assertEquals(expectedOps, ops);
+ }
+
+ public void testSetterOverload() throws Exception
+ {
+ try
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(OverloadedSetter.class, Object.class);
+ fail();
+ }
+ catch (Exception expected)
+ {
+ // expected
+ }
+ }
+
+ public void testOverridenGetter() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(TestOverridenExtend.class, Object.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ Set ops = getOperations(info);
+ Set expectedOps = new HashSet();
+ expectedOps.add(TestOperation.newGetter("getTest", "java.util.Set"));
+ assertEquals(expectedOps, ops);
+
+ }
+
+ public void testAttributesAreNotCached() throws Exception
+ {
+ AttributesAreNotCached aanc = new AttributesAreNotCached();
+ ModelMBeanInfo info = JavaBeanModelMBeanBuilder.build(aanc);
+
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ ObjectName name = new ObjectName(":a=b");
+ RequiredModelMBean mbean = new RequiredModelMBean(info);
+ mbean.setManagedResource(aanc, "ObjectReference");
+ server.registerMBean(mbean, name);
+ assertEquals(new Integer(0), server.getAttribute(name, "Count"));
+ assertEquals(new Integer(1), server.getAttribute(name, "Count"));
+
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ public void testStaticAttribute() throws Exception
+ {
+ StaticAttribute sa = new StaticAttribute();
+ ModelMBeanInfo info = JavaBeanModelMBeanBuilder.build(sa);
+
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ ObjectName name = new ObjectName(":a=b");
+ RequiredModelMBean mbean = new RequiredModelMBean(info);
+ mbean.setManagedResource(sa, "ObjectReference");
+ server.registerMBean(mbean, name);
+ try
+ {
+ server.getAttribute(name, "Read");
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ try
+ {
+ server.getAttribute(name, "ReadWrite");
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ try
+ {
+ server.setAttribute(name, new Attribute("ReadWrite", new Integer(0)));
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ try
+ {
+ server.setAttribute(name, new Attribute("Write", new Integer(0)));
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ public Set getAttributes(ModelMBeanInfo info)
+ {
+ Set set = new HashSet();
+ MBeanAttributeInfo[] attrs = info.getAttributes();
+ for (int i = 0; i < attrs.length; i++)
+ {
+ MBeanAttributeInfo attr = attrs[i];
+ set.add(new TestAttribute(attr));
+ }
+ return set;
+ }
+
+ public Set getOperations(ModelMBeanInfo info)
+ {
+ MBeanOperationInfo[] ops = info.getOperations();
+ Set set = new HashSet();
+ for (int i = 0; i < ops.length; i++)
+ {
+ MBeanOperationInfo op = ops[i];
+ set.add(new TestOperation((ModelMBeanOperationInfo)op));
+ }
+ return set;
+ }
+
+ public static class StaticAttribute
+ {
+ public static int getRead()
+ {
+ return 0;
+ }
+
+ public static void setWrite(int a)
+ {
+ }
+
+ public static int getReadWrite()
+ {
+ return 0;
+ }
+
+ public static void setReadWrite(int a)
+ {
+ }
+ }
+
+ public static class OverloadedSetter
+ {
+ public void setA(int a)
+ {
+ }
+
+ public void setA(String a)
+ {
+ }
+
+ public boolean getA()
+ {
+ return false;
+ }
+
+ public boolean isA()
+ {
+ return false;
+ }
+ }
+
+ public static class Parent
+ {
+ public void operation()
+ {
+ }
+
+ public void overridenOperation()
+ {
+ }
+ }
+
+ public static class Child extends Parent
+ {
+ public void overridenOperation()
+ {
+ }
+ }
+
+ public static class Empty
+ {
+ }
+
+ public static class TestClass
+ {
+
+ public void operation()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void operation(String s)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getString()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setString(String s)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isBoolean()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBoolean(boolean b)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public class AttributesAreNotCached
+ {
+ private int count;
+
+ public int getCount()
+ {
+ return count++;
+ }
+ }
+
+ public class TestOverridenBase
+ {
+ public Set getTest()
+ {
+ //nothing
+ return new HashSet();
+ }
+ }
+
+ public class TestOverridenExtend extends TestOverridenBase
+ {
+ public Set getTest()
+ {
+ //nothing
+ return new HashSet();
+ }
+ }
+
+ public static class TestAttribute
+ {
+
+ /** . */
+ public final String type;
+
+ /** . */
+ public final String name;
+
+ public TestAttribute(MBeanAttributeInfo info)
+ {
+ this.type = info.getType();
+ this.name = info.getName();
+ }
+
+ public TestAttribute(String type, String name)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.type = type;
+ this.name = name;
+ }
+
+ public int hashCode()
+ {
+ return type.hashCode() * 43 + name.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ TestAttribute that = (TestAttribute)obj;
+ return type.equals(that.type) && name.equals(that.name);
+ }
+
+ public String toString()
+ {
+ return "Attribute[" + type + "," + name + "]";
+ }
+ }
+
+ public static class TestOperation
+ {
+
+ /** . */
+ public final String returnType;
+
+ /** . */
+ public final String name;
+
+ /** . */
+ public final String[] argTypes;
+
+ /** . */
+ public final String role;
+
+ public TestOperation(ModelMBeanOperationInfo info)
+ {
+ Descriptor desc = info.getDescriptor();
+
+ this.returnType = info.getReturnType();
+ this.name = info.getName();
+ this.argTypes = new String[info.getSignature().length];
+ this.role = (String)desc.getFieldValue("role");
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ argTypes[i] = info.getSignature()[i].getType();
+ }
+ }
+
+ public static TestOperation newOperation(String returnType, String name, String[] argTypes)
+ {
+ return new TestOperation(returnType, name, argTypes, "operation");
+ }
+
+ public static TestOperation newGetter(String name, String type)
+ {
+ return new TestOperation(type, name, new String[0], "getter");
+ }
+
+ public static TestOperation newSetter(String name, String type)
+ {
+ return new TestOperation("void", name, new String[]{type}, "setter");
+ }
+
+ public TestOperation(String returnType, String name, String[] argTypes, String role)
+ {
+ if (returnType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (argTypes == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ if (argTypes[i] == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ this.returnType = returnType;
+ this.name = name;
+ this.argTypes = argTypes;
+ this.role = role;
+ }
+
+ public int hashCode()
+ {
+ int code = (returnType.hashCode() * 43 + name.hashCode()) * 43 + role.hashCode();
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ String argType = argTypes[i];
+ code = code * 43 + argType.hashCode();
+ }
+ return code;
+ }
+
+ public boolean equals(Object obj)
+ {
+ TestOperation that = (TestOperation)obj;
+ return returnType.equals(that.returnType) && name.equals(that.name) && role.equals(that.role) && Arrays.equals(argTypes, that.argTypes);
+ }
+
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer("Operation[").append(returnType).append(",").append(name).append(",").append(role);
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ tmp.append(",").append(argTypes[i]);
+ }
+ tmp.append(")");
+ return tmp.toString();
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,217 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Writer;
+import java.io.IOException;
+
+import org.jboss.portal.common.i18n.LocaleFormat;
+import org.jboss.portal.common.i18n.CachingLocaleFormat;
+import org.jboss.portal.common.i18n.AbstractLocaleFormat;
+import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.util.ConversionException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LocaleFormatTestCase extends TestCase
+{
+
+ public void testgetLocaleFromDefaultFormat() throws ConversionException
+ {
+ assertEquals(new Locale("a"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a"));
+ assertEquals(new Locale("a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b"));
+ assertEquals(new Locale("", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_b"));
+ assertEquals(new Locale("a", "b", "c"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b_c"));
+ assertEquals(new Locale("a", "", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a__b"));
+ assertEquals(new Locale("", "a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_a_b"));
+ assertEquals(new Locale(""), LocaleFormat.DEFAULT_NO_CACHE.getLocale(""));
+
+ //
+ try
+ {
+ assertEquals(new Locale("", "", "a"), LocaleFormat.DEFAULT.getLocale("__a"));
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ try
+ {
+ assertEquals(new Locale("", "", ""), LocaleFormat.DEFAULT_NO_CACHE.getLocale("__"));
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ try
+ {
+ LocaleFormat.DEFAULT.getLocale("_");
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ }
+
+ public void testToStringFromDefaultFormat() throws ConversionException
+ {
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("")));
+
+ //
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "")));
+ assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b")));
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "")));
+ assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a")));
+
+ //
+ assertEquals("a_B_c", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "c")));
+ assertEquals("_A_b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "b")));
+ assertEquals("a__b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "b")));
+ assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "a")));
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "")));
+ assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "")));
+ }
+
+ public void testGetLocaleFromRFC3066LanguageTag() throws ConversionException
+ {
+ assertEquals(new Locale("en"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en"));
+ assertEquals(new Locale("en", "US"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en-US"));
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("wrong");
+ fail("Should have failed since an invalid String was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("zz");
+ fail("Should have failed since an invalid language code was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-ZZ");
+ fail("Should have failed since an invalid country code was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ // weird combination should work as well
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-US");
+ }
+
+ public void testGetRFC3066LanguageTagFromLocale() throws ConversionException
+ {
+ assertEquals("en", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en")));
+ assertEquals("en-US", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en", "US")));
+ }
+
+ public void testCachingLocaleFormat() throws ConversionException
+ {
+ TestLocaleFormat delegate = new TestLocaleFormat();
+ delegate.put(new Locale("abc"), "abc");
+ CachingLocaleFormat format = new CachingLocaleFormat(delegate);
+
+ //
+ assertEquals(new Locale("abc"), format.getLocale("abc"));
+ assertEquals("abc", format.toString(new Locale("abc")));
+
+ //
+ try
+ {
+ format.getLocale("def");
+ fail();
+ }
+ catch (ConversionException e)
+ {
+ }
+
+ //
+ try
+ {
+ format.toString(new Locale("def"));
+ fail();
+ }
+ catch (ConversionException e)
+ {
+ }
+ }
+
+ private static class TestLocaleFormat extends AbstractLocaleFormat
+ {
+
+ /** . */
+ private final Map localeToString = new HashMap();
+
+ /** . */
+ private final Map stringToLocale = new HashMap();
+
+ private void put(Locale locale, String string)
+ {
+ localeToString.put(locale, string);
+ stringToLocale.put(string, locale);
+ }
+
+ protected Locale internalGetLocale(String value) throws ConversionException
+ {
+ Locale locale = (Locale)stringToLocale.get(value);
+ if (locale == null)
+ {
+ throw new ConversionException();
+ }
+ return locale;
+ }
+
+ protected void internalWrite(Locale locale, Writer writer) throws IOException, ConversionException
+ {
+ String string = (String)localeToString.get(locale);
+ if (string == null)
+ {
+ throw new ConversionException();
+ }
+ writer.write(string);
+ }
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.LocalizedString;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 6818 $
+ */
+public class LocalizedStringTestCase extends TestCase
+{
+ private Map values = new HashMap();
+ private LocalizedString localizedString;
+
+ protected void setUp() throws Exception
+ {
+ values.put(Locale.ENGLISH, "labour");
+ values.put(Locale.FRENCH, "travail");
+ values.put(Locale.US, "labor");
+ localizedString = new LocalizedString(values, Locale.US);
+ }
+
+ public void testPreferredOrBestLocalizedMappingFor()
+ {
+ try
+ {
+ localizedString.getPreferredOrBestLocalizedMappingFor(null);
+ fail("LocalizedString get most appropriate value for should have thrown an IllegalArgumentException with a null argument");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ // no desired locales: should return default
+ checkValueAndLocale(Locale.US, new String[]{});
+
+ checkValueAndLocale(Locale.ENGLISH, new String[]{"en", "en-US", "aa"});
+ checkValueAndLocale(Locale.US, new String[]{"en-US", "en", "aa"});
+ checkValueAndLocale(Locale.FRENCH, new String[]{"fr-CA"});
+ }
+
+ private void checkValueAndLocale(Locale locale, String[] desiredLocales)
+ {
+ LocalizedString.Value mapping = localizedString.getPreferredOrBestLocalizedMappingFor(desiredLocales);
+
+ Locale foundLocale = mapping.getLocale();
+ assertEquals(locale, foundLocale);
+ assertEquals(values.get(foundLocale), mapping.getString());
+ assertEquals(mapping.getString(), localizedString.getMostAppropriateValueFor(desiredLocales));
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.markup.MarkupAttribute;
+import org.jboss.portal.common.markup.MarkupElement;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MarkupTestCase extends TestCase
+{
+
+ public void testAttributeConstructor()
+ {
+ try
+ {
+ new MarkupAttribute(null, "value", MarkupAttribute.Type.CDATA);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupAttribute("name", null, MarkupAttribute.Type.CDATA);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupAttribute("name", "value", null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ MarkupAttribute attribute = new MarkupAttribute("name", "value", MarkupAttribute.Type.CDATA);
+ assertEquals("name", attribute.getName());
+ assertEquals("value", attribute.getValue());
+ assertEquals(MarkupAttribute.Type.CDATA, attribute.getType());
+ }
+
+ public void testElementContructor()
+ {
+ try
+ {
+ new MarkupElement(null, "body", false, new MarkupAttribute[0]);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupElement("name", "body", false, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupElement("name", "body", false, new MarkupAttribute[]{null});
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ MarkupElement element = new MarkupElement("elementname", "body", false, new MarkupAttribute[]{new MarkupAttribute("attributename", "attributevalue", MarkupAttribute.Type.CDATA)});
+ assertEquals("elementname", element.getName());
+ assertEquals("body", element.getBodyContent());
+ assertEquals(false, element.isNeverEmpty());
+ assertEquals(1, element.getAttributeSize());
+ MarkupAttribute attribute = element.getAttribute(0);
+ assertEquals("attributename", attribute.getName());
+ assertEquals("attributevalue", attribute.getValue());
+ assertEquals(MarkupAttribute.Type.CDATA, attribute.getType());
+ attribute = element.getAttribute("attributename");
+ assertEquals("attributename", attribute.getName());
+ assertEquals("attributevalue", attribute.getValue());
+ assertEquals(MarkupAttribute.Type.CDATA, attribute.getType());
+ assertEquals(null, element.getAttribute("someotherattributename"));
+ }
+
+ public void testAttributeURIEncoding()
+ {
+ MarkupAttribute attribute = new MarkupAttribute("name", "/-_.*ABCabc012# ", MarkupAttribute.Type.URI);
+ assertEquals("/-_.*ABCabc012%23+", attribute.getEncodedValue());
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/P3PConstantsTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/P3PConstantsTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/P3PConstantsTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,121 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import static org.jboss.portal.common.p3p.P3PConstants.*;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 9048 $
+ */
+public class P3PConstantsTestCase extends TestCase
+{
+ public void testGetPostalUserInfoKey()
+ {
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_CITY, getPostalUserInfoKey(PostalInfo.CITY, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_COUNTRY, getPostalUserInfoKey(PostalInfo.COUNTRY, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_NAME, getPostalUserInfoKey(PostalInfo.NAME, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_ORGANIZATION, getPostalUserInfoKey(PostalInfo.ORGANIZATION, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_POSTALCODE, getPostalUserInfoKey(PostalInfo.POSTALCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_STATEPROV, getPostalUserInfoKey(PostalInfo.STATEPROV, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_STREET, getPostalUserInfoKey(PostalInfo.STREET, true));
+
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_CITY, getPostalUserInfoKey(PostalInfo.CITY, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_COUNTRY, getPostalUserInfoKey(PostalInfo.COUNTRY, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_NAME, getPostalUserInfoKey(PostalInfo.NAME, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_ORGANIZATION, getPostalUserInfoKey(PostalInfo.ORGANIZATION, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_POSTALCODE, getPostalUserInfoKey(PostalInfo.POSTALCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_STATEPROV, getPostalUserInfoKey(PostalInfo.STATEPROV, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_STREET, getPostalUserInfoKey(PostalInfo.STREET, false));
+ }
+
+ public void testGetOnlineInfoKey()
+ {
+ assertEquals(INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, getOnlineUserInfoKey(OnlineInfo.EMAIL, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_ONLINE_URI, getOnlineUserInfoKey(OnlineInfo.URI, true));
+
+ assertEquals(INFO_USER_HOME_INFO_ONLINE_EMAIL, getOnlineUserInfoKey(OnlineInfo.EMAIL, false));
+ assertEquals(INFO_USER_HOME_INFO_ONLINE_URI, getOnlineUserInfoKey(OnlineInfo.URI, false));
+ }
+
+
+ public void testGetTelecomInfoKey()
+ {
+ // business fax
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_COMMENT, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.COMMENT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_EXT, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.EXT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_INTCODE, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.INTCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_LOCCODE, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.LOCCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_NUMBER, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.NUMBER, true));
+
+ // home fax
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_COMMENT, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.COMMENT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_EXT, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.EXT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_INTCODE, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.INTCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_LOCCODE, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.LOCCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_NUMBER, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.NUMBER, false));
+
+ // business mobile
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_COMMENT, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.COMMENT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_EXT, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.EXT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_INTCODE, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.INTCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_LOCCODE, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.LOCCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.NUMBER, true));
+
+ // home mobile
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_COMMENT, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.COMMENT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_EXT, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.EXT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_INTCODE, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.INTCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_LOCCODE, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.LOCCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_NUMBER, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.NUMBER, false));
+
+ // business pager
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_COMMENT, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.COMMENT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_EXT, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.EXT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_INTCODE, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.INTCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_LOCCODE, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.LOCCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_NUMBER, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.NUMBER, true));
+
+ // home pager
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_COMMENT, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.COMMENT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_EXT, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.EXT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_INTCODE, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.INTCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_LOCCODE, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.LOCCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_NUMBER, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.NUMBER, false));
+
+ // business telephone
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_COMMENT, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.COMMENT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_EXT, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.EXT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_INTCODE, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.INTCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_LOCCODE, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.LOCCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_NUMBER, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.NUMBER, true));
+
+ // home telephone
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_COMMENT, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.COMMENT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_EXT, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.EXT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_INTCODE, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.INTCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_LOCCODE, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.LOCCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_NUMBER, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.NUMBER, false));
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,143 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.ParameterMap;
+
+import java.util.HashMap;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6643 $
+ */
+public class ParameterMapTestCase extends TestCase
+{
+
+ public void testPut()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ pm.put("foo", new String[]{"bar"});
+ // ExtendedAssert.assertEquals(new String[]{"bar"}, (Object[])pm.get("foo"));
+ }
+
+ public void testEntry()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ pm.put("foo", new String[]{"bar"});
+ Set entries = pm.entrySet();
+ assertNotNull(entries);
+ Iterator iterator = entries.iterator();
+ assertTrue(iterator.hasNext());
+ Object tmp = iterator.next();
+ assertTrue(tmp instanceof Map.Entry);
+ Map.Entry entry = (Map.Entry)tmp;
+ assertEquals("foo", entry.getKey());
+ // ExtendedAssert.assertEquals(new String[]{"bar"}, (Object[])entry.getValue());
+ }
+
+ public void testPutThrowsException()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ try
+ {
+ ((Map)pm).put(new Object(), new String[]{"bar"});
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ try
+ {
+ ((Map)pm).put("foo", new Object[]{});
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ try
+ {
+ pm.put("foo", new String[]{});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ pm.put("foo", new String[]{null});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEntrySetValueThrowsException()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ pm.put("foo", new String[]{"bar"});
+ Set entries = pm.entrySet();
+ assertNotNull(entries);
+ Iterator iterator = entries.iterator();
+ assertTrue(iterator.hasNext());
+ Object tmp = iterator.next();
+ assertTrue(tmp instanceof Map.Entry);
+ Map.Entry entry = (Map.Entry)tmp;
+ try
+ {
+ entry.setValue(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ entry.setValue(new Object[]{});
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ try
+ {
+ entry.setValue(new String[]{});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ entry.setValue(new String[]{null});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.i18n.ParentChildResourceBundle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class ParentChildResourceBundleTestCase extends TestCase
+{
+ public ParentChildResourceBundleTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testBasic()
+ {
+ ResourceBundle parent = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ if ("key-a".equals(key))
+ {
+ return "parent-a";
+ }
+ if ("key-b".equals(key))
+ {
+ return "parent-b";
+ }
+ return null;
+ }
+ public Enumeration getKeys()
+ {
+ Vector keys = new Vector();
+ keys.add("key-a");
+ keys.add("key-b");
+ return keys.elements();
+ }
+ public Locale getLocale()
+ {
+ return Locale.CHINA;
+ }
+ };
+ ResourceBundle child = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ if ("key-a".equals(key))
+ {
+ return "child-a";
+ }
+ if ("key-c".equals(key))
+ {
+ return "child-c";
+ }
+ return null;
+ }
+ public Enumeration getKeys()
+ {
+ Vector keys = new Vector();
+ keys.add("key-a");
+ keys.add("key-c");
+ return keys.elements();
+ }
+ public Locale getLocale()
+ {
+ return Locale.GERMAN;
+ }
+ };
+ ResourceBundle bundle = new ParentChildResourceBundle(parent, child);
+ assertEquals(Locale.GERMAN, bundle.getLocale());
+ assertEquals("child-a", bundle.getString("key-a"));
+ assertEquals("parent-b", bundle.getString("key-b"));
+ assertEquals("child-c", bundle.getString("key-c"));
+ Set keys = new HashSet(Arrays.asList(new Object[]{"key-a","key-b","key-c"}));
+ for (Enumeration e = bundle.getKeys();e.hasMoreElements();)
+ {
+ assertTrue(keys.remove(e.nextElement()));
+ }
+ assertTrue(keys.isEmpty());
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.path.PathMapper;
+import org.jboss.portal.common.path.PathMapperContext;
+import org.jboss.portal.common.path.PathMapperResult;
+import org.jboss.portal.common.path.SimplePathMapper;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class PathMapperTestCase extends TestCase
+{
+
+ public PathMapperTestCase(String s)
+ {
+ super(s);
+ }
+
+ private PathMapper mapper;
+
+ protected void setUp() throws Exception
+ {
+ mapper = new SimplePathMapper();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ mapper = null;
+ }
+
+ public void testEmptyContext()
+ {
+ PathMapperContextImpl root = new PathMapperContextImpl(null);
+
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, null));
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, ""));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "/"));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "//"));
+
+ assertEquals(new PathMapperResult(null, null, "/a"), mapper.map(root, "/a"));
+ assertEquals(new PathMapperResult(null, null, "/a/"), mapper.map(root, "/a/"));
+ assertEquals(new PathMapperResult(null, null, "/a/b"), mapper.map(root, "/a/b"));
+ assertEquals(new PathMapperResult(null, null, "/a/b/"), mapper.map(root, "/a/b/"));
+ assertEquals(new PathMapperResult(null, null, "/a/b/c"), mapper.map(root, "/a/b/c"));
+ }
+
+ public void testOneChild()
+ {
+ PathMapperContextImpl root = new PathMapperContextImpl(null);
+ PathMapperContextImpl child = new PathMapperContextImpl(null);
+ root.addChild("a", child);
+
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, null));
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, ""));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "/"));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "//"));
+
+ assertEquals(new PathMapperResult(child, "/a", null), mapper.map(root, "/a"));
+ assertEquals(new PathMapperResult(child, "/a", "/"), mapper.map(root, "/a/"));
+ assertEquals(new PathMapperResult(child, "/a", "/b"), mapper.map(root, "/a/b"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/"), mapper.map(root, "/a/b/"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/c"), mapper.map(root, "/a/b/c"));
+
+ assertEquals(new PathMapperResult(null, null, "/b"), mapper.map(root, "/b"));
+ assertEquals(new PathMapperResult(null, null, "/b/"), mapper.map(root, "/b/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c"), mapper.map(root, "/b/c"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/"), mapper.map(root, "/b/c/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/d"), mapper.map(root, "/b/c/d"));
+ }
+
+ public void testOneChildHavingOneChild()
+ {
+ PathMapperContextImpl root = new PathMapperContextImpl(null);
+ PathMapperContextImpl child = new PathMapperContextImpl(null);
+ PathMapperContextImpl childOfChild = new PathMapperContextImpl(null);
+ root.addChild("a", child);
+ child.addChild("b", childOfChild);
+
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, null));
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, ""));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "/"));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "//"));
+
+ assertEquals(new PathMapperResult(child, "/a", null), mapper.map(root, "/a"));
+ assertEquals(new PathMapperResult(child, "/a", "/"), mapper.map(root, "/a/"));
+ assertEquals(new PathMapperResult(childOfChild, "/a/b", null), mapper.map(root, "/a/b"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/"), mapper.map(root, "/a/b/"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/c"), mapper.map(root, "/a/b/c"));
+
+ assertEquals(new PathMapperResult(null, null, "/b"), mapper.map(root, "/b"));
+ assertEquals(new PathMapperResult(null, null, "/b/"), mapper.map(root, "/b/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c"), mapper.map(root, "/b/c"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/"), mapper.map(root, "/b/c/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/d"), mapper.map(root, "/b/c/d"));
+ }
+
+ private static class Context
+ {
+ private final Map children;
+
+ public Context(Object dflt)
+ {
+ children = new HashMap();
+ }
+
+ public void addChild(String name, Object child)
+ {
+ children.put(name, child);
+ }
+ }
+
+ private static class PathMapperContextImpl extends Context implements PathMapperContext
+ {
+ public PathMapperContextImpl(Object dflt)
+ {
+ super(dflt);
+ }
+
+ public Object getRoot()
+ {
+ return this;
+ }
+
+ public Object getChild(Object parent, String name)
+ {
+ return ((Context)parent).children.get(name);
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.path.RelativePathParser;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class PathTestCase extends TestCase
+{
+
+ public void testSimpleDown()
+ {
+ String[] paths = {"abc","abc/","abc/."};
+ for (int i = 0; i < paths.length; i++)
+ {
+ String path = paths[i];
+ RelativePathParser cursor = new RelativePathParser(path);
+ assertEquals(RelativePathParser.DOWN, cursor.next());
+ assertEquals(0, cursor.getOffset());
+ assertEquals(3, cursor.getLength());
+ assertEquals("abc", path.substring(cursor.getOffset(), cursor.getLength()));
+ assertEquals(RelativePathParser.NONE, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ }
+ }
+
+ public void testSimpleNone()
+ {
+ String[] paths = {"",".","./","./."};
+ for (int i = 0; i < paths.length; i++)
+ {
+ String path = paths[i];
+ RelativePathParser cursor = new RelativePathParser(path);
+ assertEquals(RelativePathParser.NONE, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ }
+ }
+
+ public void testSimpleUp()
+ {
+ String[] paths = {"..","../","../."};
+ for (int i = 0; i < paths.length; i++)
+ {
+ String path = paths[i];
+ RelativePathParser cursor = new RelativePathParser(path);
+ assertEquals(RelativePathParser.UP, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ assertEquals(RelativePathParser.NONE, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6305 $
+ */
+public class StringTestCase extends TestCase
+{
+
+ public StringTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testReplace()
+ {
+ assertEquals("", Tools.replace("", "abc", "def"));
+ assertEquals("defg", Tools.replace("abc", "abc", "defg"));
+ assertEquals("_defg_", Tools.replace("_abc_", "abc", "defg"));
+ assertEquals("_defgdefg_", Tools.replace("_abcabc_", "abc", "defg"));
+ assertEquals("_defg_defg_", Tools.replace("_abc_abc_", "abc", "defg"));
+ }
+
+ public void testReplaceBoundedString()
+ {
+ assertEquals("", Tools.replaceAllInstancesOfBoundedString("", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("REPLACEMENT", Tools.replaceAllInstancesOfBoundedString("PREFIXSUFFIX", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("PREFIXSUFFIX", Tools.replaceBoundedString("PREFIXSUFFIX", "PREFIX", "SUFFIX", "REPLACEMENT", false, true));
+ assertEquals("PREFIXSUFFIX", Tools.replaceBoundedString("PREFIXSUFFIX", "PREFIX", "SUFFIX", "REPLACEMENT", false, false));
+ assertEquals("aaaaREPLACEMENTccccc", Tools.replaceAllInstancesOfBoundedString("aaaaPREFIXbbbbbSUFFIXccccc", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("aaaPREFIXbbbbSUFF", Tools.replaceAllInstancesOfBoundedString("aaaPREFIXbbbbSUFF", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("aRcccReeeR", Tools.replaceAllInstancesOfBoundedString("aPbbScccPdSeeePS", "P", "S", "R"));
+ assertEquals("PSaPScccReeePS", Tools.replaceBoundedString("PSaPScccPdSeeePS", "P", "S", "R", false, false));
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Calendar;
+
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class TemporaryHashTestCase extends TestCase
+{
+
+ public TemporaryHashTestCase(String key)
+ {
+ super(key);
+ }
+
+ public void testBasic()
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(2004, 1, 1, 1, 30, 0);
+ String hash = Tools.generateTemporaryHash("blah", calendar.getTimeInMillis());
+
+ calendar.set(2004, 1, 1, 1, 0, 0);
+ assertTrue(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 0, 59, 59);
+ assertFalse(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 2, 0, 0);
+ assertTrue(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 2, 59, 59);
+ assertTrue(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 3, 0, 0);
+ assertFalse(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,421 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.util.Tools;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.Vector;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 6384 $
+ * @since 2.6
+ */
+public class ToolsTestCase extends TestCase
+{
+ public void testIsContainedIn()
+ {
+ String value = "value";
+ String[] array = new String[]{"foo", "bar", value, "baz"};
+
+ assertTrue(Tools.isContainedIn(value, array));
+ assertFalse(Tools.isContainedIn(null, array));
+ assertFalse(Tools.isContainedIn(value, null));
+ assertFalse(Tools.isContainedIn(null, null));
+ assertFalse(Tools.isContainedIn("bat", array));
+ }
+
+ public void testIteratorToEnumerationThrowsIAE()
+ {
+ try
+ {
+ Tools.toEnumeration((Iterator)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIteratorToEnumeration1()
+ {
+ assertEnumeration(Tools.toEnumeration(new ArrayList<String>().iterator()));
+ }
+
+ public void testIteratorToEnumeration2()
+ {
+ List<String> tmp = new ArrayList<String>();
+ tmp.add("a");
+ assertEnumeration(Tools.toEnumeration(tmp.iterator()), "a");
+ }
+
+ public void testIteratorToEnumeration3()
+ {
+ List<String> tmp = new ArrayList<String>();
+ tmp.add("a");
+ tmp.add("b");
+ assertEnumeration(Tools.toEnumeration(tmp.iterator()), "a", "b");
+ }
+
+ public void testArrayToEnumerationThrowsIAE()
+ {
+ try
+ {
+ Tools.toEnumeration((Object[])null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayToEnumeration1()
+ {
+ assertEnumeration(Tools.toEnumeration(new String[]{}));
+ }
+
+ public void testArrayToEnumeration2()
+ {
+ assertEnumeration(Tools.toEnumeration(new String[]{"a"}), "a");
+ }
+
+ public void testArrayToEnumeration3()
+ {
+ assertEnumeration(Tools.toEnumeration(new String[]{"a","b"}), "a", "b");
+ }
+
+ public void testElementToEnumeration()
+ {
+ assertEnumeration(Tools.toEnumeration("a"), "a");
+ }
+
+ public void testEnumerationToSetThrowsIAE()
+ {
+ try
+ {
+ Tools.toSet((Enumeration)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testEnumerationToSet()
+ {
+ Vector<String> v = new Vector<String>();
+ v.add("a");
+ v.add("b");
+ v.add("a");
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, Tools.toSet(v.elements()));
+ }
+
+ public void testArrayToSetThrowsIAE()
+ {
+ try
+ {
+ Tools.toSet((Object[])null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayToSet()
+ {
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, Tools.toSet(new String[]{"a","b","a"}));
+ }
+
+ public void testIteratorToSetThrowsIAE()
+ {
+ try
+ {
+ Tools.toSet((Iterator)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIteratorToSet()
+ {
+ List<String> list = new ArrayList<String>();
+ list.add("a");
+ list.add("b");
+ list.add("a");
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, Tools.toSet(list.iterator()));
+ }
+
+ public void testEnumerationToListThrowsIAE()
+ {
+ try
+ {
+ Tools.toList((Enumeration)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testEnumerationToList()
+ {
+ Vector<String> v = new Vector<String>();
+ v.add("a");
+ v.add("b");
+ v.add("a");
+ List<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, Tools.toList(v.elements()));
+ }
+
+ public void testArrayToListThrowsIAE()
+ {
+ try
+ {
+ Tools.toList((Object[])null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayToList()
+ {
+ List<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, Tools.toList(new String[]{"a","b","a"}));
+ }
+
+ public void testIteratorToListThrowsIAE()
+ {
+ try
+ {
+ Tools.toList((Iterator)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIteratorToList()
+ {
+ List<String> list = new ArrayList<String>();
+ list.add("a");
+ list.add("b");
+ list.add("a");
+ List<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, Tools.toList(list.iterator()));
+ }
+
+
+ public void testArrayIteratorThrowsIAE()
+ {
+ try
+ {
+ Tools.iterator((Object[])null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayIterator1()
+ {
+ assertIterator(Tools.iterator(new String[]{}));
+ }
+
+ public void testArrayIterator2()
+ {
+ assertIterator(Tools.iterator(new String[]{"a"}), "a");
+ }
+
+ public void testArrayIterator3()
+ {
+ assertIterator(Tools.iterator(new String[]{"a","b"}), "a", "b");
+ }
+
+ public void testElementIterator()
+ {
+ assertIterator(Tools.iterator("a"), "a");
+ }
+
+ public void testArrayRangeIteratorThrowsIAE()
+ {
+ try
+ {
+ Tools.iterator(null, 0, 0);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayRangeIterator1()
+ {
+ assertIteratorMethodThrowIAE(new String[]{}, -1, 0);
+ assertIteratorMethodThrowIAE(new String[]{}, 0, 1);
+ assertIteratorMethodThrowIAE(new String[]{}, 1, 0);
+ assertIterator(Tools.iterator(new String[]{}, 0, 0));
+ }
+
+ public void testArrayRangeIterator2()
+ {
+ assertIteratorMethodThrowIAE(new String[]{"a"}, -1, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a"}, 1, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a"}, 1, 2);
+ assertIterator(Tools.iterator(new String[]{"a"}, 0, 0));
+ assertIterator(Tools.iterator(new String[]{"a"}, 1, 1));
+ assertIterator(Tools.iterator(new String[]{"a"}, 0, 1), "a");
+ }
+
+ public void testArrayRangeIterator3()
+ {
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, -1, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, 1, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, 2, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, 2, 1);
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, 2, 3);
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 0, 0));
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 1, 1));
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 2, 2));
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 0, 1), "a");
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 1, 2), "b");
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 0, 2), "a", "b");
+ }
+
+ public void testArrayAppendToThrowsIAE()
+ {
+ try
+ {
+ Tools.appendTo(null, "a");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testEmptyEnumeration()
+ {
+ assertEnumeration(Tools.EMPTY_ENUMERATION);
+ }
+
+ public void testEmptyIterator()
+ {
+ assertIterator(Tools.EMPTY_ITERATOR);
+ }
+
+ public void testArrayAppendTo()
+ {
+ ExtendedAssert.assertEquals(new String[]{"a"}, Tools.appendTo(new String[0], "a"));
+ ExtendedAssert.assertEquals(new String[]{null}, Tools.appendTo(new String[0], null));
+ ExtendedAssert.assertEquals(new String[]{"a", "b"}, Tools.appendTo(new String[]{"a"}, "b"));
+ ExtendedAssert.assertEquals(new String[]{null, "b"}, Tools.appendTo(new String[]{null}, "b"));
+ ExtendedAssert.assertEquals(new String[]{"a", null}, Tools.appendTo(new String[]{"a"}, null));
+ }
+
+ private <E> void assertEnumeration(Enumeration<E> elements, E... expectedElements)
+ {
+ assertNotNull(elements);
+ for (E expectedElement : expectedElements)
+ {
+ assertTrue(elements.hasMoreElements());
+ E element = elements.nextElement();
+ assertEquals(expectedElement, element);
+ }
+ assertFalse(elements.hasMoreElements());
+ try
+ {
+ elements.nextElement();
+ fail();
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ private void assertIteratorMethodThrowIAE(Object[] array, int from, int to)
+ {
+ try
+ {
+ Tools.iterator(array, from, to);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ private <E> void assertIterator(Iterator<E> elements, E... expectedElements)
+ {
+ assertNotNull(elements);
+ for (E expectedElement : expectedElements)
+ {
+ assertTrue(elements.hasNext());
+ E element = elements.next();
+ assertEquals(expectedElement, element);
+ }
+ assertFalse(elements.hasNext());
+ try
+ {
+ elements.next();
+ fail();
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,222 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.common.value.IntegerValue;
+import org.jboss.portal.common.value.StringValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ValueTestCase extends TestCase
+{
+ public ValueTestCase(String s)
+ {
+ super(s);
+ }
+
+
+ public void testIntegerValueWithNull() throws Exception
+ {
+ _testNullInteger(new IntegerValue());
+ _testNullInteger(new IntegerValue((Integer)null));
+ _testNullInteger(new IntegerValue((String)null));
+ _testNullInteger(new IntegerValue(new Integer[1]));
+ _testNullInteger(new IntegerValue(new String[1]));
+ }
+
+ private void _testNullInteger(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertTrue(value.isNull());
+ assertEquals(1, value.size());
+ assertFalse(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertNull(value.asString());
+ assertEquals(null, value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(1, value.asStringArray().length);
+ assertNull(value.asStringArray()[0]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(1, value.asObjectArray().length);
+ assertNull(value.asObjectArray()[0]);
+ }
+
+ public void testIntegerValueEmptyArray() throws Exception
+ {
+ _testIntegerValueEmptyArray(new IntegerValue(new Integer[0]));
+ _testIntegerValueEmptyArray(new IntegerValue(new int[0]));
+ _testIntegerValueEmptyArray(new IntegerValue(new String[0]));
+ }
+
+ public void _testIntegerValueEmptyArray(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertTrue(value.isNull());
+ assertEquals(0, value.size());
+ assertFalse(value.isMultiValued());
+ assertTrue(value.isEmpty());
+ assertNull(value.asString());
+ assertNull(value.asObject());
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(0, value.asObjectArray().length);
+ assertNotNull(value.asStringArray());
+ assertEquals(0, value.asStringArray().length);
+ }
+
+ public void testIntegerValueNonNullInteger() throws Exception
+ {
+ _testIntegerValueNonNullInteger(new IntegerValue(1));
+ _testIntegerValueNonNullInteger(new IntegerValue(new Integer(1)));
+ _testIntegerValueNonNullInteger(new IntegerValue(new int[]{1}));
+ _testIntegerValueNonNullInteger(new IntegerValue(new Integer[]{new Integer(1)}));
+ _testIntegerValueNonNullInteger(new IntegerValue("1"));
+ _testIntegerValueNonNullInteger(new IntegerValue(new String[]{"1"}));
+ }
+
+ private void _testIntegerValueNonNullInteger(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertFalse(value.isNull());
+ assertEquals(1, value.size());
+ assertFalse(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertEquals("1", value.asString());
+ assertEquals(new Integer(1), value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(1, value.asStringArray().length);
+ assertEquals("1", value.asStringArray()[0]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(1, value.asObjectArray().length);
+ assertEquals(new Integer(1), value.asObjectArray()[0]);
+ }
+
+ public void testIntegerValueIntegerArray() throws Exception
+ {
+ _testIntegerValueIntegerArray(new IntegerValue(new int[]{1,2}));
+ _testIntegerValueIntegerArray(new IntegerValue(new Integer[]{new Integer(1), new Integer(2)}));
+ _testIntegerValueIntegerArray(new IntegerValue(new String[]{"1","2"}));
+ }
+
+ private void _testIntegerValueIntegerArray(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertFalse(value.isNull());
+ assertEquals(2, value.size());
+ assertTrue(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertEquals("1", value.asString());
+ assertEquals(new Integer(1), value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(2, value.asStringArray().length);
+ assertEquals("1", value.asStringArray()[0]);
+ assertEquals("2", value.asStringArray()[1]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(2, value.asObjectArray().length);
+ assertEquals(new Integer(1), value.asObjectArray()[0]);
+ assertEquals(new Integer(2), value.asObjectArray()[1]);
+ }
+
+ public void testIntegerValueIntegerArrayWithNull() throws Exception
+ {
+ _testIntegerValueIntegerArrayWithNull(new IntegerValue(new Integer[]{null, new Integer(1)}));
+ _testIntegerValueIntegerArrayWithNull(new IntegerValue(new String[]{null, "1"}));
+ }
+
+ private void _testIntegerValueIntegerArrayWithNull(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertTrue(value.isNull());
+ assertEquals(2, value.size());
+ assertTrue(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertEquals(null, value.asString());
+ assertEquals(null, value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(2, value.asStringArray().length);
+ assertEquals(null, value.asStringArray()[0]);
+ assertEquals("1", value.asStringArray()[1]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(2, value.asObjectArray().length);
+ assertEquals(null, value.asObjectArray()[0]);
+ assertEquals(new Integer(1), value.asObjectArray()[1]);
+ }
+
+ public void testClone() throws Exception
+ {
+ StringValue a = new StringValue("abc");
+ Object b = a.clone();
+ assertTrue(b instanceof StringValue);
+ StringValue c = (StringValue)b;
+ assertEquals(a, c);
+
+ //
+ StringValue d = new StringValue(new String[]{"abc","def"});
+ Object e = d.clone();
+ assertTrue(e instanceof StringValue);
+ StringValue f = (StringValue)e;
+ assertEquals(d, f);
+ }
+
+ public void testEqualsOnStringValues()
+ {
+ assertEquals(new StringValue(), new StringValue());
+ assertEquals(new StringValue(), new StringValue((String)null));
+ assertEquals(new StringValue(), new StringValue(new String[0]));
+ assertEquals(new StringValue(), new StringValue(new String[]{null}));
+ assertEquals(new StringValue((String)null), new StringValue());
+ assertEquals(new StringValue((String)null), new StringValue((String)null));
+ assertEquals(new StringValue((String)null), new StringValue(new String[0]));
+ assertEquals(new StringValue((String)null), new StringValue(new String[]{null}));
+ assertEquals(new StringValue(new String[0]), new StringValue());
+ assertEquals(new StringValue(new String[0]), new StringValue((String)null));
+ assertEquals(new StringValue(new String[0]), new StringValue(new String[0]));
+ assertEquals(new StringValue(new String[0]), new StringValue(new String[]{null}));
+ assertEquals(new StringValue(new String[]{null}), new StringValue());
+ assertEquals(new StringValue(new String[]{null}), new StringValue((String)null));
+ assertEquals(new StringValue(new String[]{null}), new StringValue(new String[0]));
+ assertEquals(new StringValue(new String[]{null}), new StringValue(new String[]{null}));
+ }
+
+ public void testUnmodifiable()
+ {
+ StringValue a = new StringValue("abc");
+ String[] b = (String[])a.asObjectArray();
+ b[0] = "def";
+ assertEquals("abc", a.asString());
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,197 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import java.io.PrintStream;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.BrokenBarrierException;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.concurrent.Valve;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ValveTestCase extends TestCase
+{
+
+ public ValveTestCase(String key)
+ {
+ super(key);
+ }
+
+ public static final PrintStream out = System.out;
+
+ public void testTransitions()
+ {
+ Valve valve = new Valve();
+ assertEquals(Valve.CLOSED, valve.getState());
+ assertFalse(valve.beforeInvocation());
+ try
+ {
+ valve.closing(10);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ try
+ {
+ valve.closing();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ try
+ {
+ valve.closed();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ // Open the valve
+ valve.open();
+ try
+ {
+ assertTrue(valve.beforeInvocation());
+ }
+ finally
+ {
+ valve.afterInvocation();
+ }
+ try
+ {
+ valve.open();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ try
+ {
+ valve.closed();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+
+
+ // Closing the valve
+ valve.closing();
+ assertEquals(Valve.CLOSING, valve.getState());
+ assertFalse(valve.beforeInvocation());
+ try
+ {
+ valve.open();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ valve.closing();
+
+ // Close the valve
+ valve.closed();
+ assertEquals(Valve.CLOSED, valve.getState());
+ }
+
+ public void testTimeOut() throws Exception
+ {
+ final Valve valve = new Valve();
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ assertTrue(valve.beforeInvocation());
+
+ // The valve is enterred
+ barrier.await();
+
+ // Wait
+ barrier.await();
+ }
+ catch (BrokenBarrierException e)
+ {
+ fail("" + e.getMessage());
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+ finally
+ {
+ valve.afterInvocation();
+ try
+ {
+ // Tell the other thread we have finished
+ barrier.await();
+ }
+ catch (BrokenBarrierException e)
+ {
+ fail("" + e.getMessage());
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+ }
+ }
+ };
+
+ // Open valve and start thread
+ valve.open();
+ thread.start();
+
+ // Wait until the thread called beforeInvocation
+ barrier.await();
+
+ // Attemtp to close
+ assertFalse(valve.closing(100));
+
+ // Check it is in closing state
+ assertEquals(Valve.CLOSING, valve.getState());
+
+ // Ask the invoker thread to finish
+ barrier.await();
+
+ // Wait until invocation is finished
+ barrier.await();
+
+ // Close, no thread are inside
+ valve.closing();
+ assertEquals(Valve.CLOSING, valve.getState());
+
+ //
+ valve.closed();
+ assertEquals(Valve.CLOSED, valve.getState());
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Adapted1 implements Business1
+{
+
+ /** . */
+ int business1MethodCount;
+
+ /** . */
+ int commonMethodCount;
+
+ public void business1Method()
+ {
+ business1MethodCount++;
+ }
+
+ public void commonMethod()
+ {
+ commonMethodCount++;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Adapted2 implements Business2
+{
+
+ /** . */
+ int business2MethodCount;
+
+ /** . */
+ int commonMethodCount;
+
+ public void business2Method()
+ {
+ business2MethodCount++;
+ }
+
+ public void commonMethod()
+ {
+ commonMethodCount++;
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,162 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.adapter.ClassAdapter;
+import org.jboss.portal.common.adapter.ClassAdapted;
+import org.jboss.portal.common.adapter.ClassAdaptable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AdapterTestCase extends TestCase
+{
+
+ Adapted1 adapted1;
+ Adapted2 adapted2;
+ ObjectAdapted objectAdapted;
+ ClassAdaptable adaptable;
+
+ protected void setUp() throws Exception
+ {
+ adapted1 = new Adapted1();
+ adapted2 = new Adapted2();
+ objectAdapted = new ObjectAdapted();
+ ClassAdapted[] adapteds = new ClassAdapted[]{new ClassAdapted(Business1.class, adapted1),new ClassAdapted(Business2.class, adapted2)};
+ ClassAdapter adapter = new ClassAdapter(Thread.currentThread().getContextClassLoader(), adapteds, objectAdapted);
+ adaptable = adapter.getAdaptable();
+ }
+
+
+ protected void tearDown() throws Exception
+ {
+ adapted1 = null;
+ adapted2 = null;
+ objectAdapted = null;
+ adaptable = null;
+ }
+
+ public void testImplementedInterfaces()
+ {
+ assertTrue(adaptable instanceof Business1);
+ assertTrue(adaptable instanceof Business2);
+ }
+
+ public void testObjectMethodCall() throws Exception
+ {
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ assertEquals("Foo", adaptable.toString());
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ assertEquals(1234, adaptable.hashCode());
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(1, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ assertEquals(true, adaptable.equals(Boolean.TRUE));
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(1, objectAdapted.hashCodeCount);
+ assertEquals(1, objectAdapted.equalsCount);
+
+ //
+ assertEquals(false, adaptable.equals(Boolean.FALSE));
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(1, objectAdapted.hashCodeCount);
+ assertEquals(2, objectAdapted.equalsCount);
+ }
+
+ public void testBusinessMethodCall() throws Exception
+ {
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ Business1 business1Adapter = (Business1)adaptable;
+ Business2 business2Adapter = (Business2)adaptable;
+
+ //
+ business1Adapter.business1Method();
+ assertEquals(1, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ business2Adapter.business2Method();
+ assertEquals(1, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(1, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ business1Adapter.commonMethod();
+ assertEquals(1, adapted1.business1MethodCount);
+ assertEquals(1, adapted1.commonMethodCount);
+ assertEquals(1, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Business1
+{
+ void business1Method();
+ void commonMethod();
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Business2
+{
+ void business2Method();
+ void commonMethod();
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+import org.jboss.portal.common.adapter.JavaLangObjectAdapted;
+import org.jboss.portal.common.adapter.ClassAdaptable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ObjectAdapted implements JavaLangObjectAdapted
+{
+
+ int toStringCount;
+ int hashCodeCount;
+ int equalsCount;
+
+ public String toString(ClassAdaptable adaptable)
+ {
+ toStringCount++;
+ return "Foo";
+ }
+
+ public int hashCode(ClassAdaptable adaptable)
+ {
+ hashCodeCount++;
+ return 1234;
+ }
+
+ public boolean equals(ClassAdaptable adaptable, Object obj)
+ {
+ equalsCount++;
+ return ((Boolean)obj).booleanValue();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.http;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.http.QueryStringParser;
+import org.jboss.portal.common.util.MapBuilder;
+import org.jboss.portal.common.util.ParameterMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class QueryStringParserTestCase extends TestCase
+{
+
+ /** . */
+ private final QueryStringParser parser = new QueryStringParser();
+
+ public void testConstructorThrowsIAE()
+ {
+ try
+ {
+ new QueryStringParser(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testParseThrowsIAE()
+ {
+ try
+ {
+ QueryStringParser.getInstance().parseQueryString(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEmpty()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString(""));
+ }
+
+ public void testOneParam()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar"}).get(), parser.parseQueryString("f=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("foo=bar"));
+ }
+
+ public void testTwoValues()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"","bar2"}).get(), parser.parseQueryString("f&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"","bar2"}).get(), parser.parseQueryString("f=&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b","bar2"}).get(), parser.parseQueryString("f=b&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar","bar2"}).get(), parser.parseQueryString("f=bar&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"","bar2"}).get(), parser.parseQueryString("foo&foo=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"","bar2"}).get(), parser.parseQueryString("foo=&foo=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b","bar2"}).get(), parser.parseQueryString("foo=b&foo=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar","bar2"}).get(), parser.parseQueryString("foo=bar&foo=bar2"));
+
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2",""}).get(), parser.parseQueryString("f=bar2&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2",""}).get(), parser.parseQueryString("f=bar2&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2","b"}).get(), parser.parseQueryString("f=bar2&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2","bar"}).get(), parser.parseQueryString("f=bar2&f=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2",""}).get(), parser.parseQueryString("foo=bar2&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2",""}).get(), parser.parseQueryString("foo=bar2&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2","b"}).get(), parser.parseQueryString("foo=bar2&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2","bar"}).get(), parser.parseQueryString("foo=bar2&foo=bar"));
+ }
+
+ public void testEncodedValue()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{" "}).get(), parser.parseQueryString("foo=+"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"."}).get(), parser.parseQueryString("foo=."));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"-"}).get(), parser.parseQueryString("foo=-"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"*"}).get(), parser.parseQueryString("foo=*"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"_"}).get(), parser.parseQueryString("foo=_"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"/"}).get(), parser.parseQueryString("foo=%2F"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"/"}).get(), parser.parseQueryString("foo=/"));
+ }
+
+ public void testMalformedValue()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("foo=%2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo&foo=%2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("foo=bar&foo=%2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo=%2&foo"));
+ }
+
+ public void testTwoParams()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{""}).get(), parser.parseQueryString("x=y&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{""}).get(), parser.parseQueryString("x=y&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{"b"}).get(), parser.parseQueryString("x=y&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{"bar"}).get(), parser.parseQueryString("x=y&f=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{""}).get(), parser.parseQueryString("x=y&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{""}).get(), parser.parseQueryString("x=y&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{"b"}).get(), parser.parseQueryString("x=y&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("x=y&foo=bar"));
+ }
+
+ public void testValueContainingEqual()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b=j"}).get(), parser.parseQueryString("f=b=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar=j"}).get(), parser.parseQueryString("f=bar=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b=juu"}).get(), parser.parseQueryString("f=b=juu"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar=juu"}).get(), parser.parseQueryString("f=bar=juu"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b=j"}).get(), parser.parseQueryString("foo=b=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar=j"}).get(), parser.parseQueryString("foo=bar=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b=juu"}).get(), parser.parseQueryString("foo=b=juu"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar=juu"}).get(), parser.parseQueryString("foo=bar=juu"));
+ }
+
+ public void testInvalidChunck()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("="));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x="));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x=y"));
+ }
+
+ public void testInvalidChunckWithAmpersand()
+ {
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=&"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x&"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x=&"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x=y&"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=y&f"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=y&f="));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=x&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=x=&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=x=y&f=b"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=y&foo"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=y&foo="));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=x&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=x=&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=x=y&foo=b"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=&foo=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=x&foo=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=x=&foo=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=x=y&foo=bar"));
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,666 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.io;
+
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import junit.framework.TestCase;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.CharArrayWriter;
+import java.io.CharArrayReader;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * todo:
+ * <ul>
+ * <li>test safeBufferedWrapper</li>
+ * <li>test serialize</li>
+ * <li>test unserialize</li>
+ * <li>test clone</li>
+ * </ul>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IOToolsTestCase extends TestCase
+{
+
+ public void testGenericSafeClose()
+ {
+ IOTools.safeClose((Object)null);
+ IOTools.safeClose(new Object());
+
+ //
+ assertTrue(new GenericPublicSafeClose().apply().called);
+ assertFalse(new GenericProtectedSafeClose().apply().called);
+ assertFalse(new GenericPackageProtectedSafeClose().apply().called);
+ assertFalse(new GenericPrivateSafeClose().apply().called);
+
+ //
+ IOTools.safeClose(new GenericPublicStaticSafeClose());
+ assertFalse(GenericPublicStaticSafeClose.called);
+ IOTools.safeClose(new GenericProtectedStaticSafeClose());
+ assertFalse(GenericProtectedStaticSafeClose.called);
+ IOTools.safeClose(new GenericPackageProtectedStaticSafeClose());
+ assertFalse(GenericPackageProtectedStaticSafeClose.called);
+ IOTools.safeClose(new GenericPrivateStaticSafeClose());
+ assertFalse(GenericPrivateStaticSafeClose.called);
+ }
+
+ public static class GenericSafeClose
+ {
+ boolean called = false;
+ public GenericSafeClose apply()
+ {
+ IOTools.safeClose(this);
+ return this;
+ }
+ }
+
+ public static class GenericPublicSafeClose extends GenericSafeClose
+ {
+ public void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericProtectedSafeClose extends GenericSafeClose
+ {
+ protected void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPackageProtectedSafeClose extends GenericSafeClose
+ {
+ protected void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPrivateSafeClose extends GenericSafeClose
+ {
+ private void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPublicStaticSafeClose
+ {
+ static boolean called = false;
+ public static void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericProtectedStaticSafeClose
+ {
+ static boolean called = false;
+ protected static void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPackageProtectedStaticSafeClose
+ {
+ static boolean called = false;
+ static void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPrivateStaticSafeClose
+ {
+ static boolean called = false;
+ private static void close()
+ {
+ called = true;
+ }
+ }
+
+
+ public void testGenericSafeCloseWithThrowable()
+ {
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw new Exception();
+ }
+ }.apply(null);
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw new Throwable();
+ }
+ }.apply(null);
+ final RuntimeException runtimeException = new RuntimeException();
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw runtimeException;
+ }
+ }.apply(runtimeException);
+ final Error error = new Error();
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw error;
+ }
+ }.apply(error);
+ }
+
+ public abstract static class FailingGenericSafeClose
+ {
+ public void apply(Throwable expectedThrowable)
+ {
+ try
+ {
+ IOTools.safeClose(this);
+ assertNull(expectedThrowable);
+ }
+ catch (Throwable t)
+ {
+ assertEquals(expectedThrowable, t);
+ }
+ }
+
+ public void close() throws Throwable
+ {
+ internalClose();
+ }
+
+ protected abstract void internalClose() throws Throwable;
+ }
+
+ public void testOutputStreamSafeClose()
+ {
+ IOTools.safeClose((OutputStream)null);
+ final AtomicBoolean called = new AtomicBoolean(false);
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractOutputStream extends OutputStream
+ {
+ public void write(int b) throws IOException
+ {
+ }
+ }
+
+ public void testInputStreamSafeClose()
+ {
+ IOTools.safeClose((InputStream)null);
+ final AtomicBoolean called = new AtomicBoolean(false);
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractInputStream extends InputStream
+ {
+ public int read() throws IOException
+ {
+ return 0;
+ }
+ }
+
+ public void testReaderSafeClose()
+ {
+ IOTools.safeClose((Reader)null);
+ final AtomicBoolean called = new AtomicBoolean(false);
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractReader extends Reader
+ {
+ public int read(char cbuf[], int off, int len) throws IOException
+ {
+ return 0;
+ }
+ }
+
+ public void testWriterSafeClose()
+ {
+ IOTools.safeClose((Writer)null);
+ final AtomicBoolean called = new AtomicBoolean(false);
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractWriter extends Writer
+ {
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ }
+ public void flush() throws IOException
+ {
+ }
+ }
+
+ public void testCopyInputStreamToOutputStream() throws IOException
+ {
+ try
+ {
+ IOTools.copy(null, new ByteArrayOutputStream());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ IOTools.copy(new ByteArrayInputStream(new byte[0]), null);
+ fail("Was expecting an IOException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ final AtomicBoolean closeCalled1 = new AtomicBoolean(false);
+ final IOException ioException1 = new IOException();
+ try
+ {
+ IOTools.copy(new AbstractInputStream()
+ {
+ public int read() throws IOException
+ {
+ throw ioException1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled1.set(true);
+ }
+ }, new ByteArrayOutputStream());
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException1, expected);
+ assertFalse(closeCalled1.get());
+ }
+
+ //
+ final AtomicBoolean closeCalled2 = new AtomicBoolean(false);
+ IOTools.copy(new AbstractInputStream()
+ {
+ public int read() throws IOException
+ {
+ return -1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled2.set(true);
+ }
+ }, new ByteArrayOutputStream());
+ assertFalse(closeCalled2.get());
+
+ //
+ final IOException ioException2 = new IOException();
+ final AtomicBoolean closeCalled3 = new AtomicBoolean(false);
+ try
+ {
+ IOTools.copy(new ByteArrayInputStream(new byte[1]), new AbstractOutputStream()
+ {
+ public void write(int b) throws IOException
+ {
+ throw ioException2;
+ }
+ public void close() throws IOException
+ {
+ closeCalled3.set(true);
+ }
+ });
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException2, expected);
+ }
+
+ //
+ final AtomicBoolean closeCalled4 = new AtomicBoolean(false);
+ IOTools.copy(new ByteArrayInputStream(new byte[1]), new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ closeCalled4.set(true);
+ }
+ });
+
+ //
+ Random random = new Random();
+ byte[] bytes = new byte[2000];
+ random.nextBytes(bytes);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length);
+ IOTools.copy(new ByteArrayInputStream((byte[])bytes.clone()), baos);
+ ExtendedAssert.assertEquals(bytes, baos.toByteArray());
+ }
+
+ public void testCopyReaderToWriter() throws IOException
+ {
+ try
+ {
+ IOTools.copy(null, new CharArrayWriter());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ IOTools.copy(new CharArrayReader(new char[0]), null);
+ fail("Was expecting an IOException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ final AtomicBoolean closeCalled1 = new AtomicBoolean(false);
+ final IOException ioException1 = new IOException();
+ try
+ {
+ IOTools.copy(new AbstractReader()
+ {
+ public int read(char cbuf[], int off, int len) throws IOException
+ {
+ throw ioException1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled1.set(true);
+ }
+ }, new CharArrayWriter());
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException1, expected);
+ assertFalse(closeCalled1.get());
+ }
+
+ //
+ final AtomicBoolean closeCalled2 = new AtomicBoolean(false);
+ IOTools.copy(new AbstractReader()
+ {
+ public int read(char cbuf[], int off, int len) throws IOException
+ {
+ return -1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled2.set(true);
+ }
+ }, new CharArrayWriter());
+ assertFalse(closeCalled2.get());
+
+ //
+ final IOException ioException2 = new IOException();
+ final AtomicBoolean closeCalled3 = new AtomicBoolean(false);
+ try
+ {
+ IOTools.copy(new CharArrayReader(new char[1]), new AbstractWriter()
+ {
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ throw ioException2;
+ }
+ public void close() throws IOException
+ {
+ closeCalled3.set(true);
+ }
+ });
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException2, expected);
+ }
+
+ //
+ final AtomicBoolean closeCalled4 = new AtomicBoolean(false);
+ IOTools.copy(new CharArrayReader(new char[1]), new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ closeCalled4.set(true);
+ }
+ });
+
+ //
+ Random random = new Random();
+ char[] chars = new char[2000];
+ for (int i = 0; i < chars.length; i++)
+ {
+ chars[i] = (char)random.nextInt();
+
+ }
+ CharArrayWriter caw = new CharArrayWriter(chars.length);
+ IOTools.copy(new CharArrayReader((char[])chars.clone()), caw);
+ ExtendedAssert.assertEquals(chars, caw.toCharArray());
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/SerializationTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/SerializationTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/SerializationTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.io;
+
+import org.jboss.portal.common.io.Serialization;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.util.MapBuilder;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class SerializationTestCase extends TestCase
+{
+
+ public void testParameterMapSerialization()
+ {
+ check(new HashMap<String, String[]>());
+ check(MapBuilder.hashMap("foo", new String[]{"foo_value"}).get());
+ check(MapBuilder.hashMap("foo", new String[]{"foo_value1","foo_value2"}).get());
+ check(MapBuilder.hashMap("foo", new String[]{"foo_value1","foo_value2"}).put("bar", new String[]{"bar_value"}).get());
+ }
+
+ private void check(Map<String, String[]> map)
+ {
+ byte[] bytes = IOTools.serialize(Serialization.PARAMETER_MAP, map);
+ Map<String, String[]> copy = IOTools.unserialize(Serialization.PARAMETER_MAP, bytes);
+ assertEquals(map.keySet(), copy.keySet());
+ for (Map.Entry<String, String[]> entry : map.entrySet())
+ {
+ String[] values = map.get(entry.getKey());
+ String[] valuesCopy = copy.get(entry.getKey());
+ ExtendedAssert.assertEquals(values, valuesCopy);
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.io;
+
+import org.jboss.portal.common.io.WriterCharWriter;
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.StringWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WriterCharWriterTestCase extends TestCase
+{
+
+ public void testAppend1() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append('a');
+ s.close();
+ assertEquals("a", s.toString());
+ }
+
+ public void testAppend2() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append("abc".toCharArray());
+ s.close();
+ assertEquals("abc", s.toString());
+ }
+
+ public void testAppend3() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append("abcdef".toCharArray(), 1, 3);
+ s.close();
+ assertEquals("bcd", s.toString());
+ }
+
+ public void testAppend4() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append("abc");
+ s.close();
+ assertEquals("abc", s.toString());
+ }
+
+ private Writer failingWriter = new Writer()
+ {
+ public void write(char[] chars, int i, int i1) throws IOException
+ {
+ throw new IOException();
+ }
+
+ public void flush() throws IOException
+ {
+ throw new IOException();
+ }
+
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ };
+
+ public void testWrappedIOException()
+ {
+ WriterCharWriter writer = new WriterCharWriter(failingWriter);
+ try
+ {
+ writer.append('c');
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ try
+ {
+ writer.append("abc".toCharArray());
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ try
+ {
+ writer.append("abcdef".toCharArray(), 1, 3);
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ try
+ {
+ writer.append("abc");
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ }
+
+ public void testAppendThrowsIAE()
+ {
+ try
+ {
+ new WriterCharWriter(null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ WriterCharWriter writer = new WriterCharWriter(new StringWriter());
+ try
+ {
+ writer.append(new char[10], -1, 0);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(new char[10], 5, -1);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(new char[10], 15, 0);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(new char[10], 5, 6);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(null, 0, 5);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append((char[])null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append((CharSequence)null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractServer.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractServer.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractServer.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.net;
+
+import java.net.ServerSocket;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractServer implements Runnable
+{
+
+ /** . */
+ private int port;
+
+ /** . */
+ private ServerSocket server;
+
+ public AbstractServer(int port)
+ {
+ this.port = port;
+ }
+
+ public final void start() throws Exception
+ {
+ server = new ServerSocket(port, 1);
+ new Thread(this).start();
+ }
+
+ public final void run()
+ {
+ try
+ {
+ run(server);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ if (!server.isClosed())
+ {
+ try
+ {
+ server.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+ }
+
+ protected abstract void run(ServerSocket server) throws Exception;
+
+ public final void stop()
+ {
+ if (server != null)
+ {
+ try
+ {
+ server.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractSynchronizedServer.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractSynchronizedServer.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractSynchronizedServer.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,180 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.net;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.junit.ExtendedAssert;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.io.BufferedInputStream;
+import java.io.LineNumberReader;
+import java.io.InputStreamReader;
+import java.io.BufferedOutputStream;
+import java.io.OutputStreamWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractSynchronizedServer extends AbstractServer
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(AbstractSynchronizedServer.class);
+
+ /** . */
+ private final Object lock = new Object();
+
+ /** . */
+ private final AtomicInteger b = new AtomicInteger(0);
+
+ /** . */
+ private Throwable failure;
+
+ protected AbstractSynchronizedServer(int port)
+ {
+ super(port);
+ }
+
+ protected void run(ServerSocket server) throws Exception
+ {
+ synchronized (lock)
+ {
+ b.set(1);
+ lock.notifyAll();
+ }
+
+ //
+ log.debug("Ready for accept");
+
+ //
+ try
+ {
+ doServer(server);
+ }
+ catch (Throwable throwable)
+ {
+ failure = throwable;
+ }
+
+ //
+ synchronized (lock)
+ {
+ lock.wait();
+ }
+
+ //
+ log.debug("Shutting down");
+ }
+
+ protected abstract void doServer(ServerSocket server) throws Exception;
+
+ protected abstract void doClient() throws Exception;
+
+ public void performInteraction() throws Exception
+ {
+ try
+ {
+ start();
+
+ // Wait until the we know the server will accept
+ synchronized (lock)
+ {
+ while (b.get() != 1)
+ {
+ lock.wait();
+ }
+ }
+
+ // Perform client action
+ doClient();
+ }
+ finally
+ {
+ synchronized (lock)
+ {
+ lock.notify();
+ }
+ stop();
+ }
+
+ //
+ if (failure != null)
+ {
+ log.error("The server reported a failure", failure);
+
+ ExtendedAssert.fail("The server reported a failure");
+ }
+ }
+
+ public static abstract class AbstractTimeoutServer extends AbstractSynchronizedServer
+ {
+
+ protected AbstractTimeoutServer(int port)
+ {
+ super(port);
+ }
+
+ protected void doServer(ServerSocket server) throws Exception
+ {
+ server.accept();
+ }
+
+ }
+
+ public static abstract class AbstractOKServer extends AbstractSynchronizedServer
+ {
+
+ protected AbstractOKServer(int port)
+ {
+ super(port);
+ }
+
+ protected void doServer(ServerSocket server) throws Exception
+ {
+ //
+ Socket s = server.accept();
+ BufferedInputStream in = new BufferedInputStream(s.getInputStream());
+ LineNumberReader reader = new LineNumberReader(new InputStreamReader(in, "ISO-8859-1"));
+ for (String line = reader.readLine();line.length() > 0;line = reader.readLine())
+ {
+ log.debug("server received = " + line);
+ }
+
+ //
+ log.debug("Finished reading");
+
+ //
+ BufferedOutputStream out = new BufferedOutputStream(s.getOutputStream());
+ OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
+ writer.write("HTTP/1.1 200 OK\r\n");
+ writer.write("\r\n");
+ writer.flush();
+ out.write("CAFEBABE".getBytes("UTF-8"));
+ out.close();
+ }
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,628 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.net;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jboss.portal.common.net.URLFilter;
+import org.jboss.portal.common.net.URLNavigator;
+import org.jboss.portal.common.net.URLVisitor;
+import org.jboss.portal.common.net.URLTools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7448 $
+ */
+public class URLNavigatorTestCase extends TestCase
+{
+
+ public URLNavigatorTestCase(String name)
+ {
+ super(name);
+ }
+
+ // the name of the jar that contains the tests
+ private final String TEST_JAR_NAME="test.jar";
+
+
+ ArrayList expectedAtomsC1 = new ArrayList();
+ ArrayList expectedAtomsB1 = new ArrayList();
+ ArrayList expectedAtomsA1 = new ArrayList();
+ ArrayList expectedAtomsB1Dash = new ArrayList();
+ ArrayList expectedAtomsD1txt = new ArrayList();
+ ArrayList expectedAtomsC1txt = new ArrayList();
+ ArrayList expectedAtomsB1txt = new ArrayList();
+ ArrayList expectedAtomsB2txt = new ArrayList();
+ ArrayList expectedAtomsA3txt = new ArrayList();
+
+ ArrayList expectedURLsC1 = new ArrayList();
+ ArrayList expectedURLsB1 = new ArrayList();
+ ArrayList expectedURLsA1 = new ArrayList();
+ ArrayList expectedURLsB1Dash = new ArrayList();
+ ArrayList expectedURLsD1txt = new ArrayList();
+ ArrayList expectedURLsC1txt = new ArrayList();
+ ArrayList expectedURLsB1txt = new ArrayList();
+ ArrayList expectedURLsB2txt = new ArrayList();
+ ArrayList expectedURLsA3txt = new ArrayList();
+
+ Filter noFilter;
+ Filter fullFilter;
+ Filter noDirFilter;
+ Filter noFileFilter;
+
+ protected void setUp() throws Exception
+ {
+
+ expectedURLsD1txt = new ArrayList();
+ expectedURLsD1txt.add("/a1/b1/c1/d1.txt");
+
+ expectedURLsC1 = new ArrayList();
+ expectedURLsC1.add("/a1/b1/c1/");
+ expectedURLsC1.addAll(expectedURLsD1txt);
+ expectedURLsC1.add("/a1/b1/c1/");
+
+ expectedURLsC1txt = new ArrayList();
+ expectedURLsC1txt.add("/a1/b1/c1.txt");
+
+ expectedURLsB1 = new ArrayList();
+ expectedURLsB1.add("/a1/b1/");
+ expectedURLsB1.addAll(expectedURLsC1);
+ expectedURLsB1.addAll(expectedURLsC1txt);
+ expectedURLsB1.add("/a1/b1/");
+
+ expectedURLsB1Dash = new ArrayList();
+ expectedURLsB1Dash.add("/a1/b1-/");
+ expectedURLsB1Dash.add("/a1/b1-/");
+
+ expectedURLsB1txt = new ArrayList();
+ expectedURLsB1txt.add("/a1/b1.txt");
+
+ expectedURLsB2txt = new ArrayList();
+ expectedURLsB2txt.add("/a1/b2.txt");
+
+ expectedURLsA1 = new ArrayList();
+ expectedURLsA1.add("/a1/");
+ expectedURLsA1.addAll(expectedURLsB1);
+ expectedURLsA1.addAll(expectedURLsB1Dash);
+ expectedURLsA1.addAll(expectedURLsB1txt);
+ expectedURLsA1.addAll(expectedURLsB2txt);
+ expectedURLsA1.add("/a1/");
+
+ expectedURLsA3txt = new ArrayList();
+ expectedURLsA3txt.add("a3.txt");
+
+ expectedAtomsD1txt = new ArrayList();
+ expectedAtomsD1txt.add("d1.txt");
+
+ expectedAtomsC1 = new ArrayList();
+ expectedAtomsC1.add("<c1>");
+ expectedAtomsC1.addAll(expectedAtomsD1txt);
+ expectedAtomsC1.add("</c1>");
+
+ expectedAtomsC1txt = new ArrayList();
+ expectedAtomsC1txt.add("c1.txt");
+
+ expectedAtomsB1 = new ArrayList();
+ expectedAtomsB1.add("<b1>");
+ expectedAtomsB1.addAll(expectedAtomsC1);
+ expectedAtomsB1.addAll(expectedAtomsC1txt);
+ expectedAtomsB1.add("</b1>");
+
+ expectedAtomsB1Dash = new ArrayList();
+ expectedAtomsB1Dash.add("<b1->");
+ expectedAtomsB1Dash.add("</b1->");
+
+ expectedAtomsB1txt = new ArrayList();
+ expectedAtomsB1txt.add("b1.txt");
+
+ expectedAtomsB2txt = new ArrayList();
+ expectedAtomsB2txt.add("b2.txt");
+
+ expectedAtomsA1 = new ArrayList();
+ expectedAtomsA1.add("<a1>");
+ expectedAtomsA1.addAll(expectedAtomsB1);
+ expectedAtomsA1.addAll(expectedAtomsB1Dash);
+ expectedAtomsA1.addAll(expectedAtomsB1txt);
+ expectedAtomsA1.addAll(expectedAtomsB2txt);
+ expectedAtomsA1.add("</a1>");
+
+ expectedAtomsA3txt = new ArrayList();
+ expectedAtomsA3txt.add("a3.txt");
+
+ noFilter = new Filter(true, true);
+ fullFilter = new Filter(false, false);
+ noDirFilter = new Filter(true, false);
+ noFileFilter = new Filter(false, true);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ }
+
+
+//// Root tests
+
+ public void testRootWithFile() throws Exception
+ {
+ URL fileURL = getFileURL ("test-jar");
+
+ ArrayList expectedAtoms = new ArrayList();
+ expectedAtoms.add("<test-jar>");
+ expectedAtoms.addAll(expectedAtomsA1);
+ expectedAtoms.addAll(expectedAtomsA3txt);
+ expectedAtoms.add("</test-jar>");
+
+ ArrayList expectedURLs = new ArrayList();
+ expectedURLs.add("test-jar/");
+ expectedURLs.addAll(expectedURLsA1);
+ expectedURLs.addAll(expectedURLsA3txt);
+ expectedURLs.add("test-jar/");
+
+ doTest (fileURL, expectedAtoms, expectedURLs, noFilter);
+ doTest (fileURL, expectedAtoms, expectedURLs, null);
+ doTest (fileURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (fileURL, removeFiles(expectedAtoms), removeFiles(expectedURLs), noFileFilter);
+ //since we pass it a directory, we can't enter the directory
+ doTest (fileURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ }
+
+ public void testRootWithJar() throws Exception
+ {
+ URL jarURL = getJarURL ("/");
+
+ ArrayList expectedAtoms = new ArrayList();
+ expectedAtoms.add("</>");
+ expectedAtoms.add("<META-INF>");
+ expectedAtoms.add("MANIFEST.MF");
+ expectedAtoms.add("</META-INF>");
+ expectedAtoms.addAll(expectedAtomsA1);
+ expectedAtoms.addAll(expectedAtomsA3txt);
+ //TODO: should this really be //?
+ expectedAtoms.add("<//>");
+
+ ArrayList expectedURLs = new ArrayList();
+ expectedURLs.add("/");
+ expectedURLs.add("/META-INF/");
+ expectedURLs.add("/META-INF/MANIFEST.MF");
+ expectedURLs.add("/META-INF/");
+ expectedURLs.addAll(expectedURLsA1);
+ expectedURLs.addAll(expectedURLsA3txt);
+ expectedURLs.add("/");
+
+ doTest (jarURL, expectedAtoms, expectedURLs, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtoms), removeFiles(expectedURLs), noFileFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), noDirFilter);
+
+ }
+
+//// Directory Test
+
+ public void testDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test-jar/a1/");
+ doDirectoryTest(fileURL);
+ }
+
+ public void testDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/");
+ doDirectoryTest(jarURL);
+ }
+
+ private void doDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (url, expectedAtomsA1, expectedURLsA1, new Filter());
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (url, new ArrayList(), new ArrayList(),noDirFilter);
+
+ Filter mixFilter = new Filter();
+ List dirSeq = new ArrayList();
+ dirSeq.add(Boolean.TRUE); //a1
+ dirSeq.add(Boolean.TRUE); //b1
+ dirSeq.add(Boolean.TRUE); //c1
+ dirSeq.add(Boolean.FALSE); //b1-
+
+ List fileSeq = new ArrayList();
+ fileSeq.add(Boolean.TRUE); //d1.txt
+ fileSeq.add(Boolean.FALSE); //c1.txt
+ fileSeq.add(Boolean.FALSE); //b1.txt
+ fileSeq.add(Boolean.FALSE); //b2.txt
+
+ mixFilter.setAcceptDir(dirSeq);
+ mixFilter.setAcceptFile(fileSeq);
+
+ ArrayList expectedMixAtoms = new ArrayList();
+ expectedMixAtoms.add("<a1>");
+ expectedMixAtoms.add("<b1>");
+ expectedMixAtoms.add("<c1>");
+ expectedMixAtoms.add("d1.txt");
+ expectedMixAtoms.add("</c1>");
+ expectedMixAtoms.add("</b1>");
+ expectedMixAtoms.add("</a1>");
+
+ ArrayList expectedMixURLs = new ArrayList();
+ expectedMixURLs.add("/a1/");
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/b1/c1/");
+ expectedMixURLs.add("/a1/b1/c1/d1.txt");
+ expectedMixURLs.add("/a1/b1/c1/");
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/");
+
+ doTest (url, expectedMixAtoms, expectedMixURLs, mixFilter);
+ }
+
+//// SubDirectory Test
+
+ public void testSubDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL ("test-jar/a1/b1");
+ doSubDirectoryTest(fileURL);
+ }
+
+ public void testSubDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1/");
+ doSubDirectoryTest(jarURL);
+ }
+
+ private void doSubDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsB1, expectedURLsB1, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsB1), removeFiles(expectedURLsB1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (url, new ArrayList(), new ArrayList(),noDirFilter);
+
+ Filter mixFilter = new Filter();
+ List dirSeq = new ArrayList();
+ dirSeq.add(Boolean.TRUE); //b1
+ dirSeq.add(Boolean.FALSE); //c1
+
+ List fileSeq = new ArrayList();
+ fileSeq.add (Boolean.TRUE); //c1.txt
+
+ mixFilter.setAcceptDir(dirSeq);
+ mixFilter.setAcceptFile(fileSeq);
+
+ ArrayList expectedMixAtoms = new ArrayList();
+ expectedMixAtoms.add("<b1>");
+ expectedMixAtoms.addAll(expectedAtomsC1txt);
+ expectedMixAtoms.add("</b1>");
+
+ ArrayList expectedMixURLs = new ArrayList();
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/b1/c1.txt");
+ expectedMixURLs.add("/a1/b1/");
+
+ doTest (url, expectedMixAtoms, expectedMixURLs, mixFilter);
+ }
+
+/// SingleFileTest
+
+ public void testSingleFileWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test-jar/a1/b1/c1/d1.txt");
+ doSingleFileTest(fileURL);
+ }
+
+ public void testSingleFileWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1/c1/d1.txt");
+ doSingleFileTest(jarURL);
+ }
+
+ private void doSingleFileTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsD1txt, expectedURLsD1txt, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsD1txt), removeFiles(expectedAtomsD1txt), noFileFilter);
+ doTest (url, expectedAtomsD1txt, expectedURLsD1txt, noDirFilter);
+ }
+
+//// Empty Directory Test
+
+ public void testEmptyDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test-jar/a1/b1-");
+ doEmptyDirectoryTest(fileURL);
+ }
+
+ public void testEmptyDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1-/");
+ doEmptyDirectoryTest(jarURL);
+ }
+
+ private void doEmptyDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsB1Dash, expectedURLsB1Dash, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, expectedAtomsB1Dash, expectedURLsB1Dash, noFileFilter);
+ doTest (url, new ArrayList(), new ArrayList(), noDirFilter);
+ }
+
+////
+
+ public void testJarURLs() throws Exception
+ {
+ //Note no / at the end
+ URL jarURL = getJarURL("/a1");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (jarURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ try
+ {
+ //Note extra / at front
+ jarURL = getJarURL("//a1");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (jarURL, new ArrayList(), new ArrayList(),noDirFilter);
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+
+ try
+ {
+ jarURL = getJarURL("/foobar/");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ fail ("An invalid jar url did not cause a FileNotFoundException");
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+ }
+
+ public void testFileURLs() throws Exception
+ {
+ //Note no / at the end
+ URL fileURL = getFileURL("test-jar/a1");
+
+ doTest (fileURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (fileURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (fileURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (fileURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ try
+ {
+ fileURL = new URL("file:foobar");
+ doTest (fileURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ fail ("An invalid file url did not cause a FileNotFoundException");
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+ }
+
+
+/*----------Utility Metods and Classes ---------------*/
+
+ private URL getFileURL(String name) throws MalformedURLException
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(name);
+ assertNotNull("Could not load URL for file " + name, url);
+ assertTrue(URLTools.exists(url));
+ return url;
+ }
+
+ private URL getJarURL(String name) throws MalformedURLException
+ {
+ URL url = getFileURL(TEST_JAR_NAME);
+ File jarFile = new File(url.getFile());
+ assertTrue(jarFile.exists());
+ return new URL("jar", "", jarFile.toURL() + "!" + name);
+ }
+
+ public List removeFiles(ArrayList list)
+ {
+ ArrayList newList = (ArrayList)list.clone();
+ ArrayList fileList = new ArrayList();
+
+ Iterator iterator = newList.iterator();
+ while (iterator.hasNext())
+ {
+ String element = (String)(iterator.next());
+ if (element.endsWith(".txt") || element.endsWith(".MF"))
+ {
+ fileList.add(element);
+ }
+ }
+
+ newList.removeAll(fileList);
+
+ return newList;
+ }
+
+ private void doTest(URL url, List expectedAtoms, List expectedURLs, Filter filter) throws Exception
+ {
+ final List atoms = new ArrayList();
+ final List urls = new ArrayList();
+ URLNavigator.visit(url, new URLVisitor()
+ {
+ public void startDir(URL url, String name)
+ {
+ atoms.add("<" + name + ">");
+ urls.add(url);
+ }
+ public void endDir(URL url, String name)
+ {
+ atoms.add("</" + name + ">");
+ urls.add(url);
+ }
+ public void file(URL url, String name)
+ {
+ atoms.add(name);
+ urls.add(url);
+ }
+ }, filter);
+
+ //
+ if (urls.size() != expectedURLs.size())
+ {
+ assertEquals(expectedURLs, urls);
+ fail("URLs size does not match " + urls.size() + "!=" + expectedURLs.size());
+ }
+
+ //
+ assertEquals(expectedAtoms, atoms);
+
+ //
+ for (int i = 0;i < urls.size();i++)
+ {
+ URL entryURL = (URL)urls.get(i);
+ String suffix = (String)expectedURLs.get(i);
+ if (!entryURL.getPath().endsWith(suffix))
+ {
+ fail("URL " + entryURL + " does not end with the suffix " + suffix + " at index " + i);
+ }
+ if (entryURL.getPath().endsWith ("//" + suffix.substring(1)))
+ {
+ fail("URL " + entryURL + " ends with /" + suffix + " at index " + i);
+ }
+ }
+
+ if (filter != null)
+ {
+ assertTrue("The Sequence never completed", filter.SequenceComplete());
+ }
+ }
+
+ /**
+ * Class used to setup URLFilter behavior for tests
+ * @author Matt Wringe
+ */
+ private static class Filter implements URLFilter
+ {
+ private boolean acceptFile;
+ private boolean acceptDir;
+
+ private List acceptFileSequence = null;
+ private Iterator fileIterator = null;
+
+ private List acceptDirSequence = null;
+ private Iterator dirIterator = null;
+
+ /**
+ * Method used to setup URLFilter behavior
+ * @param acceptFile Always accept files
+ * @param acceptDir Always accept files
+ */
+ public Filter (boolean acceptFile, boolean acceptDir)
+ {
+ this.acceptFile = acceptFile;
+ this.acceptDir = acceptDir;
+ }
+
+ /**
+ * Method to setup URLFilter behavior which by default always accepts
+ * files and directories
+ */
+ public Filter()
+ {
+ this.acceptDir = true;
+ this.acceptFile = true;
+ }
+
+ /**
+ * Set the sequence to accept or reject files
+ * @param acceptFileSequence Sequence for accepting files
+ */
+ public void setAcceptFile (List acceptFileSequence)
+ {
+ this.acceptFileSequence = acceptFileSequence;
+ this.fileIterator = acceptFileSequence.iterator();
+ }
+
+ /**
+ * Set the sequence to accept or reject directories
+ * @param acceptDirSequence Sequence for accepting directories
+ */
+ public void setAcceptDir (List acceptDirSequence)
+ {
+ this.acceptDirSequence = acceptDirSequence;
+ this.dirIterator = acceptDirSequence.iterator();
+ }
+
+ /**
+ * Returns true if the sequence is complete or if no sequence has been setup
+ * @return True if the sequence is complete
+ */
+ public boolean SequenceComplete()
+ {
+ if ((dirIterator == null || !dirIterator.hasNext()) && (fileIterator == null || !fileIterator.hasNext()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public boolean acceptFile(URL url)
+ {
+ if (fileIterator != null)
+ {
+ return ((Boolean)fileIterator.next()).booleanValue();
+ }
+ else
+ {
+ return acceptFile;
+ }
+ }
+
+ public boolean acceptDir(URL url)
+ {
+ if (dirIterator != null)
+ {
+ return ((Boolean)dirIterator.next()).booleanValue();
+ }
+ return acceptDir;
+ }
+ }
+}
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,267 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.net;
+
+import junit.framework.TestCase;
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.net.URLTools;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7379 $
+ * @since 2.4 (May 29, 2006)
+ */
+public class URLToolsTestCase extends TestCase
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(URLToolsTestCase.class);
+
+ private static final String MARKUP = "Hello, Anonymous!\n" +
+ "Counter: 0<a href='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmc" +
+ "uamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphd" +
+ "mEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXI" +
+ "AE1tMamF2YS5sYW5nLlN0cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite'>My name is Julien</a><a hr" +
+ "ef='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci" +
+ "51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMW" +
+ "YNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0cmluZz" +
+ "ut0lbn6R17RwIAAHhwAAAAAXQAA1JveXg*/wsrp_rewrite'>My name is Roy</a><action='wsrp_rewrite?wsrp-urlType=bloc" +
+ "kingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQ" +
+ "ZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQA" +
+ "JdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK" +
+ "3g*/wsrp_rewrite'>counter++</a><a href='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState" +
+ "=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvT" +
+ "WFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAA" +
+ "AAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAItLXg*/wsrp_rewrite'>counter--</a>";
+
+ public void testExtractURLs()
+ {
+ String markup = MARKUP;
+
+ URLTools.URLMatch[] links = URLTools.extractURLsFrom(markup);
+ assertEquals(4, links.length);
+ URLTools.URLMatch link = links[0];
+ assertEquals("wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNl" +
+ "cnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQ" +
+ "fawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0" +
+ "cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite", link.getURLAsString());
+ assertEquals("wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9yd" +
+ "GFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXN" +
+ "oTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZ" +
+ "y5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK3g*/wsrp_rewrite", links[2].getURLAsString());
+
+ String url = "wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite";
+ markup = "12345href='" + url + "'76";
+ links = URLTools.extractURLsFrom(markup);
+ link = links[0];
+ int startIndex = 11;
+ assertEquals(startIndex, link.getStart());
+ assertEquals(url.length() + startIndex, link.getEnd());
+ assertEquals(url, markup.substring(link.getStart(), link.getEnd()));
+ assertEquals(url, link.getURLAsString());
+ }
+
+ public void testReplaceURLs()
+ {
+ String markup = URLTools.replaceURLsBy(MARKUP, new String[]{"foo", "bar", "baz", "buz"});
+ String replaced = "Hello, Anonymous!\nCounter: 0<a href='foo'>My name is Julien</a><a href='bar'>My name is Roy</a>" +
+ "<action='baz'>counter++</a><a href='buz'>counter--</a>";
+ assertEquals(replaced, markup);
+ assertEquals(replaced, URLTools.replaceURLsBy(replaced, (String[])null));
+
+ String mixed = "<a href='wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite'>My name is Julien</a>" +
+ "<a href='bar'>My name is Roy</a>";
+ assertEquals("<a href='foo'>My name is Julien</a><a href='bar'>My name is Roy</a>",
+ URLTools.replaceURLsBy(mixed, new URLTools.URLReplacementGenerator()
+ {
+ public String getReplacementFor(int currentIndex, URLTools.URLMatch currentMatch)
+ {
+ String urlAsString = currentMatch.getURLAsString();
+ if (urlAsString.startsWith("wsrp_rewrite"))
+ {
+ return "foo";
+ }
+ return urlAsString;
+ }
+ }));
+ }
+
+ public void testReplaceAllPorts()
+ {
+ String original = "<wsdl:definitions targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
+ " xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
+ " xmlns='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
+ " xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
+ " xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
+ " <import namespace='urn:oasis:names:tc:wsrp:v1:bind' location='wsrp_v1_bindings.wsdl'/>\n" +
+ " <wsdl:service name='WSRPService'>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP' name='WSRPBaseService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/ServiceDescriptionService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP' name='WSRPServiceDescriptionService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/MarkupService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Registration_Binding_SOAP' name='WSRPRegistrationService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/RegistrationService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_PortletManagement_Binding_SOAP' name='WSRPPortletManagementService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/PortletManagementService'/>\n" +
+ " </wsdl:port>\n" +
+ " </wsdl:service>\n" +
+ "</wsdl:definitions>";
+ String result = "<wsdl:definitions targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
+ " xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
+ " xmlns='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
+ " xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
+ " xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
+ " <import namespace='urn:oasis:names:tc:wsrp:v1:bind' location='wsrp_v1_bindings.wsdl'/>\n" +
+ " <wsdl:service name='WSRPService'>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP' name='WSRPBaseService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/ServiceDescriptionService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP' name='WSRPServiceDescriptionService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/MarkupService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Registration_Binding_SOAP' name='WSRPRegistrationService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/RegistrationService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_PortletManagement_Binding_SOAP' name='WSRPPortletManagementService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/PortletManagementService'/>\n" +
+ " </wsdl:port>\n" +
+ " </wsdl:service>\n" +
+ "</wsdl:definitions>";
+
+ assertEquals(result, URLTools.replaceURLsBy(original, new URLTools.PortReplacementGenerator(8888)));
+ }
+
+ public void testReplaceServerPort()
+ {
+ assertEquals("http://hostname:8088/some/path", URLTools.replaceServerPortInURL("http://hostname:8080/some/path", 8088));
+ assertEquals("https://hostname:8088/some/path", URLTools.replaceServerPortInURL("https://hostname:8080/some/path", 8088));
+ assertEquals("http://hostname:8088/some/path", URLTools.replaceServerPortInURL("http://hostname/some/path", 8088));
+ assertEquals("https://hostname:8088/some/path", URLTools.replaceServerPortInURL("https://hostname/some/path", 8088));
+ }
+
+ public void testExistsURL()
+ {
+ assertFalse(URLTools.exists(null, true));
+
+
+ }
+
+ public void testURLExistsTimeout() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractTimeoutServer(8080)
+ {
+ protected void doClient()
+ {
+ boolean exist = true;
+ try
+ {
+ URL url = new URL("http://localhost:8080/");
+ exist = URLTools.exists(url, 500);
+ }
+ catch (MalformedURLException e)
+ {
+ log.error("Cannot create URL", e);
+ fail("Cannot create URL " + e.getMessage());
+ }
+
+ //
+ assertFalse("Was not expecting the URL to exist", exist);
+ }
+ };
+
+ //
+ server.performInteraction();
+ }
+
+ public void testURLPerformGETTimeout() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractTimeoutServer(8080)
+ {
+ protected void doClient()
+ {
+ byte[] bytes = null;
+ try
+ {
+ URL url = new URL("http://localhost:8080/");
+ bytes = URLTools.getContent(url, 500, 500);
+ }
+ catch (MalformedURLException e)
+ {
+ log.error("Cannot create URL", e);
+ fail("Cannot create URL " + e.getMessage());
+ }
+
+ //
+ assertNull("Was not expecting the URL GET to return a non null value", bytes);
+ }
+ };
+
+ //
+ server.performInteraction();
+ }
+
+ public void testURLPerformGET() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractOKServer(8080)
+ {
+
+ protected void doClient() throws Exception
+ {
+ URL url = new URL("http://localhost:8080/");
+ byte[] bytes = URLTools.getContent(url, 5000, 5000);
+ ExtendedAssert.assertEquals("CAFEBABE".getBytes("UTF-8"), bytes);
+ }
+ };
+
+ //
+ server.performInteraction();
+ }
+
+ public void testURLExists() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractOKServer(8080)
+ {
+
+ protected void doClient() throws Exception
+ {
+ URL url = new URL("http://localhost:8080/");
+ boolean exists = URLTools.exists(url, 5000);
+ ExtendedAssert.assertTrue("Was expecting the URL to exist", exists);
+ }
+ };
+
+ //
+ server.performInteraction();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class Class1
+{
+
+ private void privateMethod()
+ {
+ }
+
+ public abstract void publicAbstractMethodOfClass1();
+
+ protected abstract void protectedAbstractMethodOfClass1();
+
+ private void privateMethodOfClass1()
+ {
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Class2 extends Class1
+{
+
+ private void privateMethod()
+ {
+ }
+
+ public void publicAbstractMethodOfClass1()
+ {
+ }
+
+ protected void protectedAbstractMethodOfClass1()
+ {
+ }
+
+ public void publicMethodOfClass2()
+ {
+ }
+
+ protected void protectedMethodOfClass2()
+ {
+ }
+
+ private void privateMethodOfClass2()
+ {
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Class3 extends Class2
+{
+ private void privateMethod()
+ {
+ }
+
+ private void privateMethodOfClass3()
+ {
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.reflect.Modifier;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ModifierTestCase extends TestCase
+{
+
+ public void testIsReadableProperty() throws Exception
+ {
+ try
+ {
+ Modifier.isReadableProperty(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ assertTrue(Modifier.isReadableProperty(Bean.class.getDeclaredField("publicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("privateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("protectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("packageProtectedField")));
+
+ assertTrue(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalPublicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalPrivateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalProtectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalPackageProtectedField")));
+
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticPublicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticPrivateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticProtectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticPackageProtectedField")));
+
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticPublicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticPrivateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticProtectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticPackageProtectedField")));
+ }
+
+ public void testIsWritableProperty() throws Exception
+ {
+ try
+ {
+ Modifier.isWritableProperty(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ assertTrue(Modifier.isWritableProperty(Bean.class.getDeclaredField("publicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("privateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("protectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("packageProtectedField")));
+
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalPublicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalPrivateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalProtectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalPackageProtectedField")));
+
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticPublicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticPrivateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticProtectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticPackageProtectedField")));
+
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticPublicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticPrivateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticProtectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticPackageProtectedField")));
+ }
+
+ private static class Bean
+ {
+ public Object publicField;
+ private Object privateField;
+ protected Object protectedField;
+ Object packageProtectedField;
+
+ final public Object finalPublicField = new Object();
+ final private Object finalPrivateField = new Object();
+ final protected Object finalProtectedField = new Object();
+ final Object finalPackageProtectedField = new Object();
+
+ static public Object staticPublicField;
+ static private Object staticPrivateField;
+ static protected Object staticProtectedField;
+ static Object staticPackageProtectedField;
+
+ final static public Object finalStaticPublicField = new Object();
+ final static private Object finalStaticPrivateField = new Object();
+ final static protected Object finalStaticProtectedField = new Object();
+ final static Object finalStaticPackageProtectedField = new Object();
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+import junit.framework.TestCase;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.jboss.portal.common.reflect.Reflection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ReflectionTestCase extends TestCase
+{
+
+ public void testClass1()
+ {
+ assertEquals(Class1.class, "privateMethod", Modifier.PRIVATE, Reflection.findMethod(Class1.class, "privateMethod", new Class[0]));
+
+ //
+ assertEquals(Class1.class, "privateMethodOfClass1", Modifier.PRIVATE, Reflection.findMethod(Class1.class, "privateMethodOfClass1", new Class[0]));
+ assertEquals(Class1.class, "publicAbstractMethodOfClass1", Modifier.PUBLIC | Modifier.ABSTRACT, Reflection.findMethod(Class1.class, "publicAbstractMethodOfClass1", new Class[0]));
+ assertEquals(Class1.class, "protectedAbstractMethodOfClass1", Modifier.PROTECTED | Modifier.ABSTRACT, Reflection.findMethod(Class1.class, "protectedAbstractMethodOfClass1", new Class[0]));
+ }
+
+ public void testClass2()
+ {
+ assertEquals(Class2.class, "privateMethod", Modifier.PRIVATE, Reflection.findMethod(Class2.class, "privateMethod", new Class[0]));
+
+ //
+ assertEquals(Class1.class, "privateMethodOfClass1", Modifier.PRIVATE, Reflection.findMethod(Class2.class, "privateMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "publicAbstractMethodOfClass1", Modifier.PUBLIC, Reflection.findMethod(Class2.class, "publicAbstractMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "protectedAbstractMethodOfClass1", Modifier.PROTECTED, Reflection.findMethod(Class2.class, "protectedAbstractMethodOfClass1", new Class[0]));
+
+ //
+ assertEquals(Class2.class, "privateMethodOfClass2", Modifier.PRIVATE, Reflection.findMethod(Class2.class, "privateMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "publicMethodOfClass2", Modifier.PUBLIC, Reflection.findMethod(Class2.class, "publicMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "protectedMethodOfClass2", Modifier.PROTECTED, Reflection.findMethod(Class2.class, "protectedMethodOfClass2", new Class[0]));
+ }
+
+ public void testClass3()
+ {
+ assertEquals(Class3.class, "privateMethod", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethod", new Class[0]));
+
+ //
+ assertEquals(Class1.class, "privateMethodOfClass1", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "publicAbstractMethodOfClass1", Modifier.PUBLIC, Reflection.findMethod(Class3.class, "publicAbstractMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "protectedAbstractMethodOfClass1", Modifier.PROTECTED, Reflection.findMethod(Class3.class, "protectedAbstractMethodOfClass1", new Class[0]));
+
+ //
+ assertEquals(Class2.class, "privateMethodOfClass2", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "publicMethodOfClass2", Modifier.PUBLIC, Reflection.findMethod(Class3.class, "publicMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "protectedMethodOfClass2", Modifier.PROTECTED, Reflection.findMethod(Class3.class, "protectedMethodOfClass2", new Class[0]));
+
+ //
+ assertEquals(Class3.class, "privateMethodOfClass3", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethodOfClass3", new Class[0]));
+ }
+
+ private void assertEquals(Class declaringClass, String methodName, int modifiers, Method effectiveMethod)
+ {
+ assertNotNull(effectiveMethod);
+ assertEquals(declaringClass, effectiveMethod.getDeclaringClass());
+ assertEquals(modifiers, effectiveMethod.getModifiers());
+ assertEquals(methodName, effectiveMethod.getName());
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CharBufferTestCase extends TestCase
+{
+
+ private FastURLEncoder encoder = FastURLEncoder.getUTF8Instance();
+
+ public void testUTF8EncodedStringAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("/ a$\u0400", encoder);
+ assertEquals("%2F+a%24%D0%80", buffer.asString());
+ }
+
+ public void testStringAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("abc");
+ assertEquals("abc", buffer.asString());
+ }
+
+ public void testCharArrayAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("abc".toCharArray());
+ assertEquals("abc", buffer.asString());
+ }
+
+ public void testCharsAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append('a').append('b').append('c');
+ assertEquals("abc", buffer.asString());
+ }
+
+ public void testReset()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("abc".toCharArray());
+ assertEquals("abc", buffer.asString());
+ buffer.reset();
+ buffer.append("def".toCharArray());
+ assertEquals("def", buffer.asString());
+ }
+
+ public void testCharArrayAppendThrowsIAE()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ try
+ {
+ buffer.append((char[])null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testStringAppendThrowsIAE()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ try
+ {
+ buffer.append((String)null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testUTF8EncodedAppendThrowsIAE()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ try
+ {
+ buffer.append(null, encoder);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ buffer.append("abc", null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.CharToByteEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CharToByteEncoderTestCase extends TestCase
+{
+
+ public void testCorrectness()
+ {
+ CharToByteEncoder encoder = new CharToByteEncoder.Generic("UTF8");
+
+ //
+ for (int i = 0;i <= 0x10FFFD;i++)
+ {
+ char c = (char)i;
+ int type = Character.getType(c);
+ byte[] r = encoder.encode(c);
+ if (type == Character.SURROGATE || type == Character.PRIVATE_USE)
+ {
+ if (r.length != 0)
+ {
+ fail("Char " + i + " has length " + r.length);
+ }
+ }
+ else
+ {
+ if (r.length < 1)
+ {
+ fail("Char " + i + " has length " + r.length);
+ }
+ }
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/EntityEncoderTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.EntityEncoder;
+import org.jboss.portal.common.text.CharBuffer;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EntityEncoderTestCase extends TestCase
+{
+
+ public void testChar()
+ {
+ CharBuffer buffer = new CharBuffer();
+ EntityEncoder.FULL.encode('&', buffer);
+ assertEquals("&", buffer.asString(true));
+ EntityEncoder.FULL.encode('c', buffer);
+ assertEquals("c", buffer.asString(true));
+ }
+
+ public void testString()
+ {
+ test("&", "&");
+ test("&bar", "&bar");
+ test("foo&", "foo&");
+ test("foo&bar", "foo&bar");
+ }
+
+ private void test(String expected, String actual)
+ {
+ CharBuffer buffer = new CharBuffer();
+ EntityEncoder.FULL.encode(actual, buffer);
+ assertEquals(expected, buffer.asString());
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,249 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.FastURLDecoder;
+import org.jboss.portal.common.text.CharEncoder;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.MalformedInputException;
+
+import java.net.URLEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FastURLDecoderTestCase extends TestCase
+{
+
+ public void testEncodeThrowsIAE() throws Exception
+ {
+ CharEncoder encoder = FastURLDecoder.getUTF8Instance();
+ try
+ {
+ encoder.encode(new char[10], -1, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, -1, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 15, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, 6, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(null, 0, 5, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((char[])null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((CharSequence)null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ encoder.encode(new char[10], 0, 10, null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode('A', null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("abc", null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEncode() throws Exception
+ {
+ FastURLDecoder encoder = FastURLDecoder.getUTF8Instance();
+ StringBuffer tmp = new StringBuffer();
+ for (int i = 0;i < 512;i++)
+ {
+ tmp.append((char)i);
+ }
+ CharBuffer out = new CharBuffer();
+ String s = tmp.toString();
+ String t = URLEncoder.encode(s, "UTF8");
+ encoder.encode(t, out);
+ assertEquals(s, out.asString());
+ }
+
+ public void testEncodeMalformedInput()
+ {
+ testEncodeMalformedInput(FastURLDecoder.getUTF8StrictInstance(), true);
+ testEncodeMalformedInput(FastURLDecoder.getUTF8Instance(), false);
+ }
+
+ private void testEncodeMalformedInput(FastURLDecoder encoder, boolean strict)
+ {
+ try
+ {
+ encoder.encode("%0T", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%T0", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%0\u0100", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%\u01000", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%0", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%FC", new CharBuffer());
+ fail();
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+
+ //
+ if (strict)
+ {
+ try
+ {
+ encoder.encode(";", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("\u0100", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ }
+ else
+ {
+ CharBuffer tmp = new CharBuffer();
+
+ //
+ encoder.encode(";", tmp);
+ assertEquals(";", tmp.asString());
+
+ //
+ tmp.reset();
+ encoder.encode("\u0100", tmp);
+ assertEquals("\u0100", tmp.asString());
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,147 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.CharEncoder;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+import java.net.URLEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FastURLEncoderTestCase extends TestCase
+{
+
+ public void testEncodeThrowsIAE() throws Exception
+ {
+ CharEncoder encoder = FastURLEncoder.getUTF8Instance();
+ try
+ {
+ encoder.encode(new char[10], -1, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, -1, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 15, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, 6, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(null, 0, 5, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((char[])null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((CharSequence)null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ encoder.encode(new char[10], 0, 10, null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode('A', null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("abc", null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEncode() throws Exception
+ {
+ FastURLEncoder encoder = FastURLEncoder.getUTF8Instance();
+ StringBuffer tmp = new StringBuffer();
+ for (int i = 0; i < 512; i++)
+ {
+ tmp.append((char)i);
+ }
+ String s = tmp.toString();
+ String u1 = encoder.encode(s);
+ String u2 = URLEncoder.encode(s, "UTF8");
+ assertEquals(u2, u1);
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.TextTools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TextToolsTestCase extends TestCase
+{
+
+ public void testIsAlphaNumeric()
+ {
+ assertForChar(false, 0, '0');
+ assertForChar(true, '0', '9' + 1);
+ assertForChar(false, '9' + 1, 'A');
+ assertForChar(true, 'A', 'Z' + 1);
+ assertForChar(false, 'Z' + 1, 'a');
+ assertForChar(true, 'a', 'z' + 1);
+ assertForChar(false, 'z' + 1, 512);
+ }
+
+ private void assertForChar(boolean result, int from, int to)
+ {
+ while (from < to)
+ {
+ assertEquals(result, TextTools.isAlphaNumeric((char)(from++)));
+ }
+ }
+
+ public void testToHex()
+ {
+ assertEquals('0', TextTools.toHex(0));
+ assertEquals('1', TextTools.toHex(1));
+ assertEquals('2', TextTools.toHex(2));
+ assertEquals('3', TextTools.toHex(3));
+ assertEquals('4', TextTools.toHex(4));
+ assertEquals('5', TextTools.toHex(5));
+ assertEquals('6', TextTools.toHex(6));
+ assertEquals('7', TextTools.toHex(7));
+ assertEquals('8', TextTools.toHex(8));
+ assertEquals('9', TextTools.toHex(9));
+ assertEquals('A', TextTools.toHex(10));
+ assertEquals('B', TextTools.toHex(11));
+ assertEquals('C', TextTools.toHex(12));
+ assertEquals('D', TextTools.toHex(13));
+ assertEquals('E', TextTools.toHex(14));
+ assertEquals('F', TextTools.toHex(15));
+ for (int i = 16;i < 512;i++)
+ {
+ try
+ {
+ TextTools.toHex(i);
+ fail("Was expecting an IAE at index=" + i);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+ for (int i = -512;i < 0;i++)
+ {
+ try
+ {
+ TextTools.toHex(i);
+ fail("Was expecting an IAE at index=" + i);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionBuilderTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionBuilderTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionBuilderTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,158 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CollectionBuilder;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CollectionBuilderTestCase extends TestCase
+{
+
+ public void testHashSet1()
+ {
+ HashSet expected = new HashSet();
+ assertEquals(expected, CollectionBuilder.hashSet().get());
+ }
+
+ public void testHashSet2()
+ {
+ HashSet<String> expected = new HashSet<String>();
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.hashSet("a").get());
+ }
+
+ public void testHashSet3()
+ {
+ HashSet<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.hashSet("a").add("b").get());
+ }
+
+ public void testHashSet4()
+ {
+ HashSet<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.hashSet("a").add("b").add("a").get());
+ }
+
+ public void testArrayList1()
+ {
+ ArrayList expected = new ArrayList();
+ assertEquals(expected, CollectionBuilder.arrayList().get());
+ }
+
+ public void testArrayList2()
+ {
+ ArrayList<String> expected = new ArrayList<String>();
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.arrayList("a").get());
+ }
+
+ public void testArrayList3()
+ {
+ ArrayList<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.arrayList("a").add("b").get());
+ }
+
+ public void testArrayList4()
+ {
+ ArrayList<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.arrayList("a").add("b").add("a").get());
+ }
+
+ public void testLinkedList1()
+ {
+ LinkedList expected = new LinkedList();
+ assertEquals(expected, CollectionBuilder.linkedList().get());
+ }
+
+ public void testLinkedList2()
+ {
+ LinkedList<String> expected = new LinkedList<String>();
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.linkedList("a").get());
+ }
+
+ public void testLinkedList3()
+ {
+ LinkedList<String> expected = new LinkedList<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.linkedList("a").add("b").get());
+ }
+
+ public void testLinkedList4()
+ {
+ LinkedList<String> expected = new LinkedList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.linkedList("a").add("b").add("a").get());
+ }
+
+ public void testSet1()
+ {
+ Set<String> expected = new HashSet<String>();
+ assertEquals(expected, CollectionBuilder.create(new HashSet<String>()).get());
+ }
+
+ public void testSet2()
+ {
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.create(new HashSet<String>()).add("a").get());
+ }
+
+ public void testSet3()
+ {
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.create(new HashSet<String>()).add("a").add("b").get());
+ }
+
+ public void testSet4()
+ {
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.create(new HashSet<String>()).add("a").add("b").add("a").get());
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionMapTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionMapTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionMapTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,285 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CollectionMap;
+import org.jboss.portal.common.util.ListMap;
+import org.jboss.portal.common.util.SetMap;
+
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CollectionMapTestCase extends TestCase
+{
+
+ private Key k1 = new Key();
+ private Value v1 = new Value();
+ private Value v2 = new Value();
+ private ValueExt ve1 = new ValueExt();
+ private ValueExt ve2 = new ValueExt();
+
+ public void testNormal()
+ {
+ testNormal(new SetMap<Key, Value>());
+ testNormal(new ListMap<Key, Value>());
+ }
+
+ public void testRemoveAbsent()
+ {
+ testRemoveAbsent(new SetMap<Key, Value>());
+ testRemoveAbsent(new ListMap<Key, Value>());
+ }
+
+ public void testRemoveNull()
+ {
+ testRemoveNull(new SetMap<Key, Value>());
+ testRemoveNull(new ListMap<Key, Value>());
+ }
+
+ public void testWithNullValue()
+ {
+ testWithNullValue(new SetMap<Key, Value>());
+ testWithNullValue(new ListMap<Key, Value>());
+ }
+
+ public void testClassCastException()
+ {
+ testClassCastException(new SetMap<Key, Value>());
+ testClassCastException(new ListMap<Key, Value>());
+ }
+
+ public void testThrowNPE()
+ {
+ testThrowNPE(new SetMap<Key, Value>());
+ testThrowNPE(new ListMap<Key, Value>());
+ }
+
+ public void testSorting()
+ {
+ Comparator<Value> comp = new Comparator<Value>()
+ {
+ public int compare(Value o1, Value o2)
+ {
+ return o1.i - o2.i;
+ }
+ };
+
+ testComparatorSorting(new ListMap<Key, Value>(comp));
+ testComparatorSorting(new SetMap<Key, Value>(comp));
+ }
+
+ private void testComparatorSorting(CollectionMap<Key, Value> map)
+ {
+ Value v1 = new Value(1);
+ Value v2 = new Value(2);
+ Value v3 = new Value(3);
+ Value v4 = new Value(4);
+
+ map.put(k1, v2);
+ map.put(k1, v4);
+ map.put(k1, v3);
+ map.put(k1, v1);
+
+ Iterator<Value> iterator = map.iterator(k1);
+ for (int i = 0; iterator.hasNext(); i++)
+ {
+ Value value = iterator.next();
+ switch (i)
+ {
+ case 0:
+ assertEquals(v1, value);
+ break;
+ case 1:
+ assertEquals(v2, value);
+ break;
+ case 2:
+ assertEquals(v3, value);
+ break;
+ case 3:
+ assertEquals(v4, value);
+ break;
+ }
+ }
+ }
+
+ private void testNormal(CollectionMap<Key, Value> map)
+ {
+ assertFalse(map.contains(k1, v1));
+ assertFalse(map.contains(k1, ve1));
+ map.put(k1, v1);
+ assertTrue(map.contains(k1, v1));
+ assertFalse(map.contains(k1, ve1));
+ map.put(k1, ve1);
+ assertTrue(map.contains(k1, v1));
+ assertTrue(map.contains(k1, ve1));
+ map.remove(k1, v1);
+ assertFalse(map.contains(k1, v1));
+ assertTrue(map.contains(k1, ve1));
+ map.remove(k1, ve1);
+ assertFalse(map.contains(k1, v1));
+ assertFalse(map.contains(k1, ve1));
+ }
+
+ private void testRemoveAbsent(CollectionMap<Key, Value> map)
+ {
+ map.put(k1, v1);
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(v1));
+ map.remove(k1, v2);
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(v1));
+ }
+
+ private void testRemoveNull(CollectionMap<Key, Value> map)
+ {
+ map.put(k1, v1);
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(v1));
+ map.remove(k1, null);
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(v1));
+ }
+
+ private void testWithNullValue(CollectionMap<Key, Value> map)
+ {
+ assertFalse(map.contains(k1, null));
+ map.put(k1, null);
+ assertTrue(map.contains(k1, null));
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(null));
+ map.remove(k1, null);
+ assertFalse(map.contains(k1, null));
+ assertEquals(null, map.get(k1));
+ }
+
+ private void testClassCastException(CollectionMap<Key, Value> map)
+ {
+ CollectionMap sm2 = map;
+ sm2.put(k1, new Object());
+ Iterator<Value> i = map.iterator(k1);
+ List<Value> lst = get(i);
+ try
+ {
+ Value v = lst.get(0);
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ private void testThrowNPE(CollectionMap<Key, Value> map)
+ {
+ try
+ {
+ map.put(null, v1);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.remove(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.remove(null, v1);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.contains(null, v1);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.iterator(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ }
+
+ private <V> List<V> get(Iterator<V> i)
+ {
+ List<V> list = new ArrayList<V>();
+ while (i.hasNext())
+ {
+ V v = i.next();
+ list.add(v);
+ }
+ return list;
+ }
+
+ private static final class Key
+ {
+ }
+
+ private static class Value
+ {
+ int i;
+
+ private Value()
+ {
+ }
+
+ private Value(int i)
+ {
+ this.i = i;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Value " + i;
+ }
+ }
+
+ private static class ValueExt extends Value
+ {
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/MapBuilderTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/MapBuilderTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/MapBuilderTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.MapBuilder;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MapBuilderTestCase extends TestCase
+{
+
+ public void testHashMap1()
+ {
+ assertEquals(new HashMap(), MapBuilder.hashMap().get());
+ }
+
+ public void testHashMap2()
+ {
+ HashMap<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "b");
+ assertEquals(expected, MapBuilder.hashMap("a", "b").get());
+ }
+
+ public void testHashMap3()
+ {
+ HashMap<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "b");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.hashMap("a", "b").put("c", "d").get());
+ }
+
+ public void testHashMap4()
+ {
+ HashMap<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "d");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.hashMap("a", "b").put("c", "d").put("a", "d").get());
+ }
+
+ public void testLinkedHashMap1()
+ {
+ assertEquals(new LinkedHashMap(), MapBuilder.linkedHashMap().get());
+ }
+
+ public void testLinkedHashMap2()
+ {
+ LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>();
+ expected.put("a", "b");
+ assertEquals(expected, MapBuilder.linkedHashMap("a", "b").get());
+ }
+
+ public void testLinkedHashMap3()
+ {
+ LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>();
+ expected.put("a", "b");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.linkedHashMap("a", "b").put("c", "d").get());
+ }
+
+ public void testLinkedHashMap4()
+ {
+ LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>();
+ expected.put("a", "d");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.linkedHashMap("a", "b").put("c", "d").put("a", "d").get());
+ }
+
+ public void testTreeMap1()
+ {
+ assertEquals(new TreeMap(), MapBuilder.treeMap().get());
+ }
+
+ public void testTreeMap2()
+ {
+ TreeMap<String, String> expected = new TreeMap<String, String>();
+ expected.put("a", "b");
+ assertEquals(expected, MapBuilder.treeMap("a", "b").get());
+ }
+
+ public void testTreeMap3()
+ {
+ TreeMap<String, String> expected = new TreeMap<String, String>();
+ expected.put("a", "b");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.treeMap("a", "b").put("c", "d").get());
+ }
+
+ public void testTreeMap4()
+ {
+ TreeMap<String, String> expected = new TreeMap<String, String>();
+ expected.put("a", "d");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.treeMap("a", "b").put("c", "d").put("a", "d").get());
+ }
+
+ public void testMap1()
+ {
+ assertEquals(new HashMap(), MapBuilder.create(new HashMap<String, String>()).get());
+ }
+
+ public void testMap2()
+ {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "b");
+ assertEquals(expected, MapBuilder.create(new HashMap<String, String>()).put("a", "b").get());
+ }
+
+ public void testMap3()
+ {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "b");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.create(new HashMap<String, String>()).put("a", "b").put("c", "d").get());
+ }
+
+ public void testMap4()
+ {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "d");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.create(new HashMap<String, String>()).put("a", "b").put("c", "d").put("a", "d").get());
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/TypedMapTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/TypedMapTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/TypedMapTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,462 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CollectionBuilder;
+import org.jboss.portal.common.util.TypedMap;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TypedMapTestCase extends TestCase
+{
+
+ private StringToInteger sti;
+
+ private Map<String, Integer> delegate;
+
+ private StringToIntegerMap map;
+
+ public TypedMapTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ delegate = new HashMap<String, Integer>();
+ sti = new StringToInteger();
+ map = new StringToIntegerMap(delegate, sti);
+ }
+
+ public void testGetWithBrokenGetInternalValue()
+ {
+ sti.internalValueReturnsNull = true;
+ map.get("abc");
+ delegate.put("abc", new Integer(0));
+ map.get("abc");
+ }
+
+ public void testPutWithBrokenGetInternalValue()
+ {
+ sti.internalValueReturnsNull = true;
+ try
+ {
+ map.put("abc", "0");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testRemoveWithBrokenGetInternalValue()
+ {
+ sti.internalValueReturnsNull = true;
+ map.remove("abc");
+ }
+
+ public void testRemoveWithBrokenGetExternalValue()
+ {
+ sti.externalValueReturnsNull = true;
+ map.remove("abc");
+ delegate.put("abc", new Integer(0));
+ try
+ {
+ map.remove("abc");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testGetWithBrokenGetExternalValue()
+ {
+ sti.externalValueReturnsNull = true;
+ map.get("abc");
+ delegate.put("abc", new Integer(0));
+ try
+ {
+ map.get("abc");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testPutWithBrokenGetExternalValue()
+ {
+ sti.externalValueReturnsNull = true;
+ map.put("abc", "0");
+ try
+ {
+ map.put("abc", "0");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testGetWithInvalidInternalValue()
+ {
+ ((Map)delegate).put("abc", "0");
+ try
+ {
+ map.get("abc");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testPutWithInvalidInternalValue()
+ {
+ ((Map)delegate).put("abc", "0");
+ try
+ {
+ map.put("abc", "0");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testRemoveWithInvalidInternalValue()
+ {
+ ((Map)delegate).put("abc", "0");
+ try
+ {
+ map.remove("abc");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testRemove()
+ {
+ assertNull(map.remove("abc"));
+ delegate.put("abc", new Integer(0));
+ assertEquals("0", map.remove("abc"));
+ assertTrue(delegate.isEmpty());
+ }
+
+ public void testPut()
+ {
+ map.put("abc", "0");
+ assertEquals(Collections.singletonMap("abc", new Integer(0)), delegate);
+ }
+
+ public void testGet()
+ {
+ assertNull(map.get("abc"));
+ delegate.put("abc", new Integer(0));
+ assertEquals(Collections.singletonMap("abc", "0"), map);
+ }
+
+ public void testContainsKeyWithInvalidKey()
+ {
+ try
+ {
+ map.containsKey(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.containsKey(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testContainsValueWithInvalidValue()
+ {
+ try
+ {
+ map.containsValue(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.containsValue(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testRemoveWithInvalidKey()
+ {
+ try
+ {
+ map.remove(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.remove(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testGetWithInvalidKey()
+ {
+ try
+ {
+ map.get(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.get(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testPutWithInvalidKey()
+ {
+ try
+ {
+ map.put(null, "0");
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ ((Map)map).put(new Object(), "0");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testWithPutInvalidValue()
+ {
+ try
+ {
+ map.put("", null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ ((Map)map).put("", new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testEquals()
+ {
+ Map<String, Integer> leftDelegate = new HashMap<String, Integer>();
+ StringToIntegerMap left = new StringToIntegerMap(leftDelegate, sti);
+ leftDelegate.put("abc", new Integer(0));
+ Map right = new HashMap();
+
+ //
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.put("abc", new Object());
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.put("abc", "abc");
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.put("abc", "0");
+ assertTrue(left.equals(right));
+ assertTrue(right.equals(left));
+
+ //
+ right.put("def", "1");
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.remove("def");
+ right.put(null, "0");
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.remove(null);
+ right.put("def", null);
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+ }
+
+ public void testEntrySetRetainAll()
+ {
+ Map right = new HashMap();
+ right.put("abc", new Integer(0));
+ right.put("def", new Integer(1));
+ right.put("ghi", new Integer(2));
+
+ //
+ Map<String, Integer> leftDelegate = new HashMap<String, Integer>();
+ StringToIntegerMap left = new StringToIntegerMap(leftDelegate, sti);
+ leftDelegate.putAll(right);
+
+ try
+ {
+ left.keySet().retainAll(null);
+ fail("Was expecting NPE");
+ }
+ catch (NullPointerException expected)
+ {
+ }
+
+ //
+ boolean changed = left.keySet().retainAll(CollectionBuilder.hashSet().add("abc").add("def").add("ghi").get());
+ assertFalse(changed);
+ assertEquals(right, leftDelegate);
+
+ //
+ changed = left.keySet().retainAll(CollectionBuilder.hashSet().add("def").get());
+ assertTrue(changed);
+ right.remove("abc");
+ right.remove("ghi");
+ assertEquals(right, leftDelegate);
+ }
+
+ public static class StringToIntegerMap extends TypedMap<String, String, String, Integer>
+ {
+ public StringToIntegerMap(Map<String, Integer> map, StringToInteger sti)
+ {
+ super(map, new StringToString(), sti);
+ }
+ }
+
+ private static class StringToString extends TypedMap.Converter<String, String>
+ {
+ protected String getInternal(String external) throws IllegalArgumentException, ClassCastException
+ {
+ return external;
+ }
+ protected String getExternal(String internal)
+ {
+ return internal;
+ }
+ protected boolean equals(String left, String right)
+ {
+ return left.equals(right);
+ }
+ }
+
+ private static class StringToInteger extends TypedMap.Converter<String, Integer>
+ {
+
+ /** . */
+ boolean internalValueReturnsNull = false;
+
+ /** . */
+ boolean externalValueReturnsNull = false;
+
+ protected Integer getInternal(String external) throws IllegalArgumentException, ClassCastException
+ {
+ assertNotNull(external);
+
+ //
+ if (internalValueReturnsNull)
+ {
+ return null;
+ }
+ try
+ {
+ return new Integer(external);
+ }
+ catch (NumberFormatException e)
+ {
+ IllegalArgumentException iae = new IllegalArgumentException();
+ iae.initCause(e);
+ throw iae;
+ }
+ }
+
+ protected String getExternal(Integer internal)
+ {
+ assertNotNull(internal);
+
+ //
+ if (externalValueReturnsNull)
+ {
+ return null;
+ }
+
+ //
+ return internal.toString();
+ }
+
+ protected boolean equals(Integer left, Integer right)
+ {
+ assertNotNull(left);
+ assertNotNull(right);
+ return left.intValue() == right.intValue();
+ }
+ }
+}
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/VersionTestCase.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/VersionTestCase.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/java/org/jboss/portal/test/common/util/VersionTestCase.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Version;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class VersionTestCase extends TestCase
+{
+
+ /** . */
+ private final Version.Qualifier GAQualifer = new Version.Qualifier(Version.Qualifier.Prefix.GA);
+
+ public void testIllegalNameThrowsIAE()
+ {
+ try
+ {
+ new Version(null, 0, 0, 0, GAQualifer, "code");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIllegalMajorThrowsIAE()
+ {
+ try
+ {
+ new Version("name", -1, 0, 0, GAQualifer, "code");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIllegalMinorThrowsIAE()
+ {
+ try
+ {
+ new Version("name", 0, -1, 0, GAQualifer, "code");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIllegalQualifierThrowsIAE()
+ {
+ try
+ {
+ new Version("name", 0, 0, 0, null, "code");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+
+ //
+ try
+ {
+ new Version.Qualifier(null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+
+ //
+ try
+ {
+ new Version.Qualifier(null, Version.Qualifier.Suffix.EMPTY);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+
+ //
+ try
+ {
+ new Version.Qualifier(Version.Qualifier.Prefix.GA, Version.Qualifier.Suffix.SUFFIX_1);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIllegalCodeNameThrowsIAE()
+ {
+ try
+ {
+ new Version("name", 0, 0, 0, GAQualifer, null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testState()
+ {
+ Version version = new Version("foo", 1, 2, 3, new Version.Qualifier(Version.Qualifier.Prefix.CR, Version.Qualifier.Suffix.SUFFIX_3), "bar");
+ assertEquals("foo", version.getName());
+ assertEquals(1, version.getMajor());
+ assertEquals(2, version.getMinor());
+ assertEquals(3, version.getPatch());
+ assertEquals(Version.Qualifier.Prefix.CR, version.getQualifier().getPrefix());
+ assertEquals(Version.Qualifier.Suffix.SUFFIX_3, version.getQualifier().getSuffix());
+ assertEquals("bar", version.getCodeName());
+ }
+
+ public void testQualifier()
+ {
+
+ }
+
+ public void testFormat()
+ {
+ Version version = new Version("foo", 1, 2, 3, new Version.Qualifier(Version.Qualifier.Prefix.CR, Version.Qualifier.Suffix.SUFFIX_3), "bar");
+ assertEquals("foo 1.2.3-CR3", version.toString());
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_de_DE.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_de_DE.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_de_DE.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=a_de_DE
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_fr.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_fr.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_fr.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=a_fr
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_fr_FR.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_fr_FR.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_fr_FR.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=a_fr_FR
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_it.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_it.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/a_it.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=a_it
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/b.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/b.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/b.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=b
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/c_fr.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/c_fr.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/c_fr.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=c_fr
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/d_fr_FR.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/d_fr_FR.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/d_fr_FR.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=d_fr_FR
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/e.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/e.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/e.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=e
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/e_fr.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/e_fr.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/e_fr.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=e_fr
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/f.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/f.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/f.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=f
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/f_fr_FR.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/f_fr_FR.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/f_fr_FR.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=f_fr_FR
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/g_fr.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/g_fr.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/g_fr.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=g_fr
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/g_fr_FR.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/g_fr_FR.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/g_fr_FR.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=g_fr_FR
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=h
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h_fr.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h_fr.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h_fr.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=h_fr
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h_fr_FR.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h_fr_FR.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/bundle/h_fr_FR.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+value=h_fr_FR
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/META-INF/jboss-service.xml
===================================================================
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/META-INF/jboss-service.xml
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar/bar.txt
===================================================================
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar/bar.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/web.xml
===================================================================
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/web.xml
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1 @@
+<%@ page language="java" %>
\ No newline at end of file
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/log4j.properties
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/log4j.properties (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/log4j.properties 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,7 @@
+log4j.rootCategory=DEBUG, CONSOLE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
\ No newline at end of file
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1/c1/d1.txt
===================================================================
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1/c1/d1.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1/c1.txt
===================================================================
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1/c1.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1.txt
===================================================================
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b1.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b2.txt
===================================================================
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a1/b2.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a3.txt
===================================================================
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test-jar/a3.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test01.code
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test01.code (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test01.code 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,82 @@
+this is some plain text
+<table><tr><td>I love to write entities like < or > to see how the renderer interprets that
+check the line break around this line
+here we check the wellformdness of the HTML stuff because we enter a code section
+which must terminates any open HTML tag
+[b]bold[/b]
+[i]italic[/i]
+
+the next line is a quote of myself which contains code
+[quote=julien]
+[code]
+this is an XML sample, so the great than etc... should be displayed instead of
+being treated as entities
+<?xml version="1.0"?>
+[b]<root>[/b] the root element is bold
+</root>
+[/code]
+
+the code is closed, we are going to test the nested quotes
+[quote]
+this is a nested quote
+[/quote]
+the next line is code that contains no breaks
+[code]public static void[/code]
+[/quote]
+
+next one is a quote with no line break
+[quote]quote with no line break[/quote]
+
+
+we are going to test if the renderer closes the unclosed statements
+[b][i][u]bold, italic, underline[/b]
+
+[url]http://www.test.com[/url]
+
+[list]
+[*]first item
+[/list]
+
+[list]
+[*]first item
+[*]second item
+[/list]
+
+[list=1]
+[*]first item
+[*]second item
+[/list]
+
+[list=a]
+[*]first item
+[*]second item
+[/list]
+
+[size=25][color=#FF0000]big red[/color][/size]
+
+<code><pre>
+a
+ a
+ a
+ a
+</pre></code>
+<code>
+a
+ a
+ a
+ a
+</code>
+<pre>
+a
+ a
+ a
+ a
+</pre>
+[code]
+a
+ a
+ a
+ a
+[/code]
+
+this is the end of the message
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/common/src/test/resources/test01.code
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.classpath
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.classpath (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.classpath 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.classpath
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.cvsignore
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.cvsignore (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.cvsignore 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,2 @@
+bin
+output
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.cvsignore
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.project
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.project (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.project 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>api</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/.project
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/pom.xml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/pom.xml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/pom.xml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,33 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-mc</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common MC</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/etc/portal-common-mc-lib-jar.mf
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/etc/portal-common-mc-lib-jar.mf (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/etc/portal-common-mc-lib-jar.mf 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/etc/portal-common-mc-lib-jar.mf
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/ActualBootstrap.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/ActualBootstrap.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/ActualBootstrap.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mc.bootstrap;
+
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ActualBootstrap extends BasicBootstrap
+{
+
+ /** . */
+ private final WebBootstrap callback;
+
+ // I don't know why we need to declare it since super() does not declare it
+ public ActualBootstrap(WebBootstrap callback) throws Exception
+ {
+ super();
+
+ //
+ this.callback = callback;
+ }
+
+ protected void bootstrap() throws Throwable
+ {
+ super.bootstrap();
+
+ //
+ callback.boostrap();
+ }
+
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/WebBootstrap.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/WebBootstrap.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/WebBootstrap.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,245 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mc.bootstrap;
+
+import org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.spi.event.KernelEventListener;
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * A kernel bootstrap with a life cycle triggered by the <code>ServletContextListener</code> interface.
+ * All beans will be injected as servlet context attributes. The bean xml file must be available as
+ * a servlet context resource under the path <i>/WEB-INF/jboss-beans.xml</i>.
+ *
+ * @todo specify an alternative logger name
+ * @todo implement the specification of an alternative xml file path
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBootstrap implements ServletContextListener, KernelEventListener
+{
+
+ /**
+ * The servlet context init parameter name for the bean resource location. For instance for a web application
+ * resource it could be <i>/WEB-INF/my-beans.xml</i>, for the web application classloader resource it could be
+ * <i>org/jboss/portal/my-beans.xml</i>. If no init parameter is declared then the litteral value
+ * <i>/WEB-INF/jboss-beans.xml</i> is used and the lookup is done in the servlet context resourcees.
+ */
+ public static final String BEANS_RESOURCE_LOCATION_KEY = "jboss.portal.mc.beans_resource_location";
+
+ /**
+ * The servlet context init parameter name for the bean resource type which can be the servlet context
+ * or the web application classloader. If no value is specified the servlet context will be used for
+ * resource lookup. The legal values are <i>context</i> for the servlet context and <i>classloader</i>
+ * for the web application classloader.
+ */
+ public static final String BEANS_RESOURCE_TYPE_KEY = "jboss.portal.mc.beans_resource_type";
+
+ /** Default value for the bean resource location. */
+ public static final String DEFAULT_JBOSS_BEANS_RESOURCE_LOCATION = "/WEB-INF/jboss-beans.xml";
+
+ /** Servlet context resource type. */
+ public static final String CONTEXT_RESOURCE_TYPE = "context";
+
+ /** Classloader resource type. */
+ public static final String CLASSLOADER_RESOURCE_TYPE = "classloader";
+
+ /** . */
+ private final static Logger log = Logger.getLogger(WebBootstrap.class);
+
+ /** . */
+ private ServletContext servletContext;
+
+ /** . */
+ private BeanXMLDeployer deployer;
+
+ /** . */
+ private KernelDeployment deployment;
+
+ /** . */
+ private boolean registered;
+
+ /** . */
+ private ActualBootstrap bootstrap;
+
+ public void contextInitialized(ServletContextEvent event)
+ {
+ servletContext = event.getServletContext();
+
+ //
+ try
+ {
+ bootstrap = new ActualBootstrap(this);
+
+ //
+ bootstrap.run();
+
+ //
+ log.info("Web kernel started");
+ }
+ catch (Exception e)
+ {
+ log.info("Web kernel boostrap failed", e);
+ }
+ }
+
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ log.info("Web kernel shutdown");
+
+ //
+ if (deployment != null)
+ {
+ deployer.undeploy(deployment);
+ }
+
+ //
+ if (registered)
+ {
+ registered = false;
+ try
+ {
+ KernelRegistry registry = bootstrap.getKernel().getRegistry();
+ registry.unregisterListener(this, null, "ABC");
+ }
+ catch (Throwable throwable)
+ {
+ log.error("Cannot unregister kernel registry listener", throwable);
+ }
+ }
+
+ //
+ servletContext = null;
+
+ //
+ log.info("Web kernel stopped");
+ }
+
+ public void onEvent(KernelEvent event, Object object)
+ {
+ Object context = event.getContext();
+ if (context instanceof String)
+ {
+ String key = (String)context;
+ String type = event.getType();
+ if ("KERNEL_REGISTRY_REGISTERED".equals(type))
+ {
+ KernelRegistryEntry entry = bootstrap.getKernel().getRegistry().getEntry(context);
+ Object target = entry.getTarget();
+ servletContext.setAttribute(key, target);
+ }
+ else if ("KERNEL_REGISTRY_UNREGISTERED".equals(type))
+ {
+ servletContext.removeAttribute(key);
+ }
+ }
+ }
+
+ void boostrap() throws Throwable
+ {
+ //
+ bootstrap.getKernel().getRegistry().registerListener(WebBootstrap.this, null, "ABC");
+ registered = true;
+
+ //
+ deployer = new BeanXMLDeployer(bootstrap.getKernel());
+
+ //
+ URL url = getBeansURL();
+
+ //
+ if (url != null)
+ {
+ log.debug("About to deploy beans url=" + url);
+ deployment = deployer.deploy(url);
+ }
+ else
+ {
+ log.error("No valid beans URL was determined");
+ }
+ }
+
+ protected URL getBeansURL()
+ {
+ String location = servletContext.getInitParameter(BEANS_RESOURCE_LOCATION_KEY);
+ String type = servletContext.getInitParameter(BEANS_RESOURCE_TYPE_KEY);
+
+ //
+ if (location == null)
+ {
+ location = DEFAULT_JBOSS_BEANS_RESOURCE_LOCATION;
+ type = CONTEXT_RESOURCE_TYPE;
+ }
+ else if (type == null)
+ {
+ type = CONTEXT_RESOURCE_TYPE;
+ }
+
+ //
+ if (CONTEXT_RESOURCE_TYPE.equals(type))
+ {
+ try
+ {
+ return servletContext.getResource(location);
+ }
+ catch (MalformedURLException e)
+ {
+ log.error("Cannot obtain beans definition file from servlet context with location=" + location, e);
+
+ //
+ return null;
+ }
+ }
+ else if (CLASSLOADER_RESOURCE_TYPE.equals(type))
+ {
+ URL resource = Thread.currentThread().getContextClassLoader().getResource(location);
+
+ //
+ if (resource == null)
+ {
+ log.error("Cannot obtain bean definition file from thread context classloader with location=" + location);
+ }
+
+ //
+ return resource;
+ }
+ else
+ {
+ log.error("Cannot obtain bean definition file since the context type cannot be determined type=" + type);
+
+ //
+ return null;
+ }
+ }
+}
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/pom.xml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/pom.xml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/pom.xml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,35 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-aggregator</artifactId>
+ <packaging>pom</packaging>
+ <name>JBoss Portal Modules Common (aggregator)</name>
+ <version>1.1-SNAPHOT</version>
+
+ <distributionManagement>
+ <repository>
+ <!--Copy the distribution jar file to a local checkout of the maven repository
+ - This variable can be set in $MAVEN_HOME/conf/settings.xml-->
+ <id>repository.jboss.org</id>
+ <url>file://${jboss.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <url>dav:https://snapshots.jboss.org/maven2</url>
+ <uniqueVersion>true</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <modules>
+ <module>build</module>
+ <module>common</module>
+ <module>mc</module>
+ <module>portal</module>
+ </modules>
+
+
+
+
+</project>
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.classpath
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.classpath (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.classpath 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.classpath
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.cvsignore
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.cvsignore (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.cvsignore 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,2 @@
+bin
+output
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.cvsignore
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.project
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.project (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.project 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>api</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/.project
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/pom.xml
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/pom.xml (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/pom.xml 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,20 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-portal</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common Portal</name>
+
+ <dependencies/>
+
+ <properties>
+
+ </properties>
+</project>
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/etc/portal-common-portal-lib-jar.mf
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/etc/portal-common-portal-lib-jar.mf (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/etc/portal-common-portal-lib-jar.mf 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/etc/portal-common-portal-lib-jar.mf
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/Mode.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/Mode.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/Mode.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,162 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7867 $
+ */
+public final class Mode implements Serializable
+{
+
+ /** The serialVersionUID. */
+ private static final long serialVersionUID = 6033765240710422050L;
+
+ /** . */
+ public static final Mode EDIT = new Mode("edit");
+
+ /** . */
+ public static final Mode HELP = new Mode("help");
+
+ /** . */
+ public static final Mode VIEW = new Mode("view");
+
+ /** . */
+ public static final Mode EDIT_DEFAULTS = new Mode("edit_defaults");
+
+ /** . */
+ public static final Mode ADMIN = new Mode("admin");
+
+ /** . */
+ private String name;
+
+ public Mode(String name)
+ {
+ this(name, false);
+ }
+
+ /**
+ * @param name
+ * @param preserveCase
+ * @since 2.4.2
+ */
+ private Mode(String name, boolean preserveCase)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Mode cannot be null");
+ }
+ this.name = (preserveCase ? name : name.toLowerCase(Locale.ENGLISH));
+ }
+
+
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof Mode)
+ {
+ Mode that = (Mode)o;
+ return name.equals(that.name);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+
+ private Object readResolve()
+ {
+ if (VIEW.name.equals(name))
+ {
+ return VIEW;
+ }
+ else if (EDIT.name.equals(name))
+ {
+ return EDIT;
+ }
+ else if (HELP.name.equals(name))
+ {
+ return HELP;
+ }
+ else if (EDIT_DEFAULTS.name.equals(name))
+ {
+ return EDIT_DEFAULTS;
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ public static Mode create(String name)
+ {
+ return create(name, false);
+ }
+
+ /**
+ * @param name
+ * @param preserveCase
+ * @return
+ * @since 2.4.2
+ */
+ public static Mode create(String name, boolean preserveCase)
+ {
+ if (Mode.VIEW.name.equals(name))
+ {
+ return Mode.VIEW;
+ }
+ else if (Mode.EDIT.name.equals(name))
+ {
+ return Mode.EDIT;
+ }
+ else if (Mode.HELP.name.equals(name))
+ {
+ return Mode.HELP;
+ }
+ else if (Mode.ADMIN.name.equals(name))
+ {
+ return Mode.ADMIN;
+ }
+ else if (Mode.EDIT_DEFAULTS.name.equals(name))
+ {
+ return Mode.EDIT_DEFAULTS;
+ }
+ else
+ {
+ return new Mode(name, preserveCase);
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/Mode.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/WindowState.java
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/WindowState.java (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/WindowState.java 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,144 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6901 $
+ */
+public final class WindowState implements Serializable
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6305311518934458562L;
+
+ /** . */
+ public static final WindowState NORMAL = new WindowState("normal");
+
+ /** . */
+ public static final WindowState MINIMIZED = new WindowState("minimized");
+
+ /** . */
+ public static final WindowState MAXIMIZED = new WindowState("maximized");
+
+ /** . */
+ private String name;
+
+ public WindowState(String name)
+ {
+ this(name, false);
+ }
+
+ /**
+ * @param name
+ * @param preserveCase
+ * @since 2.4.2
+ */
+ private WindowState(String name, boolean preserveCase)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Window state name cannot be null");
+ }
+
+ this.name = (preserveCase ? name : name.toLowerCase(Locale.ENGLISH));
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof WindowState)
+ {
+ WindowState that = (WindowState)o;
+ return name.equals(that.name);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+
+ private Object readResolve()
+ {
+ if (NORMAL.name.equals(name))
+ {
+ return NORMAL;
+ }
+ else if (MAXIMIZED.name.equals(name))
+ {
+ return MAXIMIZED;
+ }
+ else if (MINIMIZED.name.equals(name))
+ {
+ return MINIMIZED;
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ public static WindowState create(String name)
+ {
+ return create(name, false);
+ }
+
+ /**
+ * @param name
+ * @param preserveCase
+ * @return
+ * @since 2.4.2
+ */
+ public static WindowState create(String name, boolean preserveCase)
+ {
+ if (WindowState.NORMAL.name.equals(name))
+ {
+ return WindowState.NORMAL;
+ }
+ else if (WindowState.MINIMIZED.name.equals(name))
+ {
+ return WindowState.MINIMIZED;
+ }
+ else if (WindowState.MAXIMIZED.name.equals(name))
+ {
+ return WindowState.MAXIMIZED;
+ }
+ else
+ {
+ return new WindowState(name, preserveCase);
+ }
+ }
+}
Property changes on: modules/common/branches/JBP_COMMON_BRANCH_1_1/portal/src/main/java/org/jboss/portal/WindowState.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/branches/JBP_COMMON_BRANCH_1_1/svn-commit.tmp
===================================================================
--- modules/common/branches/JBP_COMMON_BRANCH_1_1/svn-commit.tmp (rev 0)
+++ modules/common/branches/JBP_COMMON_BRANCH_1_1/svn-commit.tmp 2008-05-05 09:09:44 UTC (rev 10736)
@@ -0,0 +1,4 @@
+Importing Branch 1.1
+--This line, and those below, will be ignored--
+
+A .
16 years, 1 month
JBoss Portal SVN: r10735 - in branches/JBoss_Portal_Branch_2_6: cms/src/main/org/jboss/portal/cms/impl/jcr and 5 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2008-05-04 02:49:23 -0400 (Sun, 04 May 2008)
New Revision: 10735
Added:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java
Modified:
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties
branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/main.jsp
Log:
[JBPORTAL-1899] - Uploading large archives into Portal CMS results in Transaction timeout
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2008-05-02 05:08:09 UTC (rev 10734)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2008-05-04 06:49:23 UTC (rev 10735)
@@ -25,6 +25,7 @@
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.cms.CMS;
import org.jboss.portal.search.impl.jcr.JCRQuery;
import java.io.InputStream;
@@ -74,6 +75,8 @@
Command createContentCreateNewVersionCommand(List contents, boolean bMakeLive);
Command createStoreArchiveCommand(String sRootPath, InputStream is, String sLanguage);
+
+ Command createAsyncStoreArchiveCommand(CMS cms, String sRootPath, InputStream is, String sLanguage);
Command createItemExistsCommand(String sPath);
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2008-05-02 05:08:09 UTC (rev 10734)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2008-05-04 06:49:23 UTC (rev 10735)
@@ -50,8 +50,11 @@
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.model.Folder;
+import org.jboss.portal.cms.CMS;
import org.jboss.portal.search.impl.jcr.JCRQuery;
+import org.jboss.portal.cms.impl.jcr.command.AsyncStoreArchiveCommand;
+
import java.io.InputStream;
import java.util.List;
import java.util.Locale;
@@ -153,8 +156,13 @@
public Command createStoreArchiveCommand(String sRootPath, InputStream is, String sLanguage)
{
- return new StoreArchiveCommand(sRootPath, is, sLanguage);
+ return new StoreArchiveCommand(sRootPath, is, sLanguage);
}
+
+ public Command createAsyncStoreArchiveCommand(CMS cms, String sRootPath, InputStream is, String sLanguage)
+ {
+ return new AsyncStoreArchiveCommand(cms,sRootPath, is, sLanguage);
+ }
public Command createItemExistsCommand(String sPath)
{
Added: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/AsyncStoreArchiveCommand.java 2008-05-04 06:49:23 UTC (rev 10735)
@@ -0,0 +1,127 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.cms.impl.jcr.command;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.portal.cms.impl.jcr.JCRCMS;
+import org.jboss.portal.cms.impl.jcr.JCRCommand;
+import org.jboss.portal.cms.impl.jcr.JCRCommandContext;
+import org.jboss.portal.cms.CMSException;
+
+
+import java.io.InputStream;
+
+import org.jboss.portal.cms.CMS;
+
+/**
+ * Saves an uploaded archive to the repo.
+ *
+ * @author <a href="mailto:roy@jboss.org">Roy Russo</a>
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ */
+public class AsyncStoreArchiveCommand extends JCRCommand
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1568453649437987499L;
+ private static Logger log = Logger.getLogger(AsyncStoreArchiveCommand.class);
+
+ String msRootPath;
+ InputStream mIS;
+ String msLanguage;
+ CMS cms = null;
+
+ private Object user = null;
+ private Object approvePublishWorkflow = null;
+
+
+ /**
+ * @param sRootPath
+ * @param is
+ * @param sLanguage
+ */
+ public AsyncStoreArchiveCommand(CMS cms, String sRootPath, InputStream is, String sLanguage)
+ {
+ this.msRootPath = sRootPath;
+ this.mIS = is;
+ this.msLanguage = sLanguage;
+ this.cms = cms;
+ }
+
+ /**
+ *
+ */
+ public Object execute()
+ {
+ try
+ {
+ //Capture context information to be passed to the Async processor
+ this.user = context.getAttribute(JCRCommandContext.scope, "user");
+ this.approvePublishWorkflow = context.getAttribute(JCRCommandContext.scope, "approvePublishWorkflow");
+
+ Thread t = new Thread(new AsyncProcessor());
+ t.start();
+
+ return null;
+ }
+ catch(Exception e)
+ {
+ throw new CMSException(e);
+ }
+ }
+ //--------------------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ */
+ private class AsyncProcessor implements Runnable
+ {
+ /**
+ *
+ */
+ public void run()
+ {
+ try
+ {
+ log.info("Async Processing started....................");
+
+ //Setup context information to be propagated to the new CMS Service Command call
+ JCRCMS.getUserInfo().set(user);
+ if(approvePublishWorkflow != null)
+ {
+ JCRCMS.turnOnWorkflow();
+ }
+
+ JCRCommand storeArchiveCommand = (JCRCommand)cms.getCommandFactory().createStoreArchiveCommand(msRootPath, mIS, msLanguage);
+ cms.execute(storeArchiveCommand);
+
+ log.info("Async Processing finished..................");
+ }
+ catch(Exception e)
+ {
+ log.error("Asynchronous Processing of archive failed------------------------------------");
+ log.error(this, e);
+ log.error("-----------------------------------------------------------------------------");
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2008-05-02 05:08:09 UTC (rev 10734)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2008-05-04 06:49:23 UTC (rev 10735)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.cms.impl.jcr.command;
+import org.apache.log4j.Logger;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;
import org.jboss.portal.cms.CMSException;
@@ -37,10 +38,8 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
-import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
@@ -54,6 +53,8 @@
{
/** The serialVersionUID */
private static final long serialVersionUID = 1568453649437987499L;
+ private static Logger log = Logger.getLogger(StoreArchiveCommand.class);
+
String msRootPath;
InputStream mIS;
String msLanguage;
@@ -75,7 +76,6 @@
*/
public Object execute()
{
- List contents = new ArrayList();
File tmpFile = null;
try
{
@@ -128,8 +128,10 @@
JCRCommand saveContentCMD = (JCRCommand)context.getCommandFactory().createContentSaveCommand(file);
context.execute(saveContentCMD);
-
- contents.add(content);
+
+ //Add this content to the repository
+ JCRCommand createContent = (JCRCommand)context.getCommandFactory().createContentCreateNewVersionCommand(content, true);
+ context.execute(createContent);
}
else // isDirectory
{
@@ -168,11 +170,11 @@
}
}
}
- return contents;
+ return null;
}
catch (Exception e)
{
- e.printStackTrace();
+ throw new CMSException(e);
}
finally
{
@@ -181,7 +183,6 @@
tmpFile.delete();
}
}
- return null;
}
/** @param parentPath */
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java 2008-05-02 05:08:09 UTC (rev 10734)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestFileArchiveUpload.java 2008-05-04 06:49:23 UTC (rev 10735)
@@ -80,13 +80,9 @@
service.setDefaultLocale(Locale.ENGLISH.getLanguage());
InputStream is = IOTools.safeBufferedWrapper(new FileInputStream(sZipFile));
Command storearchiveCMD = service.getCommandFactory().createStoreArchiveCommand("", is, "en");
- List contentsToVersion = (List)service.execute(storearchiveCMD);
- is.close();
+ service.execute(storearchiveCMD);
+ is.close();
- Command createVersions = service.getCommandFactory()
- .createContentCreateNewVersionCommand(contentsToVersion, true);
- service.execute(createVersions);
-
// retrieve list
Command listCMD = service.getCommandFactory().createFolderGetListCommand("/ziptest/poop");
Folder whopper = (Folder)service.execute(listCMD);
@@ -107,13 +103,6 @@
Command listCMD3 = service.getCommandFactory().createFolderGetListCommand("/");
Folder whopper3 = (Folder)service.execute(listCMD3);
List folders3 = whopper3.getFolders();
- List files3 = whopper3.getFiles();
-
- //Create and Test an archive containing foreign files
- is = IOTools.safeBufferedWrapper(new FileInputStream(this.foreignArchive));
- storearchiveCMD = service.getCommandFactory().createStoreArchiveCommand("", is, "en");
- contentsToVersion = (List)service.execute(storearchiveCMD);
- assertTrue("Foreign Archive Creation Failed", (contentsToVersion != null && !contentsToVersion.isEmpty() && contentsToVersion.size() == 2));
- is.close();
+ List files3 = whopper3.getFiles();
}
}
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-05-02 05:08:09 UTC (rev 10734)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2008-05-04 06:49:23 UTC (rev 10735)
@@ -68,6 +68,7 @@
import org.jboss.portlet.JBossRenderResponse;
import javax.naming.InitialContext;
+import javax.portlet.PortletConfig;
import javax.portlet.PortletException;
import javax.portlet.PortletRequest;
import javax.portlet.PortletRequestDispatcher;
@@ -85,6 +86,7 @@
import java.util.Locale;
import java.util.Set;
import java.util.Vector;
+import java.util.ResourceBundle;
/**
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
@@ -99,6 +101,7 @@
private MembershipModule membershipModule;
private ApprovePublish approvePublish;
private AuthorizationManager authorizationManager;
+ private ResourceBundle resources = null;
public void init() throws PortletException
@@ -130,9 +133,22 @@
throw new PortletException("Authorization Service not found");
}
- this.initializeApprovePublishWorkflow();
+ this.initializeApprovePublishWorkflow();
}
+
+ /**
+ *
+ */
+ public void init(PortletConfig config) throws PortletException
+ {
+ super.init(config);
+
+ //Get the Resource Bundle for this Portlet
+ this.resources = config.getResourceBundle(Locale.getDefault());
+ }
+
+
protected void doView(final JBossRenderRequest rReq, final JBossRenderResponse rRes)
throws PortletException, IOException, UnavailableException
{
@@ -222,6 +238,14 @@
{
rReq.setAttribute("manageWorkflowAccessible", new Boolean(false));
}
+
+ //Messages
+ if(rReq.getPortletSession().getAttribute("messages") != null)
+ {
+ Object messages = rReq.getPortletSession().getAttribute("messages");
+ rReq.getPortletSession().removeAttribute("messages");
+ rReq.setAttribute("messages", messages);
+ }
javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH + "/main.jsp");
prd.include(rReq, rRes);
@@ -852,12 +876,14 @@
if (!item.isFormField())
{
InputStream is = item.getInputStream();
- Command storearchiveCMD = CMSService.getCommandFactory().createStoreArchiveCommand(sPath, is, sLanguage);
- List contentstoVersion = (List)CMSService.execute(storearchiveCMD);
+
+ Command storearchiveCMD = CMSService.getCommandFactory().createAsyncStoreArchiveCommand(CMSService, sPath, is, sLanguage);
+ CMSService.execute(storearchiveCMD);
+
+ List messages = new ArrayList();
+ messages.add(this.resources.getObject("CMS_MSG_UPLOADARCHIVE_ASYNC"));
+ aReq.getPortletSession().setAttribute("messages", messages);
- Command createVersions = CMSService.getCommandFactory().createContentCreateNewVersionCommand(contentstoVersion, true);
- CMSService.execute(createVersions);
-
aRes.setRenderParameter("path", FileUtil.cleanDoubleSlashes(sPath));
}
else
@@ -870,13 +896,13 @@
else if ("language".equals(fieldName))
{
sLanguage = item.getString(aReq.getCharacterEncoding());
- }
+ }
}
}
}
catch (Exception e)
{
- throw new PortletException(e);
+ throw new PortletException("CMS_ERROR_UPLOADARCHIVE_ASYNC");
}
aRes.setRenderParameter("op", CMSAdminConstants.OP_MAIN);
}
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties 2008-05-02 05:08:09 UTC (rev 10734)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/classes/Resource.properties 2008-05-04 06:49:23 UTC (rev 10735)
@@ -58,6 +58,7 @@
CMS_CREATEFOLDER= Create Folder
CMS_CREATEFILE=Create File
CMS_UPLOADARCHIVE=Upload Archive
+CMS_UPLOADARCHIVE_ASYNC=Process Asynchronously
CMS_BACKTOBROWSER=Back to Directory Browser
CMS_TRANSFER=Import/Export
CMS_EXPORTARCHIVE=Export Folder
@@ -96,4 +97,6 @@
CMS_PATH=Location
CMS_EMPTY_FOLDER=This folder is empty.
-
\ No newline at end of file
+
+CMS_ERROR_UPLOADARCHIVE_ASYNC=An error occurred while processing your archive. Please try again with 'Asynchronous Processing' activated
+CMS_MSG_UPLOADARCHIVE_ASYNC=Your archive has been accepted for processing. The resources will appear in your Folder once the processing is finished
\ No newline at end of file
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/main.jsp
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/main.jsp 2008-05-02 05:08:09 UTC (rev 10734)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-war/WEB-INF/jsp/cms/admin/main.jsp 2008-05-04 06:49:23 UTC (rev 10735)
@@ -21,6 +21,7 @@
String createDate = "";
String modifiedDate = "";
Boolean manageWorkflowAccessible = (Boolean)request.getAttribute("manageWorkflowAccessible");
+ List messages = (List)request.getAttribute("messages");
%>
<div class="admin-ui">
@@ -31,6 +32,23 @@
<div class="cms-tab-container">
+<!-- Displaying any messages that may have occurred during this request -->
+<%if(messages != null && !messages.isEmpty()){%>
+<table width="100%">
+ <th colspan="2"><h3 class="sectionTitle-blue">Messages:</h3></th>
+ <%for(int i=0; i<messages.size(); i++){%>
+ <tr colspan="2" align="center">
+ <td colspan="2">
+ <font color="red">
+ <%=(String)messages.get(i)%>
+ </font>
+ </td>
+ </tr>
+ <%}%>
+</table>
+<br/><br/>
+<%}%>
+
<!-- Currently browsing -->
<ul class="objectpath">
<li class="pathItem"><a href="<portlet:renderURL>
16 years, 1 month
JBoss Portal SVN: r10734 - in branches/JBoss_Portal_2_6_3_JBPORTAL-2000: core/src/main/org/jboss/portal/core/controller/portlet and 6 other directories.
by portal-commits@lists.jboss.org
Author: mmillson
Date: 2008-05-02 01:08:09 -0400 (Fri, 02 May 2008)
New Revision: 10734
Added:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java
Modified:
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/PortalConstants.java
branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
Log:
Provide mechanism for resetting render parameters (window state, portlet Mode, and render request parameters) when rendering a page [JBPORTAL-2000]
Copied: branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java (from rev 10589, branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java)
===================================================================
--- branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java (rev 0)
+++ branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java 2008-05-02 05:08:09 UTC (rev 10734)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.core.aspects.controller;
+
+import java.util.Collection;
+
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
+import org.jboss.portal.core.navstate.NavigationalStateKey;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CleanNSInterceptor extends ControllerInterceptor
+{
+
+ @Override
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception, InvocationException
+ {
+ if (cmd instanceof ViewPageCommand)
+ {
+ ViewPageCommand vpc = (ViewPageCommand)cmd;
+ Collection<PortalObject> children = vpc.getPage().getChildren();
+ for (PortalObject portalObject: children)
+ {
+ cmd.removeAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, new NavigationalStateKey(WindowNavigationalState.class, portalObject.getId()));
+ }
+ }
+ return (ControllerResponse)cmd.invokeNext();
+ }
+
+}
+
Modified: branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java
===================================================================
--- branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-05-02 04:59:30 UTC (rev 10733)
+++ branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/controller/portlet/PortletInvocationFactory.java 2008-05-02 05:08:09 UTC (rev 10734)
@@ -162,7 +162,7 @@
return render;
}
- private static class ControllerActionContext extends AbstractActionContext
+ public static class ControllerActionContext extends AbstractActionContext
{
private InvokePortletCommandFactory cmdFactory;
private ControllerContext controllerContext;
@@ -199,7 +199,7 @@
}
}
- private static class ControllerRenderContext extends AbstractRenderContext
+ public static class ControllerRenderContext extends AbstractRenderContext
{
private InvokePortletCommandFactory cmdFactory;
private ControllerContext controllerContext;
Modified: branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
===================================================================
--- branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2008-05-02 04:59:30 UTC (rev 10733)
+++ branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2008-05-02 05:08:09 UTC (rev 10734)
@@ -120,14 +120,14 @@
*
* @return the children
*/
- Collection getChildren();
+ Collection<PortalObject> getChildren();
/**
* Return all the children of this object filtered with a particular mask.
*
* @return the children
*/
- Collection getChildren(int mask);
+ Collection<PortalObject> getChildren(int mask);
/**
* Return the parent object.
Modified: branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
===================================================================
--- branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-05-02 04:59:30 UTC (rev 10733)
+++ branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2008-05-02 05:08:09 UTC (rev 10734)
@@ -28,6 +28,7 @@
import org.jboss.portal.core.navstate.NavigationalStateContext;
import org.jboss.portal.core.navstate.NavigationalStateKey;
import org.jboss.portal.core.navstate.NavigationalStateObjectChange;
+import org.jboss.portal.core.model.portal.PortalObjectId;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -83,7 +84,8 @@
}
//
- return store.getAttribute(nsKey);
+ PortalObjectId id = (PortalObjectId)nsKey.getId();
+ return store.getAttribute(id.toString());
}
public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
@@ -122,7 +124,8 @@
// If we don't have the old ns then we try the store
if (oldNS == null)
{
- oldNS = (WindowNavigationalState)store.getAttribute(wantedKey);
+ PortalObjectId id = (PortalObjectId)wantedKey.getId();
+ oldNS = (WindowNavigationalState)store.getAttribute(id.toString());
}
//
@@ -198,7 +201,10 @@
maximizedKey = change.getKey();
}
}
- store.setAttribute(change.getKey(), change.getNewValue());
+
+ //
+ PortalObjectId id = (PortalObjectId)change.getKey().getId();
+ store.setAttribute(id.toString(), change.getNewValue());
}
// Unmaximize other windows if necessary
Modified: branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2008-05-02 04:59:30 UTC (rev 10733)
+++ branches/JBoss_Portal_2_6_3_JBPORTAL-2000/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2008-05-02 05:08:09 UTC (rev 10734)
@@ -209,7 +209,17 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
</mbean>
+ <!--
+ This interceptor cleans the Navigation state of windows when the user call a new page or refresh the page
+ -->
<mbean
+ code="org.jboss.portal.core.aspects.controller.CleanNSInterceptor"
+ name="portal:service=Interceptor,type=Command,name=CleanNS"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <mbean
code="org.jboss.portal.core.aspects.controller.node.PortalNodeInterceptor"
name="portal:service=Interceptor,type=Command,name=PortalNode"
xmbean-dd=""
@@ -267,6 +277,7 @@
<depends-list optional-attribute-name="InterceptorNames">
<depends-list-element>portal:service=Interceptor,type=Command,name=ResourceAcquisition</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=Ajax</depends-list-element>
+ <depends-list-element>portal:service=Interceptor,type=Command,name=CleanNS</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=NavigationalState</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PortalNode</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PolicyEnforcement</depends-list-element>
Modified: branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/PortalConstants.java
===================================================================
--- branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/PortalConstants.java 2008-05-02 04:59:30 UTC (rev 10733)
+++ branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/PortalConstants.java 2008-05-02 05:08:09 UTC (rev 10734)
@@ -60,6 +60,6 @@
/** Generic session objects. */
public static final String PORTAL_SESSION_MAP_KEY = "portal.session";
- /** Navigational state objects. */
- public static final String NAVIGATIONAL_STATE_MAP_KEY = "portal.navigationalstate";
+ /** Generic session objects. */
+ public static final String PORTAL_PRINCIPAL_MAP_KEY = "portal.principal";
}
Modified: branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java
===================================================================
--- branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2008-05-02 04:59:30 UTC (rev 10733)
+++ branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/ServerInvocationContextImpl.java 2008-05-02 05:08:09 UTC (rev 10734)
@@ -23,9 +23,7 @@
package org.jboss.portal.server.impl;
import org.jboss.portal.common.invocation.AbstractInvocationContext;
-import org.jboss.portal.common.invocation.resolver.PrincipalAttributeResolver;
import org.jboss.portal.common.invocation.resolver.RequestAttributeResolver;
-import org.jboss.portal.common.invocation.resolver.SessionAttributeResolver;
import org.jboss.portal.common.text.CharBuffer;
import org.jboss.portal.common.text.FastURLEncoder;
import org.jboss.portal.common.util.ParameterMap;
@@ -33,6 +31,7 @@
import org.jboss.portal.server.ServerInvocation;
import org.jboss.portal.server.ServerInvocationContext;
import org.jboss.portal.server.ServerURL;
+import org.jboss.portal.server.impl.invocation.SessionAttributeResolver;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
import org.jboss.portal.web.WebRequest;
@@ -133,8 +132,8 @@
//
addResolver(ServerInvocation.REQUEST_SCOPE, new RequestAttributeResolver(req));
- addResolver(ServerInvocation.SESSION_SCOPE, new SessionAttributeResolver(req, PortalConstants.PORTAL_SESSION_MAP_KEY));
- addResolver(ServerInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(req));
+ addResolver(ServerInvocation.SESSION_SCOPE, new SessionAttributeResolver(req, PortalConstants.PORTAL_SESSION_MAP_KEY, false));
+ addResolver(ServerInvocation.PRINCIPAL_SCOPE, new SessionAttributeResolver(req, PortalConstants.PORTAL_PRINCIPAL_MAP_KEY, true));
}
public WebRequest getWebRequest()
Copied: branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java (from rev 10324, branches/JBoss_Portal_2_6_3_JBPORTAL-1956/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java)
===================================================================
--- branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java (rev 0)
+++ branches/JBoss_Portal_2_6_3_JBPORTAL-2000/server/src/main/org/jboss/portal/server/impl/invocation/SessionAttributeResolver.java 2008-05-02 05:08:09 UTC (rev 10734)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.server.impl.invocation;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Enumeration;
+import java.util.Collections;
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class SessionAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ protected final HttpServletRequest req;
+
+ /** . */
+ protected final String prefix;
+
+ public SessionAttributeResolver(
+ HttpServletRequest req,
+ String prefix,
+ boolean principalScoped)
+ {
+ if (req == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (prefix == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (principalScoped)
+ {
+ Principal principal = req.getUserPrincipal();
+ if (principal != null)
+ {
+ prefix = prefix + principal.getName();
+ }
+ }
+
+ //
+ this.req = req;
+ this.prefix = prefix;
+ }
+
+ public Set getKeys()
+ {
+ HttpSession session = req.getSession(false);
+
+ //
+ if (session == null)
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ //
+ Set keys = new HashSet();
+ for (Enumeration e = session.getAttributeNames();e.hasMoreElements();)
+ {
+ String key = (String)e.nextElement();
+
+ //
+ if (key.startsWith(prefix))
+ {
+ keys.add(key);
+ }
+ }
+
+ //
+ return keys;
+ }
+
+ public Object getAttribute(Object o) throws IllegalArgumentException
+ {
+ HttpSession session = req.getSession(false);
+
+ //
+ if (session == null)
+ {
+ return null;
+ }
+
+ //
+ return session.getAttribute(prefix + o);
+ }
+
+ public void setAttribute(Object o, Object o1) throws IllegalArgumentException
+ {
+ req.getSession().setAttribute(prefix + o, o1);
+ }
+}
\ No newline at end of file
16 years, 1 month
JBoss Portal SVN: r10733 - modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-2000.
by portal-commits@lists.jboss.org
Author: mmillson
Date: 2008-05-02 00:59:30 -0400 (Fri, 02 May 2008)
New Revision: 10733
Modified:
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-2000/.classpath
Log:
Fix typo in Eclipse .classpath file.
Modified: modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-2000/.classpath
===================================================================
--- modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-2000/.classpath 2008-05-02 02:58:39 UTC (rev 10732)
+++ modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-2000/.classpath 2008-05-02 04:59:30 UTC (rev 10733)
@@ -12,7 +12,7 @@
<classpathentry kind="lib" path="thirdparty/junit/lib/junit.jar"/>
<classpathentry kind="lib" path="thirdparty/jboss-portal/modules/test/lib/portal-test-lib.jar"/>
<classpathentry kind="lib" path="thirdparty/sun-servlet/lib/servlet-api.jar"/>
- <classpathentry kind="lib" path="/thirdparty/sun-jaf/lib/activation.jar"/>
+ <classpathentry kind="lib" path="thirdparty/sun-jaf/lib/activation.jar"/>
<classpathentry kind="lib" path="thirdparty/jboss-portal/modules/common/lib/portal-common-portal-lib.jar"/>
<classpathentry kind="lib" path="thirdparty/jboss-portal/modules/web/lib/portal-web-lib.jar"/>
<classpathentry kind="lib" path="thirdparty/sun-servlet/lib/jsp-api.jar"/>
16 years, 1 month
JBoss Portal SVN: r10732 - modules/portlet/branches.
by portal-commits@lists.jboss.org
Author: mmillson
Date: 2008-05-01 22:58:39 -0400 (Thu, 01 May 2008)
New Revision: 10732
Added:
modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-2000/
Log:
Create JBPORTAL-2000 patch branch from JBPORTAL-1956 branch
Copied: modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-2000 (from rev 10731, modules/portlet/branches/JBP_PORTLET_1_0_1_JBPORTAL-1956)
16 years, 1 month
JBoss Portal SVN: r10731 - in modules/common/tags: JBP_COMMON_1_1_1 and 102 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2008-05-01 16:31:41 -0400 (Thu, 01 May 2008)
New Revision: 10731
Added:
modules/common/tags/JBP_COMMON_1_1_1/
modules/common/tags/JBP_COMMON_1_1_1/.classpath
modules/common/tags/JBP_COMMON_1_1_1/.project
modules/common/tags/JBP_COMMON_1_1_1/.settings/
modules/common/tags/JBP_COMMON_1_1_1/.settings/org.eclipse.jdt.ui.prefs
modules/common/tags/JBP_COMMON_1_1_1/build/
modules/common/tags/JBP_COMMON_1_1_1/build/.cvsignore
modules/common/tags/JBP_COMMON_1_1_1/build/.project
modules/common/tags/JBP_COMMON_1_1_1/build/build.bat
modules/common/tags/JBP_COMMON_1_1_1/build/ide/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.1/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.1/config/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.1/config/jboss-format.xml
modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/team/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/team/anonymous-projectSet.psf
modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/team/commiter-projectSet.psf
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/codestyles/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/jboss-portal-common.ipr
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/common/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/common/common.iml
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/mc/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/mc/mc.iml
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/portal/
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/portal/portal.iml
modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/readme.txt
modules/common/tags/JBP_COMMON_1_1_1/common/
modules/common/tags/JBP_COMMON_1_1_1/common/.classpath
modules/common/tags/JBP_COMMON_1_1_1/common/.cvsignore
modules/common/tags/JBP_COMMON_1_1_1/common/.project
modules/common/tags/JBP_COMMON_1_1_1/common/pom.xml
modules/common/tags/JBP_COMMON_1_1_1/common/src/
modules/common/tags/JBP_COMMON_1_1_1/common/src/etc/
modules/common/tags/JBP_COMMON_1_1_1/common/src/etc/portal-common-lib-jar.mf
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/FixMe.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/NotYetImplemented.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcher.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcherFactory.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdaptable.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapted.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapter.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/DefaultJavaLangObjectAdapted.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectAdapted.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcher.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcherFactory.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcher.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcherFactory.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/concurrent/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeader.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeaders.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpRequest.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpResponse.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/QueryStringParser.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/I18NTools.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFactory.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleManager.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleFactory.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/AbstractInvocationContext.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/AttributeResolver.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyAttributeResolver.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyInterceptorStackFactory.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStackFactory.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationContext.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationHandler.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Scope.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/AbstractSessionAttributeResolver.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/MapAttributeResolver.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/PrincipalAttributeResolver.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/RequestAttributeResolver.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/SessionAttributeResolver.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/IOTools.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/UndeclaredIOException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/jar/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/jar/JarEntryInfo.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/jar/JarInfo.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTask.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTest.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableXMLJUnitResultFormatter.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameter.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameterValue.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/markup/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupElement.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLFilter.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/file/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/jar/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/p3p/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/reflect/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/reflect/Modifier.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/reflect/Reflection.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingRequestWrapper.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingResponseWrapper.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharToByteEncoder.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharWriter.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/EncodingException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/MalformedInputException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/TextTools.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/UnsupportedCharsetException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionMap.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CopyOnWriteRegistry.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/IteratorStatus.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ListMap.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MapAccessor.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MapBuilder.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MarkupInfo.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/SimpleMapAccessor.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/NullEntityResolver.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_close.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_close.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_close.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/email.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_close.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/img.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/listitem.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_close.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_close.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_username_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_close.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_close.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_close.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_open.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/url.tpl
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/filters/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/P3PConstantsTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/http/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/io/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractServer.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractSynchronizedServer.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionBuilderTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionMapTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/MapBuilderTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/TypedMapTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/VersionTestCase.java
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_de_DE.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_fr.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_fr_FR.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_it.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/b.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/c_fr.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/d_fr_FR.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/e.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/e_fr.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/f.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/f_fr_FR.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/g_fr.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/g_fr_FR.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h_fr.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h_fr_FR.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/META-INF/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/META-INF/jboss-service.xml
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/web.xml
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar/bar.txt
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/log4j.properties
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1-/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1.txt
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1/c1.txt
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1/c1/
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1/c1/d1.txt
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b2.txt
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a3.txt
modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test01.code
modules/common/tags/JBP_COMMON_1_1_1/mc/
modules/common/tags/JBP_COMMON_1_1_1/mc/.classpath
modules/common/tags/JBP_COMMON_1_1_1/mc/.cvsignore
modules/common/tags/JBP_COMMON_1_1_1/mc/.project
modules/common/tags/JBP_COMMON_1_1_1/mc/pom.xml
modules/common/tags/JBP_COMMON_1_1_1/mc/src/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/etc/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/etc/portal-common-mc-lib-jar.mf
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/ActualBootstrap.java
modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/WebBootstrap.java
modules/common/tags/JBP_COMMON_1_1_1/pom.xml
modules/common/tags/JBP_COMMON_1_1_1/portal/
modules/common/tags/JBP_COMMON_1_1_1/portal/.classpath
modules/common/tags/JBP_COMMON_1_1_1/portal/.cvsignore
modules/common/tags/JBP_COMMON_1_1_1/portal/.project
modules/common/tags/JBP_COMMON_1_1_1/portal/pom.xml
modules/common/tags/JBP_COMMON_1_1_1/portal/src/
modules/common/tags/JBP_COMMON_1_1_1/portal/src/etc/
modules/common/tags/JBP_COMMON_1_1_1/portal/src/etc/portal-common-portal-lib-jar.mf
modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/
modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/
modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/
modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/
modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/
modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/Mode.java
modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/WindowState.java
Log:
Tagging 1.1.1 (WIP)
Added: modules/common/tags/JBP_COMMON_1_1_1/.classpath
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/.classpath (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/.classpath 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="mc/src/main/java"/>
+ <classpathentry kind="src" path="portal/src/main/java"/>
+ <classpathentry kind="src" path="common/src/main/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="thirdparty/jboss/microcontainer/lib/jboss-microcontainer.jar"/>
+ <classpathentry kind="lib" path="thirdparty/sun-servlet/lib/servlet-api.jar"/>
+ <classpathentry kind="lib" path="thirdparty/apache-log4j/lib/log4j.jar"/>
+ <classpathentry kind="lib" path="thirdparty/apache-ant/lib/ant.jar"/>
+ <classpathentry kind="lib" path="thirdparty/oswego-concurrent/lib/concurrent.jar"/>
+ <classpathentry kind="lib" path="thirdparty/junit/lib/junit.jar"/>
+ <classpathentry kind="lib" path="thirdparty/jbossas/core-libs/lib/jboss-j2ee.jar"/>
+ <classpathentry kind="lib" path="thirdparty/apache-httpclient/lib/commons-httpclient.jar"/>
+ <classpathentry kind="lib" path="thirdparty/sun-jaf/lib/activation.jar"/>
+ <classpathentry kind="lib" path="/home/theute/.m2/repository/org/codehaus/cargo/cargo-core-uberjar/0.8/cargo-core-uberjar-0.8.jar"/>
+ <classpathentry kind="lib" path="/home/theute/.m2/repository/ant/ant-junit/1.6.5/ant-junit-1.6.5.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: modules/common/tags/JBP_COMMON_1_1_1/.project
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/.project (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/.project 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>module-common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: modules/common/tags/JBP_COMMON_1_1_1/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/.settings/org.eclipse.jdt.ui.prefs (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/.settings/org.eclipse.jdt.ui.prefs 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,3 @@
+#Tue Nov 13 13:01:47 CET 2007
+eclipse.preferences.version=1
+internal.default.compliance=default
Added: modules/common/tags/JBP_COMMON_1_1_1/build/.cvsignore
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/.cvsignore (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/.cvsignore 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,3 @@
+build.log
+local.properties
+build.iml
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/.cvsignore
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/.project
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/.project (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/.project 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>build</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/.project
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/build.bat
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/build.bat (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/build.bat 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,54 @@
+@echo off
+rem
+rem Invokes a script of the same name in the 'tools' module.
+rem
+rem The 'tools' module is expected to be a peer directory of the directory
+rem in which this script lives.
+rem
+rem @author Jason Dillon <jason(a)planet57.com>
+rem
+
+rem $Id: build.bat 2 2005-01-14 23:01:32Z vietj $
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+set MODULE_ROOT=%DIRNAME%
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..\tools
+set TARGET=%TOOLS_ROOT%\bin\build.bat
+set ARGS=%*
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug TARGET=%TARGET%
+
+if exist %TARGET% call :call-script & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target executable does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %TARGET%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools' module
+echo %PROGNAME%: and make sure it is up to date.
+goto :EOF
+
+:call-script
+call :debug Executing %TARGET% %ARGS%
+call %TARGET% %ARGS%
+goto :EOF
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/build.bat
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.1/config/jboss-format.xml
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.1/config/jboss-format.xml (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.1/config/jboss-format.xml 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,244 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<profiles version="8">
+<profile name="JBoss" version="8">
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="52"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="48"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="64"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="64"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_comments" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="3"/>
+</profile>
+</profiles>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.1/config/jboss-format.xml
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/team/anonymous-projectSet.psf
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/team/anonymous-projectSet.psf (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/team/anonymous-projectSet.psf 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<psf version="2.0">
+ <provider id="org.tigris.subversion.subclipse.core.svnnature">
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/api,api"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/bridge,bridge"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/build,build"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/cms,cms"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/common,common"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core,core"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-admin,core-admin"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-cms,core-cms"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-management,core-ma..."/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-samples,core-samples"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/core-search,core-search"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/faces,faces"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/format,format"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/identity,identity"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/jems,jems"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/portlet,portlet"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/portlet-federation,port..."/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/registration,registration"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/samples,samples"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/search,search"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/security,security"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/server,server"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/test,test"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/testsuite,testsuite"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/theme,theme"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/tools,tools"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/workflow,workflow"/>
+ <project reference="0.9.3,http://anonsvn.jboss.org/repos/portal/trunk/wsrp,wsrp"/>
+ </provider>
+</psf>
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/team/commiter-projectSet.psf
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/team/commiter-projectSet.psf (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/eclipse/3.2/team/commiter-projectSet.psf 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<psf version="2.0">
+ <provider id="org.tigris.subversion.subclipse.core.svnnature">
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/api,api"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/bridge,bridge"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/build,build"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/cms,cms"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/common,common"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core,core"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-admin,core-admin"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-cms,core-cms"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-management,core-manag..."/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-samples,core-samples"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/core-search,core-search"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/faces,faces"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/format,format"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/identity,identity"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/jems,jems"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/portlet,portlet"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/portlet-federation,portlet..."/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/registration,registration"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/samples,samples"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/search,search"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/security,security"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/server,server"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/test,test"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/testsuite,testsuite"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/theme,theme"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/tools,tools"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/workflow,workflow"/>
+ <project reference="0.9.3,https://svn.jboss.org/repos/portal/trunk/wsrp,wsrp"/>
+ </provider>
+</psf>
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<code_scheme name="jboss">
+ <option name="JAVA_INDENT_OPTIONS">
+ <value>
+ <option name="INDENT_SIZE" value="3" />
+ <option name="CONTINUATION_INDENT_SIZE" value="3" />
+ <option name="TAB_SIZE" value="3" />
+ <option name="USE_TAB_CHARACTER" value="false" />
+ <option name="SMART_TABS" value="false" />
+ <option name="LABEL_INDENT_SIZE" value="0" />
+ <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+ </value>
+ </option>
+ <option name="BRACE_STYLE" value="2" />
+ <option name="CLASS_BRACE_STYLE" value="2" />
+ <option name="METHOD_BRACE_STYLE" value="2" />
+ <option name="ELSE_ON_NEW_LINE" value="true" />
+ <option name="WHILE_ON_NEW_LINE" value="true" />
+ <option name="CATCH_ON_NEW_LINE" value="true" />
+ <option name="FINALLY_ON_NEW_LINE" value="true" />
+ <option name="SPACE_AFTER_TYPE_CAST" value="false" />
+ <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="5000" />
+ <option name="WRAP_COMMENTS" value="true" />
+ <option name="IF_BRACE_FORCE" value="3" />
+ <option name="DOWHILE_BRACE_FORCE" value="3" />
+ <option name="WHILE_BRACE_FORCE" value="3" />
+ <option name="FOR_BRACE_FORCE" value="3" />
+ <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" />
+ <option name="XML_KEEP_WHITESPACES" value="true" />
+</code_scheme>
+
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/codestyles/jboss.xml
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,128 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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 ${PACKAGE_NAME};
+
+import org.jboss.portal.test.framework.container.server.result.AssertResult;
+import org.jboss.portal.test.framework.container.server.result.InvokeGetResult;
+import org.jboss.portal.test.framework.container.server.result.FailureResult;
+import org.jboss.portal.test.framework.container.server.result.ServerResult;
+import org.jboss.portal.test.framework.container.server.TestContext;
+import org.jboss.portal.test.portlet.AbstractTestPortlet;
+
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletPreferences;
+import javax.portlet.ValidatorException;
+import javax.portlet.PortletURL;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:boleslaw.dawidowicz@jboss.org">Boleslaw Dawidowicz</a>
+ * @version $Revision: 1951 $
+
+ */
+public class ${NAME} extends AbstractTestPortlet
+{
+
+
+ private AssertResult ares;
+
+ public void doProcessAction(final ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
+ {
+ int requestCount = TestContext.getCurrentRequestCount();
+ if (ares == null)
+ {
+ if (requestCount == 1)
+ {
+ ares = new AssertResult();
+ ares.execute(new AssertResult.Test()
+ {
+ public void run() throws Exception
+ {
+
+ }
+ });
+ }
+ }
+ else if (!ares.isFailed())
+ {
+ if (requestCount == 2)
+ {
+ ares.execute(new AssertResult.Test()
+ {
+ public void run() throws Exception
+ {
+
+ }
+ });
+ }
+ }
+ }
+
+ public void doRender(final RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
+ {
+ ServerResult result = null;
+
+ int requestCount = TestContext.getCurrentRequestCount();
+ if (ares == null)
+ {
+ if (requestCount == 0)
+ {
+ PortletURL url = response.createActionURL();
+ result = new InvokeGetResult(url.toString());
+ AbstractTestPortlet.marshall(result, response, TestContext.getCurrentTestCaseId());
+ }
+ else
+ {
+ AbstractTestPortlet.marshall(new FailureResult("The assert result was expected to be not null"), response, TestContext.getCurrentTestCaseId());
+ }
+ }
+ else if (ares.isFailed())
+ {
+ AbstractTestPortlet.marshall(ares, response, TestContext.getCurrentTestCaseId());
+ }
+ else
+ {
+ if (requestCount == 0)
+ {
+ AbstractTestPortlet.marshall(new FailureResult("The assert result was expected to be not null"), response, TestContext.getCurrentTestCaseId());
+ }
+ else if (requestCount == 1)
+ {
+ PortletURL url = response.createActionURL();
+ result = new InvokeGetResult(url.toString());
+ AbstractTestPortlet.marshall(result, response, TestContext.getCurrentTestCaseId());
+ }
+ else if (requestCount == 2)
+ {
+ AbstractTestPortlet.marshall(ares, response, TestContext.getCurrentTestCaseId());
+ }
+ }
+ }
+
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/StandartTestCasePortlet.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,4 @@
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/Body Header.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,22 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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. *
+ ******************************************************************************/
\ No newline at end of file
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/includes/File Header.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,5 @@
+#parse("File Header.java")
+package ${PACKAGE_NAME};
+#parse("Body Header.java")
+public @interface ${NAME} {
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/AnnotationType.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,5 @@
+#parse("File Header.java")
+package ${PACKAGE_NAME};
+#parse("Body Header.java")
+public class ${NAME} {
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Class.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,5 @@
+#parse("File Header.java")
+package ${PACKAGE_NAME};
+#parse("Body Header.java")
+public enum ${NAME} {
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Enum.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,5 @@
+#parse("File Header.java")
+package ${PACKAGE_NAME};
+#parse("Body Header.java")
+public interface ${NAME} {
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/config/fileTemplates/internal/Interface.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/jboss-portal-common.ipr
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/jboss-portal-common.ipr (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/jboss-portal-common.ipr 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,492 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4" relativePaths="false">
+ <component name="AntConfiguration">
+ <defaultAnt bundledAnt="true" />
+ </component>
+ <component name="BuildJarProjectSettings">
+ <option name="BUILD_JARS_ON_MAKE" value="false" />
+ </component>
+ <component name="CodeStyleProjectProfileManger">
+ <option name="PROJECT_PROFILE" />
+ <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
+ </component>
+ <component name="CodeStyleSettingsManager">
+ <option name="PER_PROJECT_SETTINGS" />
+ <option name="USE_PER_PROJECT_SETTINGS" value="false" />
+ </component>
+ <component name="CompilerConfiguration">
+ <option name="DEFAULT_COMPILER" value="Javac" />
+ <option name="DEPLOY_AFTER_MAKE" value="0" />
+ <resourceExtensions>
+ <entry name=".+\.(properties|xml|html|dtd|tld)" />
+ <entry name=".+\.(gif|png|jpeg|jpg)" />
+ </resourceExtensions>
+ <wildcardResourcePatterns>
+ <entry name="?*.properties" />
+ <entry name="?*.xml" />
+ <entry name="?*.gif" />
+ <entry name="?*.png" />
+ <entry name="?*.jpeg" />
+ <entry name="?*.jpg" />
+ <entry name="?*.html" />
+ <entry name="?*.dtd" />
+ <entry name="?*.tld" />
+ </wildcardResourcePatterns>
+ </component>
+ <component name="DataSourceManagerImpl" />
+ <component name="DependenciesAnalyzeManager">
+ <option name="myForwardDirection" value="false" />
+ </component>
+ <component name="DependencyValidationManager" />
+ <component name="EclipseCompilerSettings">
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="true" />
+ <option name="DEPRECATION" value="false" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
+ </component>
+ <component name="EclipseEmbeddedCompilerSettings">
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="true" />
+ <option name="DEPRECATION" value="false" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
+ </component>
+ <component name="EntryPointsManager">
+ <entry_points />
+ </component>
+ <component name="ExportToHTMLSettings">
+ <option name="PRINT_LINE_NUMBERS" value="false" />
+ <option name="OPEN_IN_BROWSER" value="false" />
+ <option name="OUTPUT_DIRECTORY" />
+ </component>
+ <component name="GUI Designer component loader factory" />
+ <component name="IdProvider" IDEtalkID="E2A438D8B6AE84F43587A2210E562521" />
+ <component name="InspectionProjectProfileManager">
+ <option name="PROJECT_PROFILE" value="Project Default" />
+ <option name="USE_PROJECT_LEVEL_SETTINGS" value="false" />
+ <scopes />
+ <profiles>
+ <profile version="1.0" is_locked="false">
+ <option name="myName" value="Project Default" />
+ <option name="myLocal" value="false" />
+ <used_levels>
+ <error>
+ <option name="myName" value="ERROR" />
+ <option name="myVal" value="200" />
+ </error>
+ <warning>
+ <option name="myName" value="WARNING" />
+ <option name="myVal" value="100" />
+ </warning>
+ <information>
+ <option name="myName" value="INFO" />
+ <option name="myVal" value="100" />
+ </information>
+ <server>
+ <option name="myName" value="SERVER PROBLEM" />
+ <option name="myVal" value="100" />
+ </server>
+ </used_levels>
+ </profile>
+ </profiles>
+ </component>
+ <component name="JavacSettings">
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="false" />
+ <option name="DEPRECATION" value="true" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ <option name="MAXIMUM_HEAP_SIZE" value="128" />
+ </component>
+ <component name="JavadocGenerationManager">
+ <option name="OUTPUT_DIRECTORY" />
+ <option name="OPTION_SCOPE" value="protected" />
+ <option name="OPTION_HIERARCHY" value="true" />
+ <option name="OPTION_NAVIGATOR" value="true" />
+ <option name="OPTION_INDEX" value="true" />
+ <option name="OPTION_SEPARATE_INDEX" value="true" />
+ <option name="OPTION_DOCUMENT_TAG_USE" value="false" />
+ <option name="OPTION_DOCUMENT_TAG_AUTHOR" value="false" />
+ <option name="OPTION_DOCUMENT_TAG_VERSION" value="false" />
+ <option name="OPTION_DOCUMENT_TAG_DEPRECATED" value="true" />
+ <option name="OPTION_DEPRECATED_LIST" value="true" />
+ <option name="OTHER_OPTIONS" value="" />
+ <option name="HEAP_SIZE" />
+ <option name="LOCALE" />
+ <option name="OPEN_IN_BROWSER" value="true" />
+ </component>
+ <component name="JikesSettings">
+ <option name="JIKES_PATH" value="" />
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="DEPRECATION" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="false" />
+ <option name="IS_EMACS_ERRORS_MODE" value="true" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ </component>
+ <component name="LogConsolePreferences">
+ <option name="FILTER_ERRORS" value="false" />
+ <option name="FILTER_WARNINGS" value="false" />
+ <option name="FILTER_INFO" value="true" />
+ <option name="CUSTOM_FILTER" />
+ </component>
+ <component name="MavenBuildProjectComponent">
+ <option name="mavenExecutable" value="" />
+ <option name="Settings File" value="" />
+ <option name="mavenCommandLineParams" value="" />
+ <option name="vmOptions" value="" />
+ <option name="useMavenEmbedder" value="false" />
+ <option name="useFilter" value="false" />
+ <option name="Batch Mode" value="false" />
+ <option name="Check Plugin Updates" value="false" />
+ <option name="Debug" value="false" />
+ <option name="Errors" value="false" />
+ <option name="Fail At End" value="false" />
+ <option name="Fail Fast" value="false" />
+ <option name="Fail Never" value="false" />
+ <option name="Lax Checksums" value="false" />
+ <option name="No Plugin Registry" value="false" />
+ <option name="No Plugin Updates" value="false" />
+ <option name="Non Recursive" value="false" />
+ <option name="Offline" value="false" />
+ <option name="Reactor" value="false" />
+ <option name="Strict Checksums" value="false" />
+ <option name="Update Plugins" value="false" />
+ <option name="Update Snapshots" value="false" />
+ <option name="Skip Tests" value="false" />
+ <pom-list />
+ </component>
+ <component name="Palette2">
+ <group name="Swing">
+ <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
+ </item>
+ <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
+ </item>
+ <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
+ <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
+ <initial-values>
+ <property name="text" value="Button" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="RadioButton" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="CheckBox" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
+ <initial-values>
+ <property name="text" value="Label" />
+ </initial-values>
+ </item>
+ <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
+ <preferred-size width="150" height="-1" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
+ <preferred-size width="150" height="50" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+ <preferred-size width="200" height="200" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
+ <preferred-size width="200" height="200" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
+ </item>
+ <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
+ </item>
+ <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
+ </item>
+ <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
+ <preferred-size width="-1" height="20" />
+ </default-constraints>
+ </item>
+ <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
+ </item>
+ <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
+ <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
+ </item>
+ </group>
+ </component>
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/common/common.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/common/common.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/mc/mc.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/mc/mc.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/portal/portal.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/portal/portal.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/testsuite/testsuite.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/testsuite/testsuite.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/thirdparty/thirdparty.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/thirdparty/thirdparty.iml" />
+ <module fileurl="file://$PROJECT_DIR$/build/ide/intellij/idea60/modules/tools/tools.iml" filepath="$PROJECT_DIR$/build/ide/intellij/idea60/modules/tools/tools.iml" />
+ </modules>
+ </component>
+ <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="false" project-jdk-name="1.5" project-jdk-type="JavaSDK">
+ <output url="file://$PROJECT_DIR$/output" />
+ </component>
+ <component name="ProjectRunConfigurationManager" />
+ <component name="RmicSettings">
+ <option name="IS_EANABLED" value="false" />
+ <option name="DEBUGGING_INFO" value="true" />
+ <option name="GENERATE_NO_WARNINGS" value="false" />
+ <option name="GENERATE_IIOP_STUBS" value="false" />
+ <option name="ADDITIONAL_OPTIONS_STRING" value="" />
+ </component>
+ <component name="StarteamVcsAdapter" />
+ <component name="VssVcs">
+ <SourceSafePersistencyRemovedFolder>$PROJECT_DIR$/wsrp/src/resources/test</SourceSafePersistencyRemovedFolder>
+ </component>
+ <component name="com.intellij.jsf.UserDefinedFacesConfigs">
+ <option name="USER_DEFINED_CONFIGS">
+ <value>
+ <list size="0" />
+ </value>
+ </option>
+ </component>
+ <component name="copyright">
+ <Base>
+ <setting name="state" value="1" />
+ </Base>
+ <LanguageOptions name="$TEMPLATE$">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="true" />
+ <option name="separateAfter" value="true" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="true" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="JBoss, a division of Red Hat Copyright &#36;today.year, Red Hat Middleware, LLC, and individual contributors as indicated by the @authors tag. See the copyright.txt 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 Fr!
anklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="4" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="CSS">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="HTML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JAVA">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JSP">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JavaScript">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="Properties">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="1" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="XML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ </component>
+ <component name="libraryTable" />
+ <component name="uidesigner-configuration">
+ <option name="INSTRUMENT_CLASSES" value="true" />
+ <option name="COPY_FORMS_RUNTIME_TO_OUTPUT" value="true" />
+ <option name="DEFAULT_LAYOUT_MANAGER" value="GridLayoutManager" />
+ </component>
+ <UsedPathMacros />
+</project>
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/common/common.iml
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/common/common.iml (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/common/common.iml 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,556 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+ <component name="FacetManager">
+ <facet type="web" name="Web">
+ <configuration>
+ <descriptors>
+ <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/../../../../../../common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/web.xml" optional="false" version="2.4" />
+ </descriptors>
+ <webroots>
+ <root url="file://$MODULE_DIR$/../../../../../../common/src/test/resources/implode/foo.sar/bar.war" relative="/" />
+ </webroots>
+ <building>
+ <setting name="EXPLODED_URL" value="file://" />
+ <setting name="EXPLODED_ENABLED" value="false" />
+ <setting name="JAR_URL" value="file://" />
+ <setting name="JAR_ENABLED" value="false" />
+ <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+ <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+ <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+ <setting name="RUN_JASPER_VALIDATION" value="true" />
+ <setting name="BUILD_ONLY_WEB_RESOURCES" value="false" />
+ </building>
+ <packaging>
+ <containerElement type="module" name="common">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/classes" />
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-launcher.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-launcher.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-nodeps.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-nodeps.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/bsf.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/bsf.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/buildmagic-tasks.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/buildmagic-tasks.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/cargo-core-uberjar-0.8.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/crimson.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/crimson.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/explode.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/explode.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jboss-test.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jboss-test.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jbossbuild.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jbossbuild.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/saxon.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/saxon.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xalan.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xercesImpl.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xercesImpl.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xml-apis.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xml-apis.jar!/</url>
+ </containerElement>
+ </packaging>
+ </configuration>
+ </facet>
+ <facet type="web" name="Web2">
+ <configuration>
+ <descriptors>
+ <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/../../../../../../common/target/test-classes/implode/foo.sar/bar.war/WEB-INF/web.xml" optional="false" version="2.4" />
+ </descriptors>
+ <webroots>
+ <root url="file://$MODULE_DIR$/../../../../../../common/target/test-classes/implode/foo.sar/bar.war" relative="/" />
+ </webroots>
+ <building>
+ <setting name="EXPLODED_URL" value="file://" />
+ <setting name="EXPLODED_ENABLED" value="false" />
+ <setting name="JAR_URL" value="file://" />
+ <setting name="JAR_ENABLED" value="false" />
+ <setting name="BUILD_MODULE_ON_FRAME_DEACTIVATION" value="false" />
+ <setting name="BUILD_EXTERNAL_DEPENDENCIES" value="false" />
+ <setting name="EXCLUDE_EXPLODED_DIRECTORY" value="true" />
+ <setting name="RUN_JASPER_VALIDATION" value="true" />
+ <setting name="BUILD_ONLY_WEB_RESOURCES" value="false" />
+ </building>
+ <packaging>
+ <containerElement type="module" name="common">
+ <attribute name="method" value="0" />
+ <attribute name="URI" value="/WEB-INF/classes" />
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-launcher.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-launcher.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant-nodeps.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant-nodeps.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/ant.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/ant.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/bsf.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/bsf.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/buildmagic-tasks.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/buildmagic-tasks.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/cargo-core-uberjar-0.8.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/crimson.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/crimson.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/explode.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/explode.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jboss-test.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jboss-test.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/jbossbuild.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/jbossbuild.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/junit.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/junit.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/saxon.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/saxon.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xalan.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xercesImpl.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xercesImpl.jar!/</url>
+ </containerElement>
+ <containerElement type="library" level="module">
+ <attribute name="method" value="1" />
+ <attribute name="URI" value="/WEB-INF/lib/xml-apis.jar" />
+ <url>jar://$MODULE_DIR$/../../../../../../tools/lib/xml-apis.jar!/</url>
+ </containerElement>
+ </packaging>
+ </configuration>
+ </facet>
+ </component>
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/../../../../../../common/output/idea50/classes" />
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../../../../../../common">
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/main/resources" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/test/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../common/src/test/resources" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../../../../../../common/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/junit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-launcher.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/jboss-test.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/jbossbuild.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/explode.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xml-apis.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xercesImpl.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-junit.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/xalan.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/cargo-core-uberjar-0.8.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/ant-nodeps.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/buildmagic-tasks.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/bsf.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/saxon.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/../../../../../../tools/lib/crimson.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntryProperties />
+ </component>
+ <component name="VcsManagerConfiguration">
+ <option name="ACTIVE_VCS_NAME" value="svn" />
+ <option name="USE_PROJECT_VCS" value="false" />
+ </component>
+ <component name="copyright">
+ <Base>
+ <setting name="state" value="1" />
+ </Base>
+ <LanguageOptions name="$TEMPLATE$">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="true" />
+ <option name="separateAfter" value="true" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="true" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="JBoss, a division of Red Hat Copyright &#36;today.year, Red Hat Middleware, LLC, and individual contributors as indicated by the @authors tag. See the copyright.txt 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 Fr!
anklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="4" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="CSS">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="HTML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JAVA">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JSP">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JavaScript">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="Properties">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="XML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ </component>
+</module>
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/mc/mc.iml
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/mc/mc.iml (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/mc/mc.iml 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../../../../../../mc">
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../mc/src/main/java" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../../../../../../mc/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntryProperties />
+ </component>
+</module>
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/portal/portal.iml
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/portal/portal.iml (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/modules/portal/portal.iml 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module version="4" relativePaths="true" type="JAVA_MODULE">
+ <component name="ModuleRootManager" />
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$/../../../../../../portal">
+ <sourceFolder url="file://$MODULE_DIR$/../../../../../../portal/src/main/java" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/../../../../../../portal/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntryProperties />
+ </component>
+ <component name="VcsManagerConfiguration">
+ <option name="ACTIVE_VCS_NAME" value="svn" />
+ <option name="USE_PROJECT_VCS" value="false" />
+ </component>
+</module>
+
Added: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/readme.txt
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/readme.txt (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/readme.txt 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,10 @@
+- Main project file and modules:
+Copy jboss-portal.ipr to the root of the Portal source directory. You might need to change the JDK to use but
+it should otherwise work out the box. Alternatively, you can create a new project file at the root of your Portal
+installation and import the module files (*.iml) found in the modules directory manually.
+
+- Codestyles and headers:
+The config directory contains standard settings for the JBoss Portal project regarding headers and code style. If
+you intend to commit code to JBoss Portal, you need to update your IDEA installation to use these files. Please
+refer to the IDEA manual on how to precisely do it, the short version being that you can replace the files found
+in your IDEA preference directory by the ones found in the config directory.
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/build/ide/intellij/idea60/readme.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/.classpath
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/.classpath (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/.classpath 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="/thirdparty/apache-ant/lib/ant.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/oswego-concurrent/lib/concurrent.jar"/>
+ <classpathentry kind="lib" path="/tools/lib/xalan.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/sun-jaf/lib/activation.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-common.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-j2ee.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/apache-log4j/lib/log4j.jar"/>
+ <classpathentry kind="lib" path="/tools/lib/cargo-core-uberjar-0.8.jar"/>
+ <classpathentry kind="lib" path="/tools/lib/ant-junit.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/apache-httpclient/lib/commons-httpclient.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/backport-concurrent/lib/jboss-backport-concurrent.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/sun-servlet/lib/servlet-api.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/.classpath
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/.cvsignore
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/.cvsignore (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/.cvsignore 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,2 @@
+output
+bin
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/.cvsignore
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/.project
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/.project (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/.project 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>common</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/.project
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/pom.xml
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/pom.xml (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/pom.xml 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,211 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.1.1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-common</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+
+ <dependency>
+ <groupId>oswego-concurrent</groupId>
+ <artifactId>concurrent</artifactId>
+ <version>1.3.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-j2ee</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>2.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-jmx</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-system</artifactId>
+ <version>4.2.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-backport-concurrent</artifactId>
+ <version>2.1.0.GA</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-core-uberjar</artifactId>
+ <version>0.8</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-nodeps</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-launcher</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>false</filtering>
+ <directory>src/main/resources/format/code</directory>
+ <includes>
+ <include>*.tpl</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <encoding>iso-8859-1</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- To use in conjonctin with
+ export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
+ -->
+<!--
+ <forkMode>never</forkMode>
+ <argLine>-enableassertions</argLine>
+-->
+ <excludes>
+ <exclude>org/jboss/portal/test/common/BundleNameParserTestCase*.java</exclude>
+ <exclude>org/jboss/portal/test/common/net/URLNavigatorTestCase.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ <testSourceDirectory>src/test/java</testSourceDirectory>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>false</filtering>
+ </testResource>
+ </testResources>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-changes-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <linkXref>true</linkXref>
+ <targetJdk>1.5</targetJdk>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <properties/>
+</project>
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/etc/portal-common-lib-jar.mf
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/etc/portal-common-lib-jar.mf (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/etc/portal-common-lib-jar.mf 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/etc/portal-common-lib-jar.mf
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/FixMe.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/FixMe.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/FixMe.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class FixMe extends UnsupportedOperationException
+{
+ public FixMe()
+ {
+ super("Fix me");
+ }
+
+ public FixMe(String featureName)
+ {
+ super("Feature: " + featureName + " needs to be fixed");
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/NotYetImplemented.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/NotYetImplemented.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/NotYetImplemented.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common;
+
+/**
+ * Thrown when a code join point is not implemented.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7331 $
+ */
+public class NotYetImplemented extends UnsupportedOperationException
+{
+ public NotYetImplemented()
+ {
+ super("Not yet implemented");
+ }
+
+ /**
+ * Constructor that takes a feature name for formatting the message.
+ *
+ * @param featureName the feature name that is not implemented
+ */
+ public NotYetImplemented(String featureName)
+ {
+ super("Feature: " + featureName + " is not yet implemented");
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcher.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcher.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcher.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class AdaptedMethodDispatcher implements MethodDispatcher
+{
+
+ /** . */
+ private final Method method;
+
+ /** . */
+ private final Object target;
+
+ public AdaptedMethodDispatcher(Method method, Object target)
+ {
+ this.method = method;
+ this.target = target;
+ }
+
+ public Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable
+ {
+ return method.invoke(target, args);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcherFactory.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcherFactory.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/AdaptedMethodDispatcherFactory.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class AdaptedMethodDispatcherFactory implements MethodDispatcherFactory
+{
+
+ /** . */
+ private final Object target;
+
+ public AdaptedMethodDispatcherFactory(Object target)
+ {
+ this.target = target;
+ }
+
+ public MethodDispatcher createDispatcher(Method method)
+ {
+ return new AdaptedMethodDispatcher(method, target);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdaptable.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdaptable.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdaptable.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * Denotes an object that is class adaptable.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface ClassAdaptable
+{
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapted.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapted.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapted.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * A class adapted.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ClassAdapted
+{
+
+ /** . */
+ final Class itf;
+
+ /** . */
+ final Object object;
+
+ public ClassAdapted(Class itf, Object object)
+ {
+ if (itf == null)
+ {
+ throw new IllegalArgumentException("No null adapted interface accepted");
+ }
+ if (!itf.isInterface())
+ {
+ throw new IllegalArgumentException("Adapted interface is not an interface");
+ }
+ if (object == null)
+ {
+ throw new IllegalArgumentException("No null adapted object accepted");
+ }
+
+ //
+ this.itf = itf;
+ this.object = object;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapter.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapter.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/ClassAdapter.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Creates a new class adapter.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ClassAdapter
+{
+
+ /** . */
+ private final Map dispatchers;
+
+ /** . */
+ private final Constructor ctor;
+
+ /** . */
+ private final InvocationHandler handler = new InvocationHandler()
+ {
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ MethodDispatcher dispatcher = (MethodDispatcher)dispatchers.get(method);
+
+ //
+ ClassAdaptable adaptable = (ClassAdaptable)proxy;
+
+ //
+ return dispatcher.dispatch(adaptable, args);
+ }
+ };
+
+ /**
+ * Creates a new class adapter. The object adapted implementation used will be an instance of
+ * <code>JavaLangObjectAdapted</code>.
+ *
+ * @param loader the class loader that will contain the dynamic proxy generated class
+ * @param adapteds the array of class adapteds
+ * @throws NoSuchMethodException
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public ClassAdapter(ClassLoader loader, ClassAdapted[] adapteds) throws NoSuchMethodException, IllegalArgumentException
+ {
+ this(loader, adapteds, new DefaultJavaLangObjectAdapted());
+ }
+
+ /**
+ * Create a new class adapter.
+ *
+ * @param loader the class loader that will contain the dynamic proxy generated class
+ * @param adapteds the array of class adapteds
+ * @param objectAdapted the implementation of object adapted
+ * @throws NoSuchMethodException
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public ClassAdapter(ClassLoader loader, ClassAdapted[] adapteds, JavaLangObjectAdapted objectAdapted) throws NoSuchMethodException, IllegalArgumentException
+ {
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("No null class loader accepted");
+ }
+ if (adapteds == null)
+ {
+ throw new IllegalArgumentException("No null adapteds accepted");
+ }
+ if (objectAdapted == null)
+ {
+ throw new IllegalArgumentException("No null object adapted accepted");
+ }
+
+ //
+ dispatchers = new HashMap();
+
+ //
+ addAdapted(Object.class, new JavaLangObjectMethodDispatcherFactory(objectAdapted));
+
+ //
+ Class[] itfs = new Class[adapteds.length + 1];
+ itfs[0] = ClassAdaptable.class;
+
+ //
+ for (int i = 0; i < adapteds.length; i++)
+ {
+ ClassAdapted adapted = adapteds[i];
+
+ //
+ if (adapted == null)
+ {
+ throw new IllegalArgumentException("No null adapted accepted");
+ }
+
+ //
+ itfs[1 + i] = adapted.itf;
+
+ //
+ addAdapted(adapted.itf, new AdaptedMethodDispatcherFactory(adapted.object));
+ }
+
+ //
+ ctor = Proxy.getProxyClass(loader, itfs).getConstructor(new Class[]{InvocationHandler.class});
+ }
+
+ private void addAdapted(Class adaptedClass, MethodDispatcherFactory methodDispatcherFactory)
+ {
+ Method[] methods = adaptedClass.getMethods();
+ for (int j = 0; j < methods.length; j++)
+ {
+ Method method = methods[j];
+ int modifiers = method.getModifiers();
+ if (Modifier.isPublic(modifiers) && !Modifier.isFinal(modifiers) && !Modifier.isStatic(modifiers))
+ {
+ if (!dispatchers.containsKey(method))
+ {
+ dispatchers.put(method, methodDispatcherFactory.createDispatcher(method));
+ }
+ }
+ }
+ }
+
+ /** Returns an instance of the the adaptable object. */
+ public ClassAdaptable getAdaptable() throws IllegalAccessException, InstantiationException, InvocationTargetException
+ {
+ return (ClassAdaptable)ctor.newInstance(new Object[]{handler});
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/DefaultJavaLangObjectAdapted.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/DefaultJavaLangObjectAdapted.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/DefaultJavaLangObjectAdapted.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class DefaultJavaLangObjectAdapted implements JavaLangObjectAdapted
+{
+
+ public String toString(ClassAdaptable adaptable)
+ {
+ return "Adapter[class=" + adaptable.getClass().getName() + ",hashCode=" + System.identityHashCode(adaptable) + "]";
+ }
+
+ public int hashCode(ClassAdaptable adaptable)
+ {
+ return System.identityHashCode(adaptable);
+ }
+
+ public boolean equals(ClassAdaptable adaptable, Object obj)
+ {
+ return adaptable == obj;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectAdapted.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectAdapted.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectAdapted.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * Defines contract for the <code>java.lang.Object</code> adapted.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface JavaLangObjectAdapted
+{
+ /**
+ * Implementation of <code>toString()</code>.
+ *
+ * @param adaptable the adaptable object
+ * @return the string value
+ */
+ String toString(ClassAdaptable adaptable);
+
+ /**
+ * Implementation of <code>hashCode</code>.
+ *
+ * @param adaptable the adaptable object
+ * @return the hash code value
+ */
+ int hashCode(ClassAdaptable adaptable);
+
+ /**
+ * Implementation of <code>equals</code>.
+ *
+ * @param adaptable the adaptable object
+ * @param obj the object to test equality with
+ * @return true the equals value
+ */
+ boolean equals(ClassAdaptable adaptable, Object obj);
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcher.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcher.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcher.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * Implementation of the <code>MethodDispatcher</code> interface for the methods of <code>java.lang.Object</code> which
+ * are delegated by a dynamic proxy to the <code>InvocationHandler</code>.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+abstract class JavaLangObjectMethodDispatcher implements MethodDispatcher
+{
+
+ /** . */
+ protected final JavaLangObjectAdapted target;
+
+ public JavaLangObjectMethodDispatcher(JavaLangObjectAdapted target)
+ {
+ this.target = target;
+ }
+
+ static class ToString extends JavaLangObjectMethodDispatcher
+ {
+
+ public ToString(JavaLangObjectAdapted target)
+ {
+ super(target);
+ }
+
+ public Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable
+ {
+ return target.toString(adaptable);
+ }
+ }
+
+ static class Equals extends JavaLangObjectMethodDispatcher
+ {
+
+ public Equals(JavaLangObjectAdapted target)
+ {
+ super(target);
+ }
+
+ public Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable
+ {
+ return Boolean.valueOf(target.equals(adaptable, args[0]));
+ }
+ }
+
+ static class HashCode extends JavaLangObjectMethodDispatcher
+ {
+
+ public HashCode(JavaLangObjectAdapted target)
+ {
+ super(target);
+ }
+
+ public Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable
+ {
+ return new Integer(target.hashCode(adaptable));
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcherFactory.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcherFactory.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/JavaLangObjectMethodDispatcherFactory.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class JavaLangObjectMethodDispatcherFactory implements MethodDispatcherFactory
+{
+
+ /** . */
+ private final JavaLangObjectAdapted target;
+
+ public JavaLangObjectMethodDispatcherFactory(JavaLangObjectAdapted target)
+ {
+ this.target = target;
+ }
+
+ public MethodDispatcher createDispatcher(Method method)
+ {
+ if ("toString".equals(method.getName()))
+ {
+ return new JavaLangObjectMethodDispatcher.ToString(target);
+ }
+ else if ("equals".equals(method.getName()))
+ {
+ return new JavaLangObjectMethodDispatcher.Equals(target);
+ }
+ else if ("hashCode".equals(method.getName()))
+ {
+ return new JavaLangObjectMethodDispatcher.HashCode(target);
+ }
+ else
+ {
+ throw new AssertionError("Should not be possible");
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcher.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcher.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcher.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+interface MethodDispatcher
+{
+ Object dispatch(ClassAdaptable adaptable, Object[] args) throws Throwable;
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcherFactory.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcherFactory.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/adapter/MethodDispatcherFactory.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.adapter;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+interface MethodDispatcherFactory
+{
+ MethodDispatcher createDispatcher(Method method);
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.codehaus.cargo.container.ContainerType;
+import org.codehaus.cargo.container.RemoteContainer;
+import org.codehaus.cargo.container.configuration.Configuration;
+import org.codehaus.cargo.container.configuration.ConfigurationType;
+import org.codehaus.cargo.container.jboss.JBossJMXDeployer;
+import org.codehaus.cargo.container.property.GeneralPropertySet;
+import org.codehaus.cargo.container.property.ServletPropertySet;
+import org.codehaus.cargo.generic.ContainerFactory;
+import org.codehaus.cargo.generic.DefaultContainerFactory;
+import org.codehaus.cargo.generic.configuration.ConfigurationFactory;
+import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory;
+
+import java.io.File;
+
+/**
+ * A deployment task.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public abstract class AbstractDeploymentTask extends Task
+{
+
+ /** The file. */
+ private File file;
+
+ /** The JBoss config. */
+ private String config;
+
+ public AbstractDeploymentTask()
+ {
+ file = null;
+ config = "default";
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+
+ public void setFile(File file)
+ {
+ this.file = file;
+ }
+
+ public String getConfig()
+ {
+ return config;
+ }
+
+ public void setConfig(String config)
+ {
+ this.config = config;
+ }
+
+ public void execute() throws BuildException
+ {
+ //
+ ConfigurationFactory cfgFactory = new DefaultConfigurationFactory();
+ Configuration cfg = cfgFactory.createConfiguration("jboss4x", ConfigurationType.RUNTIME);
+
+ // Configure the container
+ if ("default".equals(config))
+ {
+ cfg.setProperty(GeneralPropertySet.PROTOCOL, "http");
+ cfg.setProperty(GeneralPropertySet.HOSTNAME, "localhost");
+ cfg.setProperty(ServletPropertySet.PORT, "8080");
+ }
+ else
+ {
+ throw new BuildException("Unknown configuration " + config);
+ }
+
+ //
+ if (file == null)
+ {
+ throw new BuildException("No specified file to deploy");
+ }
+
+ //
+ ContainerFactory containerFactory = new DefaultContainerFactory();
+ RemoteContainer container = (RemoteContainer)containerFactory.createContainer("jboss4x", ContainerType.REMOTE, cfg);
+
+ //
+ JBossJMXDeployer deployer = new JBossJMXDeployer(container);
+ execute(deployer);
+ }
+
+ protected abstract void execute(JBossJMXDeployer deployer);
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/AbstractDeploymentTask.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class CannotCreateDirException extends DirException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 4911314548182164515L;
+
+ public CannotCreateDirException(File file)
+ {
+ super(file, "Cannot create directory " + file.getName());
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/CannotCreateDirException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.codehaus.cargo.container.deployable.Deployable;
+import org.codehaus.cargo.container.deployable.EAR;
+import org.codehaus.cargo.container.jboss.JBossJMXDeployer;
+
+/**
+ * A blocking deploy task.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Deploy extends AbstractDeploymentTask
+{
+
+ public Deploy()
+ {
+ }
+
+ protected void execute(JBossJMXDeployer deployer)
+ {
+ //
+ Deployable deployable = new EAR(getFile().getAbsolutePath());
+
+ //
+ deployer.deploy(deployable);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Deploy.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class DirException extends Exception
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7944765663293180164L;
+ private File file;
+
+ public DirException(File file, String msg)
+ {
+ super(msg);
+ this.file = file;
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/DirException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,274 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipException;
+import java.util.zip.ZipInputStream;
+
+/**
+ * Ant task that explode an archive.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Explode extends Task
+{
+
+ /** Unzipped extensions. */
+ private static final Set extensions = new HashSet(Arrays.asList(new String[]{"ear", "war", "sar", "har"}));
+
+ /** The exploded file. */
+ private File file;
+
+ /** The target directory. */
+ private File todir;
+
+ /** The target optional name. */
+ private String name;
+
+ /** filename to exclude from decompression * */
+ private String exclude;
+
+ public void setExclude(String exclude)
+ {
+ this.exclude = exclude;
+ }
+
+ public void setFile(File file)
+ {
+ this.file = file;
+ }
+
+ public void setTodir(File todir)
+ {
+ this.todir = todir;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public void execute() throws BuildException
+ {
+ try
+ {
+ explode(file, todir);
+ }
+ catch (DirException e)
+ {
+ throw new BuildException(e.getMessage());
+ }
+ }
+
+ public void explode(File file, File todir) throws BuildException, DirException
+ {
+ if (!file.exists())
+ {
+ throw new BuildException("source file does not exists");
+ }
+ if (!file.isFile())
+ {
+ throw new BuildException("source file is not file");
+ }
+ if (name == null)
+ {
+ name = file.getName();
+ }
+ ZipInputStream zip = null;
+ try
+ {
+ zip = new ZipInputStream(new BufferedInputStream(new FileInputStream(file)));
+ log("Process archive " + name);
+ explode(this, name, zip, todir, this.exclude);
+ }
+ catch (FileNotFoundException e)
+ {
+ throw new BuildException("Unexpected error " + e.getMessage());
+ }
+ finally
+ {
+ if (zip != null)
+ {
+ try
+ {
+ zip.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+ }
+ }
+
+ /**
+ * Explode a zip stream into a directory.
+ *
+ * @param explode used to log
+ * @param name the name of the created directory
+ * @param zip the zip stream will not be closed
+ * @param todir the parent directory
+ * @throws BuildException
+ * @throws DirException
+ */
+ public static void explode(Explode explode, String name, ZipInputStream zip, File todir, String exclude) throws BuildException, DirException
+ {
+ // First ensure the target directory exists
+ if (!todir.exists())
+ {
+ throw new BuildException("target dir does not exists");
+ }
+ if (!todir.isDirectory())
+ {
+ throw new BuildException("target dir is not a directory");
+ }
+ try
+ {
+ // Buffer
+ byte[] buffer = new byte[512];
+
+ // The real target dir
+ todir = new File(todir, name);
+
+ // Get the directory
+ ensureDirExist(explode, todir);
+
+ // Process each file
+ for (ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry())
+ {
+ // Next entry
+ File fic = new File(todir, entry.getName());
+ int lastDot = fic.getName().lastIndexOf(".");
+
+ if (entry.isDirectory())
+ {
+ // This is a directory that we must create
+ try
+ {
+ ensureDirExist(explode, fic);
+ }
+ catch (DirException e)
+ {
+ explode.log(e.getMessage());
+ }
+ }
+ else if (lastDot != -1 && extensions.contains(fic.getName().substring(lastDot + 1)))
+ {
+ // This is a nested archive, we explode it
+ try
+ {
+ explode.log("Process nested archive " + fic.getName());
+ if (!fic.getName().equalsIgnoreCase(exclude))
+ {
+ explode(explode, fic.getName(), new ZipInputStream(zip), todir, exclude);
+ }
+ }
+ catch (DirException e)
+ {
+ explode.log(e.getMessage());
+ }
+ }
+ else
+ {
+ // This is a file we write it
+ OutputStream out = null;
+ try
+ {
+ out = new BufferedOutputStream(new FileOutputStream(fic));
+ for (int size = zip.read(buffer); size != -1; size = zip.read(buffer))
+ {
+ out.write(buffer, 0, size);
+ }
+ }
+ catch (IOException e)
+ {
+ explode.log("Problem when writing file " + e.getMessage());
+ }
+ finally
+ {
+ if (out != null)
+ {
+ try
+ {
+ out.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (ZipException e)
+ {
+ throw new BuildException(e);
+ }
+ catch (IOException e)
+ {
+ throw new BuildException(e);
+ }
+ }
+
+ /** When it returns the dir exists otherwise it throws a BuildException */
+ private static void ensureDirExist(Explode explode, File dir) throws FileIsNotDirException, CannotCreateDirException
+ {
+ if (dir.exists())
+ {
+ if (dir.isDirectory())
+ {
+ // explode.log(dir.getName() + " exists and is used");
+ }
+ else
+ {
+ throw new FileIsNotDirException(dir);
+ }
+ }
+ else
+ {
+ if (dir.mkdirs())
+ {
+ // explode.log("Created directory " + dir.getName());
+ }
+ else
+ {
+ throw new CannotCreateDirException(dir);
+ }
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Explode.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,40 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class FileIsNotDirException extends DirException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7596495857634457803L;
+
+ public FileIsNotDirException(File file)
+ {
+ super(file, file.getName() + " exists and is not a directory");
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/FileIsNotDirException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,207 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Implode extends Task
+{
+
+ /** Unzipped extensions. */
+ private static final Set extensions = new HashSet(Arrays.asList(new String[]{"ear", "war", "sar", "har"}));
+
+ /** The exploded dir. */
+ private File dir;
+
+ /** The target file. */
+ private File tofile;
+
+ public void setDir(File dir)
+ {
+ this.dir = dir;
+ }
+
+ public void setTofile(File tofile)
+ {
+ this.tofile = tofile;
+ }
+
+ public void execute() throws BuildException
+ {
+ if (tofile == null)
+ {
+ throw new BuildException("target file should not be null");
+ }
+ if (dir == null)
+ {
+ throw new BuildException("source dir should not be null");
+ }
+ if (!dir.exists())
+ {
+ throw new BuildException("source dir does not exist");
+ }
+ if (dir.isFile())
+ {
+ throw new BuildException("source dir is a file");
+ }
+ if (tofile.exists() && tofile.isDirectory())
+ {
+ throw new BuildException("target file " + tofile + " designates a directory");
+ }
+ //if (tofile == null || tofile.lastModified() < dir.lastModified())
+
+
+ OutputStream out = null;
+ try
+ {
+ byte[] bytes = implode(dir);
+ out = new BufferedOutputStream(new FileOutputStream(tofile));
+ out.write(bytes);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ throw new BuildException(e.getMessage());
+ }
+ finally
+ {
+ if (out != null)
+ {
+ try
+ {
+ out.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+
+ }
+
+ public byte[] implode(File f) throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ JarOutputStream out = new JarOutputStream(baos);
+ implode(f, "", out);
+ out.close();
+ return baos.toByteArray();
+ }
+
+ public void implode(File f, String path, JarOutputStream out) throws IOException
+ {
+ if (f.isFile())
+ {
+ InputStream in = null;
+ try
+ {
+ in = new BufferedInputStream(new FileInputStream(f));
+ byte[] bytes = new byte[1024];
+
+ //
+ String fileName = path.substring(1);
+ JarEntry fileEntry = new JarEntry(fileName);
+ out.putNextEntry(fileEntry);
+
+ //
+ for (int l = in.read(bytes, 0, bytes.length); l > -0; l = in.read(bytes, 0, bytes.length))
+ {
+ out.write(bytes, 0, l);
+ }
+
+ //
+ out.closeEntry();
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+ }
+ else
+ {
+ if (path.length() > 1)
+ {
+ String dirName = path.substring(1) + '/';
+ JarEntry dirEntry = new JarEntry(dirName);
+ out.putNextEntry(dirEntry);
+ out.closeEntry();
+ }
+
+ //
+ File[] children = f.listFiles();
+ for (int i = 0; i < children.length; i++)
+ {
+ File child = children[i];
+ int lastDot = child.getName().lastIndexOf(".");
+ if (extensions.contains(child.getName().substring(lastDot + 1)))
+ {
+ byte[] bytes = implode(child);
+
+ //
+ String fileName = (path + '/' + child.getName()).substring(1);
+ JarEntry fileEntry = new JarEntry(fileName);
+ out.putNextEntry(fileEntry);
+
+ //
+ out.write(bytes, 0, bytes.length);
+
+ //
+ out.closeEntry();
+ }
+ else
+ {
+ implode(child, path + '/' + child.getName(), out);
+ }
+ }
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Implode.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.ant;
+
+import org.codehaus.cargo.container.deployable.Deployable;
+import org.codehaus.cargo.container.deployable.EAR;
+import org.codehaus.cargo.container.jboss.JBossJMXDeployer;
+
+/**
+ * A blocking undeploy task.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Undeploy extends AbstractDeploymentTask
+{
+
+ protected void execute(JBossJMXDeployer deployer)
+ {
+ //
+ Deployable deployable = new EAR(getFile().getAbsolutePath());
+
+ //
+ deployer.undeploy(deployable);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/ant/Undeploy.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,273 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.concurrent;
+
+/**
+ * Start in closed mode and adds an open() method to keep the same valve.
+ *
+ * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class Valve
+{
+
+ // Constants -----------------------------------------------------
+
+ /**
+ * The valve is open.
+ */
+ public static final int OPEN = 0;
+
+ /**
+ * The valve is in holding state.
+ */
+ public static final int CLOSING = 1;
+
+ /**
+ * The valve is in hold state.
+ */
+ public static final int CLOSED = 2;
+
+ /**
+ * User friendly names.
+ */
+ private static final String[] STATE_NAMES = {"OPEN","CLOSING","CLOSED"};
+
+ // Attributes ----------------------------------------------------
+
+ /**
+ * The state lock.
+ */
+ protected final Object stateLock = new Object();
+
+ /**
+ * The state.
+ */
+ protected int state;
+
+ /**
+ * The invocation count.
+ */
+ protected int invocations = 0;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Create a valve in the closed state
+ */
+ public Valve()
+ {
+ this(CLOSED);
+ }
+
+ /**
+ * Create a valve with the give initial state
+ *
+ * @param state the initial state
+ */
+ protected Valve(int state)
+ {
+ this.state = state;
+ }
+
+ // Public --------------------------------------------------------
+
+ /**
+ * Are we closed?
+ *
+ * @return true when closing or closed, false otherwise
+ */
+ public boolean isClosed()
+ {
+ synchronized (stateLock)
+ {
+ return state != OPEN;
+ }
+ }
+
+ /**
+ * Invoked before an invocation
+ *
+ * @return true if allowed entry, false otherwise
+ */
+ public boolean beforeInvocation()
+ {
+ synchronized (stateLock)
+ {
+ if (state != OPEN)
+ {
+ return false;
+ }
+ ++invocations;
+ }
+ return true;
+ }
+
+ /**
+ * Invoked after an invocation
+ */
+ public void afterInvocation()
+ {
+ synchronized (stateLock)
+ {
+ --invocations;
+ stateLock.notifyAll();
+ }
+ }
+
+ /**
+ * Return the state.
+ */
+ public int getState()
+ {
+ return state;
+ }
+
+ /**
+ * How many invocations are held in the valve.
+ */
+ public int getInvocations()
+ {
+ return invocations;
+ }
+
+ /**
+ * Open the valve.
+ *
+ * @throws IllegalStateException if the valve is not closed
+ */
+ public void open() throws IllegalStateException
+ {
+ synchronized (stateLock)
+ {
+ if (state != CLOSED)
+ {
+ throw new IllegalStateException("Cannot invoke open() valve in state " + STATE_NAMES[state]);
+ }
+ state = OPEN;
+ }
+ }
+
+ /**
+ * Invoked before closing.
+ *
+ * @throws IllegalStateException if the valve is closed
+ */
+ public void closing() throws IllegalStateException
+ {
+ closing(0);
+ }
+
+ /**
+ * Invoked before closing.
+ *
+ * @throws IllegalStateException if the valve is closed
+ */
+ public boolean closing(long millis) throws IllegalStateException
+ {
+ boolean interrupted = false;
+ boolean empty = false;
+ synchronized (stateLock)
+ {
+ if (state == CLOSED)
+ {
+ throw new IllegalStateException("Cannot invoke closing() valve in state " + STATE_NAMES[state]);
+ }
+
+ //
+ state = CLOSING;
+
+ //
+ long finished = -1;
+ if (millis > 0)
+ {
+ finished = System.currentTimeMillis() + millis;
+ }
+
+ while (invocations > 0)
+ {
+ try
+ {
+ if (finished == -1)
+ {
+ stateLock.wait();
+ }
+ else
+ {
+ long time = finished - System.currentTimeMillis();
+ if (time > 0)
+ {
+ stateLock.wait(time);
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ catch (InterruptedException e)
+ {
+ interrupted = true;
+ }
+ }
+
+ empty = invocations == 0;
+ }
+
+ if (interrupted)
+ {
+ Thread.currentThread().interrupt();
+ }
+
+ return empty;
+ }
+
+ /**
+ * Invoked after closing.
+ *
+ * @throws IllegalStateException if the valve is not closing
+ */
+ public void closed() throws IllegalStateException
+ {
+ synchronized (stateLock)
+ {
+ if (state != CLOSING)
+ {
+ throw new IllegalStateException("Cannot invoke close() valve in state " + STATE_NAMES[state]);
+ }
+ state = CLOSED;
+ }
+ }
+
+ // Protected -----------------------------------------------------
+
+ // Package Private -----------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/concurrent/Valve.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeader.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeader.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeader.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,243 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Modelize an http header structure.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class HttpHeader implements Serializable
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private List elements = new ArrayList();
+
+ public HttpHeader(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Element addElement(String name)
+ {
+ return addElement(new Element(name));
+ }
+
+ public Element addElement(String name, String value)
+ {
+ return addElement(new Element(name, value));
+ }
+
+ public Element addElement(Element element)
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ elements.add(element);
+ return element;
+ }
+
+ public Element getElement()
+ {
+ if (elements.size() > 0)
+ {
+ return (Element)elements.get(0);
+ }
+ return null;
+ }
+
+ public Iterator elements()
+ {
+ return elements.iterator();
+ }
+
+ /** An element of an header */
+ public static class Element implements Serializable
+ {
+ /** The mandatory name. */
+ private String name;
+
+ /** The optional value. */
+ private String value;
+
+ /** The params. */
+ private List params;
+
+ public Element(String name)
+ {
+ this(name, null);
+ }
+
+ public Element(String name, String value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.name = name;
+ this.value = value;
+ this.params = new ArrayList();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public Param addParam(String name)
+ {
+ return addParam(new Param(name));
+ }
+
+ public Param addParam(String name, String value)
+ {
+ return addParam(new Param(name, value));
+ }
+
+ public Param addParam(Param param)
+ {
+ if (param == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ params.add(param);
+ return param;
+ }
+
+ /**
+ * Return the first param of this element or null.
+ *
+ * @return the first param
+ */
+ public Param getParam()
+ {
+ if (params.size() > 0)
+ {
+ return (Param)params.get(0);
+ }
+ return null;
+ }
+
+ /**
+ * Returns an iterator over the params.
+ *
+ * @return a param iterator
+ */
+ public Iterator params()
+ {
+ return params.iterator();
+ }
+
+ /** A param of an element. */
+ public static class Param implements Serializable
+ {
+ /** The mandatory name. */
+ private String name;
+
+ /** The optional value. */
+ private String value;
+
+ public Param(String name)
+ {
+ this(name, null);
+ }
+
+ public Param(String name, String value)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+ }
+ }
+
+ public String getValue()
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator j = elements(); j.hasNext();)
+ {
+ HttpHeader.Element elt = (HttpHeader.Element)j.next();
+ buffer.append(elt.getName());
+ if (elt.getValue() != null)
+ {
+ buffer.append("=").append(elt.getValue());
+ }
+ for (Iterator k = elt.params(); k.hasNext();)
+ {
+ HttpHeader.Element.Param param = (HttpHeader.Element.Param)k.next();
+ buffer.append(";").append(param.getName());
+ if (param.getValue() != null)
+ {
+ buffer.append("=").append(param.getValue());
+ }
+ }
+ if (j.hasNext())
+ {
+ buffer.append(",");
+ }
+ }
+ return buffer.toString();
+ }
+
+ public String toString()
+ {
+ return name + ": " + getValue();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeaders.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeaders.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpHeaders.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class HttpHeaders implements Serializable
+{
+
+ /** . */
+ private List headers = new ArrayList();
+
+ public HttpHeader addHeader(String name)
+ {
+ return addHeader(new HttpHeader(name));
+ }
+
+ public HttpHeader addHeader(HttpHeader header)
+ {
+ if (header == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ headers.add(header);
+ return header;
+ }
+
+ public HttpHeader getHeader(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ for (Iterator i = headers.iterator(); i.hasNext();)
+ {
+ HttpHeader header = (HttpHeader)i.next();
+ if (header.getName().equals(name))
+ {
+ return header;
+ }
+ }
+ return null;
+ }
+
+ public Iterator headers()
+ {
+ return headers.iterator();
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator i = headers.iterator(); i.hasNext();)
+ {
+ HttpHeader header = (HttpHeader)i.next();
+ buffer.append(header.toString());
+ buffer.append("\n");
+ }
+ return buffer.toString();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpRequest.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpRequest.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpRequest.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,112 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Just used to define the request body.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class HttpRequest implements Serializable
+{
+
+ public abstract static class Body implements Serializable
+ {
+ }
+
+ public static class Raw extends Body
+ {
+
+ /** . */
+ private byte[] bytes;
+
+ public byte[] getBytes()
+ {
+ return bytes;
+ }
+
+ public void setBytes(byte[] bytes)
+ {
+ this.bytes = bytes;
+ }
+ }
+
+ public static class Form extends Body
+ {
+
+ /** . */
+ private Map parameters = new HashMap();
+
+ public void addParameter(String name, String[] values)
+ {
+ if (name == null)
+ {
+ throw new IllegalStateException();
+ }
+ if (values == null)
+ {
+ throw new IllegalStateException();
+ }
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (value == null)
+ {
+ throw new IllegalStateException();
+ }
+ }
+ parameters.put(name, values.clone());
+ }
+
+ public void removeParameter(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalStateException();
+ }
+ parameters.remove(name);
+ }
+
+ public Set getParameterNames()
+ {
+ return Collections.unmodifiableSet(parameters.keySet());
+ }
+
+ public String[] getParameterValues(String name)
+ {
+ if (name == null)
+ {
+ throw new IllegalStateException();
+ }
+ String[] values = (String[])parameters.get(name);
+ return (String[])values.clone();
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpResponse.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpResponse.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/HttpResponse.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class HttpResponse implements Serializable
+{
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/QueryStringParser.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/QueryStringParser.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/http/QueryStringParser.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,268 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.http;
+
+import org.jboss.portal.common.net.URLTools;
+import org.jboss.portal.common.text.CharEncoder;
+import org.jboss.portal.common.text.FastURLDecoder;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.EncodingException;
+import org.jboss.portal.common.util.ParameterMap;
+import org.apache.log4j.Logger;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * A parser for query string for the HTTP protocol. This class is thread safe.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7379 $
+ */
+public class QueryStringParser
+{
+
+ /** . */
+ private static QueryStringParser DEFAULT_PARSER = new QueryStringParser();
+
+ public static QueryStringParser getInstance()
+ {
+ return DEFAULT_PARSER;
+ }
+
+ /** . */
+ private static final Logger log = Logger.getLogger(QueryStringParser.class);
+
+ /** . */
+ private static final int LOOKUP = 0;
+
+ /** . */
+ private static final int INVALID_CHUNK = 1;
+
+ /** . */
+ private static final int PARAM_NAME = 2;
+
+ /** . */
+ private static final int PARAM_VALUE = 3;
+
+ /** . */
+ private CharEncoder parameterDecoder;
+
+ /**
+ * Create a new parser with the specified parameter decoder.
+ *
+ * @param parameterDecoder the parameter decoder
+ * @throws IllegalArgumentException if the decoder is null
+ */
+ public QueryStringParser(CharEncoder parameterDecoder) throws IllegalArgumentException
+ {
+ if (parameterDecoder == null)
+ {
+ throw new IllegalArgumentException("No parameter decoder");
+ }
+ this.parameterDecoder = parameterDecoder;
+ }
+
+ /**
+ * Creates a new parser with a decoder that will decode x-www-formurlencoded parameters with the
+ * UTF-8 charset.
+ */
+ public QueryStringParser()
+ {
+ this(FastURLDecoder.getUTF8Instance());
+ }
+
+ public CharEncoder getParameterDecoder()
+ {
+ return parameterDecoder;
+ }
+
+ private void append(ParameterMap parameterMap, String parameterName, String parameterValue)
+ {
+ String[] values = parameterMap.getValues(parameterName);
+
+ //
+ if (values == null)
+ {
+ values = new String[]{parameterValue};
+ }
+ else
+ {
+ String[] tmp = new String[values.length + 1];
+ System.arraycopy(values, 0, tmp, 0, values.length);
+ values = tmp;
+ values[values.length - 1] = parameterValue;
+ }
+
+ //
+ parameterMap.setValues(parameterName, values);
+ }
+
+ /**
+ * Parse the query string and build an unmodifiable parameter map of it.
+ *
+ * @param queryString the non null query string
+ * @return a <String,String[]> map
+ * @throws IllegalArgumentException if the query string is null
+ */
+ public ParameterMap parseQueryString(String queryString) throws IllegalArgumentException
+ {
+ if (queryString == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ // Map result = Collections.EMPTY_MAP;
+
+ ParameterMap parameterMap = new ParameterMap();
+
+ String encodedName = null;
+ CharBuffer buffer = new CharBuffer(50);
+
+
+ int pos = 0;
+ int len = queryString.length();
+ int state = LOOKUP;
+ while (true)
+ {
+ char c;
+ if (pos < len)
+ {
+ c = queryString.charAt(pos++);
+ }
+ else if (pos == len)
+ {
+ c = '&';
+ pos++;
+ }
+ else
+ {
+ break;
+ }
+
+ //
+ switch(state)
+ {
+ case LOOKUP:
+ if (c == '&')
+ {
+ // Do nothing
+ }
+ else if (c == '=')
+ {
+ state = INVALID_CHUNK;
+ }
+ else
+ {
+ state = PARAM_NAME;
+ buffer.append(c);
+ }
+ break;
+ case PARAM_NAME:
+ if (c == '&')
+ {
+ String tmp = buffer.asString();
+
+ //
+ try
+ {
+ parameterDecoder.encode(tmp, buffer);
+ append(parameterMap, buffer.asString(false), "");
+ }
+ catch (EncodingException e)
+ {
+ log.debug("Could not decode parameter name " + tmp, e);
+ }
+
+ //
+ buffer.reset();
+ state = LOOKUP;
+ }
+ else if (c == '=')
+ {
+ encodedName = buffer.asString();
+ buffer.reset();
+ state = PARAM_VALUE;
+ }
+ else
+ {
+ buffer.append(c);
+ }
+ break;
+ case PARAM_VALUE:
+ if (c == '&')
+ {
+
+ //
+ try
+ {
+ // Save value
+ String encodedValue = buffer.asString();
+
+ // Decode parameter name
+ parameterDecoder.encode(encodedName, buffer);
+ String name = buffer.asString(false);
+
+ // Now decode parameter value
+ try
+ {
+ buffer.reset();
+ parameterDecoder.encode(encodedValue, buffer);
+ String value = buffer.asString();
+ append(parameterMap, name, value);
+ }
+ catch (EncodingException e)
+ {
+ log.debug("Could not decode parameter value " + encodedValue, e);
+ }
+ }
+ catch (EncodingException e)
+ {
+ log.debug("Could not decode parameter name " + encodedName, e);
+ }
+
+ //
+ buffer.reset();
+ state = LOOKUP;
+ }
+ else
+ {
+ buffer.append(c);
+ }
+ break;
+ case INVALID_CHUNK:
+ if (c == '&')
+ {
+ state = LOOKUP;
+ }
+ break;
+ }
+ }
+
+ //
+ return parameterMap;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/AbstractLocaleFormat.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+import org.jboss.portal.common.util.ConversionException;
+import org.jboss.portal.common.util.NullConversionException;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public abstract class AbstractLocaleFormat implements LocaleFormat
+{
+
+ public Locale getLocale(String value) throws ConversionException
+ {
+ if (value == null)
+ {
+ throw new NullConversionException("No null locale value accepted");
+ }
+ return internalGetLocale(value);
+ }
+
+ public String toString(Locale locale) throws ConversionException
+ {
+ if (locale == null)
+ {
+ throw new NullConversionException("No null locale accepted");
+ }
+ return internalToString(locale);
+ }
+
+ public void write(Locale locale, Writer writer) throws IOException, ConversionException
+ {
+ if (locale == null)
+ {
+ throw new NullConversionException("No null locale accepted");
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("No null writer accepted");
+ }
+ internalWrite(locale, writer);
+ }
+
+ protected abstract Locale internalGetLocale(String value) throws ConversionException;
+
+ protected String internalToString(Locale locale) throws ConversionException
+ {
+ try
+ {
+ StringWriter writer = new StringWriter();
+ internalWrite(locale, writer);
+ return writer.toString();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ protected abstract void internalWrite(Locale locale, Writer writer) throws IOException, ConversionException;
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/BundleName.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,310 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+import java.util.NoSuchElementException;
+
+/**
+ * The immutable name of a bundle.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class BundleName
+{
+
+ public BundleName(String baseName)
+ {
+ this(baseName, "", "", "");
+ }
+
+ public BundleName(String baseName, String language)
+ {
+ this(baseName, language, "", "");
+ }
+
+ public BundleName(String baseName, String language, String country)
+ {
+ this(baseName, language, country, "");
+ }
+
+ public BundleName(String baseName, String language, String country, String variant)
+ {
+ if (baseName == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (language == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (country == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (variant == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.baseName = baseName;
+ this.language = language;
+ this.country = country;
+ this.variant = variant;
+ }
+
+ /** . */
+ private final String baseName;
+
+ /** Lower-case two-letter codes as defined by ISO-639. */
+ private final String language;
+
+ /** Upper-case two-letter codes as defined by ISO-3166. */
+ private final String country;
+
+ /** . */
+ private final String variant;
+
+ public String getBaseName()
+ {
+ return baseName;
+ }
+
+ public String getLanguage()
+ {
+ return language;
+ }
+
+ public String getCountry()
+ {
+ return country;
+ }
+
+ public String getVariant()
+ {
+ return variant;
+ }
+
+ public static class Iterator implements java.util.Iterator
+ {
+
+ /** . */
+ private final String language;
+
+ /** . */
+ private final String country;
+
+ /** . */
+ private final String variant;
+
+ /** . */
+ private String name;
+
+ /** . */
+ private int status;
+
+ public Iterator(String baseName, Locale locale)
+ {
+ language = locale.getLanguage();
+ country = locale.getCountry();
+ variant = locale.getVariant();
+ status = 8 + (language.length() > 0 ? 4 : 0) + (country.length() > 0 ? 2 : 0) + (variant.length() > 0 ? 1 : 0);
+ switch (status & 0x7)
+ {
+ case 0:
+ name = baseName;
+ break;
+ case 1:
+ name = baseName + "___" + variant;
+ break;
+ case 2:
+ name = baseName + "__" + country;
+ break;
+ case 3:
+ name = baseName + "__" + country + "_" + variant;
+ break;
+ case 4:
+ name = baseName + "_" + language;
+ break;
+ case 5:
+ name = baseName + "_" + language + "__" + variant;
+ break;
+ case 6:
+ name = baseName + "_" + language + "_" + country;
+ break;
+ case 7:
+ name = baseName + "_" + language + "_" + country + "_" + variant;
+ break;
+ default:
+ throw new AssertionError("Should not be here");
+ }
+ }
+
+ public boolean hasNext()
+ {
+ return status != 0;
+ }
+
+ public Object next()
+ {
+ if (status >= 8)
+ {
+ status -= 8;
+ }
+ else
+ {
+ switch (status)
+ {
+ case 0:
+ throw new NoSuchElementException();
+ case 1:
+ name = name.substring(0, name.length() - 3 - variant.length());
+ status = 0;
+ break;
+ case 2:
+ name = name.substring(0, name.length() - 2 - country.length());
+ status = 0;
+ break;
+ case 3:
+ name = name.substring(0, name.length() - 1 - variant.length());
+ status = 2;
+ break;
+ case 4:
+ name = name.substring(0, name.length() - 1 - language.length());
+ status = 0;
+ break;
+ case 5:
+ name = name.substring(0, name.length() - 2 - variant.length());
+ status = 4;
+ break;
+ case 6:
+ name = name.substring(0, name.length() - 1 - country.length());
+ status = 4;
+ break;
+ case 7:
+ name = name.substring(0, name.length() - 1 - variant.length());
+ status = 6;
+ break;
+ default:
+ throw new AssertionError("Should not be here");
+ }
+ }
+ return name;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ /**
+ *
+ */
+ public static class Parser
+ {
+ /**
+ * @param s
+ * @param from inclusive
+ * @param to exclusive
+ * @return
+ */
+ public BundleName parse(String s, int from, int to)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (from < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (to < s.length())
+ {
+ throw new IllegalArgumentException();
+ }
+ if (to < from)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ int p1 = s.lastIndexOf('_', to - 1);
+ if (p1 < from)
+ {
+ p1 = -1;
+ }
+
+ //
+ if (p1 == -1)
+ {
+ // We have base name
+ return new BundleName(s.substring(from, to));
+ }
+ else if (p1 == to - 1)
+ {
+ // It ends up with _ or __ or ___
+ return null;
+ }
+ String a = s.substring(p1 + 1, to);
+
+ //
+ int p2 = s.lastIndexOf('_', p1 - 1);
+ if (p2 < from)
+ {
+ p2 = -1;
+ }
+
+ //
+ if (p2 == -1)
+ {
+ // We have base name + language
+ return new BundleName(s.substring(from, p1), a);
+ }
+ String b = p2 == p1 - 1 ? "" : s.substring(p2 + 1, p1);
+
+ //
+ int p3 = s.lastIndexOf('_', p2 - 1);
+ if (p3 < from)
+ {
+ p3 = -1;
+ }
+
+ //
+ if (p3 == -1)
+ {
+ // We have (base name + language + country) or (base name + country)
+ return new BundleName(s.substring(from, p2), b, a);
+ }
+
+ //
+ String c = (p3 == p2 - 1) ? "" : s.substring(p3 + 1, p2);
+
+ // We have (base name + variant)
+ // or (base name + country + variant)
+ // or (base name + language + country + variant)
+ // or (base name + language + variant)
+ return new BundleName(s.substring(from, p3), c, b, a);
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/CachingLocaleFormat.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
+import org.jboss.portal.common.util.ConversionException;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class CachingLocaleFormat implements LocaleFormat
+{
+
+ /** . */
+ private final LocaleFormat delegate;
+
+ /** . */
+ private final ConcurrentHashMap localeCache;
+
+ /** . */
+ private final ConcurrentHashMap stringCache;
+
+ /**
+ * @param delegate the delegate when the cache value has not been found
+ * @throws IllegalArgumentException if the delegate object provided is null
+ */
+ public CachingLocaleFormat(LocaleFormat delegate) throws IllegalArgumentException
+ {
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException("No null delegate is possible");
+ }
+ this.delegate = delegate;
+ this.localeCache = new ConcurrentHashMap();
+ this.stringCache = new ConcurrentHashMap();
+ }
+
+ public Locale getLocale(String value) throws ConversionException
+ {
+ Locale locale = (Locale)localeCache.get(value);
+
+ //
+ if (locale != null)
+ {
+ return locale;
+ }
+ else
+ {
+ locale = delegate.getLocale(value);
+ localeCache.put(value, locale);
+ }
+
+ //
+ return locale;
+ }
+
+ public String toString(Locale locale) throws ConversionException
+ {
+ String string = (String)stringCache.get(locale);
+
+ //
+ if (string != null)
+ {
+ return string;
+ }
+ else
+ {
+ string = delegate.toString(locale);
+ stringCache.put(locale, string);
+ }
+
+ //
+ return string;
+ }
+
+ public void write(Locale locale, Writer writer) throws IOException, ConversionException
+ {
+ delegate.write(locale, writer);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ComplexResourceBundleFactory.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,123 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.io.IOTools;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Locale;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7374 $
+ */
+public class ComplexResourceBundleFactory implements ResourceBundleFactory
+{
+
+ /** . */
+ private final ClassLoader resourceLoader;
+
+ /** . */
+ private final String baseName;
+
+ public ComplexResourceBundleFactory(ClassLoader resourceLoader, String baseName)
+ {
+ this.resourceLoader = resourceLoader;
+ this.baseName = baseName;
+ }
+
+ public ResourceBundle getBundle(Locale locale) throws IllegalArgumentException
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ for (BundleName.Iterator iterator = new BundleName.Iterator(baseName, locale); iterator.hasNext();)
+ {
+ String name = (String)iterator.next();
+
+ // We don't want to process the base name only with the specified locale
+ // in order to respect the sequence of candidate bundle names
+ if (!iterator.hasNext())
+ {
+ break;
+ }
+
+ //
+ ResourceBundle bundle = lookup(name);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+ }
+
+ // Try default locale
+ for (BundleName.Iterator iterator = new BundleName.Iterator(baseName, Locale.getDefault()); iterator.hasNext();)
+ {
+ String name = (String)iterator.next();
+
+ //
+ ResourceBundle bundle = lookup(name);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+ }
+
+ // Nothing was found
+ return null;
+ }
+
+ protected ResourceBundle lookup(String s)
+ {
+ // Try to load class first
+ // we don't do that for now !!!
+
+ // Try to load bundle then
+ String propertyName = s.replace('.', '/') + ".properties";
+ InputStream in = resourceLoader.getResourceAsStream(propertyName);
+ if (in != null)
+ {
+ try
+ {
+ in = IOTools.safeBufferedWrapper(in);
+ return new PropertyResourceBundle(in);
+ }
+ catch (IOException e)
+ {
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ //
+ return null;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/DefaultLocaleFormat.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,120 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.FormatConversionException;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Implementation for the programmatic name of a locale.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class DefaultLocaleFormat extends AbstractLocaleFormat
+{
+
+ /** . */
+ private static final Map CACHE = new HashMap();
+
+ static
+ {
+ for (Iterator i = LocaleManager.getLocales().iterator(); i.hasNext();)
+ {
+ Locale locale = (Locale)i.next();
+
+ //
+ CACHE.put(locale.toString(), locale);
+ }
+ }
+
+ /** . */
+ private LocaleFactory factory;
+
+ public DefaultLocaleFormat(LocaleFactory factory)
+ {
+ this.factory = factory;
+ }
+
+ public DefaultLocaleFormat()
+ {
+ this(LocaleFactory.DEFAULT_FACTORY);
+ }
+
+ protected Locale internalGetLocale(String value) throws FormatConversionException
+ {
+ Locale locale = (Locale)CACHE.get(value);
+ if (locale != null)
+ {
+ return locale;
+ }
+
+ //
+ int p1 = value.lastIndexOf('_');
+ if (p1 < 0)
+ {
+ return factory.createLocale(value);
+ }
+
+ //
+ String a = (p1 == (value.length() - 1)) ? "" : value.substring(p1 + 1, value.length());
+
+ //
+ int p2 = value.lastIndexOf('_', p1 - 1);
+ if (p2 < 0)
+ {
+ if (a.length() == 0)
+ {
+ throw new FormatConversionException();
+ }
+ else
+ {
+ return factory.createLocale(value.substring(0, p1), a);
+ }
+ }
+
+ //
+ boolean emptyLanguage = p2 == p1 - 1;
+ if (p2 == 0 && emptyLanguage)
+ {
+ throw new FormatConversionException();
+ }
+
+ //
+ String b = emptyLanguage ? "" : value.substring(p2 + 1, p1);
+
+ //
+ return factory.createLocale(value.substring(0, p2), b, a);
+ }
+
+ protected void internalWrite(Locale locale, Writer writer) throws IOException
+ {
+ writer.write(locale.toString());
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/I18NTools.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/I18NTools.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/I18NTools.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class I18NTools
+{
+
+ /** Separator. */
+ private static final String RFC3066_SEPARATOR = "-";
+
+ /**
+ * Retrieves the language identification tag associated to the specified Locale as defined by <a
+ * href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter language code per ISO standard
+ * 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes. E.g. "en-US" for American
+ * English, "en-GB" for British English, etc.
+ *
+ * @param locale the locale which language tag is wanted
+ * @return a <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>-compatible language tag.
+ * @throws IllegalArgumentException if the given locale is not valid
+ * @since 2.4
+ */
+ public static String getRFC3066LanguageTagFor(Locale locale)
+ {
+ String country = locale.getCountry(); // country will be empty if no country was specified in the locale
+ return locale.getLanguage() + ((country.length() == 2) ? RFC3066_SEPARATOR + country : country);
+ }
+
+ /**
+ * Compute the trailing name for a given locale.
+ *
+ * @param locale the locale
+ * @return the trailing name
+ * @throws IllegalArgumentException if locale is null
+ */
+ public static String computeTrailingName(Locale locale) throws IllegalArgumentException
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("locale parameter is null");
+ }
+ StringBuffer tmp = new StringBuffer();
+ if (locale.getLanguage() != null && locale.getLanguage().length() > 0)
+ {
+ tmp.append('_').append(locale.getLanguage());
+ if (locale.getCountry() != null && locale.getCountry().length() > 0)
+ {
+ tmp.append('_').append(locale.getCountry());
+ {
+ if (locale.getVariant() != null && locale.getVariant().length() > 0)
+ {
+ tmp.append('_').append(locale.getVariant());
+ }
+ }
+ }
+ }
+ return tmp.toString();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFactory.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFactory.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFactory.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface LocaleFactory
+{
+
+ LocaleFactory DEFAULT_FACTORY = new LocaleFactory()
+ {
+ public Locale createLocale(String language)
+ {
+ return new Locale(language);
+ }
+
+ public Locale createLocale(String language, String country)
+ {
+ return new Locale(language, country);
+ }
+
+ public Locale createLocale(String language, String country, String variant)
+ {
+ return new Locale(language, country, variant);
+ }
+ };
+
+ Locale createLocale(String language);
+
+ Locale createLocale(String language, String country);
+
+ Locale createLocale(String language, String country, String variant);
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleFormat.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.ConversionException;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface LocaleFormat
+{
+
+ /** . */
+ final LocaleFormat RFC3066_LANGUAGE_TAG_NO_CACHE = new RFC3066LanguageTagLocaleFormat();
+
+ /** . */
+ final LocaleFormat DEFAULT_NO_CACHE = new DefaultLocaleFormat();
+
+ /** . */
+ final LocaleFormat RFC3066_LANGUAGE_TAG = new CachingLocaleFormat(new RFC3066LanguageTagLocaleFormat());
+
+ /** . */
+ final LocaleFormat DEFAULT = new CachingLocaleFormat(new DefaultLocaleFormat());
+
+ Locale getLocale(String value) throws ConversionException;
+
+ String toString(Locale locale) throws ConversionException;
+
+ void write(Locale locale, Writer writer) throws IOException, ConversionException;
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleManager.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleManager.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocaleManager.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.Tools;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class LocaleManager
+{
+
+ /** . */
+ private static final Collection all = Collections.unmodifiableSet(Tools.toSet(Locale.getAvailableLocales()));
+
+ /** Return a collection of all available locale info for the platform. */
+ public static Collection getLocales()
+ {
+ return all;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.PropertyResourceBundle;
+import java.util.Locale;
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class LocalizedPropertyResourceBundle extends PropertyResourceBundle
+{
+
+ private final Locale locale;
+
+ /**
+ * Create an instanceof of localized property resource bundle.
+ *
+ * @param stream the stream to decode the property file
+ * @param locale the locale to use
+ * @throws IllegalArgumentException if the locale is null
+ */
+ public LocalizedPropertyResourceBundle(InputStream stream, Locale locale) throws IOException
+ {
+ super(stream);
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("Locale cannot be null");
+ }
+ this.locale = locale;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedPropertyResourceBundle.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,442 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.util.ConversionException;
+
+/**
+ * An immutable locale sensitive object that returns strings.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7200 $
+ */
+public final class LocalizedString
+{
+
+ /** The logger. */
+ private static final Logger log = Logger.getLogger(LocalizedString.class);
+
+ /** An unmodifiable <Locale,String>Map. */
+ private final Map values;
+
+ /** The default locale. */
+ private final Locale defaultLocale;
+
+ /** The cached hashCode. */
+ private Integer hashCode;
+
+ /** The cached toString. */
+ private String cachedToString;
+
+ /**
+ * Convenience constructor for simple localized strings with only one value using the <code>Locale.ENGLISH</code> locale.
+ *
+ * @param defaultValue the localized value using the specified default locale
+ * @throws IllegalArgumentException if no default value or locale is provided
+ * @since 2.6
+ */
+ public LocalizedString(String defaultValue) throws IllegalArgumentException
+ {
+ this(defaultValue, Locale.ENGLISH);
+ }
+
+ /**
+ * Convenience constructor for simple localized strings with only one value using the default locale.
+ *
+ * @param defaultValue the localized value using the specified default locale
+ * @param defaultLocale the default locale
+ * @throws IllegalArgumentException if no default value or locale is provided
+ * @since 2.4
+ */
+ public LocalizedString(String defaultValue, Locale defaultLocale) throws IllegalArgumentException
+ {
+ if (defaultValue == null)
+ {
+ throw new IllegalArgumentException("No null default value allowed");
+ }
+ if (defaultLocale == null)
+ {
+ throw new IllegalArgumentException("No null default locale allowed");
+ }
+
+ //
+ Map values = new HashMap(1);
+ addValueForLocale(values, defaultLocale, defaultValue);
+
+ //
+ this.defaultLocale = defaultLocale;
+ this.values = Collections.unmodifiableMap(values);
+ }
+
+ /**
+ * Build an empty localized string.
+ *
+ * @param defaultLocale the default locale
+ * @throws IllegalArgumentException if no default locale is provided
+ */
+ public LocalizedString(Locale defaultLocale) throws IllegalArgumentException
+ {
+ if (defaultLocale == null)
+ {
+ throw new IllegalArgumentException("No null default locale allowed");
+ }
+
+ //
+ this.defaultLocale = defaultLocale;
+ this.values = Collections.EMPTY_MAP;
+ }
+
+ /**
+ * Build a localized string using a <Locale,String>Map object.
+ *
+ * @param values the <Locale,String>Map
+ * @param defaultLocale
+ * @throws IllegalArgumentException if one argument if null or if the map entries are different from <Locale,String>Map.Entry
+ */
+ public LocalizedString(Map values, Locale defaultLocale) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException("No null description map allowed");
+ }
+ if (defaultLocale == null)
+ {
+ throw new IllegalArgumentException("No null default locale allowed");
+ }
+
+ // Convert strings to value
+ Map tmp = new HashMap(values.size());
+ for (Iterator i = values.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ Object key = entry.getKey();
+ if (!(key instanceof Locale))
+ {
+ throw new IllegalArgumentException("Key not a locale " + entry.getKey());
+ }
+ Object value = entry.getValue();
+ if (!(value instanceof String))
+ {
+ throw new IllegalArgumentException("Value not a string " + entry.getValue());
+ }
+ addValueForLocale(tmp, (Locale)key, (String)value);
+ }
+
+ //
+ this.defaultLocale = defaultLocale;
+ this.values = Collections.unmodifiableMap(tmp);
+ }
+
+ /**
+ * Adds a new value for the specified locale to this LocalizedString. Note that if a value existed for this Locale,
+ * it will be overwritten.
+ *
+ * @param locale the locale of the value
+ * @param value the value
+ * @since 2.4
+ */
+ private static void addValueForLocale(Map values, Locale locale, String value)
+ {
+ values.put(locale, new Value(locale, value));
+ }
+
+ /**
+ * Determines if this LocalizedString contains any values.
+ *
+ * @return <code>true</code> if this LocalizedString contains localized values, <code>false</code> otherwise.
+ * @since 2.4
+ */
+ public boolean hasValues()
+ {
+ return values.isEmpty() == false;
+ }
+
+ /**
+ * Return the string for the default locale.
+ *
+ * @return the string for the default locale
+ */
+ public String getDefaultString()
+ {
+ return getString(defaultLocale, false);
+ }
+
+ /**
+ * Returns the value for the default locale.
+ *
+ * @return the value for the default locale
+ */
+ public Value getDefaultValue()
+ {
+ return getValue(defaultLocale, false);
+ }
+
+ /**
+ * Returns a string value.
+ *
+ * @param locale the desired locale
+ * @param resolve true if the locale must be resolved to the most appropriate
+ * @return the description string or null if it is not found
+ */
+ public String getString(Locale locale, boolean resolve)
+ {
+ Value value = getValue(locale, resolve);
+ if (value != null)
+ {
+ return value.getString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Returns a localized value. The lookup operation can be done without resolution which
+ * means that the locale is just used as a key during the lookup. If the lookup operation is done with
+ * resolution then the different parts of the locale will be used during the operation.
+ *
+ * @param locale the desired locale
+ * @param resolve true if the locale must be resolved to the most appropriate
+ * @return the value or null if it is not found
+ */
+ public Value getValue(Locale locale, boolean resolve)
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("No null locale accepted as argument");
+ }
+
+ // fail fast is there aren't any values
+ if (values.isEmpty())
+ {
+ return null;
+ }
+
+ if (resolve)
+ {
+ Value value = (Value)values.get(locale);
+ if (value == null && !locale.getVariant().equals(""))
+ {
+ value = (Value)values.get(new Locale(locale.getLanguage(), locale.getCountry()));
+ }
+ if (value == null && !locale.getCountry().equals(""))
+ {
+ value = (Value)values.get(new Locale(locale.getLanguage()));
+ }
+ if (value == null)
+ {
+ value = (Value)values.get(defaultLocale);
+ }
+ return value;
+ }
+ else
+ {
+ return (Value)values.get(locale);
+ }
+ }
+
+ public Map getValues()
+ {
+ return Collections.unmodifiableMap(values);
+ }
+
+ /**
+ * Return the default locale of this localized string.
+ *
+ * @return the default locale
+ */
+ public Locale getDefaultLocale()
+ {
+ return defaultLocale;
+ }
+
+ /**
+ * Retrieves the localized value most appropriate based on the given desired locales.
+ *
+ * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
+ * RFC 3066</a>) ordered according to locale preferences.
+ * @return the most appropriate localized value based on locale preferences.
+ * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see
+ * #getLocaleFromRFC3066LanguageTag(String))
+ * @since 2.4
+ */
+ public String getMostAppropriateValueFor(String[] desiredLocales) throws IllegalArgumentException
+ {
+ Value mapping = getPreferredOrBestLocalizedMappingFor(desiredLocales);
+ return (mapping == null) ? null : mapping.getString();
+ }
+
+ /**
+ * Retrieves the Locale-String mapping most appropriate based on the given desired locales, which are ordered
+ * according to locale preferences.
+ *
+ * @param desiredLocales an array of compound language tags (as defined by <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF
+ * RFC 3066</a>) ordered according to locale preferences.
+ * @return a Map.Entry representing the most appropriate mapping between Locale and localized value, based on locale
+ * preferences.
+ * @throws IllegalArgumentException if the array is null or one of the array string is null or invalid (see {@link
+ * LocaleFormat#RFC3066_LANGUAGE_TAG#getLocale(String)}
+ * @since 2.4
+ */
+ public Value getPreferredOrBestLocalizedMappingFor(String[] desiredLocales) throws IllegalArgumentException
+ {
+ if (desiredLocales == null)
+ {
+ throw new IllegalArgumentException("No null desired locale array accepted");
+ }
+
+ //
+ if (values.isEmpty())
+ {
+ return null;
+ }
+
+ //
+ Value value = null;
+ if (desiredLocales.length > 0)
+ {
+ for (int i = 0; value == null && i < desiredLocales.length; i++)
+ {
+ String desiredLocale = desiredLocales[i];
+
+ //
+ if (desiredLocale == null)
+ {
+ throw new IllegalArgumentException("Null desired locale not accepted");
+ }
+
+ //
+ try
+ {
+ Locale locale = LocaleFormat.RFC3066_LANGUAGE_TAG.getLocale(desiredLocale);
+ value = getValue(locale, true);
+ }
+ catch (ConversionException e)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Invalid desired locale " + desiredLocale);
+ }
+ }
+ }
+
+ // todo julien
+ // We could have a smarter version of this method but this version requires that desiredLocales
+ // are ordered by locale preference. Hence the first found is by definition the best.
+ }
+
+ //
+ if (value == null)
+ {
+ value = getValue(defaultLocale, true);
+ }
+
+ //
+ return value;
+ }
+
+ public String toString()
+ {
+ if (cachedToString == null)
+ {
+ cachedToString = "LocalizedString[value='" + getMostAppropriateValueFor(new String[0]) + "',defaultLocale=" + getDefaultLocale() + "]";
+ }
+ return cachedToString;
+ }
+
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || LocalizedString.class != o.getClass())
+ {
+ return false;
+ }
+
+ //
+ LocalizedString that = (LocalizedString)o;
+ return defaultLocale.equals(that.defaultLocale) && getMostAppropriateValueFor(new String[0]).equals(that.getMostAppropriateValueFor(new String[0]));
+ }
+
+ public int hashCode()
+ {
+ if (hashCode == null)
+ {
+ hashCode = new Integer(31 * getMostAppropriateValueFor(new String[0]).hashCode() + defaultLocale.hashCode());
+ }
+ return hashCode.intValue();
+ }
+
+ /**
+ * A localized string value.
+ */
+ public static class Value
+ {
+
+ /** The locale that describes the string. */
+ private final Locale locale;
+
+ /** the string value. */
+ private final String string;
+
+ /**
+ * @param locale the locale
+ * @param string the string
+ * @throws IllegalArgumentException if one argument is null
+ */
+ public Value(Locale locale, String string) throws IllegalArgumentException
+ {
+ if (locale == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (string == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.locale = locale;
+ this.string = string;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public String getString()
+ {
+ return string;
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/LocalizedString.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.ResourceBundle;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.Collections;
+
+/**
+ * A resource bundle that use a map as content.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class MapResourceBundle extends ResourceBundle
+{
+
+ protected Map content;
+
+ public MapResourceBundle(Map content)
+ {
+ this.content = new HashMap(content);
+ }
+
+ protected Object handleGetObject(String key)
+ {
+ if (key == null)
+ {
+ throw new NullPointerException();
+ }
+ return content.get(key);
+ }
+
+ public Enumeration getKeys()
+ {
+ return Collections.enumeration(content.keySet());
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/MapResourceBundle.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,110 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.Tools;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+/**
+ * This resource bundle takes two resource bundle to make one :
+ * - The locale of this resource bundle is given by the child.
+ * - For a given key present in the child and the parent, the child
+ * value overrides the parent value.
+ *
+ * The locale used for the bundle is the child locale.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 6818 $
+ */
+public class ParentChildResourceBundle extends ResourceBundle
+{
+
+ /** The bundle locale. */
+ private Locale locale;
+
+ /** The bundle values. */
+ private Map values;
+
+ /**
+ * Construct a new resource bundle whose content is based on the child
+ * and parent content.
+ *
+ * @param parent the parent eventually null
+ * @param child the child
+ * @throws IllegalArgumentException if the child is null or its locale is null
+ */
+ public ParentChildResourceBundle(ResourceBundle parent, ResourceBundle child) throws IllegalArgumentException
+ {
+ // Arg check
+ if (child == null)
+ {
+ throw new IllegalArgumentException("Child cannot be null");
+ }
+ if (child.getLocale() == null)
+ {
+ throw new IllegalArgumentException("Child locale must not be null");
+ }
+ this.locale = child.getLocale();
+ this.values = new HashMap();
+
+ // Set the parent content
+ if (parent != null)
+ {
+ for (Enumeration e = parent.getKeys();e.hasMoreElements();)
+ {
+ String key = (String)e.nextElement();
+ Object value = parent.getObject(key);
+ values.put(key, value);
+ }
+ }
+
+ // Set the child content
+ for (Enumeration e = child.getKeys();e.hasMoreElements();)
+ {
+ String key = (String)e.nextElement();
+ Object value = child.getObject(key);
+ values.put(key, value);
+ }
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ protected Object handleGetObject(String key)
+ {
+ return values.get(key);
+ }
+
+ public Enumeration getKeys()
+ {
+ return Tools.toEnumeration(values.keySet().iterator());
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ParentChildResourceBundle.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/RFC3066LanguageTagLocaleFormat.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.jboss.portal.common.util.FormatConversionException;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+class RFC3066LanguageTagLocaleFormat extends AbstractLocaleFormat
+{
+
+ /** Separator. */
+ private static final String RFC3066_SEPARATOR = "-";
+
+ /** Valid language tag matcher (see <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>). */
+ private final Pattern RFC3066_COMPOUND_LANG_PATTERN = Pattern.compile("(\\p{Lower}{2})(-(\\p{Upper}{2}))?");
+
+ /** Sorted valid ISO country codes (needed for Arrays.binarySearch). */
+ private final String[] SORTED_ISO_COUNTRIES = Locale.getISOCountries();
+
+ /** Sorted valid ISO language codes (needed for Arrays.binarySearch). */
+ private final String[] SORTED_ISO_LANGUAGES = Locale.getISOLanguages();
+
+ protected Locale internalGetLocale(String value) throws FormatConversionException
+ {
+ Matcher matcher = RFC3066_COMPOUND_LANG_PATTERN.matcher(value);
+ if (matcher.matches())
+ {
+ String language = matcher.group(1);
+ if (Arrays.binarySearch(SORTED_ISO_LANGUAGES, language) < 0)
+ {
+ throw new FormatConversionException("Invalid ISO language code: " + language);
+ }
+ String country = matcher.group(3);
+ if (country == null)
+ {
+ return new Locale(language);
+ }
+ else if (Arrays.binarySearch(SORTED_ISO_COUNTRIES, country) < 0)
+ {
+ throw new FormatConversionException("Invalid ISO country code: " + country);
+ }
+ return new Locale(language, country);
+ }
+ throw new FormatConversionException(value + " is not a valid compound language : accepted " +
+ "format is xx-YY where xx is a valid ISO language code and YY is a valid country code. See " +
+ "java.util.Locale javadoc for more info.");
+ }
+
+ /**
+ * Retrieves the language identification tag associated to the specified Locale as defined by <a
+ * href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a> limited to 2-letter language code per ISO standard
+ * 639, a "-" (dash) and a 2-letter country code per ISO 3166 alpha-2 country codes. E.g. "en-US" for American
+ * English, "en-GB" for British English, etc.
+ *
+ * @param locale the locale which language tag is wanted
+ * @return a <a href="http://www.ietf.org/rfc/rfc3066.txt">IETF RFC 3066</a>-compatible language tag.
+ * @throws IllegalArgumentException if the given locale is not valid
+ * @since 2.4
+ */
+ protected void internalWrite(Locale locale, Writer writer) throws IOException
+ {
+ String country = locale.getCountry(); // country will be empty if no country was specified in the locale
+ writer.write(locale.getLanguage());
+ if (country.length() == 2)
+ {
+ writer.write(RFC3066_SEPARATOR);
+ writer.write(country);
+ }
+ else
+ {
+ writer.write(country);
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleFactory.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleFactory.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleFactory.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Definition of a factory for resource bundles.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface ResourceBundleFactory
+{
+ /**
+ * Returns a resource bundle for the specified locale, it may be an expensive operation.
+ *
+ * @param locale the locale for the resource bundle
+ * @return a resource bundle for the locale or null if no such bundle can be obtained
+ * @throws IllegalArgumentException if the locale is null
+ */
+ ResourceBundle getBundle(Locale locale) throws IllegalArgumentException;
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/ResourceBundleManager.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,164 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import org.apache.log4j.Logger;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * <p>Manage a set of resource bundles. Obtaining bundles is done using a ResourceBundleFactory object. A bundle
+ * obtained successfully is cached in order to avoid the potential expensive cost of bundle retrieval.</p>
+ * <p/>
+ * <p>The manager can also be used to build LocalizedString object from the loaded bundles.</p>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 7228 $
+ */
+public class ResourceBundleManager
+{
+
+ /** . */
+ private Logger log = Logger.getLogger(getClass());
+
+ /** . */
+ private volatile Map localeBundles;
+
+ /** . */
+ private ResourceBundle defaultBundle;
+
+ /** . */
+ private ResourceBundleFactory resourceBundleFactory;
+
+ /**
+ * @param defaultBundle the default bundle returned when no bundle has been obtained for the locale
+ * @param resourceBundleFactory the resource bundle factory
+ * @throws IllegalArgumentException IllegalArgumentException if the resource bundle factory is null
+ */
+ public ResourceBundleManager(ResourceBundle defaultBundle, ResourceBundleFactory resourceBundleFactory) throws IllegalArgumentException
+ {
+ if (resourceBundleFactory == null)
+ {
+ throw new IllegalArgumentException("Need a resource bundle factory");
+ }
+ this.localeBundles = new HashMap();
+ this.defaultBundle = defaultBundle;
+ this.resourceBundleFactory = resourceBundleFactory;
+ }
+
+ /**
+ * Return a localized value constructed from the various resource bundles. The supported locales of the manager are
+ * used in combination with the specified key. The default value is used if no value is found for the
+ * <code>Locale.ENGLISH</code>. Two successive calls to this method may not return identical results since the
+ * returned <code>LocalizedString</code> is built using the bundles known by the manager.
+ *
+ * @param key the key to lookup in the bundles
+ * @param defaultValue the default value
+ * @return the localized string
+ * @throws IllegalArgumentException if the key of the default value is null
+ */
+ public LocalizedString getLocalizedValue(String key, String defaultValue) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (defaultValue == null)
+ {
+ throw new IllegalArgumentException("No null default value accepted");
+ }
+ Map m = new HashMap();
+ for (Iterator j = localeBundles.entrySet().iterator(); j.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)j.next();
+ try
+ {
+ Locale locale = (Locale)entry.getKey();
+ ResourceBundle bundle = (ResourceBundle)entry.getValue();
+ String localizedDisplayName = bundle.getString(key);
+ m.put(locale, localizedDisplayName);
+ }
+ catch (MissingResourceException ignore)
+ {
+ }
+ }
+ if (!m.containsKey(Locale.ENGLISH))
+ {
+ m.put(Locale.ENGLISH, defaultValue);
+ }
+ return new LocalizedString(m, Locale.ENGLISH);
+ }
+
+ /**
+ * Return a bundle for the given locale. If the complete locale (language + country + variant) does not exist then it
+ * falls back to (language + country) or (language) or the default file.
+ * <p/>
+ * When the resource bundle object is found and was not in the global map, it put it in that map with a copy on
+ * write.
+ *
+ * @throws IllegalArgumentException if the locale is null
+ */
+ public ResourceBundle getResourceBundle(Locale locale) throws IllegalArgumentException
+ {
+ // Arg check
+ if (locale == null)
+ {
+ throw new IllegalArgumentException("Locale cannot be null");
+ }
+
+ // Try to get the bundle if the map
+ ResourceBundle bundle = (ResourceBundle)localeBundles.get(locale);
+ if (bundle != null)
+ {
+ return bundle;
+ }
+
+ //
+ log.debug("Want to load bundle for locale " + locale);
+ bundle = resourceBundleFactory.getBundle(locale);
+
+ //
+ if (bundle != null)
+ {
+ log.debug("Obtained bundle " + bundle + " for locale " + locale);
+ }
+ else
+ {
+ log.debug("No bundle obtained for locale " + locale + " will use default bundle " + defaultBundle + "instead");
+ }
+
+ // Cache the bundle
+ Map copy = new HashMap(localeBundles);
+ copy.put(locale, bundle);
+ localeBundles = copy;
+
+ //
+ return bundle;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/i18n/SimpleResourceBundleFactory.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.i18n;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * An implementation that delegates bundle loading to <code>ResourceBundle.getBundle(String,Locale,ClassLoader)</code>.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class SimpleResourceBundleFactory implements ResourceBundleFactory
+{
+
+ /** The base name of the resource bundles. */
+ private String baseName;
+
+ /** The classloader to load resource from. */
+ private ClassLoader classLoader;
+
+ public SimpleResourceBundleFactory(String baseName, ClassLoader classLoader) throws IllegalArgumentException
+ {
+ if (baseName == null)
+ {
+ throw new IllegalArgumentException("No base name provided");
+ }
+ if (classLoader == null)
+ {
+ throw new IllegalArgumentException("No classloader provided");
+ }
+ this.baseName = baseName;
+ this.classLoader = classLoader;
+ }
+
+ public ResourceBundle getBundle(Locale locale) throws IllegalArgumentException
+ {
+ return ResourceBundle.getBundle(baseName, locale, classLoader);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/AbstractInvocationContext.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/AbstractInvocationContext.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/AbstractInvocationContext.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,163 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class AbstractInvocationContext implements InvocationContext
+{
+
+ /** . */
+ private final Map resolvers;
+
+ public AbstractInvocationContext()
+ {
+ this.resolvers = new HashMap();
+ }
+
+ protected final void addResolver(Scope resolverScope, InvocationContext federatedContext) throws IllegalArgumentException
+ {
+ if (resolverScope == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (federatedContext == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ resolvers.put(resolverScope, new InvocationContextRegistration(federatedContext));
+ }
+
+ protected final void addResolver(Scope resolverScope, AttributeResolver resolver) throws IllegalArgumentException
+ {
+ if (resolverScope == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (resolver == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ resolvers.put(resolverScope, new AttributeResolverRegistration(resolver));
+ }
+
+ public AttributeResolver getAttributeResolver(Scope attrScope) throws IllegalArgumentException
+ {
+ if (attrScope == null)
+ {
+ throw new IllegalArgumentException("Attribute name must not be null");
+ }
+ AttributeResolver resolver = null;
+ Registration registration = (Registration)resolvers.get(attrScope);
+ if (registration instanceof AttributeResolverRegistration)
+ {
+ resolver = ((AttributeResolverRegistration)registration).resolver;
+ }
+ else if (registration instanceof InvocationContextRegistration)
+ {
+ InvocationContext federaredContext = ((InvocationContextRegistration)registration).context;
+ resolver = federaredContext.getAttributeResolver(attrScope);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Scope not recognized " + attrScope);
+ }
+ return resolver;
+ }
+
+ public Object getAttribute(Scope attrScope, Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException("Attribute name must not be null");
+ }
+ if (attrScope == null)
+ {
+ throw new IllegalArgumentException("Attribute scope must not be null");
+ }
+ AttributeResolver resolver = getAttributeResolver(attrScope);
+ if (resolver == null)
+ {
+ throw new IllegalArgumentException("Scope not recognized " + attrScope);
+ }
+ return resolver.getAttribute(attrKey);
+ }
+
+ public void setAttribute(Scope attrScope, Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException("Attribute name must not be null");
+ }
+ if (attrScope == null)
+ {
+ throw new IllegalArgumentException("Attribute scope must not be null");
+ }
+ AttributeResolver resolver = getAttributeResolver(attrScope);
+ if (resolver == null)
+ {
+ throw new IllegalArgumentException("Scope not recognized " + attrScope);
+ }
+ resolver.setAttribute(attrKey, attrValue);
+ }
+
+ public void removeAttribute(Scope attrScope, Object attrKey)
+ {
+ setAttribute(attrScope, attrKey, null);
+ }
+
+ /**
+ * Typed registration to avoid issues classes that implement both interfaces AttributeResolver and
+ * InvocationContext.
+ */
+ private abstract static class Registration
+ {
+ }
+
+ private final static class AttributeResolverRegistration extends Registration
+ {
+ /** . */
+ private final AttributeResolver resolver;
+
+ private AttributeResolverRegistration(AttributeResolver resolver)
+ {
+ this.resolver = resolver;
+ }
+ }
+
+ private final static class InvocationContextRegistration extends Registration
+ {
+ /** . */
+ private final InvocationContext context;
+
+ private InvocationContextRegistration(InvocationContext context)
+ {
+ this.context = context;
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/AttributeResolver.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/AttributeResolver.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/AttributeResolver.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+import java.util.Set;
+
+/**
+ * An attribute resolver.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface AttributeResolver
+{
+ /**
+ * Returns the set of keys of the attributes bound in that resolver.
+ *
+ * @return a set of keys
+ */
+ Set getKeys();
+
+ /**
+ * Return an attribute from this resolver.
+ *
+ * @param attrKey
+ * @return the attribute value or null if it is not found
+ * @throws IllegalArgumentException if the attribute key is not valid
+ */
+ Object getAttribute(Object attrKey) throws IllegalArgumentException;
+
+ /**
+ * Update an attribute value on this resolve. If the attribute value is null the resolver must treat the operation as
+ * a removal of the attribute.
+ *
+ * @param attrKey
+ * @param attrValue the attribute value
+ * @throws IllegalArgumentException if the attribute key is not valid
+ */
+ void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException;
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyAttributeResolver.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyAttributeResolver.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyAttributeResolver.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.portal.common.invocation;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class EmptyAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ private static final EmptyAttributeResolver instance = new EmptyAttributeResolver();
+
+ public static EmptyAttributeResolver getInstance()
+ {
+ return instance;
+ }
+
+ public Set getKeys()
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return null;
+ }
+
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyInterceptorStackFactory.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyInterceptorStackFactory.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/EmptyInterceptorStackFactory.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class EmptyInterceptorStackFactory implements InterceptorStackFactory
+{
+
+ /** . */
+ private static final InterceptorStack instance = new InterceptorStack()
+ {
+ public int getLength()
+ {
+ return 0;
+ }
+
+ public Interceptor getInterceptor(int index) throws ArrayIndexOutOfBoundsException
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ };
+
+ public static InterceptorStack getInstance()
+ {
+ return instance;
+ }
+
+ public InterceptorStack getInterceptorStack()
+ {
+ return getInstance();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public interface Interceptor
+{
+ /**
+ * todo
+ */
+ Object invoke(Invocation invocation) throws Exception, InvocationException;
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Interceptor.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * A wrapper for a list of interceptors.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public interface InterceptorStack
+{
+ /**
+ * Returns the stack length.
+ *
+ * @return the length
+ */
+ int getLength();
+
+ /**
+ * Return the interceptor at the specified index.
+ *
+ * @param index the interceptor index in the stack
+ * @return the specified interceptor
+ * @throws ArrayIndexOutOfBoundsException if the index is not valid
+ */
+ Interceptor getInterceptor(int index) throws ArrayIndexOutOfBoundsException;
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStack.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStackFactory.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStackFactory.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InterceptorStackFactory.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface InterceptorStackFactory
+{
+ InterceptorStack getInterceptorStack();
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,166 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * A generic invocation object.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5597 $
+ */
+public abstract class Invocation
+{
+
+ /** . */
+ public static final InterceptorStack EMPTY_STACK = new InterceptorStack()
+ {
+ public int getLength()
+ {
+ return 0;
+ }
+ public Interceptor getInterceptor(int index) throws ArrayIndexOutOfBoundsException
+ {
+ throw new ArrayIndexOutOfBoundsException();
+ }
+ };
+
+ /** The current index in the chain. */
+ private int currentIndex = 0;
+
+ /** The current interceptor stack. */
+ private InterceptorStack currentStack = Invocation.EMPTY_STACK;
+
+ /** . */
+ private InvocationHandler handler;
+
+ /**
+ * Return the invocation context or throw IllegalStateException.
+ *
+ * @return the invocation context
+ * @throws IllegalStateException if no context is associated with this invocation
+ */
+ public abstract InvocationContext getContext() throws IllegalStateException;
+
+ /**
+ * @see InvocationContext#getAttribute(Scope,Object)
+ */
+ public Object getAttribute(Scope attrScope, Object attrKey) throws IllegalArgumentException
+ {
+ return getContext().getAttribute(attrScope, attrKey);
+ }
+
+ /**
+ * @see InvocationContext#setAttribute(Scope,Object,Object)
+ */
+ public void setAttribute(Scope attrScope, Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ getContext().setAttribute(attrScope, attrKey, attrValue);
+ }
+
+ /**
+ * @see InvocationContext#removeAttribute(Scope,Object)
+ */
+ public void removeAttribute(Scope attrScope, Object attrKey) throws IllegalArgumentException
+ {
+ getContext().removeAttribute(attrScope, attrKey);
+ }
+
+ public InvocationHandler getHandler()
+ {
+ return handler;
+ }
+
+ public void setHandler(InvocationHandler handler)
+ {
+ this.handler = handler;
+ }
+
+ /**
+ * Invoke the next interceptor in the chain. If the end of the chain is reached then the <code>dispatch()</code>
+ * is invoked.
+ */
+ public Object invokeNext() throws Exception, InvocationException
+ {
+ if (currentIndex < currentStack.getLength())
+ {
+ try
+ {
+ Interceptor interceptor = currentStack.getInterceptor(currentIndex++);
+ if (interceptor == null)
+ {
+ throw new InvocationException("Null interceptor at index=" + (currentIndex - 1));
+ }
+ else
+ {
+ return interceptor.invoke(this);
+ }
+ }
+ finally
+ {
+ currentIndex--;
+ }
+ }
+ else
+ {
+ if (handler == null)
+ {
+ throw new InvocationException("No handler");
+ }
+ else
+ {
+ return handler.invoke(this);
+ }
+ }
+ }
+
+ /**
+ * Execute the invocation through the chain of interceptors.
+ */
+ public Object invoke(InterceptorStack newStack) throws Exception, InvocationException
+ {
+ if (newStack == null)
+ {
+ throw new InvocationException("Cannot invoke with a null interceptor[]");
+ }
+
+ // Save the previous context
+ InterceptorStack previousInterceptors = currentStack;
+ int previousIndex = currentIndex;
+
+ try
+ {
+ // Set the new context
+ currentStack = newStack;
+ currentIndex = 0;
+
+ // Perform invoke
+ return invokeNext();
+ }
+ finally
+ {
+ // Restablish the previous context
+ currentStack = previousInterceptors;
+ currentIndex = previousIndex;
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Invocation.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationContext.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationContext.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationContext.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,68 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface InvocationContext
+{
+ /**
+ * Return the attribute resolver of this context.
+ *
+ * @param attrScope the attribute resolver scope
+ * @return the attribute resolver or null if not found
+ * @throws IllegalArgumentException if the attribute scope is invalid
+ */
+ AttributeResolver getAttributeResolver(Scope attrScope) throws IllegalArgumentException;
+
+ /**
+ * Returns an attribute value.
+ *
+ * @param attrScope the attribute scope
+ * @param attrKey
+ * @return the attribute value or null if not found
+ * @throws IllegalArgumentException if the attribute key or the attribute scope is not valid
+ */
+ Object getAttribute(Scope attrScope, Object attrKey) throws IllegalArgumentException;
+
+ /**
+ * Update an attribute value.
+ *
+ * @param attrScope the attribute scope
+ * @param attrKey
+ * @param attrValue the attribute value
+ * @throws IllegalArgumentException if the attribute key or the attribute scope is not valid
+ */
+ void setAttribute(Scope attrScope, Object attrKey, Object attrValue) throws IllegalArgumentException;
+
+ /**
+ * Remove an attribute value. If the attribute value is null the resolver must treat the operation as a removal of
+ * the attribute.
+ *
+ * @param attrKey
+ * @throws IllegalArgumentException if the attribute key is null or the attribute scope is not valid
+ */
+ void removeAttribute(Scope attrScope, Object attrKey);
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class InvocationException extends RuntimeException
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 7607329736844391861L;
+
+ public InvocationException()
+ {
+ }
+
+ public InvocationException(String message)
+ {
+ super(message);
+ }
+
+ public InvocationException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public InvocationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationHandler.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationHandler.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/InvocationHandler.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface InvocationHandler
+{
+ /**
+ *
+ */
+ Object invoke(Invocation invocation) throws Exception, InvocationException;
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Scope.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Scope.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/Scope.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,88 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation;
+
+/**
+ * The scope of an attribute.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Scope
+{
+
+ /** Principal scope. */
+ public static final Scope PRINCIPAL_SCOPE = new Scope("principal");
+
+ /** Request scope. */
+ public static final Scope REQUEST_SCOPE = new Scope("request");
+
+ /** Thread scope. */
+ public static final Scope THREAD_SCOPE = new Scope("thread");
+
+ /** Session scope. */
+ public static final Scope SESSION_SCOPE = new Scope("session");
+
+ /** Invocation scope. */
+ public static final Scope INVOCATION_SCOPE = new Scope("invocation");
+
+ /** The value. */
+ private final String value;
+
+ /**
+ * @param value the scope value
+ * @throws IllegalArgumentException if the value is null
+ */
+ public Scope(String value) throws IllegalArgumentException
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.value = value;
+ }
+
+ public int hashCode()
+ {
+ return value.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof Scope)
+ {
+ Scope that = (Scope)obj;
+ return value.equals(that.value);
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ return value;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/AbstractSessionAttributeResolver.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/AbstractSessionAttributeResolver.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/AbstractSessionAttributeResolver.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public abstract class AbstractSessionAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ protected final HttpServletRequest req;
+
+ public AbstractSessionAttributeResolver(HttpServletRequest req)
+ {
+ if (req == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.req = req;
+ }
+
+
+ public Set getKeys()
+ {
+ Map map = getMap(false);
+
+ //
+ if (map != null)
+ {
+ return map.keySet();
+ }
+ else
+ {
+ return Collections.EMPTY_SET;
+ }
+ }
+
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Object value = null;
+ Map map = getMap(false);
+ if (map != null)
+ {
+ value = map.get(attrKey);
+ }
+ return value;
+ }
+
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Map map = getMap(false);
+ if (map != null)
+ {
+ if (attrValue != null)
+ {
+ map.put(attrKey, attrValue);
+ }
+ else
+ {
+ map.remove(attrKey);
+ }
+ }
+ else
+ {
+ if (attrValue != null)
+ {
+ map = getMap(true);
+ map.put(attrKey, attrValue);
+ }
+ }
+ }
+
+ protected abstract String getMapKey();
+
+ protected Map createMap(String mapKey)
+ {
+ return new HashMap();
+ }
+
+ private Map getMap(boolean create)
+ {
+ HttpSession session = req.getSession(create);
+ if (session != null)
+ {
+ String mapKey = getMapKey();
+ Map map = (Map)session.getAttribute(mapKey);
+ if (map == null)
+ {
+ map = createMap(mapKey);
+ session.setAttribute(mapKey, map);
+ }
+ return map;
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/MapAttributeResolver.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/MapAttributeResolver.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/MapAttributeResolver.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MapAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ private final Map attributes;
+
+ public MapAttributeResolver(Map attributes)
+ {
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.attributes = attributes;
+ }
+
+ public MapAttributeResolver()
+ {
+ this(new HashMap());
+ }
+
+
+ public Set getKeys()
+ {
+ return attributes.keySet();
+ }
+
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return attributes.get(attrKey);
+ }
+
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (attrValue != null)
+ {
+ attributes.put(attrKey, attrValue);
+ }
+ else
+ {
+ attributes.remove(attrKey);
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/PrincipalAttributeResolver.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/PrincipalAttributeResolver.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/PrincipalAttributeResolver.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,87 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import javax.servlet.http.HttpServletRequest;
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class PrincipalAttributeResolver extends AbstractSessionAttributeResolver
+{
+
+ /** . */
+ private String cachedPrincipalName;
+
+ /** . */
+ private String cachedMapKey;
+
+ public PrincipalAttributeResolver(HttpServletRequest req)
+ {
+ super(req);
+ }
+
+ protected String getMapKey()
+ {
+ Principal principal = req.getUserPrincipal();
+
+ //
+ if (cachedMapKey != null)
+ {
+ if (cachedPrincipalName == null)
+ {
+ if (principal != null)
+ {
+ cachedMapKey = null;
+ }
+ }
+ else
+ {
+ if (principal == null || (cachedPrincipalName.equals(principal.getName()) == false))
+ {
+ cachedMapKey = null;
+ }
+ }
+ }
+
+ //
+ if (cachedMapKey == null)
+ {
+ if (principal == null)
+ {
+ cachedMapKey = "portal.principal";
+ cachedPrincipalName = null;
+ }
+ else
+ {
+ cachedMapKey = "portal.principal." + principal.getName();
+ cachedPrincipalName = principal.getName();
+ }
+ }
+
+ //
+ return cachedMapKey;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/RequestAttributeResolver.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/RequestAttributeResolver.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/RequestAttributeResolver.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,92 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import org.jboss.portal.common.invocation.AttributeResolver;
+import org.jboss.portal.common.util.Tools;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class RequestAttributeResolver implements AttributeResolver
+{
+
+ /** . */
+ private final HttpServletRequest req;
+
+ public RequestAttributeResolver(HttpServletRequest req)
+ {
+ if (req == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.req = req;
+ }
+
+
+ public Set getKeys()
+ {
+ return Tools.toSet(req.getAttributeNames());
+ }
+
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException("No null attribute key accepted");
+ }
+ if (attrKey instanceof String == false)
+ {
+ throw new IllegalArgumentException("Attribute key must be a string");
+ }
+
+ //
+ return req.getAttribute((String)attrKey);
+ }
+
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException("No null attribute key accepted");
+ }
+ if (attrKey instanceof String == false)
+ {
+ throw new IllegalArgumentException("Attribute key must be a string");
+ }
+
+ //
+ if (attrValue != null)
+ {
+ req.setAttribute((String)attrKey, attrValue);
+ }
+ else
+ {
+ req.removeAttribute((String)attrKey);
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/SessionAttributeResolver.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/SessionAttributeResolver.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/invocation/resolver/SessionAttributeResolver.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.invocation.resolver;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class SessionAttributeResolver extends AbstractSessionAttributeResolver
+{
+
+ /** . */
+ private final String mapKey;
+
+ public SessionAttributeResolver(HttpServletRequest req, String mapKey)
+ {
+ super(req);
+
+ //
+ if (mapKey == null)
+ {
+ throw new IllegalArgumentException("No null map key allowed");
+ }
+
+ //
+ this.mapKey = mapKey;
+ }
+
+ protected String getMapKey()
+ {
+ return mapKey;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/IOTools.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/IOTools.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/IOTools.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,438 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.io;
+
+import org.jboss.portal.common.util.Tools;
+import org.apache.log4j.Logger;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.InvocationTargetException;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.ByteArrayOutputStream;
+import java.io.Writer;
+import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+
+/**
+ * IO tools.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IOTools
+{
+
+ /** The logger. */
+ public static final Logger log = Logger.getLogger(IOTools.class);
+
+ /** . */
+ private static final Object[] EMPTY_ARGS = new Object[0];
+
+ /** . */
+ private static final Class[] EMPTY_PARAMETER_TYPES = new Class[0];
+
+ /**
+ * <p>Attempt to close an object. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * <p>It will try to obtain a <code>close()</code> method by reflection and it
+ * will be invoked only if the method is public and not static. If the method is called, any <code>Error</code>
+ * or <code>RuntimeException</code> will be rethrown, any other kind of throwable will not be rethrown in any form.</p>
+ *
+ * @param closable the object to close
+ */
+ public static void safeClose(Object closable)
+ {
+ if (closable != null)
+ {
+ try
+ {
+ Method m = closable.getClass().getMethod("close", EMPTY_PARAMETER_TYPES);
+ if (Modifier.isStatic(m.getModifiers()))
+ {
+ log.warn("close() method on closable object is static");
+ return;
+ }
+ m.invoke(closable, EMPTY_ARGS);
+ }
+ catch (NoSuchMethodException e)
+ {
+ log.warn("The closable object does not have a close() method", e);
+ }
+ catch (IllegalAccessException e)
+ {
+ log.warn("Cannot access close() method on closable object", e);
+ }
+ catch (InvocationTargetException e)
+ {
+ Throwable t = e.getCause();
+
+ //
+ if (t instanceof RuntimeException)
+ {
+ log.error("The close() method threw a runtime exception", t);
+ throw (RuntimeException)t;
+ }
+ else if (t instanceof Error)
+ {
+ log.error("The close() method threw an error", t);
+ throw (Error)t;
+ }
+ else if (t instanceof Exception)
+ {
+ log.error("The close() method threw an exception", t);
+ }
+ else
+ {
+ log.error("The close() method threw an unexpected throwable", t);
+ }
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>OutputStream</code>. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param out the stream to close
+ */
+ public static void safeClose(OutputStream out)
+ {
+ if (out != null)
+ {
+ try
+ {
+ out.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing outstream", e);
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>InputStream</code>. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param in the stream to close
+ */
+ public static void safeClose(InputStream in)
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing inputstream", e);
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>Reader</code>. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param reader the stream to close
+ */
+ public static void safeClose(Reader reader)
+ {
+ if (reader != null)
+ {
+ try
+ {
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing reader", e);
+ }
+ }
+ }
+
+ /**
+ * <p>Attempt to close an <code>Writer</code>. Null argument value is authorized and no operation will be performed in that
+ * use case.</p>
+ *
+ * @param writer the stream to close
+ */
+ public static void safeClose(Writer writer)
+ {
+ if (writer != null)
+ {
+ try
+ {
+ writer.close();
+ }
+ catch (IOException e)
+ {
+ log.error("Error while closing writer", e);
+ }
+ }
+ }
+
+ /**
+ * @see #getBytes(java.io.InputStream, int)
+ * @param in the input stream
+ * @return the bytes read from the stream
+ * @throws java.io.IOException
+ * @throws IllegalArgumentException if the input stream is null
+ */
+ public static byte[] getBytes(InputStream in) throws IOException, IllegalArgumentException
+ {
+ return getBytes(in, Tools.DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Get the bytes from the provided input stream. No attempt will be made to close the stream.
+ *
+ * @param in the input stream
+ * @param bufferSize the buffer size used to copy the bytes
+ * @return the bytes read from the stream
+ * @throws java.io.IOException
+ * @throws IllegalArgumentException if the input stream is null or the buffer size < 1
+ */
+ public static byte[] getBytes(InputStream in, int bufferSize) throws IOException, IllegalArgumentException
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ copy(in, out, bufferSize);
+ return out.toByteArray();
+ }
+
+ /**
+ * @see #copy(java.io.InputStream, java.io.OutputStream, int)
+ * @param in the incoming stream
+ * @param out the outcoming stream
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public static void copy(InputStream in, OutputStream out) throws IOException
+ {
+ copy(in, out, Tools.DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Pipe an incoming stream in an outcoming stream until no bytes is available from the input stream.
+ * No attempts will be made to close the streams.
+ *
+ * @param in the incoming stream
+ * @param out the outcoming stream
+ * @param bufferSize the buffer size
+ * @throws IllegalArgumentException if bufferSize < 1 or an argument is null
+ */
+ public static void copy(InputStream in, OutputStream out, int bufferSize) throws IOException
+ {
+ // arguments check
+ if (in == null)
+ {
+ throw new IllegalArgumentException("null in");
+ }
+ if (out == null)
+ {
+ throw new IllegalArgumentException("null out");
+ }
+ if (bufferSize < 1)
+ {
+ throw new IllegalArgumentException("Buffer size is too small");
+ }
+
+ // do the job
+ byte[] buffer = new byte[bufferSize];
+ while (true)
+ {
+ int i = in.read(buffer);
+ if (i == 0)
+ {
+ continue;
+ }
+ if (i == -1)
+ {
+ break;
+ }
+ out.write(buffer, 0, i);
+ }
+ }
+
+ /**
+ * Pipe an input stream in an output stream.
+ *
+ * @param reader the incoming reader
+ * @param writer the outcoming writer
+ * @throws IllegalArgumentException if an argument is null
+ */
+ public static void copy(Reader reader, Writer writer) throws IOException
+ {
+ copy(reader, writer, Tools.DEFAULT_BUFFER_SIZE);
+ }
+
+ /**
+ * Pipe an incoming stream in an outcoming stream.
+ *
+ * @param reader the incoming reader
+ * @param writer the outcoming writer
+ * @param bufferSize the buffer size
+ * @throws IllegalArgumentException if bufferSize < 1 or an argument is null
+ */
+ public static void copy(Reader reader, Writer writer, int bufferSize) throws IOException
+ {
+ // arguments check
+ if (reader == null)
+ {
+ throw new IllegalArgumentException("null in");
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("null out");
+ }
+ if (bufferSize < 1)
+ {
+ throw new IllegalArgumentException("Buffer size is too small");
+ }
+
+ // do the job
+ char[] buffer = new char[bufferSize];
+ while (true)
+ {
+ int i = reader.read(buffer);
+ if (i == 0)
+ {
+ continue;
+ }
+ if (i == -1)
+ {
+ break;
+ }
+ writer.write(buffer, 0, i);
+ }
+ }
+
+ /**
+ * Clone an object implementing the <code>Serializable</code> interface.
+ *
+ * @param serializable
+ * @return
+ * @throws IllegalArgumentException if the serializable object is null
+ * @throws IOException
+ */
+ public static Object clone(Serializable serializable) throws IllegalArgumentException, IOException
+ {
+ try
+ {
+ return unserialize(serialize(serializable));
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new Error("Got a class not found exception for a class that was used", e);
+ }
+ }
+
+ public static byte[] serialize(Serializable serializable) throws IllegalArgumentException, IOException
+ {
+ if (serializable == null)
+ {
+ throw new IllegalArgumentException("No null serializable accepted");
+ }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(serializable);
+ oos.close();
+ return baos.toByteArray();
+ }
+
+ public static Serializable unserialize(byte[] bytes) throws IllegalArgumentException, IOException, ClassNotFoundException
+ {
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("No null serializable accepted");
+ }
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ return (Serializable)ois.readObject();
+ }
+
+ /**
+ * Check that the provided input stream is buffered. If the argument is already an instance of <code>BufferedInputStream</code>
+ * no operation will be performed, otherwise a instance of <code>BufferedInputStream</code> will be created and returned.
+ *
+ * If the provided argument is null, the null value is returned.
+ *
+ * @param in the stream
+ * @return a buffered wrapper
+ */
+ public static BufferedInputStream safeBufferedWrapper(InputStream in)
+ {
+ if (in != null)
+ {
+ if (in instanceof BufferedInputStream)
+ {
+ return (BufferedInputStream)in;
+ }
+ else
+ {
+ return new BufferedInputStream(in);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Check that the provided output stream is buffered. If the argument is already an instance of <code>BufferedOutputStream</code>
+ * no operation will be performed, otherwise a instance of <code>BufferedOutputStream</code> will be created and returned.
+ *
+ * If the provided argument is null, the null value is returned.
+ *
+ * @param out the stream
+ * @return a buffered wrapper
+ */
+ public static BufferedOutputStream safeBufferedWrapper(OutputStream out)
+ {
+ if (out != null)
+ {
+ if (out instanceof BufferedOutputStream)
+ {
+ return (BufferedOutputStream)out;
+ }
+ else
+ {
+ return new BufferedOutputStream(out);
+ }
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/UndeclaredIOException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/UndeclaredIOException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/UndeclaredIOException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.io;
+
+import java.io.IOException;
+import java.lang.reflect.UndeclaredThrowableException;
+
+/**
+ * Avoid a method to declare an IOException in its signature when it is not necessary.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class UndeclaredIOException extends UndeclaredThrowableException
+{
+ public UndeclaredIOException(IOException undeclaredIOException)
+ {
+ super(undeclaredIOException);
+ }
+
+ public UndeclaredIOException(IOException undeclaredIOException, String s)
+ {
+ super(undeclaredIOException, s);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/io/WriterCharWriter.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,164 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.io;
+
+import org.jboss.portal.common.text.CharWriter;
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WriterCharWriter implements CharWriter
+{
+
+ /** . */
+ private final Writer writer;
+
+ /**
+ * @param writer the target writer
+ * @throws IllegalArgumentException if the writer is null
+ */
+ public WriterCharWriter(Writer writer) throws IllegalArgumentException
+ {
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("No null writer accepted");
+ }
+ this.writer = writer;
+ }
+
+ public CharWriter append(char c) throws UndeclaredIOException
+ {
+ try
+ {
+ writer.write(c);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return this;
+ }
+
+ public CharWriter append(char[] chars, int off, int len) throws UndeclaredIOException
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (len < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off + len > chars.length)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ writer.write(chars, off, len);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return this;
+ }
+
+ public CharWriter append(char[] chars) throws UndeclaredIOException
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ writer.write(chars, 0, chars.length);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return this;
+ }
+
+ public CharWriter append(CharSequence s) throws UndeclaredIOException
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ if (s instanceof String)
+ {
+ writer.write((String)s);
+ }
+ else
+ {
+ for (int i = 0;i < s.length();i++)
+ {
+ char c = s.charAt(i);
+ writer.write(c);
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ return this;
+ }
+
+ public void flush() throws UndeclaredIOException
+ {
+ try
+ {
+ writer.flush();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public void close() throws UndeclaredIOException
+ {
+ try
+ {
+ writer.flush();
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/jar/JarEntryInfo.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/jar/JarEntryInfo.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/jar/JarEntryInfo.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,234 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.jar;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.JarEntry;
+
+/**
+ * Enhance jar entry object by adding more info.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7448 $
+ */
+public class JarEntryInfo implements Comparable
+{
+
+ /** The real jar entry. */
+ private final JarEntry entry;
+
+ /** . */
+ private final List names;
+
+ public JarEntryInfo(JarEntry entry)
+ {
+ if (entry == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ String entryName = entry.getName();
+ ArrayList atoms = new ArrayList();
+
+ //add the root element since this is not actually included in the jar as a entry
+ atoms.add("/");
+
+ int previous = -1;
+ while (true)
+ {
+ int current = entryName.indexOf('/', previous + 1);
+ if (current == -1)
+ {
+ current = entryName.length();
+ }
+ if (current >= entryName.length() - 1)
+ {
+ if (current - previous > 1)
+ {
+ atoms.add(entryName.substring(previous + 1, current));
+ }
+ break;
+ }
+ if (current - previous > 1)
+ {
+ atoms.add(entryName.substring(previous + 1, current));
+ }
+ previous = current;
+ }
+
+ //
+ this.entry = entry;
+ this.names = Collections.unmodifiableList(atoms);
+ }
+
+ public JarEntry getEntry()
+ {
+ return entry;
+ }
+
+ public boolean isDirectory()
+ {
+ return entry.isDirectory();
+ }
+
+ public int size()
+ {
+ return names.size();
+ }
+
+ public List getNames()
+ {
+ return names;
+ }
+
+ public String getName(int index)
+ {
+ return (String)names.get(index);
+ }
+
+ public boolean isChildOf(JarEntryInfo parent) throws IllegalArgumentException
+ {
+ if (parent == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!parent.isDirectory())
+ {
+ return false;
+ }
+ if (parent.size() + 1 != names.size())
+ {
+ return false;
+ }
+ return parent.names.equals(parent.names.subList(0, names.size() - 1));
+ }
+
+ public boolean isDescendantOf(JarEntryInfo ancestor) throws IllegalArgumentException
+ {
+ if (ancestor == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (!ancestor.isDirectory())
+ {
+ return false;
+ }
+ if (ancestor.names.size() >= names.size())
+ {
+ return false;
+ }
+ return ancestor.names.equals(names.subList(0, ancestor.size()));
+ }
+
+ public URL toURL(URL jarURL) throws IllegalArgumentException, IllegalStateException, MalformedURLException
+ {
+ if (jarURL == null)
+ {
+ throw new IllegalArgumentException("No null jarURL");
+ }
+ if (isDirectory())
+ {
+ throw new IllegalStateException("Cannot create dir URL");
+ }
+ StringBuffer tmp = new StringBuffer(jarURL.toString()).append("!/");
+ for (int i = 0; i < names.size(); i++)
+ {
+ String atom = (String)names.get(i);
+ tmp.append(i > 0 ? "/" : "").append(atom);
+ }
+ return new URL("jar", "", tmp.toString());
+ }
+
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer();
+ for (int i = 0; i < names.size(); i++)
+ {
+ String atom = (String)names.get(i);
+ tmp.append(i > 0 ? "/" : "").append(atom);
+ }
+ if (entry.isDirectory())
+ {
+ tmp.append("/");
+ }
+ return tmp.toString();
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof JarEntryInfo)
+ {
+ return compareTo(obj) == 0;
+ }
+ return false;
+ }
+
+ public int compareTo(Object obj)
+ {
+ JarEntryInfo that = (JarEntryInfo)obj;
+ Iterator i1 = this.getNames().iterator();
+ Iterator i2 = that.getNames().iterator();
+ while (true)
+ {
+ if (i1.hasNext())
+ {
+ Object o = i1.next();
+ String s1 = (String)o;
+ if (i2.hasNext())
+ {
+ String s2 = (String)i2.next();
+ int res = s1.compareTo(s2);
+ if (res != 0)
+ {
+ return res;
+ }
+ }
+ else
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ if (i2.hasNext())
+ {
+ return -1;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/jar/JarInfo.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/jar/JarInfo.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/jar/JarInfo.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.jar;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class JarInfo
+{
+
+ /** . */
+ private SortedSet entries;
+
+ public JarInfo(JarFile file)
+ {
+ if (file == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ entries = new TreeSet();
+ for (Enumeration e = file.entries(); e.hasMoreElements();)
+ {
+ JarEntry entry = (JarEntry)e.nextElement();
+ JarEntryInfo info = new JarEntryInfo(entry);
+ entries.add(info);
+ }
+ }
+
+ public JarInfo(JarInputStream in) throws IOException
+ {
+ if (in == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ entries = new TreeSet();
+ for (JarEntry entry = in.getNextJarEntry(); entry != null; entry = in.getNextJarEntry())
+ {
+ JarEntryInfo info = new JarEntryInfo(entry);
+ entries.add(info);
+ }
+ }
+
+ public Iterator entries()
+ {
+ return entries.iterator();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,221 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit;
+
+import junit.framework.Assert;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Add more assert methods.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7374 $
+ */
+public class ExtendedAssert extends Assert
+{
+
+ /** @see #assertEquals(Object[],Object[]) */
+ public static void assertEquals(Object[] expected, Object[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ /** Test equality as defined by java.util.Array#equals(Object[], Object[]). */
+ public static void assertEquals(String message, Object[] expected, Object[] actual)
+ {
+ if (Arrays.equals(expected, actual))
+ {
+ return;
+ }
+ fail(format(message, expected, actual));
+ }
+
+ /** @see #assertEquals(char[],char[]) */
+ public static void assertEquals(char[] expected, char[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ /** Test equality as defined by java.util.Array#equals(char[], char[]). */
+ public static void assertEquals(String message, char[] expected, char[] actual)
+ {
+ if (Arrays.equals(expected, actual))
+ {
+ return;
+ }
+ fail(format(message, expected, actual));
+ }
+
+ /** @see #assertEquals(byte[],byte[]) */
+ public static void assertEquals(byte[] expected, byte[] actual)
+ {
+ assertEquals(null, expected, actual);
+ }
+
+ /** Test equality as defined by java.util.Array#equals(char[], char[]). */
+ public static void assertEquals(String message, byte[] expected, byte[] actual)
+ {
+ if (Arrays.equals(expected, actual))
+ {
+ return;
+ }
+ fail(format(message, expected, actual));
+ }
+
+ private static String format(String message, Object expected, Object actual)
+ {
+ String formatted = "";
+ if (message != null)
+ {
+ formatted = message + " ";
+ }
+ return formatted + "expected:<" + format(expected) + "> but was:<" + format(actual) + ">";
+ }
+
+ private static String format(Object o)
+ {
+ if (o instanceof Object[])
+ {
+ Object[] array = (Object[])o;
+ StringBuffer buffer = new StringBuffer("[");
+ for (int i = 0; i < array.length; i++)
+ {
+ buffer.append(i == 0 ? "" : ",").append(String.valueOf(array[i]));
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+ else
+ {
+ return String.valueOf(o);
+ }
+ }
+
+ public static void assertEquals(Object[] expected, Object[] tested, boolean isOrderRelevant, String failMessage)
+ {
+ if (isOrderRelevant)
+ {
+ if (!Arrays.equals(expected, tested))
+ {
+ fail(failMessage);
+ }
+ }
+ else
+ {
+ boolean equals = (expected == tested);
+
+ if (!equals)
+ {
+ if (expected == null || tested == null)
+ {
+ fail(failMessage + " Not both null.");
+ }
+
+ if (expected.getClass().getComponentType() != tested.getClass().getComponentType())
+ {
+ fail(failMessage + " Different classes.");
+ }
+
+ if (expected.length != tested.length)
+ {
+ fail(failMessage + " Different sizes (tested: " + tested.length + ", expected: " + expected.length + ").");
+ }
+
+ List expectedList = Arrays.asList(expected);
+ List testedList = Arrays.asList(tested);
+ if (!expectedList.containsAll(testedList))
+ {
+ fail(failMessage);
+ }
+ }
+ }
+ }
+
+ public static void assertEquals(Object[] expected, Object[] tested, boolean isOrderRelevant, String failMessage, Decorator decorator)
+ {
+ Object[] decoratedExpected = null, decoratedTested = null;
+ if (decorator != null)
+ {
+ decoratedExpected = decorate(expected, decorator);
+ decoratedTested = decorate(tested, decorator);
+ }
+
+ assertEquals(decoratedExpected, decoratedTested, isOrderRelevant, failMessage);
+ }
+
+ public static Object[] decorate(Object[] toBeDecorated, Decorator decorator)
+ {
+ if (toBeDecorated != null)
+ {
+ DecoratedObject[] decorated = new DecoratedObject[toBeDecorated.length];
+ for (int i = 0; i < decorated.length; i++)
+ {
+ decorated[i] = new DecoratedObject(toBeDecorated[i], decorator);
+ }
+ return decorated;
+ }
+ return null;
+
+ }
+
+ public static void assertString1ContainsString2(String string1, String string2)
+ {
+ assertTrue("<" + string1 + "> does not contain <" + string2 + ">", string1.indexOf(string2) >= 0);
+ }
+
+ public static interface Decorator
+ {
+ void decorate(Object decorated);
+ }
+
+ public static class DecoratedObject
+ {
+ private Decorator decorator;
+ private Object decorated;
+
+ public Object getDecorated()
+ {
+ return decorated;
+ }
+
+ public DecoratedObject(Object decorated, Decorator decorator)
+ {
+ this.decorator = decorator;
+ this.decorated = decorated;
+ }
+
+ public boolean equals(Object obj)
+ {
+ decorator.decorate(decorated);
+ return decorator.equals(obj);
+ }
+
+ public String toString()
+ {
+ decorator.decorate(decorated);
+ return decorator.toString();
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ExtendedAssert.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,290 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit;
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class TransactionAssert extends Assert
+{
+
+ private static final String[] STATUS_NAMES = {
+ "STATUS_ACTIVE",
+ "STATUS_MARKED_ROLLBACK",
+ "STATUS_PREPARED",
+ "STATUS_COMMITTED",
+ "STATUS_ROLLEDBACK",
+ "STATUS_UNKNOWN",
+ "STATUS_NO_TRANSACTION",
+ "STATUS_PREPARING",
+ "STATUS_COMMITTING",
+ "STATUS_ROLLING_BACK"};
+
+ /**
+ * Decode the status name.
+ *
+ * @param status the status value
+ * @return the translated status name or null if it is not valid
+ */
+ public static String decodeStatus(int status)
+ {
+ if (status >= 0 && status <= STATUS_NAMES.length)
+ {
+ return STATUS_NAMES[status];
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /** . */
+ public static final Terminator NONE = new Terminator("NONE");
+
+ /** . */
+ public static final Terminator MARKED_AS_ROLLBACK = new Terminator("MARKED_AS_ROLLBACK");
+
+ /** . */
+ public static final Terminator MUST_COMMIT = new Terminator("MUST_COMMIT");
+
+ /** . */
+ public static final Terminator MUST_ROLLBACK = new Terminator("MUST ROLLBACK");
+
+ /**
+ *
+ */
+ public static final class Terminator
+ {
+
+ /** . */
+ private final String name;
+
+ public Terminator(String name)
+ {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Assert the status of the current transaction.
+ *
+ * @param expectedStatus the expected status
+ */
+ public static void assertStatusEquals(int expectedStatus)
+ {
+ try
+ {
+ UserTransaction ut = getUserTransaction();
+ int status = ut.getStatus();
+ if (status != expectedStatus)
+ {
+ fail("The status of the current transaction is " + status + " was expecting " + expectedStatus);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Unexpected exception");
+ }
+ }
+
+ /** Commit the transaction or fail. */
+ public static void commitTransaction()
+ {
+ try
+ {
+ getUserTransaction().commit();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Cannot commit transaction");
+ }
+ }
+
+ /** Rollback the transaction or fail. */
+ public static void rollbackTransaction()
+ {
+ rollbackTransaction(true);
+ }
+
+ public static void rollbackTransaction(boolean marked)
+ {
+ try
+ {
+ UserTransaction ut = getUserTransaction();
+ int status = ut.getStatus();
+ if (status == Status.STATUS_MARKED_ROLLBACK)
+ {
+ ut.rollback();
+ if (marked == false)
+ {
+ fail("Transaction should have been marked as rollback");
+ }
+ }
+ else if (status == Status.STATUS_ACTIVE)
+ {
+ ut.rollback();
+ if (marked)
+ {
+ fail("Transaction should have been marked as rollback");
+ }
+ }
+ else
+ {
+ if (marked)
+ {
+ fail("Unexpected transaction status " + status);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Cannot end transaction");
+ }
+ }
+
+ /** Begin a transaction or fail. */
+ public static void beginTransaction()
+ {
+ try
+ {
+ getUserTransaction().begin();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Cannot begin transaction");
+ }
+ }
+
+ /** If no transaction do nothing. End the transaction if it is active or marked for rollback otherwise fail. */
+ public static int endTransaction()
+ {
+ try
+ {
+ UserTransaction ut = getUserTransaction();
+ int status = ut.getStatus();
+ if (status == Status.STATUS_MARKED_ROLLBACK)
+ {
+ ut.rollback();
+ }
+ else if (status == Status.STATUS_ACTIVE)
+ {
+ ut.commit();
+ }
+ else if (status == Status.STATUS_NO_TRANSACTION)
+ {
+ // Do nothing
+ }
+ else
+ {
+ fail("Unexpected transaction status " + status);
+ }
+ return status;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new AssertionFailedError("Cannot end transaction");
+ }
+ }
+
+ /** If no transaction do nothing. End the transaction if it is active or marked for rollback otherwise fail. */
+ public static int endTransaction(Terminator expectedTerminator)
+ {
+ if (expectedTerminator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ UserTransaction ut = getUserTransaction();
+ int status = ut.getStatus();
+ if (status == Status.STATUS_MARKED_ROLLBACK)
+ {
+ ut.rollback();
+ if (expectedTerminator != MARKED_AS_ROLLBACK)
+ {
+ fail("Was expecting the transaction to be marked as rollback instead got " + decodeStatus(status));
+ }
+ }
+ else if (status == Status.STATUS_ACTIVE)
+ {
+ if (expectedTerminator == MUST_COMMIT)
+ {
+ ut.commit();
+ }
+ else if (expectedTerminator == MUST_ROLLBACK)
+ {
+ ut.rollback();
+ }
+ else
+ {
+ fail("Was expecting the transaction to be either commiting or rollbacking instead got " + decodeStatus(status));
+ }
+ }
+ else if (status == Status.STATUS_NO_TRANSACTION)
+ {
+ if (expectedTerminator != NONE)
+ {
+ fail("Was expecting no transaction instead got " + decodeStatus(status));
+ }
+ }
+ else
+ {
+ fail("Unexpected transaction status " + decodeStatus(status));
+ }
+ return status;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new AssertionFailedError("Cannot end transaction");
+ }
+ }
+
+ public static UserTransaction getUserTransaction()
+ {
+ try
+ {
+ return (UserTransaction)new InitialContext().lookup("UserTransaction");
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ fail("Cannot obtain user transaction");
+ return null;
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/TransactionAssert.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTask.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTask.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTask.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTask;
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+import org.apache.tools.ant.BuildException;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ConfigurableJUnitTask extends JUnitTask
+{
+
+ public ConfigurableJUnitTask() throws Exception
+ {
+ }
+
+ public void addZest(ConfigurableJUnitTest test)
+ {
+ test.setTask(this);
+ addTest(test);
+ }
+
+ protected void execute(JUnitTest test) throws BuildException
+ {
+ // Delete any existing file
+ File tmp = new File(System.getProperty("java.io.tmpdir"), TestParameter.PARAMETRIZATION_FILE_NAME);
+ if (tmp.exists() && tmp.isFile())
+ {
+ if (!tmp.delete())
+ {
+ throw new Error("Cannot delete previous saved parametrization");
+ }
+ }
+
+ //
+ try
+ {
+ // Basically we are only sure at this time of the execution that the nested parameter map is fully initialized
+ if (test instanceof ConfigurableJUnitTest)
+ {
+ ((ConfigurableJUnitTest)test).saveState();
+ }
+
+ // Let the parent class execute the super class
+ super.execute(test);
+ }
+ finally
+ {
+ // Cleanup any save state
+ if (tmp.exists() && tmp.isFile())
+ {
+ if (!tmp.delete())
+ {
+ tmp.deleteOnExit();
+ }
+ }
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTest.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTest.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableJUnitTest.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,128 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Used by ant to create a representation of the test to run.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ConfigurableJUnitTest extends JUnitTest
+{
+
+ /** . */
+ private final ArrayList nestedParameters;
+
+ /** . */
+ private ConfigurableJUnitTask task;
+
+ /** . */
+ private String id;
+
+ public ConfigurableJUnitTest()
+ {
+ nestedParameters = new ArrayList();
+ }
+
+ public void addParameter(TestParameter parameter)
+ {
+ nestedParameters.add(parameter);
+ }
+
+ public void setTask(ConfigurableJUnitTask task)
+ {
+ this.task = task;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+
+ //
+ TestParameter parameter = new TestParameter();
+ parameter.setName(TestParameter.TEST_ID_PARAM);
+ parameter.setValue(id);
+ addParameter(parameter);
+ }
+
+ /**
+ * Save the state of the junit test on the disk for reuse later in the forked virtual machine.
+ * As there is not clear life cycle of the usage of this class, we need to save the state initially
+ * and on every update.
+ */
+ public void saveState()
+ {
+ try
+ {
+ Map parameters = new HashMap();
+ for (int i = 0; i < nestedParameters.size(); i++)
+ {
+ TestParameter parameter = (TestParameter)nestedParameters.get(i);
+ String[] values = null;
+ if (parameter.value != null)
+ {
+ values = new String[]{parameter.value};
+ }
+ else if (parameter.nestedValues.size() > 0)
+ {
+ values = new String[parameter.nestedValues.size()];
+ for (int j = 0; j < values.length; j++)
+ {
+ values[j] = ((TestParameterValue)parameter.nestedValues.get(j)).text;
+ }
+ }
+ if (values != null)
+ {
+ parameters.put(parameter.name, values);
+ }
+ }
+ File tmp = new File(System.getProperty("java.io.tmpdir"), TestParameter.PARAMETRIZATION_FILE_NAME);
+ tmp.deleteOnExit();
+ FileOutputStream fos = new FileOutputStream(tmp);
+ ObjectOutputStream oos = new ObjectOutputStream(fos);
+ oos.writeObject(parameters);
+ oos.close();
+
+ }
+ catch (IOException e)
+ {
+ throw new Error(e);
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableXMLJUnitResultFormatter.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableXMLJUnitResultFormatter.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/ConfigurableXMLJUnitResultFormatter.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,82 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+import org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter;
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest;
+import org.w3c.dom.Element;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConfigurableXMLJUnitResultFormatter extends XMLJUnitResultFormatter
+{
+
+ /** . */
+ private static final Field f;
+
+ static
+ {
+ try
+ {
+ f = XMLJUnitResultFormatter.class.getDeclaredField("rootElement");
+ if (!f.isAccessible())
+ {
+ f.setAccessible(true);
+ }
+ }
+ catch (NoSuchFieldException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ public void startTestSuite(JUnitTest suite)
+ {
+ super.startTestSuite(suite);
+
+ //
+ Map parameters = TestParameter.readExternalParameters();
+ if (parameters != null)
+ {
+ String[] values = (String[])parameters.get(TestParameter.TEST_ID_PARAM);
+ if (values != null && values.length > 0)
+ {
+ try
+ {
+ String id = values[0];
+ Element rootElement = (Element)f.get(this);
+ rootElement.setAttribute("name", id);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new Error(e);
+ }
+ }
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameter.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameter.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameter.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class TestParameter
+{
+
+ /** . */
+ static final String TEST_ID_PARAM = "test.param.id";
+
+ /** . */
+ static final String PARAMETRIZATION_FILE_NAME = "junit.parameters";
+
+ /** . */
+ protected String name;
+
+ /** . */
+ protected String value;
+
+ /** . */
+ protected ArrayList nestedValues = new ArrayList();
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public void addValue(TestParameterValue value)
+ {
+ nestedValues.add(value);
+ }
+
+ public static Map readExternalParameters()
+ {
+ try
+ {
+ File tmp = new File(System.getProperty("java.io.tmpdir"), PARAMETRIZATION_FILE_NAME);
+ if (tmp.exists() && tmp.isFile())
+ {
+ FileInputStream fis = new FileInputStream(tmp);
+ ObjectInputStream ois = new ObjectInputStream(fis);
+ Map parameters = (Map)ois.readObject();
+ ois.close();
+ return parameters;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ catch (Exception e)
+ {
+ throw new Error(e);
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameterValue.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameterValue.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/junit/ant/TestParameterValue.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.junit.ant;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class TestParameterValue
+{
+
+ /** . */
+ protected String text;
+
+ public void addText(String text)
+ {
+ this.text = text;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.logging;
+
+import org.apache.log4j.Hierarchy;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggerRepository;
+import org.apache.log4j.spi.RepositorySelector;
+import org.apache.log4j.spi.RootCategory;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.jboss.portal.common.util.ResourceLoader;
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.common.io.IOTools;
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Stan Silvert
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7374 $
+ */
+public class LoaderRepositorySelector implements org.apache.log4j.spi.RepositorySelector
+{
+
+ private static boolean initialized = false;
+
+ // This object is used for the guard because it doesn't get
+ // recycled when the application is redeployed.
+ private static Object guard = LogManager.getRootLogger();
+ private static Map repositories = new HashMap();
+ private static LoggerRepository defaultRepository;
+ private static Logger log = Logger.getLogger(LoaderRepositorySelector.class);
+
+ /**
+ * Register with this repository selector.
+ */
+ public static synchronized void register(ClassLoader classloader, ResourceLoader loader, String pathToLog4jFile)
+ {
+ if (classloader == null)
+ {
+ throw new IllegalArgumentException("No classloader provided");
+ }
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("No loader provided");
+ }
+ if (pathToLog4jFile == null)
+ {
+ throw new IllegalArgumentException("No pathToLog4jFile provided");
+ }
+
+ // Set the global RepositorySelector
+ if (!initialized)
+ {
+ // defaultRepository = LogManager.getLoggerRepository();
+ RepositorySelector theSelector = new LoaderRepositorySelector();
+ LogManager.setRepositorySelector(theSelector, guard);
+ initialized = true;
+ }
+
+ InputStream log4JConfig = null;
+ try
+ {
+ log4JConfig = loader.load(pathToLog4jFile);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document doc = builder.parse(log4JConfig);
+ DOMConfigurator conf = new DOMConfigurator();
+
+ Hierarchy hierarchy = new Hierarchy(new RootCategory(Level.DEBUG));
+ conf.doConfigure(doc.getDocumentElement(), hierarchy);
+ repositories.put(classloader, hierarchy);
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ throw new IllegalArgumentException("Cannot load log4j configuration");
+ }
+ finally
+ {
+ IOTools.safeClose(log4JConfig);
+ }
+ }
+
+ public static synchronized void unregister(ClassLoader classloader)
+ {
+ if (classloader == null)
+ {
+ throw new IllegalArgumentException("No classloader provided");
+ }
+ Hierarchy hierarchy = (Hierarchy)repositories.remove(classloader);
+ if (hierarchy != null)
+ {
+ hierarchy.shutdown();
+ }
+ else
+ {
+ System.out.print("No hierarchy found for classloader : ");
+ Writer writer = new PrintWriter(System.out);
+ Tools.dumpClassLoaderHierarchyInfo(writer, classloader);
+ }
+ }
+
+ private LoaderRepositorySelector()
+ {
+ }
+
+ public LoggerRepository getLoggerRepository()
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ LoggerRepository repository = (LoggerRepository)repositories.get(loader);
+ if (repository == null)
+ {
+ return defaultRepository;
+ }
+ else
+ {
+ return repository;
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/LoaderRepositorySelector.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.logging;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+import java.io.Writer;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class Log4JWriter extends Writer
+{
+
+ /** The open/closed status. */
+ private boolean open;
+
+ /** The logger. */
+ private Logger log;
+
+ /** The logging level. */
+ private Level level;
+
+ /**
+ * @throws IllegalArgumentException if log or level is null
+ */
+ public Log4JWriter(Logger log, Level level) throws IllegalArgumentException
+ {
+ if (log == null)
+ {
+ throw new IllegalArgumentException("No logger provided");
+ }
+ if (level == null)
+ {
+ throw new IllegalArgumentException("No level provided");
+ }
+ this.open = false;
+ this.log = log;
+ this.level = level;
+ }
+
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ if (open)
+ {
+ log.log(level, new String(cbuf, off, len));
+ }
+ else
+ {
+ throw new IOException("Stream closed");
+ }
+ }
+
+ public void flush() throws IOException
+ {
+ }
+
+ public void close() throws IOException
+ {
+ open = false;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/logging/Log4JWriter.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupAttribute.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,194 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.markup;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+import org.jboss.portal.common.io.WriterCharWriter;
+import org.jboss.portal.common.text.AbstractCharEncoder;
+import org.jboss.portal.common.text.CharEncoder;
+import org.jboss.portal.common.text.CharWriter;
+import org.jboss.portal.common.text.EncodingException;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+
+/**
+ * A markup attribute.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MarkupAttribute
+{
+
+ /** . */
+ final String name;
+
+ /** . */
+ final String value;
+
+ /** . */
+ final Type type;
+
+ /** . */
+ final String encodedValue;
+
+ /**
+ * @param name the attribute name
+ * @param value the attribute value
+ * @param type the attribute type
+ */
+ public MarkupAttribute(String name, String value, Type type)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name accepted");
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("No null value accepted");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No null type accepted");
+ }
+ this.name = name;
+ this.value = value;
+ this.type = type;
+
+ //
+ StringWriter tmp = new StringWriter();
+ type.encode(value, tmp);
+ this.encodedValue = tmp.toString();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public String getEncodedValue()
+ {
+ return encodedValue;
+ }
+
+ public Type getType()
+ {
+ return type;
+ }
+
+ /** The type of the attribute value. */
+ public abstract static class Type
+ {
+
+ /**
+ * Encode the string in the proper format according to the type.
+ *
+ * @param string the string to encode
+ * @return the encoded string
+ */
+ public abstract void encode(String string, Writer writer) throws UndeclaredIOException;
+
+ private static class CDATAType extends Type
+ {
+ public void encode(String string, Writer writer)
+ {
+ try
+ {
+ writer.write(string);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+ }
+
+ /**
+ * CDATA is a sequence of characters from the document character set and may include character entities. User
+ * agents should interpret attribute values as follows: <ul> <li>Replace character entities with characters,</li>
+ * <li>Ignore line feeds,</li> <li>Replace each carriage return or tab with a single space.</li> </ul>
+ */
+ public static final Type CDATA = new CDATAType();
+
+ /**
+ * NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]),
+ * hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
+ */
+ public static final Type NAME = new CDATAType();
+
+ /** %ContentType required : CDATA -- media type, as per [RFC2045]. */
+ public static final Type CONTENT_TYPE = new CDATAType();
+
+ private static final char[] SLASH_ARRAY = "/".toCharArray();
+
+ /** %URI : CDATA -- a Uniform Resource Identifier, see [URI]. */
+ public static final Type URI = new CDATAType()
+ {
+ {
+ // Patches the encoder to let '/' not being encoded
+ encoder = new AbstractCharEncoder()
+ {
+ public void encode(char c, CharWriter writer) throws EncodingException
+ {
+ if (c == '/')
+ {
+ writer.append(SLASH_ARRAY);
+ }
+ else
+ {
+ FastURLEncoder.getUTF8Instance().encode(c, writer);
+ }
+ }
+ };
+ }
+
+ /** Our encoder for URI. */
+ final CharEncoder encoder;
+
+ public void encode(String string, Writer writer)
+ {
+ encoder.encode(string, new WriterCharWriter(writer));
+ }
+ };
+
+ /** %LinkTypes : CDATA -- space-separated list of link types. */
+ public static final Type LINK_TYPES = new CDATAType();
+
+ /** %Text : CDATA : CDATA. */
+ public static final Type TEXT = new CDATAType();
+
+ /** %MediaDesc : CDATA -- single or comma-separated list of media descriptors. */
+ public static final Type MEDIA_DESC = new CDATAType();
+
+ /** %URI : CDATA -- a Uniform Resource Identifier, see [URI]. */
+ public static final Type HREF = new CDATAType();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupElement.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupElement.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/markup/MarkupElement.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,210 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.markup;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * An markup element.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MarkupElement
+{
+
+ /** . */
+ final String name;
+
+ /** . */
+ final String bodyContent;
+
+ /**
+ * If true and the body content is null then output the start tag and the end tag instead of an empty tag. The use
+ * case is for the script element which when it is empty raise issues on IE, so it start element and end element have
+ * to be used.
+ */
+ final boolean neverEmpty;
+
+ /** . */
+ final MarkupAttribute[] attributes;
+
+ /**
+ * @param name the element name
+ * @param bodyContent the optional body content
+ * @param neverEmpty
+ * @param attributes
+ */
+ public MarkupElement(
+ String name,
+ String bodyContent,
+ boolean neverEmpty,
+ MarkupAttribute[] attributes)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name accepted");
+ }
+ if (attributes == null)
+ {
+ throw new IllegalArgumentException("No null attributes accepted");
+ }
+
+ //
+ Set tmp = new HashSet();
+ for (int i = 0; i < attributes.length; i++)
+ {
+ MarkupAttribute attribute = attributes[i];
+ if (attribute == null)
+ {
+ throw new IllegalArgumentException("Cannot have a null attribute");
+ }
+ if (tmp.add(attribute.name) == false)
+ {
+ throw new IllegalArgumentException("Cannot have two identical attributes " + attribute.name);
+ }
+ }
+
+ this.name = name;
+ this.bodyContent = bodyContent;
+ this.neverEmpty = neverEmpty;
+ this.attributes = (MarkupAttribute[])attributes.clone();
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getBodyContent()
+ {
+ return bodyContent;
+ }
+
+ public boolean isNeverEmpty()
+ {
+ return neverEmpty;
+ }
+
+ public int getAttributeSize()
+ {
+ return attributes.length;
+ }
+
+ public MarkupAttribute getAttribute(int index)
+ {
+ return attributes[index];
+ }
+
+ public MarkupAttribute getAttribute(String name)
+ {
+ for (int i = 0; i < attributes.length; i++)
+ {
+ MarkupAttribute attribute = attributes[i];
+ if (attribute.name.equals(name))
+ {
+ return attribute;
+ }
+ }
+ return null;
+ }
+
+ public void write(String urlPrefix, Writer writer) throws UndeclaredIOException
+ {
+ if (urlPrefix == null)
+ {
+ throw new IllegalArgumentException("No context path provided");
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("No writer provided");
+ }
+ try
+ {
+ writer.write("<");
+ writer.write(name);
+ for (int i = 0; i < attributes.length; i++)
+ {
+ MarkupAttribute attribute = attributes[i];
+
+ // If it is an URI type we prepend the context path
+ if (attribute.type == MarkupAttribute.Type.URI)
+ {
+ writer.write(" ");
+ writer.write(attribute.name);
+ writer.write("=\"");
+ if (attribute.value.startsWith("/"))
+ {
+ MarkupAttribute.Type.URI.encode(urlPrefix, writer);
+ }
+ writer.write(attribute.encodedValue);
+ writer.write('"');
+ }
+ else
+ {
+ writer.write(" ");
+ writer.write(attribute.name);
+ writer.write("=\"");
+ writer.write(attribute.encodedValue);
+ writer.write('"');
+ }
+ }
+ if (bodyContent != null && bodyContent.length() > 0)
+ {
+ writer.write(">");
+ writer.write(bodyContent);
+ writer.write("</");
+ writer.write(name);
+ writer.write(">\n");
+ }
+ else if (neverEmpty)
+ {
+ writer.write(">");
+ writer.write("</");
+ writer.write(name);
+ writer.write(">\n");
+ }
+ else
+ {
+ writer.write("/>\n");
+ }
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public String toString(String contextPath)
+ {
+ StringWriter buffer = new StringWriter(64);
+ write(contextPath, buffer);
+ return buffer.toString();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,383 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mx;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.Descriptor;
+import javax.management.modelmbean.ModelMBeanAttributeInfo;
+import javax.management.modelmbean.ModelMBeanConstructorInfo;
+import javax.management.modelmbean.ModelMBeanInfo;
+import javax.management.modelmbean.ModelMBeanInfoSupport;
+import javax.management.modelmbean.ModelMBeanNotificationInfo;
+import javax.management.modelmbean.ModelMBeanOperationInfo;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7452 $
+ */
+public class JavaBeanModelMBeanBuilder
+{
+ private final static String CURRENCY_TIME_LIMIT = "currencyTimeLimit";
+ private final static String GET_METHOD = "getMethod";
+ private final static String SET_METHOD = "setMethod";
+ private final static String PERSIST_POLICY = "persistPolicy";
+ private final static String ROLE = "role";
+
+ private ArrayList mmais;
+ private ArrayList mmois;
+ private String className;
+
+ public JavaBeanModelMBeanBuilder(Class from, Class to) throws Exception
+ {
+ if (from == null)
+ {
+ throw new IllegalArgumentException("The from class must not be null");
+ }
+ if (from.isInterface())
+ {
+ throw new IllegalArgumentException("The from class " + from + " must not be an interface");
+ }
+ if (to != null)
+ {
+ if (to.isInterface())
+ {
+ throw new IllegalArgumentException("The to class " + to + " must not be an interface");
+ }
+ if (!to.isAssignableFrom(from))
+ {
+ throw new IllegalArgumentException("The from class " + from + " is not a subclass of " + to);
+ }
+ }
+
+ //
+ Map beanGetters = new HashMap();
+ Map beanSetters = new HashMap();
+ Map beanMethods = new HashMap();
+
+ //
+ for (Class c = from;c != null && !c.equals(to);c = c.getSuperclass())
+ {
+ Map currentClassGetters = new HashMap();
+ Map currentClassSetters = new HashMap();
+
+ Method[] methods = c.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++)
+ {
+ Method method = methods[i];
+ int modifiers = method.getModifiers();
+ if (Modifier.isPublic(modifiers) &&
+ !Modifier.isAbstract(modifiers) &&
+ !Modifier.isStatic(modifiers))
+ {
+ String methodName = method.getName();
+ Class returnType = method.getReturnType();
+ Class[] parameterTypes = method.getParameterTypes();
+ if (methodName.startsWith("get") &&
+ !void.class.equals(returnType) &&
+ parameterTypes.length == 0 &&
+ methodName.length() > 3)
+ {
+ String propertyName = methodName.substring(3);
+
+ // Try to locate an existing setter for the same property
+ Method beanSetter = (Method)currentClassSetters.get(propertyName);
+ if (beanSetter == null)
+ {
+ beanSetter = (Method)beanSetters.get(propertyName);
+ }
+
+ // Check we do not have a setter with a different return type
+ if (beanSetter != null && !beanSetter.getParameterTypes()[0].equals(returnType))
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has a setter" +
+ " type " + beanSetter.getParameterTypes()[0] + " different from the corresponding" +
+ " getter type " + returnType);
+ }
+
+ // Get an existing bean getter
+ Method beanGetter = (Method)currentClassGetters.get(propertyName);
+ if (beanGetter != null)
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has two getters " +
+ beanGetter + " and " + method);
+ }
+
+ //
+ currentClassGetters.put(propertyName, method);
+ }
+ else if (methodName.startsWith("is") &&
+ !void.class.equals(returnType) &&
+ parameterTypes.length == 0 &&
+ methodName.length() > 2)
+ {
+ String propertyName = methodName.substring(2);
+
+ // Try to locate an existing setter for the same property
+ Method beanSetter = (Method)beanSetters.get(propertyName);
+ if (beanSetter != null)
+ {
+ beanSetter = (Method)currentClassSetters.get(propertyName);
+ }
+
+ // Check we do not have a setter with a different return type
+ if (beanSetter != null && !beanSetter.getParameterTypes()[0].equals(returnType))
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has a setter" +
+ " type " + beanSetter.getParameterTypes()[0] + " different from the corresponding" +
+ " getter type " + returnType);
+ }
+
+ // Get an existing getter
+ Method beanGetter = (Method)beanGetters.get(propertyName);
+ if (beanGetter != null)
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has two getters " +
+ beanGetter + " and " + method);
+ }
+
+ //
+ currentClassGetters.put(propertyName, method);
+ }
+ else if (methodName.startsWith("set") &&
+ void.class.equals(returnType) &&
+ parameterTypes.length == 1 &&
+ methodName.length() > 3)
+ {
+ String propertyName = methodName.substring(3);
+
+ // Try to locate an existing getter
+ Method beanGetter = (Method)beanGetters.get(propertyName);
+ if (beanGetter == null)
+ {
+ beanGetter = (Method)currentClassGetters.get(propertyName);
+ }
+
+ // Check we do not have a getter with a different return type
+ if (beanGetter != null && !beanGetter.getReturnType().equals(parameterTypes[0]))
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " has a setter" +
+ " type " + parameterTypes[0] + " different from the corresponding" +
+ " getter type " + beanGetter.getReturnType());
+ }
+
+ // Get an existing setter
+ Method beanSetter = (Method)beanSetters.get(propertyName);
+ if (beanSetter != null)
+ {
+ throw new IllegalArgumentException("Property " + propertyName + " cannot have two setters " +
+ beanSetter + " and " + method);
+ }
+
+ //
+ currentClassSetters.put(propertyName, method);
+ }
+
+ //
+ beanMethods.put(new MethodKey(method), method);
+ }
+ }
+ beanGetters.putAll(currentClassGetters);
+ beanSetters.putAll(currentClassSetters);
+ }
+
+ // Keep track of property accessors methods
+ Map roles = new HashMap();
+
+ // Properties->Attributes
+ mmais = new ArrayList();
+ Set allPropertyNames = new HashSet();
+ allPropertyNames.addAll(beanGetters.keySet());
+ allPropertyNames.addAll(beanSetters.keySet());
+ for (Iterator i = allPropertyNames.iterator(); i.hasNext();)
+ {
+ String propertyName = (String)i.next();
+
+ //
+ Method getter = (Method)beanGetters.get(propertyName);
+ Method setter = (Method)beanSetters.get(propertyName);
+
+ // Create the metadata
+ ModelMBeanAttributeInfo mmai = new ModelMBeanAttributeInfo(
+ propertyName,
+ "Javabean introspected attribute",
+ getter,
+ setter);
+
+ // Complete the descriptor
+ Descriptor desc = mmai.getDescriptor();
+ desc.setField(JavaBeanModelMBeanBuilder.CURRENCY_TIME_LIMIT, "-1");
+ desc.setField(JavaBeanModelMBeanBuilder.PERSIST_POLICY, "Never");
+
+ //
+ if (getter != null)
+ {
+ roles.put(getter, "getter");
+ desc.setField(JavaBeanModelMBeanBuilder.GET_METHOD, getter.getName());
+ }
+
+ //
+ if (setter != null)
+ {
+ roles.put(setter, "setter");
+ desc.setField(JavaBeanModelMBeanBuilder.SET_METHOD, setter.getName());
+ }
+
+ //
+ mmai.setDescriptor(desc);
+
+ // Finally add the metadata
+ mmais.add(mmai);
+ }
+
+ //
+ className = from.getName();
+
+ // Methods->Operations
+ mmois = new ArrayList();
+ for (Iterator i = beanMethods.values().iterator(); i.hasNext();)
+ {
+ Method method = (Method)i.next();
+
+ // Create the metadata
+ ModelMBeanOperationInfo mmoi = new ModelMBeanOperationInfo("Javabean introspected method", method);
+
+ // Complete the descriptor
+ Descriptor desc = mmoi.getDescriptor();
+ String role = (String)roles.get(method);
+ desc.setField(JavaBeanModelMBeanBuilder.ROLE, role != null ? role : "operation");
+ mmoi.setDescriptor(desc);
+
+ // Finally add the metadata
+ mmois.add(mmoi);
+ }
+ }
+
+ /**
+ * Remove an interface from the management interface.
+ */
+ public void remove(Class itf)
+ {
+ throw new UnsupportedOperationException("To be implemented if useful, just a placeholder now");
+ }
+
+ /**
+ * Generates and returns the management interface.
+ */
+ public ModelMBeanInfo getInfo()
+ {
+ // Assemble the mbean info
+ ModelMBeanInfoSupport info = new ModelMBeanInfoSupport(
+ className,
+ "Javabean model mbean",
+ (ModelMBeanAttributeInfo[])mmais.toArray(new ModelMBeanAttributeInfo[mmais.size()]),
+ new ModelMBeanConstructorInfo[0],
+ (ModelMBeanOperationInfo[])mmois.toArray(new ModelMBeanOperationInfo[mmois.size()]),
+ new ModelMBeanNotificationInfo[0]);
+
+ //
+ return info;
+ }
+
+ public static ModelMBeanInfo build(Class from, Class to) throws Exception
+ {
+ return new JavaBeanModelMBeanBuilder(from, to).getInfo();
+ }
+
+ public static ModelMBeanInfo build(Object o) throws Exception
+ {
+ return new JavaBeanModelMBeanBuilder(o.getClass(), null).getInfo();
+ }
+
+ /**
+ * Key a method during the lookup operations
+ */
+ private static class MethodKey
+ {
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final Class[] parameterTypes;
+
+ /** . */
+ private final int hashCode;
+
+ public MethodKey(Method method)
+ {
+ this.name = method.getName();
+ this.parameterTypes = method.getParameterTypes();
+
+ // Compute hash code
+ int hashCode = method.getName().hashCode();
+ for (int i = 0;i < parameterTypes.length;i++)
+ {
+ Class parameterType = parameterTypes[i];
+ hashCode = hashCode * 43 + parameterType.hashCode();
+ }
+ this.hashCode = hashCode;
+ }
+
+ public int hashCode()
+ {
+ return hashCode;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof MethodKey)
+ {
+ MethodKey that = (MethodKey)obj;
+
+ //
+ if (that.name.equals(this.name) && that.parameterTypes.length == this.parameterTypes.length)
+ {
+ for (int i = 0;i < that.parameterTypes.length;i++)
+ {
+ if (!that.parameterTypes[i].equals(this.parameterTypes[i]))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/JavaBeanModelMBeanBuilder.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mx;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Helper class that filter and listen notifications and help to registration.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class Listener implements NotificationFilter, NotificationListener
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 444957117668223654L;
+ protected final MBeanServer server;
+ protected final Logger log;
+
+ public Listener(MBeanServer server)
+ {
+ if (server == null)
+ {
+ throw new IllegalArgumentException("server must not be null");
+ }
+ this.server = server;
+ this.log = Logger.getLogger(getClass());
+ }
+
+ public void register(ObjectName broadcaster)
+ {
+ register(broadcaster, null);
+ }
+
+ public void register(ObjectName broadcaster, Object handback)
+ {
+ try
+ {
+ if (broadcaster == null)
+ {
+ throw new IllegalArgumentException("Broadcaster is null");
+ }
+
+ log.debug("Register notifications on MBean " + broadcaster.getCanonicalName());
+ server.addNotificationListener(broadcaster, this, this, handback);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ throw new ListenerException(e);
+ }
+ }
+
+ public void unregister(ObjectName broadcaster)
+ {
+ try
+ {
+ if (broadcaster == null)
+ {
+ throw new IllegalArgumentException("Broadcaster is null");
+ }
+
+ log.debug("Unregister notifications on MBean " + broadcaster.getCanonicalName());
+ server.removeNotificationListener(broadcaster, this);
+ }
+ catch (InstanceNotFoundException e)
+ {
+ throw new ListenerException(e);
+ }
+ catch (ListenerNotFoundException e)
+ {
+ throw new ListenerException(e);
+ }
+ }
+
+ /**
+ * Returns true by default.
+ */
+ public boolean isNotificationEnabled(Notification notification)
+ {
+ return true;
+ }
+
+ /**
+ * Does not perform anything by default.
+ */
+ public void handleNotification(Notification notification, Object handback)
+ {
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/Listener.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mx;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ListenerException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 2024301956562398716L;
+
+ public ListenerException()
+ {
+ }
+
+ public ListenerException(String message)
+ {
+ super(message);
+ }
+
+ public ListenerException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ListenerException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/mx/ListenerException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLFilter.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLFilter.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLFilter.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface URLFilter
+{
+ /** Return true if the filter accepts the url. */
+ boolean acceptFile(URL url);
+
+ /** Return true if the directory should be visited. */
+ boolean acceptDir(URL url);
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import java.net.URL;
+import java.io.IOException;
+
+/**
+ * Defines an interface that provides navigation for URLs.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6834 $
+ */
+public interface URLNavigationProvider
+{
+ /**
+ * Visit all the children recursively.
+ *
+ * @param url the target url
+ * @param visitor the visitor
+ * @param filter the filter
+ * @throws IllegalArgumentException if an argument is null or if the url is not accepted
+ * @throws IOException
+s */
+ void visit(URL url, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException;
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigationProvider.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import org.jboss.portal.common.net.file.FileURLNavigationProvider;
+import org.jboss.portal.common.net.jar.JarURLNavigationProvider;
+
+import java.io.IOException;
+import java.net.URL;
+
+/**
+ * The URLNavigator class is a registry for various URLNavigationProvider.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6852 $
+ */
+public class URLNavigator
+{
+
+ private static final URLNavigationProvider fileNav = new FileURLNavigationProvider();
+
+ private static final URLNavigationProvider jarNav = new JarURLNavigationProvider();
+
+ private static final URLFilter NULL_FILTER = new URLFilter()
+ {
+ public boolean acceptFile(URL url)
+ {
+ return true;
+ }
+
+ public boolean acceptDir(URL url)
+ {
+ return true;
+ }
+ };
+
+ public static void visit(URL url, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException
+ {
+ URLNavigationProvider provider = getProvider(url);
+
+ if (filter == null)
+ {
+ filter = NULL_FILTER;
+ }
+
+ provider.visit(url, visitor, filter);
+ }
+
+ public static void visit(URL url, URLVisitor visitor) throws IOException
+ {
+ visit(url, visitor, null);
+ }
+
+ /**
+ * Return an URLNavigationProvider for the specified URL.
+ *
+ * @param url the target url
+ * @return the corresponding URL navigator
+ * @throws IllegalArgumentException if the url is null or no provider is found
+ */
+ private static URLNavigationProvider getProvider(URL url) throws IllegalArgumentException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("Null not accepted");
+ }
+ String protocol = url.getProtocol();
+ if ("file".equals(protocol))
+ {
+ return fileNav;
+ }
+ else if ("jar".equals(protocol))
+ {
+ return jarNav;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Not recognized " + protocol);
+ }
+ }
+
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLNavigator.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,456 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.text.FastURLDecoder;
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.util.ParameterValidation;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7686 $
+ * @since 2.4 (May 26, 2006)
+ */
+public class URLTools
+{
+ public static final String RE_EMAIL_VALIDATION = "^([a-zA-Z0-9]+(([\\.\\-\\_]?[a-zA-Z0-9]+)+)?)\\(a)(([a-zA-Z0-9]+[\\.\\-\\_])+[a-zA-Z]{2,4})$";
+ private static final Pattern LINK = Pattern.compile("(?:href|action|src|location)\\s*=\\s*('|\")\\s*([^'\"]*)\\s*('|\")",
+ Pattern.CASE_INSENSITIVE);
+
+ public static final String HTTP_PREFIX = "http://";
+ public static final String HTTPS_PREFIX = "https://";
+ public static final String FTP_PREFIX = "ftp://";
+ public static final String FILE_PREFIX = "/";
+
+ private static final Logger log = Logger.getLogger(URLTools.class);
+
+ public static boolean isURLAbsolute(String url)
+ {
+ return isNetworkURL(url) || url.startsWith(FILE_PREFIX);
+ }
+
+ /**
+ * Fetches content from of the URL as a byte array or <code>null</code> if a problem occurred. The timeout values
+ * must not be negative integers, when it is equals to zero it means that it does not setup a timeout and use the
+ * default values.
+ *
+ * @param url the URL the URL of the resource
+ * @param soTimeoutMillis the socket connection timeout in millis
+ * @param connTimeoutMillis the connection timeout in millis
+ * @return the retrieved byte array
+ * @throws IllegalArgumentException if the URL is null or any time out value is negative
+ */
+ public static byte[] getContent(URL url, int soTimeoutMillis, int connTimeoutMillis) throws IllegalArgumentException
+ {
+ InputStream in = null;
+ try
+ {
+ in = getContentAsInputStream(url, soTimeoutMillis, connTimeoutMillis);
+ return IOTools.getBytes(in);
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ /**
+ * Fetches content from URL as an InputStream. The timeout values must not be negative integers, when it is equals to
+ * zero it means that it does not setup a timeout and use the default values.
+ *
+ * @param url the URL the URL of the resource
+ * @param soTimeoutMillis the socket connection timeout in millis
+ * @param connTimeoutMillis the connection timeout in millis
+ * @return the buffered content for the URL
+ * @throws IllegalArgumentException if the URL is null or any time out value is negative
+ * @since 1.1
+ */
+ public static InputStream getContentAsInputStream(URL url, int soTimeoutMillis, int connTimeoutMillis) throws IOException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (soTimeoutMillis < 0)
+ {
+ throw new IllegalArgumentException("No negative socket timeout " + soTimeoutMillis);
+ }
+ if (connTimeoutMillis < 0)
+ {
+ throw new IllegalArgumentException("No negative connection timeout" + connTimeoutMillis);
+ }
+
+ //
+ URLConnection conn;
+ try
+ {
+ conn = url.openConnection();
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+
+ // Configure
+ conn.setConnectTimeout(soTimeoutMillis);
+ conn.setReadTimeout(connTimeoutMillis);
+
+ conn.connect();
+ try
+ {
+ return new BufferedInputStream(conn.getInputStream());
+ }
+ catch (SocketTimeoutException e)
+ {
+ log.debug("Time out on: " + url);
+ throw e;
+ }
+ }
+
+ /**
+ * @param url
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean isNetworkURL(String url)
+ {
+ if (url == null || url.length() == 0)
+ {
+ return false;
+ }
+
+ return url.startsWith(HTTP_PREFIX) || url.startsWith(HTTPS_PREFIX) || url.startsWith(FTP_PREFIX);
+ }
+
+ /**
+ * Enforces that the given URL is absolute
+ *
+ * @param url the String representation of the URL to be checked
+ * @throws IllegalArgumentException if the given URL is not absolute
+ */
+ public static void enforceAbsoluteURL(String url) throws IllegalArgumentException
+ {
+ if (!isURLAbsolute(url))
+ {
+ throw new IllegalArgumentException("URL must be absolute. Was: " + url);
+ }
+ }
+
+ public static String encodeXWWWFormURL(String s)
+ {
+ return FastURLEncoder.getUTF8Instance().encode(s);
+ }
+
+ public static String decodeXWWWFormURL(String s)
+ {
+ return FastURLDecoder.getUTF8Instance().encode(s);
+ }
+
+ /** Return true is the address is not null and matches the email validation regular expression. */
+ public static boolean isEmailValid(String address)
+ {
+ return address != null && Pattern.matches(RE_EMAIL_VALIDATION, address);
+ }
+
+ /**
+ * Determines that the specified URL corresponds to an existing resource by trying to open a stream from it. Same as
+ * <code>exists(url, 1000)</code>
+ *
+ * @param url
+ * @return
+ */
+ public static boolean exists(URL url)
+ {
+ return exists(url, 1000);
+ }
+
+ /**
+ * Determines if the specified URL corresponds to an existing resource by trying to open a stream from it.
+ *
+ * @param url the URL to be tested
+ * @param waitForMillis the number of milliseconds to wait before timing out, 0 meaning never timing out.
+ * @return
+ * @throws IllegalArgumentException if the url is null or the time out negative
+ * @since 2.4.2
+ */
+ public static boolean exists(URL url, long waitForMillis) throws IllegalArgumentException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("No null URL accepted");
+ }
+ if (waitForMillis < 0)
+ {
+ throw new IllegalArgumentException("Read time out must be a positive value instead of " + waitForMillis);
+ }
+
+ //
+ URLConnection conn;
+ try
+ {
+ conn = url.openConnection();
+ }
+ catch (IOException e)
+ {
+ log.debug("Could not open connection for " + url, e);
+ return false;
+ }
+
+ // Configure
+ conn.setConnectTimeout((int)waitForMillis);
+ conn.setReadTimeout((int)waitForMillis);
+
+ //
+ InputStream in = null;
+ try
+ {
+ conn.connect();
+ in = conn.getInputStream();
+ return true;
+ }
+ catch (SocketTimeoutException e)
+ {
+ return false;
+ }
+ catch (IOException e)
+ {
+ return false;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ /**
+ * to remove : an API should not try to accomodate the client for that kind of situation, why not also something
+ * like forbidStringLengthToDivisibleBy3 ?
+ *
+ * @param stringURL
+ * @param allowNull <code>true</code> if passing <code>null</code> will be ignored and just return
+ * <code>false</code>, <code>false</code> to throw an {@link IllegalArgumentException} is the given
+ * URL is <code>null</code>.
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean exists(String stringURL, boolean allowNull)
+ {
+ if (!allowNull)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(stringURL, "URL", null);
+ }
+
+ try
+ {
+ URL url = new URL(stringURL);
+ return exists(url);
+ }
+ catch (MalformedURLException e)
+ {
+ return false;
+ }
+ }
+
+ public static URLMatch[] extractURLsFrom(String markup)
+ {
+ // todo: will need to re-write without regex after 2.4
+ int length;
+ if (markup != null && (length = markup.length()) != 0)
+ {
+ Matcher matcher = LINK.matcher(markup);
+ int currentIndex = 0;
+ List links = new ArrayList();
+ while (matcher.find(currentIndex) && currentIndex < length)
+ {
+ links.add(new URLMatch(matcher.start(2), matcher.end(2), matcher.group(2)));
+ currentIndex = matcher.end();
+ }
+
+ return (URLMatch[])links.toArray(new URLMatch[0]);
+ }
+ throw new IllegalArgumentException("Cannot extract URLs from a null or empty markup string!");
+ }
+
+ public static int getURLCountIn(String markup)
+ {
+ int length;
+ if (markup != null && (length = markup.length()) != 0)
+ {
+ Matcher matcher = LINK.matcher(markup);
+ int count = 0;
+ int currentIndex = 0;
+ while (matcher.find(currentIndex) && currentIndex < length)
+ {
+ count++;
+ currentIndex = matcher.end();
+ }
+ return count;
+ }
+ return 0;
+ }
+
+ public static String replaceURLsBy(String markup, final String[] replacements)
+ {
+ if (replacements == null || replacements.length == 0)
+ {
+ return markup;
+ }
+
+ int urlCount = getURLCountIn(markup);
+ if (replacements.length != urlCount)
+ {
+ throw new IllegalArgumentException("Trying to replace " + urlCount + " URLs by " + replacements.length + " replacement(s).");
+ }
+
+ return replaceURLsBy(markup, new URLReplacementGenerator()
+ {
+ public String getReplacementFor(int currentIndex, URLMatch currentMatch)
+ {
+ return replacements[currentIndex];
+ }
+ });
+ }
+
+ public static String replaceURLsBy(String markup, URLReplacementGenerator generator)
+ {
+
+ URLMatch[] urls = extractURLsFrom(markup);
+ if (urls.length > 0)
+ {
+ StringBuffer newMarkup = new StringBuffer(markup.length());
+ int currentIndex = 0;
+ for (int i = 0; i < urls.length; i++)
+ {
+ URLMatch url = urls[i];
+ newMarkup.append(markup.substring(currentIndex, url.getStart())).append(generator.getReplacementFor(i, url));
+ currentIndex = url.getEnd();
+ }
+ newMarkup.append(markup.substring(currentIndex));
+ markup = newMarkup.toString();
+ }
+ return markup;
+ }
+
+ public static class URLMatch
+ {
+ private int start;
+ private int end;
+ private String urlAsString;
+
+ private URLMatch(int start, int end, String urlAsString)
+ {
+ this.start = start;
+ this.end = end;
+ this.urlAsString = urlAsString;
+ }
+
+ public int getStart()
+ {
+ return start;
+ }
+
+ public int getEnd()
+ {
+ return end;
+ }
+
+ public String getURLAsString()
+ {
+ return urlAsString;
+ }
+ }
+
+ /** @since 2.4.2 */
+ public abstract static class URLReplacementGenerator
+ {
+ public abstract String getReplacementFor(int currentIndex, URLMatch currentMatch);
+ }
+
+ public static class PortReplacementGenerator extends URLReplacementGenerator
+ {
+ private int replacementPort;
+
+ public PortReplacementGenerator(int replacementPort)
+ {
+ this.replacementPort = replacementPort;
+ }
+
+ public String getReplacementFor(int currentIndex, URLMatch currentMatch)
+ {
+ return replaceServerPortInURL(currentMatch.getURLAsString(), replacementPort);
+ }
+ }
+
+ /**
+ * @param url
+ * @param newPort
+ * @return
+ * @since 2.4.2
+ */
+ public static String replaceServerPortInURL(String url, int newPort)
+ {
+ if (!isNetworkURL(url))
+ {
+ return url;
+ }
+
+ StringBuffer buf = new StringBuffer(url);
+ int afterProtocol = url.indexOf("://") + 3;
+ int beforePort = url.indexOf(':', afterProtocol);
+ int afterPort;
+
+ if (beforePort != -1)
+ {
+ afterPort = url.indexOf('/', beforePort);
+ buf.delete(beforePort + 1, afterPort);
+ buf.insert(beforePort + 1, newPort);
+ }
+ else
+ {
+ // port number was not present
+ afterPort = url.indexOf('/', afterProtocol);
+ buf.insert(afterPort, ":" + newPort);
+ }
+
+ return buf.toString();
+ }
+
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLTools.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net;
+
+import java.net.URL;
+
+/**
+ * Visitor pattern interface.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public interface URLVisitor
+{
+ /**
+ * Signal the visitor enters a directory.
+ *
+ * @param url the dir URL
+ * @param name the dir name
+ */
+ void startDir(URL url, String name);
+
+ /**
+ * Signals the visitor leavers a directory.
+ *
+ * @param url the dir URL
+ * @param name the dir name
+ */
+ void endDir(URL url, String name);
+
+ /**
+ * Signals the visitor there is a file.
+ *
+ * @param url the file URL
+ * @param name the file name
+ */
+ void file(URL url, String name);
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/URLVisitor.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,108 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net.file;
+
+import org.jboss.portal.common.net.URLNavigationProvider;
+import org.jboss.portal.common.net.URLVisitor;
+import org.jboss.portal.common.net.URLFilter;
+import org.apache.log4j.Logger;
+
+import java.util.Arrays;
+import java.net.URL;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.File;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7448 $
+ */
+public class FileURLNavigationProvider implements URLNavigationProvider
+{
+
+ /** The logger. */
+ private Logger log = Logger.getLogger(FileURLNavigationProvider.class);
+
+ /** Trace. */
+ private boolean trace = log.isDebugEnabled();
+
+ public void visit(URL url, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException
+ {
+ File file = new File(url.getFile()).getCanonicalFile();
+ visit(file, visitor, filter);
+ }
+
+ private void visit(File file, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException
+ {
+ if (!file.exists())
+ {
+ throw new FileNotFoundException();
+ }
+ else
+ {
+ String name = file.getName();
+ if (file.isDirectory())
+ {
+ if (trace)
+ {
+ log.debug("entering directory" + file.getAbsolutePath());
+ }
+ URL url = file.toURL();
+ boolean visit = filter == null || filter.acceptDir(url);
+ if (visit)
+ {
+ visitor.startDir(url, name);
+ File[] childrenFiles = file.listFiles();
+ Arrays.sort(childrenFiles);
+ for (int i = 0; i < childrenFiles.length; i++)
+ {
+ File childFile = childrenFiles[i];
+ visit(childFile, visitor, filter);
+ }
+ visitor.endDir(file.toURL(), name);
+ if (trace)
+ {
+ log.debug("leaving directory" + file.getAbsolutePath());
+ }
+ }
+ }
+ else
+ {
+ if (trace)
+ {
+ log.debug("visiting file " + file.getAbsolutePath());
+ }
+ URL url = file.toURL();
+ File file2 = new File(url.getFile());
+ if (file.equals(file2) && filter.acceptFile(url))
+ {
+ visitor.file(url, name);
+ }
+ else if (trace)
+ {
+ log.debug("The file does not respect url format");
+ }
+ }
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/file/FileURLNavigationProvider.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,293 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.net.jar;
+
+import org.jboss.portal.common.net.URLNavigationProvider;
+import org.jboss.portal.common.net.URLVisitor;
+import org.jboss.portal.common.net.URLFilter;
+import org.jboss.portal.common.jar.JarEntryInfo;
+import org.jboss.portal.common.jar.JarInfo;
+
+import java.io.IOException;
+import java.net.JarURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7448 $
+ */
+public class JarURLNavigationProvider implements URLNavigationProvider
+{
+
+ public void visit(URL url, URLVisitor visitor, URLFilter filter) throws IllegalArgumentException, IOException
+ {
+ if (url == null)
+ {
+ throw new IllegalArgumentException("Null URL not accepted");
+ }
+ if (!"jar".equals(url.getProtocol()))
+ {
+ throw new IllegalArgumentException("Only jar URL are accepted, not " + url.getProtocol());
+ }
+ JarURLConnection conn = (JarURLConnection)url.openConnection();
+ visit(conn, visitor, filter);
+ }
+
+ private void visit(JarURLConnection conn, URLVisitor visitor, URLFilter filter) throws IOException
+ {
+ JarFile jarFile = conn.getJarFile();
+ URL jarURL = conn.getJarFileURL();
+ JarEntry rootEntry = conn.getJarEntry();
+
+ // if the URL specifies a directory without a "/" at the end
+ // the entry will be found, except it won't actually exist.
+ // To get around this issue, we need to check if an entry exists
+ // with a "/" at the end.
+ if (rootEntry != null)
+ {
+ JarEntry testDirEntry = conn.getJarFile().getJarEntry(rootEntry + "/");
+ if (testDirEntry != null)
+ {
+ rootEntry = testDirEntry;
+ }
+ }
+ else
+ {
+ // if rootEntry == null then the url points to the root of the jar. The problem
+ // is that the root of the jar doesn't actually exist in the jar.
+ // We need to create a fake jar entry to mimic this behavior
+ rootEntry = new JarEntry("/");
+ }
+
+ // Get the root entry
+ JarEntryInfo rootEntryInfo = new JarEntryInfo(rootEntry);
+
+ // The entries we will browse
+ JarInfo jarInfo = new JarInfo(jarFile);
+
+ boolean enabled = true;
+
+ //
+ Stack stack = new Stack(jarURL, rootEntryInfo);
+ for (Iterator i = jarInfo.entries(); i.hasNext();)
+ {
+ JarEntryInfo entryInfo = (JarEntryInfo)i.next();
+
+ // Only consider descendant of the root or root itself
+ if (entryInfo.equals(rootEntryInfo) || entryInfo.isDescendantOf(rootEntryInfo))
+ {
+ List relPath;
+ // The relative path from the root
+ if (rootEntryInfo.size() > 1){
+ relPath = entryInfo.getNames().subList(rootEntryInfo.size() - 1, entryInfo.size());
+ }
+ else
+ {
+ relPath = entryInfo.getNames();
+ }
+
+ // Enter intermediate dirs
+ while (stack.size() < relPath.size() - 1 && enabled)
+ {
+ String name = (String)relPath.get(stack.size());
+ stack.push(name, true);
+ URL url = stack.getURL();
+ boolean visit = filter == null || filter.acceptDir(url);
+ if (visit)
+ {
+ visitor.startDir(url, name);
+ }
+ else
+ {
+ enabled = false;
+ }
+ }
+
+ // Leave intermediate dirs
+ while (stack.size() > relPath.size() - 1)
+ {
+ URL url = stack.getURL();
+ Stack.Entry entry = stack.pop();
+ if (enabled)
+ {
+ String name = entry.name;
+ visitor.endDir(url, name);
+ }
+ enabled = true;
+ }
+
+ //
+ if (enabled)
+ {
+ if (entryInfo.isDirectory())
+ {
+ String name = (String)relPath.get(relPath.size() - 1);
+ stack.push(name, true);
+ URL url = stack.getURL();
+ boolean visit = filter == null || filter.acceptDir(url);
+ if (visit)
+ {
+ visitor.startDir(url, name);
+ }
+ else
+ {
+ enabled = false;
+ }
+ }
+ else
+ {
+ String name = (String)relPath.get(relPath.size() - 1);
+ stack.push(name, false);
+ URL url = stack.getURL();
+ if (filter.acceptFile(url))
+ {
+ visitor.file(url, name);
+ }
+ stack.pop();
+ }
+ }
+ }
+ }
+
+ //
+ while (stack.size() > 0)
+ {
+ URL url = stack.getURL();
+ Stack.Entry entry = stack.pop();
+ if (enabled)
+ {
+ String name = entry.name;
+ visitor.endDir(url, name);
+ }
+ enabled = true;
+ }
+ }
+
+ private static class Stack
+ {
+
+ // The jar URL
+ final URL jarURL;
+
+ // The root entry
+ final JarEntryInfo root;
+
+ // The list of names relative to the root entry
+ final LinkedList entries;
+
+ //
+ boolean enabled;
+
+ public Stack(URL jarURL, JarEntryInfo root)
+ {
+ this.jarURL = jarURL;
+ this.root = root;
+ this.entries = new LinkedList();
+ }
+
+ int size()
+ {
+ return entries.size();
+ }
+
+ void push(String name, boolean dir)
+ {
+ entries.addLast(new Entry(name, dir));
+ }
+
+ Entry pop()
+ {
+ return (Entry)entries.removeLast();
+ }
+
+ Entry peek()
+ {
+ return (Entry)entries.getLast();
+ }
+
+ /**
+ * Generate the full URL for the current entry.
+ *
+ * @return
+ * @throws MalformedURLException
+ */
+ URL getURL() throws MalformedURLException
+ {
+ StringBuffer tmp = new StringBuffer(jarURL.toString()).append("!/");
+ for (int i = 0; i < root.size() - 1; i++)
+ {
+ String name = root.getName(i);
+ if (!tmp.toString().endsWith("/"))
+ {
+ tmp.append("/");
+ }
+ // we don't want to add an extra '/' if the actual jar root element
+ if (!name.equals("/"))
+ {
+ tmp.append(name);
+ }
+ }
+ for (int i = 0; i < entries.size(); i++)
+ {
+ Entry entry = (Entry)entries.get(i);
+ String name = entry.name;
+ if (!tmp.toString().endsWith("/"))
+ {
+ tmp.append("/");
+ }
+ if (!name.equals("/"))
+ {
+ tmp.append(name);
+ }
+
+ }
+ Entry entry = peek();
+ if (entry.dir && !entry.name.equals("/") && !(tmp.toString().endsWith("/")))
+ {
+ tmp.append('/');
+ }
+ return new URL("jar", "", tmp.toString());
+ }
+
+ static class Entry
+ {
+ /** The entry name. */
+ final String name;
+
+ /** Whether the name represents a dir or not. */
+ final boolean dir;
+
+ public Entry(String name, boolean dir)
+ {
+ this.name = name;
+ this.dir = dir;
+ }
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/net/jar/JarURLNavigationProvider.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,243 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.p3p;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 5451 $
+ */
+public final class P3PConstants
+{
+ public enum TelecomType
+ {
+ TELEPHONE(TELECOM_TELEPHONE),
+ FAX(TELECOM_FAX),
+ MOBILE(TELECOM_MOBILE),
+ PAGER(TELECOM_PAGER);
+
+ private final String prefix;
+
+ TelecomType(String prefix)
+ {
+ this.prefix = prefix;
+ }
+
+ public String getPrefix()
+ {
+ return prefix;
+ }
+ }
+
+ public enum TelecomInfo
+ {
+ INTCODE(TELECOM_INTCODE),
+ LOCCODE(TELECOM_LOCCODE),
+ NUMBER(TELECOM_NUMBER),
+ EXT(TELECOM_EXT),
+ COMMENT(TELECOM_COMMENT);
+
+ private final String name;
+
+ TelecomInfo(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+
+ public enum PostalInfo
+ {
+ NAME(POSTAL_NAME),
+ STREET(POSTAL_STREET),
+ CITY(POSTAL_CITY),
+ STATEPROV(POSTAL_STATEPROV),
+ POSTALCODE(POSTAL_POSTALCODE),
+ COUNTRY(POSTAL_COUNTRY),
+ ORGANIZATION(POSTAL_ORGANIZATION);
+
+ private final String name;
+
+ PostalInfo(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+
+ public enum OnlineInfo
+ {
+ EMAIL(ONLINE_EMAIL),
+ URI(ONLINE_URI);
+
+ private final String name;
+
+ OnlineInfo(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ }
+
+
+ // Postal
+ private static final String POSTAL_NAME = "postal.name";
+ private static final String POSTAL_STREET = "postal.street";
+ private static final String POSTAL_CITY = "postal.city";
+ private static final String POSTAL_STATEPROV = "postal.stateprov";
+ private static final String POSTAL_POSTALCODE = "postal.postalcode";
+ private static final String POSTAL_COUNTRY = "postal.country";
+ private static final String POSTAL_ORGANIZATION = "postal.organization";
+
+ // Telecom
+ private static final String TELECOM_TELEPHONE = "telecom.telephone.";
+ private static final String TELECOM_FAX = "telecom.fax.";
+ private static final String TELECOM_MOBILE = "telecom.mobile.";
+ private static final String TELECOM_PAGER = "telecom.pager.";
+ private static final String TELECOM_INTCODE = "intcode";
+ private static final String TELECOM_LOCCODE = "loccode";
+ private static final String TELECOM_NUMBER = "number";
+ private static final String TELECOM_EXT = "ext";
+ private static final String TELECOM_COMMENT = "comment";
+
+ // Online
+ private static final String ONLINE_URI = "online.uri";
+ private static final String ONLINE_EMAIL = "online.email";
+
+ /*
+ * User information attribute names (PLT.D in the portlet spec) that are defined in P3P spec.
+ */
+
+ //
+ public static final String INFO_USER_BDATE = "user.bdate";
+ public static final String INFO_USER_GENDER = "user.gender";
+ public static final String INFO_USER_EMPLOYER = "user.employer";
+ public static final String INFO_USER_DEPARTMENT = "user.department";
+ public static final String INFO_USER_JOB_TITLE = "user.jobtitle";
+ public static final String INFO_USER_NAME_PREFIX = "user.name.prefix";
+ public static final String INFO_USER_NAME_GIVEN = "user.name.given";
+ public static final String INFO_USER_NAME_FAMILY = "user.name.family";
+ public static final String INFO_USER_NAME_MIDDLE = "user.name.middle";
+ public static final String INFO_USER_NAME_SUFFIX = "user.name.suffix";
+ public static final String INFO_USER_NAME_NICKNAME = "user.name.nickName";
+
+ // User home
+ private static final String INFO_USER_HOME_PREFIX = "user.home-info.";
+ public static final String INFO_USER_HOME_INFO_POSTAL_NAME = INFO_USER_HOME_PREFIX + POSTAL_NAME;
+ public static final String INFO_USER_HOME_INFO_POSTAL_STREET = INFO_USER_HOME_PREFIX + POSTAL_STREET;
+ public static final String INFO_USER_HOME_INFO_POSTAL_CITY = INFO_USER_HOME_PREFIX + POSTAL_CITY;
+ public static final String INFO_USER_HOME_INFO_POSTAL_STATEPROV = INFO_USER_HOME_PREFIX + POSTAL_STATEPROV;
+ public static final String INFO_USER_HOME_INFO_POSTAL_POSTALCODE = INFO_USER_HOME_PREFIX + POSTAL_POSTALCODE;
+ public static final String INFO_USER_HOME_INFO_POSTAL_COUNTRY = INFO_USER_HOME_PREFIX + POSTAL_COUNTRY;
+ public static final String INFO_USER_HOME_INFO_POSTAL_ORGANIZATION = INFO_USER_HOME_PREFIX + POSTAL_ORGANIZATION;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_INTCODE = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_INTCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_LOCCODE = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_LOCCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_NUMBER = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_NUMBER;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_EXT = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_EXT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_TELEPHONE_COMMENT = INFO_USER_HOME_PREFIX + TELECOM_TELEPHONE + TELECOM_COMMENT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_INTCODE = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_INTCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_LOCCODE = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_LOCCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_NUMBER = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_NUMBER;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_EXT = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_EXT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_FAX_COMMENT = INFO_USER_HOME_PREFIX + TELECOM_FAX + TELECOM_COMMENT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_INTCODE = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_INTCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_LOCCODE = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_LOCCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_NUMBER = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_NUMBER;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_EXT = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_EXT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_MOBILE_COMMENT = INFO_USER_HOME_PREFIX + TELECOM_MOBILE + TELECOM_COMMENT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_INTCODE = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_INTCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_LOCCODE = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_LOCCODE;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_NUMBER = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_NUMBER;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_EXT = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_EXT;
+ public static final String INFO_USER_HOME_INFO_TELECOM_PAGER_COMMENT = INFO_USER_HOME_PREFIX + TELECOM_PAGER + TELECOM_COMMENT;
+ public static final String INFO_USER_HOME_INFO_ONLINE_EMAIL = INFO_USER_HOME_PREFIX + ONLINE_EMAIL;
+ public static final String INFO_USER_HOME_INFO_ONLINE_URI = INFO_USER_HOME_PREFIX + ONLINE_URI;
+
+ // User Business
+ private static final String INFO_USER_BUSINESS_PREFIX = "user.business-info.";
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_NAME = INFO_USER_BUSINESS_PREFIX + POSTAL_NAME;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_STREET = INFO_USER_BUSINESS_PREFIX + POSTAL_STREET;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_CITY = INFO_USER_BUSINESS_PREFIX + POSTAL_CITY;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_STATEPROV = INFO_USER_BUSINESS_PREFIX + POSTAL_STATEPROV;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_POSTALCODE = INFO_USER_BUSINESS_PREFIX + POSTAL_POSTALCODE;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_COUNTRY = INFO_USER_BUSINESS_PREFIX + POSTAL_COUNTRY;
+ public static final String INFO_USER_BUSINESS_INFO_POSTAL_ORGANIZATION = INFO_USER_BUSINESS_PREFIX + POSTAL_ORGANIZATION;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_INTCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_INTCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_LOCCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_LOCCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_NUMBER = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_NUMBER;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_EXT = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_EXT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_COMMENT = INFO_USER_BUSINESS_PREFIX + TELECOM_TELEPHONE + TELECOM_COMMENT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_INTCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_INTCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_LOCCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_LOCCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_NUMBER = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_NUMBER;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_EXT = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_EXT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_FAX_COMMENT = INFO_USER_BUSINESS_PREFIX + TELECOM_FAX + TELECOM_COMMENT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_INTCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_INTCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_LOCCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_LOCCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_NUMBER;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_EXT = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_EXT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_COMMENT = INFO_USER_BUSINESS_PREFIX + TELECOM_MOBILE + TELECOM_COMMENT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_INTCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_INTCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_LOCCODE = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_LOCCODE;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_NUMBER = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_NUMBER;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_EXT = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_EXT;
+ public static final String INFO_USER_BUSINESS_INFO_TELECOM_PAGER_COMMENT = INFO_USER_BUSINESS_PREFIX + TELECOM_PAGER + TELECOM_COMMENT;
+ public static final String INFO_USER_BUSINESS_INFO_ONLINE_EMAIL = INFO_USER_BUSINESS_PREFIX + ONLINE_EMAIL;
+ public static final String INFO_USER_BUSINESS_INFO_ONLINE_URI = INFO_USER_BUSINESS_PREFIX + ONLINE_URI;
+
+ private P3PConstants()
+ {
+ }
+
+ private static String getHomeOrBusinessPrefix(boolean isBusiness)
+ {
+ return isBusiness ? P3PConstants.INFO_USER_BUSINESS_PREFIX : P3PConstants.INFO_USER_HOME_PREFIX;
+ }
+
+ public static String getPostalUserInfoKey(PostalInfo info, boolean isBusiness)
+ {
+ return getHomeOrBusinessPrefix(isBusiness) + info.getName();
+ }
+
+ public static String getTelecomInfoKey(TelecomType type, TelecomInfo info, boolean isBusiness)
+ {
+ return getHomeOrBusinessPrefix(isBusiness) + type.getPrefix() + info.getName();
+ }
+
+ public static String getOnlineUserInfoKey(OnlineInfo info, boolean isBusiness)
+ {
+ return getHomeOrBusinessPrefix(isBusiness) + info.getName();
+ }
+}
\ No newline at end of file
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/p3p/P3PConstants.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * Map request uri path to portal object.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public interface PathMapper
+{
+
+ /**
+ * Map a path to a result.
+ *
+ * @param pathMapperContext the context of the mapping
+ * @param path the path to map
+ * @return returns a path mapper result
+ */
+ public PathMapperResult map(PathMapperContext pathMapperContext, String path);
+
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapper.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * Interface that provide access to objects that are mapped to pathes.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public interface PathMapperContext
+{
+ /**
+ * Returns the object graph root.
+ *
+ * @return the root object
+ */
+ Object getRoot();
+
+ /**
+ * Return the child object having the specified name or null if it does not exists.
+ *
+ * @return the child of the parent object matching the specifed name
+ */
+ Object getChild(Object parent, String name);
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperContext.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * The result of a request to a mapper.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class PathMapperResult
+{
+
+ /** . */
+ private final Object target;
+
+ /** . */
+ private final String targetPath;
+
+ /** . */
+ private final String targetPathInfo;
+
+ public PathMapperResult(Object target, String targetPath, String targetPathInfo)
+ {
+ this.target = target;
+ this.targetPath = targetPath;
+ this.targetPathInfo = targetPathInfo;
+ }
+
+ public Object getTarget()
+ {
+ return target;
+ }
+
+ public String getTargetPathInfo()
+ {
+ return targetPathInfo;
+ }
+
+ public int hashCode()
+ {
+ int hashCode = (target != null ? target.hashCode() : 0) +
+ (targetPath != null ? targetPath.hashCode() : 0) +
+ (targetPathInfo != null ? targetPathInfo.hashCode() : 0);
+ return hashCode;
+ }
+
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj instanceof PathMapperResult)
+ {
+ PathMapperResult other = (PathMapperResult)obj;
+ return (target == null ? (other.target == null) : target.equals(other.target)) &&
+ (targetPath == null ? (other.targetPath == null) : targetPath.equals(other.targetPath)) &&
+ (targetPathInfo == null ? (other.targetPathInfo == null) : targetPathInfo.equals(other.targetPathInfo));
+ }
+ return false;
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer("MappingResult[");
+ buffer.append(target == null ? "-" : target.toString());
+ buffer.append(',');
+ buffer.append(targetPath == null ? "-" : targetPath);
+ buffer.append(',');
+ buffer.append(targetPathInfo == null ? "-" : targetPathInfo);
+ buffer.append("]");
+ return buffer.toString();
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/PathMapperResult.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,202 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * Utility class to pull parse a relative path.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class RelativePathParser
+{
+
+ // Constants ********************************************************************************************************
+
+ private static final int STATE_BEGIN = 0;
+ private static final int STATE_DOT = 1;
+ private static final int STATE_DOT_DOT = 2;
+ private static final int STATE_CHAR = 3;
+
+ /**
+ * The parser has reached the end of the stream. The values returned by <code>getOffset()</code> and
+ * <code>getLength()</code> is undertermined.
+ */
+ public static final int NONE = 0;
+
+ /**
+ * The recognized token is up. The values returned by <code>getOffset()</code> and
+ * <code>getLength()</code> is undertermined.
+ */
+ public static final int UP = 1;
+
+ /**
+ * The recognized token is down. The values returned by <code>getOffset()</code> and
+ * <code>getLength()</code> determine the token string value.
+ */
+ public static final int DOWN = 2;
+
+ // Variables ********************************************************************************************************
+
+ /**
+ * The path being parsed.
+ */
+ private final String path;
+
+ /**
+ * The current index of parsing.
+ */
+ private int current;
+
+ /**
+ * The current internal offset.
+ */
+ private int previous;
+
+ /**
+ * The offset value when a down token is recognized.
+ */
+ private int offset;
+
+ /**
+ * The length value when a down token is recognized.
+ */
+ private int length;
+
+ public RelativePathParser(String path)
+ {
+ if (path == null)
+ {
+ throw new IllegalArgumentException("No path");
+ }
+ this.path = path;
+ this.previous = 0;
+ this.current = 0;
+ }
+
+ /**
+ * Read the next token available.
+ *
+ * @return the token type recognized which can be NONE, UP or DOWN.
+ */
+ public int next()
+ {
+ //
+ previous = current;
+ int state = STATE_BEGIN;
+
+ //
+ while (current < path.length())
+ {
+ char c = path.charAt(current++);
+ switch (c)
+ {
+ case '.':
+ {
+ switch (state)
+ {
+ case STATE_BEGIN:
+ state = STATE_DOT;
+ break;
+ case STATE_DOT:
+ state = STATE_DOT_DOT;
+ break;
+ case STATE_CHAR:
+ break;
+ default:
+ case STATE_DOT_DOT:
+ throw new IllegalArgumentException();
+ }
+ break;
+ }
+ case '/':
+ {
+ switch (state)
+ {
+ default:
+ case STATE_BEGIN:
+ throw new IllegalStateException("");
+ case STATE_DOT:
+ previous = current;
+ state = STATE_BEGIN;
+ break;
+ case STATE_DOT_DOT:
+ length = -1;
+ offset = -1;
+ return UP;
+ case STATE_CHAR:
+ length = current - previous - 1;
+ offset = previous;
+ return DOWN;
+ }
+ break;
+ }
+ default:
+ {
+ switch (state)
+ {
+ case STATE_BEGIN:
+ state = STATE_CHAR;
+ break;
+ case STATE_CHAR:
+ break;
+ case STATE_DOT:
+ case STATE_DOT_DOT:
+ default:
+ throw new IllegalStateException("");
+ }
+ }
+ }
+ }
+
+ //
+ switch (state)
+ {
+ case STATE_DOT:
+ case STATE_BEGIN:
+ length = -1;
+ offset = -1;
+ return NONE;
+ case STATE_CHAR:
+ offset = previous;
+ length = current - previous;
+ return DOWN;
+ case STATE_DOT_DOT:
+ length = -1;
+ offset = -1;
+ return UP;
+ default:
+ throw new IllegalStateException("");
+ }
+ }
+
+ public int getOffset()
+ {
+ return offset;
+ }
+
+ public int getLength()
+ {
+ return length;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/RelativePathParser.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.path;
+
+/**
+ * A simple mapper implementation. The limitations is that only the root and its children can have children
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class SimplePathMapper implements PathMapper
+{
+ public PathMapperResult map(PathMapperContext ctx, String path)
+ {
+ Object root = ctx.getRoot();
+ Object target = null;
+ String targetPath = null;
+ String targetPathInfo = null;
+
+ if (path == null || path.length() == 0)
+ {
+ targetPath = null;
+ targetPathInfo = null;
+ }
+ else if ("/".equals(path))
+ {
+ targetPath = null;
+ targetPathInfo = "/";
+ }
+ else
+ {
+ int firstSlashPos = path.indexOf('/', 1);
+ if (firstSlashPos == -1)
+ {
+ String firstChunk = path.substring(1);
+ target = ctx.getChild(root, firstChunk);
+ if (target != null)
+ {
+ targetPath = path;
+ targetPathInfo = null;
+ }
+ else
+ {
+ targetPath = null;
+ targetPathInfo = path;
+ }
+ }
+ else if (firstSlashPos == 1)
+ {
+ targetPath = null;
+ targetPathInfo = "/";
+ }
+ else
+ {
+ String firstChunk = path.substring(1, firstSlashPos);
+ target = ctx.getChild(root, firstChunk);
+ if (target != null)
+ {
+ int secondSlashPos = path.indexOf('/', firstSlashPos + 1);
+ if (secondSlashPos == -1)
+ {
+ String secondChunck = path.substring(firstSlashPos + 1);
+ if (secondChunck.length() == 0)
+ {
+ targetPath = "/" + firstChunk;
+ targetPathInfo = "/";
+ }
+ else
+ {
+ Object child = ctx.getChild(target, secondChunck);
+ if (child != null)
+ {
+ target = child;
+ targetPath = path;
+ targetPathInfo = null;
+ }
+ else
+ {
+ targetPath = "/" + firstChunk;
+ targetPathInfo = "/" + secondChunck;
+ }
+ }
+ }
+ else
+ {
+ targetPath = "/" + firstChunk;
+ targetPathInfo = path.substring(firstSlashPos);
+ }
+ }
+ else
+ {
+ targetPath = null;
+ targetPathInfo = path;
+ }
+ }
+ }
+ return new PathMapperResult(target, targetPath, targetPathInfo);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/path/SimplePathMapper.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/reflect/Modifier.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/reflect/Modifier.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/reflect/Modifier.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.reflect;
+
+import java.lang.reflect.Field;
+
+/**
+ * Extends the java Modifier object in order to add more utility methods.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class Modifier extends java.lang.reflect.Modifier
+{
+
+ /**
+ * Return true if the field is considered as a readable property which means that it is public and non static.
+ *
+ * @param f the field to test
+ * @return true if the field is a readable property
+ * @throws IllegalArgumentException if the field argument is null
+ */
+ public static boolean isReadableProperty(Field f) throws IllegalArgumentException
+ {
+ if (f == null)
+ {
+ throw new IllegalArgumentException("No field provided");
+ }
+
+ //
+ int modifiers = f.getModifiers();
+ return (modifiers & STATIC) == 0 && (modifiers & PUBLIC) != 0;
+ }
+
+ /**
+ * Return true if the field is considered as a writable property which means that it is public, non static and non
+ * final.
+ *
+ * @param f the field to test
+ * @return true if the field is a writable property
+ * @throws IllegalArgumentException if the field argument is null
+ */
+ public static boolean isWritableProperty(Field f)
+ {
+ if (f == null)
+ {
+ throw new IllegalArgumentException("No field provided");
+ }
+
+ //
+ int modifiers = f.getModifiers();
+ return (modifiers & (STATIC | FINAL)) == 0 && (modifiers & PUBLIC) != 0;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/reflect/Reflection.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/reflect/Reflection.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/reflect/Reflection.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,142 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.reflect;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Reflection
+{
+
+ /**
+ * Search a method on the specified class. The search will try find methods with any scope and will
+ * start with the provided class. First it will inspect the public method on the class, if one is found
+ * then this method is returned. If no public method is found then it will inspect the declared methods
+ * of the provided class and its super classes.
+ *
+ * @param clazz the class to inspect
+ * @param methodName the method name
+ * @param parameterTypes the parameter types
+ * @return the matched method or null
+ * @throws IllegalArgumentException if one argument is null
+ */
+ public static Method findMethod(
+ Class clazz,
+ String methodName,
+ Class[] parameterTypes) throws IllegalArgumentException
+ {
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException("No class provided");
+ }
+ if (methodName == null)
+ {
+ throw new IllegalArgumentException("No method name provided");
+ }
+ if (parameterTypes == null)
+ {
+ throw new IllegalArgumentException("No parameter types provided");
+ }
+ for (int i = 0; i < parameterTypes.length; i++)
+ {
+ if (parameterTypes[i] == null)
+ {
+ throw new IllegalArgumentException("Null parameter type at element=" + i);
+ }
+ }
+
+ // First try a public method, which could be an implemented from an interface
+ try
+ {
+ return clazz.getMethod(methodName, parameterTypes);
+ }
+ catch (NoSuchMethodException ignore)
+ {
+ }
+
+ //
+ return findDeclaredMethod(clazz, methodName, parameterTypes);
+ }
+
+ /**
+ * Search a declared method on the specified class and its super classes.
+ *
+ * @param clazz the class to inspect
+ * @param methodName the method name
+ * @param parameterTypes the parameter types
+ * @return the matched method or null
+ * @throws IllegalArgumentException if one argument is null
+ */
+ private static Method findDeclaredMethod(
+ Class clazz,
+ String methodName,
+ Class[] parameterTypes) throws IllegalArgumentException
+ {
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException("No class provided");
+ }
+ if (methodName == null)
+ {
+ throw new IllegalArgumentException("No method name provided");
+ }
+ if (parameterTypes == null)
+ {
+ throw new IllegalArgumentException("No parameter types provided");
+ }
+ for (int i = 0; i < parameterTypes.length; i++)
+ {
+ if (parameterTypes[i] == null)
+ {
+ throw new IllegalArgumentException("Null parameter type at element=" + i);
+ }
+ }
+
+ //
+ try
+ {
+ return clazz.getDeclaredMethod(methodName, parameterTypes);
+ }
+ catch (NoSuchMethodException ignore)
+ {
+ }
+
+ //
+ Class parentClass = clazz.getSuperclass();
+ if (parentClass != null)
+ {
+ Method method = findDeclaredMethod(parentClass, methodName, parameterTypes);
+ if (method != null)
+ {
+ return method;
+ }
+ }
+
+ // Nothing found
+ return null;
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingRequestWrapper.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingRequestWrapper.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingRequestWrapper.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.servlet;
+
+import org.jboss.portal.common.util.Tools;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wrapper around a HTTPServletRequest to add attributes without affecting the actual request.
+ *
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 7228 $
+ */
+public class BufferingRequestWrapper extends HttpServletRequestWrapper
+{
+
+ /** . */
+ private static final Object REMOVED_ATTRIBUTE = new Object();
+
+ /** . */
+ private Map attributes;
+
+ /** . */
+ private Locale[] locales;
+
+ /** . */
+ private String contextPath;
+
+ public BufferingRequestWrapper(HttpServletRequest servletRequest, String contextPath, Locale[] locales)
+ {
+ super(servletRequest);
+
+ //
+ this.contextPath = contextPath;
+ this.locales = locales;
+ this.attributes = new HashMap();
+ }
+
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+
+ public Locale getLocale()
+ {
+ return locales.length > 0 ? locales[0] : null;
+ }
+
+ public Enumeration getLocales()
+ {
+ return Tools.toEnumeration(locales);
+ }
+
+ public String getMethod()
+ {
+ return "GET";
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ if (value == null)
+ {
+ value = REMOVED_ATTRIBUTE;
+ }
+
+ //
+ attributes.put(name, value);
+ }
+
+ public Object getAttribute(String name)
+ {
+ Object value = attributes.get(name);
+
+ //
+ if (value == REMOVED_ATTRIBUTE)
+ {
+ value = null;
+ }
+ else if (value == null)
+ {
+ value = getRequest().getAttribute(name);
+ }
+
+ //
+ return value;
+ }
+
+ public void removeAttribute(String name)
+ {
+ setAttribute(name, null);
+ }
+
+ public Enumeration getAttributeNames()
+ {
+ Set names = new HashSet();
+
+ //
+ for (Enumeration e = getRequest().getAttributeNames(); e.hasMoreElements();)
+ {
+ names.add(e.nextElement());
+ }
+
+ //
+ for (Iterator i = attributes.entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ Object value = entry.getValue();
+ if (value == REMOVED_ATTRIBUTE)
+ {
+ names.remove(name);
+ }
+ else
+ {
+ names.add(name);
+ }
+ }
+
+ //
+ return Tools.toEnumeration(names.iterator());
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingResponseWrapper.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingResponseWrapper.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/BufferingResponseWrapper.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,225 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.servlet;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Locale;
+
+/**
+ * Redirection of the Writer
+ *
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision: 7228 $
+ */
+public class BufferingResponseWrapper extends HttpServletResponseWrapper
+{
+
+ /** . */
+ private ServletOutputStreamBuffer outputStream;
+
+ /** . */
+ private PrintWriter writer;
+
+ /** . */
+ private StringWriter chars;
+
+ /** . */
+ private String characterEncoding;
+
+ /** Not really used but we need it to memorize what the client set optionally. */
+ protected int bufferSize;
+
+ public BufferingResponseWrapper(HttpServletResponse response)
+ {
+ super(response);
+
+ // By default inherit the character encoding of the wrapped response
+ this.characterEncoding = response.getCharacterEncoding();
+
+ // 0 means no buffering - we say no buffering
+ this.bufferSize = 0;
+ }
+
+ public String getContent()
+ {
+ if (outputStream != null)
+ {
+ try
+ {
+ outputStream.flush();
+ return outputStream.getContent(characterEncoding);
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+ else if (chars != null)
+ {
+ writer.flush();
+ return chars.toString();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void addCookie(Cookie arg0)
+ {
+ }
+
+ public void addDateHeader(String arg0, long arg1)
+ {
+ }
+
+ public void addHeader(String arg0, String arg1)
+ {
+ }
+
+ public void addIntHeader(String arg0, int arg1)
+ {
+ }
+
+ public void sendError(int arg0) throws IOException
+ {
+ }
+
+ public void sendError(int arg0, String arg1) throws IOException
+ {
+ }
+
+ public void sendRedirect(String arg0) throws IOException
+ {
+ }
+
+ public void setDateHeader(String arg0, long arg1)
+ {
+ }
+
+ public void setHeader(String arg0, String arg1)
+ {
+ }
+
+ public void setIntHeader(String arg0, int arg1)
+ {
+ }
+
+ public void setStatus(int arg0)
+ {
+ }
+
+ public void setStatus(int arg0, String arg1)
+ {
+ }
+
+ public int getBufferSize()
+ {
+ return bufferSize;
+ }
+
+ public String getCharacterEncoding()
+ {
+ return characterEncoding;
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException
+ {
+ if (writer != null)
+ {
+ throw new IllegalStateException("Already obtained a PrintWriter");
+ }
+ if (outputStream == null)
+ {
+ outputStream = new ServletOutputStreamBuffer(500);
+ }
+ return outputStream;
+ }
+
+ public PrintWriter getWriter() throws IOException
+ {
+ if (outputStream != null)
+ {
+ throw new IllegalStateException("Already obtained a ServletOutputStream");
+ }
+ if (writer == null)
+ {
+ chars = new StringWriter();
+ writer = new PrintWriter(chars, false);
+ }
+ return writer;
+ }
+
+ public boolean isCommitted()
+ {
+ return false;
+ }
+
+ public void reset()
+ {
+ resetBuffer();
+ }
+
+ public void resetBuffer()
+ {
+ if (outputStream != null)
+ {
+ outputStream.reset();
+ }
+ else if (chars != null)
+ {
+ writer.flush();
+ chars.getBuffer().setLength(0);
+ }
+ }
+
+ public void setBufferSize(int bufferSize)
+ {
+ this.bufferSize = bufferSize;
+ }
+
+ public void setCharacterEncoding(String characterEncoding)
+ {
+ this.characterEncoding = characterEncoding;
+ }
+
+ public void setContentLength(int arg0)
+ {
+ }
+
+ public void setContentType(String arg0)
+ {
+ }
+
+ public void setLocale(Locale arg0)
+ {
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/servlet/ServletOutputStreamBuffer.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.servlet;
+
+import javax.servlet.ServletOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class ServletOutputStreamBuffer extends ServletOutputStream
+{
+
+ /** . */
+ private ByteArrayOutputStream buffer;
+
+ public ServletOutputStreamBuffer(int size)
+ {
+ buffer = new ByteArrayOutputStream(size);
+ }
+
+ public void write(int value) throws IOException
+ {
+ buffer.write(value);
+ }
+
+ public String getContent(String encoding) throws IOException
+ {
+ buffer.flush();
+
+ //
+ return buffer.toString(encoding);
+ }
+
+ public byte[] getBinaryContent() throws IOException
+ {
+ buffer.flush();
+
+ //
+ return buffer.toByteArray();
+ }
+
+ public void reset()
+ {
+ buffer.reset();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/AbstractCharEncoder.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractCharEncoder implements CharEncoder
+{
+
+ public void encode(char[] chars, int off, int len, CharWriter writer) throws EncodingException
+ {
+ for (int i = off;i < len;i++)
+ {
+ encode(chars[i], writer);
+ }
+ }
+
+ public void encode(char[] chars, CharWriter writer) throws EncodingException
+ {
+ encode(chars, 0, chars.length, writer);
+ }
+
+ public void encode(CharSequence s, CharWriter writer) throws EncodingException
+ {
+ for (int i = 0;i < s.length();i++)
+ {
+ encode(s.charAt(i), writer);
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharBuffer.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,234 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * A simple char buffer.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class CharBuffer implements CharWriter
+{
+
+ /** . */
+ protected char[] buffer;
+
+ /** . */
+ protected int length;
+
+ /**
+ *
+ * @param size the initial size
+ * @throws IllegalArgumentException if the initial size is not a positive value.
+ */
+ public CharBuffer(int size) throws IllegalArgumentException
+ {
+ if (size < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.buffer = new char[size];
+ this.length = 0;
+ }
+
+ public CharBuffer()
+ {
+ this.buffer = new char[512];
+ this.length = 0;
+ }
+
+ public CharBuffer append(String s, CharEncoder encoder)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (encoder == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ encoder.encode(s, this);
+ return this;
+ }
+
+ public CharWriter append(CharSequence s)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ appendNoCheck(s);
+ return this;
+ }
+
+ public CharWriter append(char[] chars, int off, int len)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off + len > chars.length)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ appendNoCheck(chars, off, len);
+
+ //
+ return this;
+ }
+
+
+ public CharWriter append(char c)
+ {
+ ensureCapacity(length + 1);
+
+ //
+ buffer[length++] = c;
+
+ //
+ return this;
+ }
+
+ public CharWriter append(char[] chars)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ appendNoCheck(chars, 0, chars.length);
+
+ //
+ return this;
+ }
+
+ public String asString()
+ {
+ return asString(true);
+ }
+
+ public String asString(boolean reset)
+ {
+ String s = new String(buffer, 0, length);
+ if (reset)
+ {
+ reset();
+ }
+ return s;
+ }
+
+ public int getCapacity()
+ {
+ return buffer.length;
+ }
+
+ public int getLength()
+ {
+ return length;
+ }
+
+ public void setLength(int length)
+ {
+ if (length < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ this.length = length;
+
+ //
+ if (length > buffer.length)
+ {
+ char[] tmp = new char[length];
+ System.arraycopy(buffer, 0, tmp, 0, buffer.length);
+ buffer = tmp;
+ }
+ }
+
+ public void reset()
+ {
+ this.length = 0;
+ }
+
+ protected final void appendNoCheck(char[] chars, int off, int len)
+ {
+ ensureCapacity(length + len);
+ if (len < 10)
+ {
+ while (off < len)
+ {
+ buffer[length++] = chars[off++];
+ }
+ }
+ else
+ {
+ System.arraycopy(chars, off, buffer, length, len);
+ length += len;
+ }
+ }
+
+ protected final void appendNoCheck(CharSequence s)
+ {
+ ensureCapacity(length + s.length());
+
+ //
+ if (s instanceof String)
+ {
+ ((String)s).getChars(0, s.length(), buffer, length);
+ length += s.length();
+ }
+ else
+ {
+ for (int i = 0;i < s.length();i++)
+ {
+ char c = s.charAt(i);
+ buffer[length++] = c;
+ }
+ }
+ }
+
+ protected final void ensureCapacity(int minimumCapacity)
+ {
+ int capacity = buffer.length;
+ if (capacity < minimumCapacity)
+ {
+ while (capacity < minimumCapacity)
+ {
+ capacity = capacity * 2 + 1;
+ }
+ char[] tmp = new char[capacity];
+ System.arraycopy(buffer, 0, tmp, 0, length);
+ buffer = tmp;
+ }
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharEncoder.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CharEncoder
+{
+ void encode(char c, CharWriter writer) throws EncodingException;
+ void encode(char[] chars, int off, int len, CharWriter writer) throws EncodingException;
+ void encode(char[] chars, CharWriter writer) throws EncodingException;
+ void encode(CharSequence s, CharWriter writer) throws EncodingException;
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharToByteEncoder.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharToByteEncoder.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharToByteEncoder.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.Charset;
+import java.nio.CharBuffer;
+import java.nio.ByteBuffer;
+
+/**
+ * Defines an interface for encoding a char to a sequence of bytes.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CharToByteEncoder
+{
+
+ /**
+ * Encode the specified char. The returned byte array can be used safely until a new invocation to the same
+ * object is done. If the returned array has a length of zero it means that the char cannot be encoded.
+ *
+ * @param c the char to encode
+ * @return the encoded char as a byte array
+ * @throws EncodingException
+ */
+ byte[] encode(char c) throws EncodingException;
+
+ /** . */
+ final byte[] EMPTY = new byte[0];
+
+ /**
+ * Generic implementation that works for any charset, based on NIO.
+ */
+ public static class Generic implements CharToByteEncoder
+ {
+
+ /** . */
+ public static final Generic UTF8 = new Generic("UTF8");
+
+ /** . */
+ private final CharsetEncoder encoder;
+
+ /** . */
+ private final java.nio.CharBuffer in;
+
+ /** . */
+ private final ByteBuffer out;
+
+ /** . */
+ private final byte[][] arrays = {new byte[0],new byte[1],new byte[2],new byte[3],new byte[4], new byte[5]};
+
+ public Generic(Charset charset)
+ {
+ encoder = charset.newEncoder();
+ in = CharBuffer.allocate(1);
+ out = ByteBuffer.allocate(100);
+ }
+
+ public Generic(String encoding)
+ {
+ this(Charset.forName(encoding));
+ }
+
+ public byte[] encode(char c) throws EncodingException
+ {
+ switch(Character.getType(c))
+ {
+ case Character.SURROGATE:
+ case Character.PRIVATE_USE:
+ return EMPTY;
+ default:
+ if (encoder.canEncode(c))
+ {
+ in.rewind();
+ out.rewind();
+ in.put(0, c);
+ encoder.reset();
+ encoder.encode(in, out, true);
+ encoder.flush(out);
+ int length = out.position();
+ byte[] bytes = arrays[length];
+ System.arraycopy(out.array(), 0, bytes, 0, length);
+ return bytes;
+ }
+ else
+ {
+ return EMPTY;
+ }
+ }
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharWriter.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharWriter.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/CharWriter.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface CharWriter
+{
+ CharWriter append(char c);
+ CharWriter append(char[] chars, int off, int len);
+ CharWriter append(char[] chars);
+ CharWriter append(CharSequence s);
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/EncodingException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/EncodingException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/EncodingException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class EncodingException extends RuntimeException
+{
+ public EncodingException()
+ {
+ }
+
+ public EncodingException(String string)
+ {
+ super(string);
+ }
+
+ public EncodingException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public EncodingException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLDecoder.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,388 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.jboss.portal.common.io.WriterCharWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FastURLDecoder implements CharEncoder
+{
+
+ /** . */
+ private static final FastURLDecoder UTF8 = new FastURLDecoder(CharToByteEncoder.Generic.UTF8);
+
+ /** . */
+ private static final FastURLDecoder UTF8_STRICT = new FastURLDecoder(CharToByteEncoder.Generic.UTF8, true);
+
+ public static FastURLDecoder getUTF8Instance()
+ {
+ return UTF8;
+ }
+
+ public static FastURLDecoder getUTF8StrictInstance()
+ {
+ return UTF8_STRICT;
+ }
+
+ /** . */
+ private static final char FROM = 0;
+
+ /** . */
+ private static final char TO = (char)0x10FFFD;
+
+ /** . */
+ private static final int AS_IS = 0;
+
+ /** . */
+ private static final int PLUS = 1;
+
+ /** . */
+ private static final int ESCAPE = 2;
+
+ /** . */
+ private static final int ERROR = 3;
+
+ /** . */
+ private final LookupNonTerm root;
+
+ /** . */
+ private final int[] decisions;
+
+ /** . */
+ private final int[][] conversions;
+
+ /** . */
+ private final boolean strict;
+
+ public FastURLDecoder(CharToByteEncoder encoder)
+ {
+ this(encoder, false);
+ }
+
+ public FastURLDecoder(CharToByteEncoder encoder, boolean strict)
+ {
+ this.strict = strict;
+
+ //
+ root = new LookupNonTerm();
+ for (char c = FROM; c <= TO; c++)
+ {
+ byte[] v = encoder.encode(c);
+ LookupNonTerm node = root;
+ int k = v.length;
+ for (int i = 0; i < k; i++)
+ {
+ int index = (int)v[i] & 0xFF;
+ if (i == k - 1)
+ {
+ node.children[index] = new LookupTerm(c);
+ }
+ else
+ {
+ if (node.children[index] == null)
+ {
+ node.children[index] = new LookupNonTerm();
+ }
+ node = (LookupNonTerm)node.children[index];
+ }
+ }
+ }
+
+ //
+ conversions = new int[256][256];
+ for (char i = 0; i < 256; i++)
+ {
+ int x = hexValue(i);
+ for (char j = 0; j < 256; j++)
+ {
+ int y = hexValue(j);
+ if (x != -1 && y != -1)
+ {
+ conversions[i][j] = (x << 4) + y;
+ }
+ else
+ {
+ conversions[i][j] = -1;
+ }
+ }
+ }
+
+ //
+ decisions = new int[256];
+ for (int i = 0; i < decisions.length; i++)
+ {
+ if (TextTools.isAlphaNumeric((char)i))
+ {
+ decisions[i] = AS_IS;
+ }
+ else
+ {
+ switch (i)
+ {
+ case '+':
+ decisions[i] = PLUS;
+ break;
+ case '.':
+ case '-':
+ case '*':
+ case '_':
+ decisions[i] = AS_IS;
+ break;
+ case '%':
+ decisions[i] = ESCAPE;
+ break;
+ default:
+ decisions[i] = ERROR;
+ break;
+ }
+ }
+ }
+ }
+
+ public void encode(char c, CharWriter writer)
+ {
+ encode(new char[]{c}, writer);
+ }
+
+ public void encode(char[] chars, int off, int len, CharWriter writer)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (len < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off + len > chars.length)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ encodeNoCheck(chars, off, len, writer);
+ }
+
+ public void encode(char[] chars, CharWriter writer)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ encodeNoCheck(chars, 0, chars.length, writer);
+ }
+
+ public void encode(CharSequence s, CharWriter writer)
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ if (s instanceof String)
+ {
+ char[] chars = ((String)s).toCharArray();
+ encodeNoCheck(chars, 0, chars.length, writer);
+ }
+ else
+ {
+ char[] chars = new char[s.length()];
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ chars[i] = c;
+ }
+ encodeNoCheck(chars, 0, chars.length, writer);
+ }
+ }
+
+ /**
+ * @param s
+ * @return
+ * @throws IllegalArgumentException
+ * @since 1.1
+ */
+ public String encode(String s) throws IllegalArgumentException
+ {
+ Writer sw = new StringWriter();
+ CharWriter charWriter = new WriterCharWriter(sw);
+ encodeNoCheck(s.toCharArray(), 0, s.length(), charWriter);
+ return sw.toString();
+ }
+
+ private void encodeNoCheck(char[] chars, int i, int length, CharWriter tmp)
+ {
+ while (i < length)
+ {
+ char c = chars[i++];
+ int decision = c < 256 ? decisions[c] : ERROR;
+ switch (decision)
+ {
+ case AS_IS:
+ tmp.append(c);
+ break;
+ case PLUS:
+ tmp.append(' ');
+ break;
+ case ESCAPE:
+ int j = i;
+
+ //
+ LookupNonTerm current = root;
+ while (true)
+ {
+ if (j + 2 > length)
+ {
+ throw new MalformedInputException("Not enough chars to decode an escaped value length should have been" +
+ (j + 2) + " but is " + length);
+ }
+
+ //
+ char c1 = chars[j++];
+ char c2 = chars[j++];
+
+ //
+ if (c1 > 255)
+ {
+ throw new MalformedInputException("Input out of the lookup range (" + c1 + "," + c2 + ")");
+ }
+ if (c2 > 255)
+ {
+ throw new MalformedInputException("Input out of the lookup range (" + c1 + "," + c2 + ")");
+ }
+
+
+ int z = conversions[c1][c2];
+
+ //
+ if (z == -1)
+ {
+ throw new MalformedInputException("Input out of the lookup range (" + c1 + "," + c2 + ")");
+ }
+
+ //
+ LookupNode child = current.children[z];
+ if (child instanceof LookupTerm)
+ {
+ LookupTerm term = (LookupTerm)child;
+ tmp.append(term.c);
+ i = j;
+ break;
+ }
+ else
+ {
+ current = (LookupNonTerm)child;
+ }
+
+ //
+ j++;
+ }
+ break;
+ case ERROR:
+ if (strict)
+ {
+ throw new MalformedInputException("Cannot decode char " + c);
+ }
+ else
+ {
+ tmp.append(c);
+ }
+ break;
+ }
+ }
+ }
+
+ public boolean isStrict()
+ {
+ return strict;
+ }
+
+ private static class LookupNode
+ {
+ }
+
+ private static class LookupTerm extends LookupNode
+ {
+
+ /** . */
+ private final char c;
+
+ public LookupTerm(char c)
+ {
+ this.c = c;
+ }
+ }
+
+ private static class LookupNonTerm extends LookupNode
+ {
+ private final LookupNode[] children = new LookupNode[256];
+ }
+
+ /**
+ * Returns the hex value of the char c. If the char cannot be converted then -1 is returned.
+ *
+ * @param c the char to convert
+ * @return the converted hex value
+ */
+ private static int hexValue(char c)
+ {
+ if (c >= 'A' && c <= 'F')
+ {
+ return c - 'A' + 10;
+ }
+ if (c >= 'a' && c <= 'f')
+ {
+ return c - 'a' + 10;
+ }
+ if (c >= '0' && c <= '9')
+ {
+ return c - '0';
+ }
+ return -1;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/FastURLEncoder.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,267 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * An implementation based on a table for lookups.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class FastURLEncoder implements CharEncoder
+{
+
+ /** . */
+ private static final FastURLEncoder DEFAULT_ENCODER = new FastURLEncoder(CharToByteEncoder.Generic.UTF8);
+
+ public static FastURLEncoder getUTF8Instance()
+ {
+ return DEFAULT_ENCODER;
+ }
+
+ /** . */
+ private final char[][] table;
+
+ /** . */
+ private static final char MAX = (char)0x10FFFD;
+
+ public FastURLEncoder(CharToByteEncoder encoder) throws IllegalArgumentException
+ {
+ if (encoder == null)
+ {
+ throw new IllegalArgumentException("No encoding provided");
+ }
+
+ //
+ this.table = new char[MAX + 1][];
+
+ //
+ for (char c = 0; c <= MAX; c++)
+ {
+ char[] z;
+ if (TextTools.isAlphaNumeric(c))
+ {
+ z = new char[]{c};
+ }
+ else
+ {
+ switch (c)
+ {
+ case ' ':
+ z = new char[]{'+'};
+ break;
+ case '.':
+ case '-':
+ case '*':
+ case '_':
+ z = new char[]{c};
+ break;
+ default:
+ byte[] v = encoder.encode(c);
+ if (v.length > 0)
+ {
+ z = new char[v.length * 3];
+ int index = 0;
+ for (int i = 0; i < v.length; i++)
+ {
+ byte b = v[i];
+ z[index++] = '%';
+ z[index++] = TextTools.toHex((b & 0xF0) >> 4);
+ z[index++] = TextTools.toHex(b & 0x0F);
+ }
+ }
+ else
+ {
+ z = null;
+ }
+ break;
+ }
+ }
+ table[c] = z;
+ }
+ }
+
+ public void encode(CharSequence s, CharWriter out) throws IllegalArgumentException
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (out == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new MalformedInputException("Wrong");
+ }
+ out.append(z);
+ }
+ }
+
+ public void encode(char c, CharWriter writer)
+ {
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new MalformedInputException("Wrong");
+ }
+ writer.append(z);
+ }
+
+ public void encode(char[] chars, int off, int len, CharWriter writer)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (len < 0)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (off + len > chars.length)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ encodeNoCheck(chars, off, len, writer);
+ }
+
+ public void encode(char[] chars, CharWriter writer)
+ {
+ if (chars == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (writer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ encodeNoCheck(chars, 0, chars.length, writer);
+ }
+
+ private void encodeNoCheck(char[] chars, int off, int len, CharWriter writer)
+ {
+ for (int i = off; i < len; i++)
+ {
+ char c = chars[i];
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new IllegalArgumentException("Wrong");
+ }
+ writer.append(z);
+ }
+ }
+
+ public String encode(String s) throws IllegalArgumentException
+ {
+ StringBuffer tmp = new StringBuffer();
+ encode(s, tmp);
+ return tmp.toString();
+ }
+
+ public void encode(String s, StringBuffer out) throws IllegalArgumentException
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (out == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new MalformedInputException("Cannot encode char=" + (int)c);
+ }
+ out.append(z);
+ }
+ }
+
+ public void encode(String s, Writer out) throws IllegalArgumentException, UndeclaredIOException
+ {
+ if (s == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (out == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ for (int i = 0; i < s.length(); i++)
+ {
+ char c = s.charAt(i);
+ char[] z = table[c];
+ if (z == null)
+ {
+ throw new MalformedInputException("Wrong");
+ }
+ out.write(z);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new UndeclaredIOException(e);
+ }
+ }
+
+ public String toString()
+ {
+ return "FastURLEncoder[" + "" + ",[" + 0 + "," + MAX + "]]";
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/MalformedInputException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/MalformedInputException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/MalformedInputException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MalformedInputException extends EncodingException
+{
+ public MalformedInputException()
+ {
+ }
+
+ public MalformedInputException(String string)
+ {
+ super(string);
+ }
+
+ public MalformedInputException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public MalformedInputException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/TextTools.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/TextTools.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/TextTools.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TextTools
+{
+
+ /**
+ * Returns true if the char c is alpha numeric i.e it belongs to one of the following ranges [0,9], [A,Z] or
+ * [a,z]
+ * @param c the char to test
+ * @return true if c is alpha numeric
+ */
+ public static boolean isAlphaNumeric(char c)
+ {
+ return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
+ }
+
+ /**
+ * Returns the hexadecimal value of the provided numeric value.
+ * @param z the numeric value to convert
+ * @return the hexadecimal char
+ * @throws IllegalArgumentException if the value is not between 0 and 15
+ */
+ public static char toHex(int z) throws IllegalArgumentException
+ {
+ if (z >= 0 && z < 10)
+ {
+ return (char)('0' + z);
+ }
+ else if (z >= 10 && z < 16)
+ {
+ return (char)('A' - 10 + z);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Wrong character");
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/UnsupportedCharsetException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/UnsupportedCharsetException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/text/UnsupportedCharsetException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.text;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UnsupportedCharsetException extends EncodingException
+{
+ public UnsupportedCharsetException()
+ {
+ }
+
+ public UnsupportedCharsetException(String string)
+ {
+ super(string);
+ }
+
+ public UnsupportedCharsetException(String string, Throwable throwable)
+ {
+ super(string, throwable);
+ }
+
+ public UnsupportedCharsetException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.transaction;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class NestedException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 8546585764241990455L;
+
+ public NestedException(Throwable throwable)
+ {
+ super(throwable);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/NestedException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.transaction;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class TransactionException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 8968893103336776336L;
+ public TransactionException()
+ {
+ }
+ public TransactionException(Throwable cause)
+ {
+ super(cause);
+ }
+ public TransactionException(String message)
+ {
+ super(message);
+ }
+ public TransactionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.transaction;
+
+import javax.transaction.TransactionManager;
+import javax.naming.InitialContext;
+
+/**
+ * Implementations provides access to a transaction manager.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public interface TransactionManagerProvider
+{
+ /**
+ * Provide access to the transaction manager.
+ *
+ * @return return the transaction manager.
+ * @throws Exception any exception that prevent to get the transaction manager
+ */
+ TransactionManager getTransactionManager() throws Exception;
+
+ /**
+ * JBoss transaction manager provider implementation.
+ */
+ TransactionManagerProvider JBOSS_PROVIDER = new TransactionManagerProvider()
+ {
+ public TransactionManager getTransactionManager() throws Exception
+ {
+ return (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
+ }
+ };
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/TransactionManagerProvider.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,704 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.transaction;
+
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.NotSupportedException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.RollbackException;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Utility class for managing transactions.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class Transactions
+{
+
+ /** . */
+ private static Logger log = Logger.getLogger(Transactions.class);
+
+ /** . */
+ private static final String[] STATUS_NAMES = {
+ "STATUS_ACTIVE",
+ "STATUS_MARKED_ROLLBACK",
+ "STATUS_PREPARED",
+ "STATUS_COMMITTED",
+ "STATUS_ROLLEDBACK",
+ "STATUS_UNKNOWN",
+ "STATUS_NO_TRANSACTION",
+ "STATUS_PREPARING",
+ "STATUS_COMMITTING",
+ "STATUS_ROLLING_BACK"};
+
+ /**
+ * Decode the status name.
+ *
+ * @param status the status value
+ * @return the translated status name or null if it is not valid
+ */
+ public static String decodeStatus(int status)
+ {
+ if (status >= 0 && status <= STATUS_NAMES.length)
+ {
+ return STATUS_NAMES[status];
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * Apply the transaction type before the unit of work.
+ *
+ * @param type the transaction type
+ * @param tm the transaction manager
+ * @return the new transaction if one has been started.
+ * @throws TransactionException
+ * @throws IllegalArgumentException if the type or the transaction manager is null
+ */
+ public static Transaction applyBefore(Type type, TransactionManager tm) throws TransactionException, IllegalArgumentException
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager provided");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No type");
+ }
+
+ // Suspend the incoming transaction
+ Transaction oldTx = suspend(tm);
+
+ if (oldTx != null)
+ {
+ type.txBefore(tm, oldTx);
+ }
+ else
+ {
+ type.noTxBefore(tm);
+ }
+
+ return oldTx;
+ }
+
+ /**
+ * Apply the transaction type after the unit of work has been done.
+ *
+ * @param type the transaction type
+ * @param tm the transaction manager
+ * @param oldTx the old transaction if it is not null
+ * @throws TransactionException
+ * @throws IllegalArgumentException if the type of the transaction manager is null
+ */
+ public static void applyAfter(Type type, TransactionManager tm, Transaction oldTx) throws TransactionException, IllegalArgumentException
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager provided");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No type");
+ }
+
+ try
+ {
+ if (oldTx != null)
+ {
+ type.txAfter(tm, oldTx);
+ }
+ else
+ {
+ type.noTxAfter(tm);
+ }
+ }
+ finally
+ {
+ if (oldTx != null)
+ {
+ try
+ {
+ resume(tm, oldTx);
+ }
+ catch (TransactionException ignore)
+ {
+ log.error("Was not capable to resume the incoming transaction", ignore);
+ }
+ }
+ }
+ }
+
+ /**
+ * Apply the transaction type around the unit of work.
+ *
+ * @param type the transaction type
+ * @param tm the transaction manager
+ * @param runnable the unit of work
+ * @return the object returned by the runnable object
+ * @throws NestedException wraps any exception throws by the runnable object
+ * @throws TransactionException
+ * @throws IllegalArgumentException if any method argument is null
+ */
+ public static Object apply(Type type, TransactionManager tm, final Runnable runnable) throws NestedException, TransactionException, IllegalArgumentException
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager provided");
+ }
+ if (runnable == null)
+ {
+ throw new IllegalArgumentException("No code to execute");
+ }
+ if (type == null)
+ {
+ throw new IllegalArgumentException("No type");
+ }
+
+ // Any throwable thrown by the wrapped code
+ Throwable throwable = null;
+
+ // Any object returned by the wrapped code
+ Object ret = null;
+
+ // Suspend the incoming transaction
+ Transaction oldTx = suspend(tm);
+
+ try
+ {
+ if (oldTx != null)
+ {
+ type.txBefore(tm, oldTx);
+ try
+ {
+ ret = runnable.run();
+ }
+ catch (Throwable t)
+ {
+ throwable = t;
+ }
+ finally
+ {
+ type.txAfter(tm, oldTx);
+ }
+ }
+ else
+ {
+ type.noTxBefore(tm);
+ try
+ {
+ ret = runnable.run();
+ }
+ catch (Throwable t)
+ {
+ throwable = t;
+ }
+ finally
+ {
+ type.noTxAfter(tm);
+ }
+ }
+ }
+ finally
+ {
+ if (oldTx != null)
+ {
+ try
+ {
+ resume(tm, oldTx);
+ }
+ catch (TransactionException ignore)
+ {
+ log.error("Was not capable to resume the incoming transaction", ignore);
+ }
+ }
+ }
+ if (throwable != null)
+ {
+ if (throwable instanceof Error)
+ {
+ throw (Error)throwable;
+ }
+ else
+ {
+ throw new NestedException(throwable);
+ }
+ }
+ else
+ {
+ return ret;
+ }
+ }
+
+ public static Object notSupported(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_NOT_SUPPORTED, tm, runnable);
+ }
+
+ public static Object never(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_NEVER, tm, runnable);
+ }
+
+ public static Object mandatory(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_MANDATORY, tm, runnable);
+ }
+
+ public static Object supports(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_SUPPORTS, tm, runnable);
+ }
+
+ public static Object required(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_REQUIRED, tm, runnable);
+ }
+
+ public static Object requiresNew(TransactionManager tm, Runnable runnable)
+ throws NestedException, TransactionException
+ {
+ return apply(TYPE_REQUIRES_NEW, tm, runnable);
+ }
+
+ /**
+ * Begin a new transaction.
+ *
+ * @param tm the transaction manager
+ * @throws IllegalArgumentException if the tm is null
+ */
+ public static void begin(TransactionManager tm) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ tm.begin();
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when beginning transaction", e);
+ throw new TransactionException(e);
+ }
+ catch (NotSupportedException e)
+ {
+ log.error("Problem when beginning transaction", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ /**
+ * Mark the transaction as rollback only.
+ *
+ * @param tx the transaction to mark as rollback only
+ * @throws IllegalArgumentException if the transaction is null
+ * @throws TransactionException
+ */
+ private static void setRollbackOnly(Transaction tx) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tx == null)
+ {
+ throw new IllegalArgumentException("No transaction to set rollback only");
+ }
+ tx.setRollbackOnly();
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when setting transaction as rollback only", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ /**
+ * Mark the active transaction for this thread as rollback only
+ *
+ * @see #setRollbackOnly(javax.transaction.Transaction)
+ * @param tm the transaction manager
+ * @throws IllegalArgumentException if the tm is null
+ */
+ public static void setRollbackOnly(TransactionManager tm) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ Transaction tx = tm.getTransaction();
+ if (tx == null)
+ {
+ throw new TransactionException("No active transaction to set rollback only");
+ }
+ setRollbackOnly(tx);
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when setting transaction as rollback only", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ public void safeSetRollbackOnly(TransactionManager tm)
+ {
+ try
+ {
+ setRollbackOnly(tm);
+ }
+ catch (IllegalArgumentException e)
+ {
+ log.error("", e);
+ }
+ catch (TransactionException e)
+ {
+ log.error("", e);
+ }
+ }
+
+ public static void safeEnd(TransactionManager tm)
+ {
+ try
+ {
+ end(tm);
+ }
+ catch (IllegalArgumentException e)
+ {
+ log.error("", e);
+ }
+ catch (TransactionException e)
+ {
+ log.error("", e);
+ }
+ }
+
+ /**
+ * Terminate the active transaction for this thread. If the transaction is marked for rollback
+ * then it is rollbacked otherwise it is commited.
+ *
+ * @param tm the transaction manager
+ * @return true if commit happened, false otherwise
+ * @throws IllegalArgumentException if the tm is null
+ */
+ public static boolean end(TransactionManager tm) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ int status = tm.getStatus();
+ switch (status)
+ {
+ case Status.STATUS_MARKED_ROLLBACK:
+ tm.rollback();
+ return false;
+ case Status.STATUS_ACTIVE:
+ tm.commit();
+ return true;
+ default:
+ throw new TransactionException("Abnormal status for ending a tx " + STATUS_NAMES[status]);
+ }
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when ending transaction", e);
+ throw new TransactionException(e);
+ }
+ catch (HeuristicMixedException e)
+ {
+ log.error("Problem when ending transaction", e);
+ throw new TransactionException(e);
+ }
+ catch (HeuristicRollbackException e)
+ {
+ log.error("Problem when ending transaction", e);
+ throw new TransactionException(e);
+ }
+ catch (RollbackException e)
+ {
+ log.error("Problem when ending transaction", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ /**
+ * Associate the thread with a transaction
+ *
+ * @param tm the transaction manager
+ * @param tx the transaction to associate with the this thread
+ * @throws IllegalArgumentException if any argument is null
+ * @throws TransactionException
+ */
+ public static void resume(TransactionManager tm, Transaction tx) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ if (tx == null)
+ {
+ throw new IllegalArgumentException("No transaction to resume");
+ }
+ tm.resume(tx);
+ }
+ catch (Exception e)
+ {
+ log.error("Problem when resuming transaction", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ /**
+ * Disassociate the current thread with the active transaction.
+ *
+ * @param tm the transaction manager
+ * @return the transaction previously associated with this thread
+ * @throws IllegalArgumentException if the transaction manager is null
+ * @throws TransactionException
+ */
+ public static Transaction suspend(TransactionManager tm) throws IllegalArgumentException, TransactionException
+ {
+ try
+ {
+ if (tm == null)
+ {
+ throw new IllegalArgumentException("No transaction manager");
+ }
+ return tm.suspend();
+ }
+ catch (SystemException e)
+ {
+ log.error("Problem when suspending transaction", e);
+ throw new TransactionException(e);
+ }
+ }
+
+ public interface Runnable
+ {
+ Object run() throws Exception;
+ }
+
+ public abstract static class Type
+ {
+ private final String name;
+
+ private Type(String name)
+ {
+ this.name = name;
+ }
+
+ public Transaction before(TransactionManager tm)
+ {
+ return applyBefore(this, tm);
+ }
+
+ public void after(TransactionManager tm, Transaction oldTx)
+ {
+ applyAfter(this, tm, oldTx);
+ }
+
+ abstract void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException;
+
+ abstract void txAfter(TransactionManager tm, Transaction oldTx);
+
+ abstract void noTxBefore(TransactionManager tm) throws TransactionException;
+
+ abstract void noTxAfter(TransactionManager tm);
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+ }
+
+ public static final Type TYPE_NOT_SUPPORTED = new Type("NOT_SUPPORTED")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx)
+ {
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ }
+ void noTxBefore(TransactionManager tm)
+ {
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ }
+ };
+
+ public static final Type TYPE_SUPPORTS = new Type("SUPPORTS")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException
+ {
+ resume(tm, oldTx);
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ try
+ {
+ suspend(tm);
+ }
+ catch (IllegalStateException ignore)
+ {
+ log.error("Problem when suspending transaction", ignore);
+ }
+ }
+ void noTxBefore(TransactionManager tm)
+ {
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ }
+ };
+
+ public static final Type TYPE_REQUIRED = new Type("REQUIRED")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx)
+ {
+ resume(tm, oldTx);
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ try
+ {
+ suspend(tm);
+ }
+ catch (TransactionException ignore)
+ {
+ log.error("Problem when suspending transaction", ignore);
+ }
+ }
+ void noTxBefore(TransactionManager tm) throws TransactionException
+ {
+ begin(tm);
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ try
+ {
+ end(tm);
+ }
+ catch (IllegalStateException ignore)
+ {
+ log.error("Problem when ending transaction", ignore);
+ }
+ }
+ };
+
+ public static final Type TYPE_REQUIRES_NEW = new Type("REQUIRES_NEW")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException
+ {
+ begin(tm);
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ try
+ {
+ end(tm);
+ }
+ catch (IllegalStateException ignore)
+ {
+ log.error("Problem when ending transaction", ignore);
+ }
+ }
+ void noTxBefore(TransactionManager tm) throws TransactionException
+ {
+ begin(tm);
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ try
+ {
+ end(tm);
+ }
+ catch (IllegalStateException ignore)
+ {
+ log.error("Problem when ending transaction", ignore);
+ }
+ }
+ };
+
+ public static final Type TYPE_MANDATORY = new Type("MANDATORY")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException
+ {
+ resume(tm, oldTx);
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ }
+ void noTxBefore(TransactionManager tm) throws TransactionException
+ {
+ throw new TransactionException("No incoming transaction");
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ throw new UnsupportedOperationException("Should never ne called");
+ }
+ };
+
+ public static final Type TYPE_NEVER = new Type("NEVER")
+ {
+ void txBefore(TransactionManager tm, Transaction oldTx) throws TransactionException
+ {
+ throw new TransactionException("Need no incoming transaction");
+ }
+ void txAfter(TransactionManager tm, Transaction oldTx)
+ {
+ throw new UnsupportedOperationException("Should never ne called");
+ }
+ void noTxBefore(TransactionManager tm)
+ {
+ }
+ void noTxAfter(TransactionManager tm)
+ {
+ }
+ };
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/transaction/Transactions.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,560 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * <p>Encodes and decodes to and from Base64 and URL-safe Base64 encodings. URL-safe Base64 encoding being defined here
+ * as standard Base64 encoding with the following modifications:</p>
+ * <ul>
+ * <li>use '-' and '_' instead of '+' and '/'</li>
+ * <li>no line feeds</li>
+ * <li>padding character is '*' instead of '='</li>
+ * </ul>
+ * <p/>
+ * <p>Based on version 2.1 of the Base64 class developed by Robert Harder (public domain).
+ * Please visit <a href="http://iharder.net/base64">http://iharder.net/base64</a>
+ * periodically to check for updates or to contribute improvements.
+ * </p>
+ *
+ * @author <a href="mailto:rob@iharder.net">Robert Harder</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @since 2.4 (Apr 30, 2006)
+ */
+public class Base64
+{
+
+/* ******** P R I V A T E F I E L D S ******** */
+
+
+ /** Maximum line length (76) of Base64 output. */
+ private final static int MAX_LINE_LENGTH = 76;
+
+
+ /** The equals sign (=) as a byte. */
+ private final static byte EQUALS_SIGN = (byte)'=';
+
+ /** '*' as a byte */
+ private final static byte STAR = (byte)'*';
+
+ /** The character to be used as a padding character in the encoded Strings. */
+ private byte PADDING_CHAR;
+
+
+ /** The new line character (\n) as a byte. */
+ private final static byte NEW_LINE = (byte)'\n';
+
+
+ /** Preferred encoding. */
+ private final static String PREFERRED_ENCODING = "UTF-8";
+
+
+ /** The 64 valid Base64 values. */
+ private byte[] ALPHABET;
+ private final static byte[] NATIVE_ALPHABET = /* May be something funny like EBCDIC */
+ {
+ (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G',
+ (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N',
+ (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U',
+ (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z',
+ (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g',
+ (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n',
+ (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u',
+ (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z',
+ (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5',
+ (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/'
+ };
+ private final static byte[] NATIVE_URL_SAFE_ALPHABET =
+ {
+ (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G',
+ (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N',
+ (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U',
+ (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z',
+ (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g',
+ (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n',
+ (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u',
+ (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z',
+ (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5',
+ (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'-', (byte)'_'
+ };
+
+ private static final int IGNORE = -9; // Indicates ignored characters
+ private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding
+ private final static byte PADDING_CHAR_ENC = -1; // Indicates equals sign in encoding
+
+ /**
+ * Translates a value to either its 6-bit reconstruction value
+ * or a negative number indicating some other meaning.
+ */
+ private byte[] DECODABET;
+
+ /**
+ * Translates a Base64 value to either its 6-bit reconstruction value
+ * or a negative number indicating some other meaning.
+ */
+ private final static byte[] BASE64_DECODABET =
+ {
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 0 - 8
+ WHITE_SPACE_ENC, WHITE_SPACE_ENC, // Whitespace: Tab and Linefeed
+ IGNORE, IGNORE, // Decimal 11 - 12
+ WHITE_SPACE_ENC, // Whitespace: Carriage Return
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 14 - 26
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 27 - 31
+ WHITE_SPACE_ENC, // Whitespace: Space
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 33 - 42
+ 62, // Plus sign at decimal 43
+ IGNORE, IGNORE, IGNORE, // Decimal 44 - 46
+ 63, // Slash at decimal 47
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine
+ IGNORE, IGNORE, IGNORE, // Decimal 58 - 60
+ PADDING_CHAR_ENC, // Equals sign at decimal 61 (padding character)
+ IGNORE, IGNORE, IGNORE, // Decimal 62 - 64
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 91 - 96
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'
+ IGNORE, IGNORE, IGNORE, IGNORE // Decimal 123 - 126
+ };
+
+ /**
+ * Translates a URL-modified Base64 value to either its 6-bit reconstruction value
+ * or a negative number indicating some other meaning.
+ */
+ private final static byte[] URL_SAFE_DECODABET =
+ {
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 0 - 8
+ WHITE_SPACE_ENC, WHITE_SPACE_ENC, // Whitespace: Tab and Linefeed
+ IGNORE, IGNORE, // Decimal 11 - 12
+ WHITE_SPACE_ENC, // Whitespace: Carriage Return
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 14 - 26
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 27 - 31
+ WHITE_SPACE_ENC, // Whitespace: Space
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 33 - 41
+ PADDING_CHAR_ENC, // Star sign at decimal 42 (padding character)
+ IGNORE, IGNORE, // Decimal 43 - 44
+ 62, // Minus sign at decimal 45
+ IGNORE, IGNORE, // Decimal 46 - 47
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, // Numbers zero through nine
+ IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 58 - 64
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, // Letters 'A' through 'N'
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, // Letters 'O' through 'Z'
+ IGNORE, IGNORE, IGNORE, IGNORE, // Decimal 91 - 94
+ 63, // Underscore at decimal 95
+ IGNORE, // Decimal 96
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // Letters 'a' through 'm'
+ 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, // Letters 'n' through 'z'
+ IGNORE, IGNORE, IGNORE, IGNORE // Decimal 123 - 126
+ };
+
+ /** Determine which ALPHABET to use. */
+ public void initAlphabets(boolean useURLSafeEncoding)
+ {
+ byte[] __bytes;
+ String alphabetString;
+ byte[] nativeAlphabet;
+
+ if (useURLSafeEncoding)
+ {
+ alphabetString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
+ nativeAlphabet = NATIVE_URL_SAFE_ALPHABET;
+ PADDING_CHAR = STAR;
+ DECODABET = URL_SAFE_DECODABET;
+ }
+ else
+ {
+ alphabetString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ nativeAlphabet = NATIVE_ALPHABET;
+ PADDING_CHAR = EQUALS_SIGN;
+ DECODABET = BASE64_DECODABET;
+ }
+
+ try
+ {
+ __bytes = alphabetString.getBytes(PREFERRED_ENCODING);
+ } // end try
+ catch (java.io.UnsupportedEncodingException use)
+ {
+ __bytes = nativeAlphabet; // Fall back to native encoding
+ } // end catch
+ ALPHABET = __bytes;
+ } // end initAlphabets
+
+ private static final Base64 STANDARD_BASE64 = new Base64();
+ private static final Base64 URL_SAFE_BASE64 = new Base64(true);
+
+ private Base64()
+ {
+ this(false);
+ }
+
+ private Base64(boolean useURLSafeEncoding)
+ {
+ initAlphabets(useURLSafeEncoding);
+ }
+
+ private static Base64 getBase64(boolean useURLSafeEncoding)
+ {
+ return useURLSafeEncoding ? URL_SAFE_BASE64 : STANDARD_BASE64;
+ }
+
+/* ******** E N C O D I N G M E T H O D S ******** */
+
+
+ /**
+ * Encodes up to three bytes of the array <var>source</var>
+ * and writes the resulting four Base64 bytes to <var>destination</var>.
+ * The source and destination arrays can be manipulated
+ * anywhere along their length by specifying
+ * <var>srcOffset</var> and <var>destOffset</var>.
+ * This method does not check to make sure your arrays
+ * are large enough to accomodate <var>srcOffset</var> + 3 for
+ * the <var>source</var> array or <var>destOffset</var> + 4 for
+ * the <var>destination</var> array.
+ * The actual number of significant bytes in your array is
+ * given by <var>numSigBytes</var>.
+ *
+ * @param source the array to convert
+ * @param srcOffset the index where conversion begins
+ * @param numSigBytes the number of significant bytes in your array
+ * @param destination the array to hold the conversion
+ * @param destOffset the index where output will be put
+ * @return the <var>destination</var> array
+ */
+ private byte[] encode3to4(byte[] source, int srcOffset, int numSigBytes,
+ byte[] destination, int destOffset)
+ {
+ // 1 2 3
+ // 01234567890123456789012345678901 Bit position
+ // --------000000001111111122222222 Array position from threeBytes
+ // --------| || || || | Six bit groups to index ALPHABET
+ // >>18 >>12 >> 6 >> 0 Right shift necessary
+ // 0x3f 0x3f 0x3f Additional AND
+
+ // Create buffer with zero-padding if there are only one or two
+ // significant bytes passed in the array.
+ // We have to shift left 24 in order to flush out the 1's that appear
+ // when Java treats a value as negative that is cast from a byte to an int.
+ int inBuff = (numSigBytes > 0 ? ((source[srcOffset] << 24) >>> 8) : 0)
+ | (numSigBytes > 1 ? ((source[srcOffset + 1] << 24) >>> 16) : 0)
+ | (numSigBytes > 2 ? ((source[srcOffset + 2] << 24) >>> 24) : 0);
+
+ switch (numSigBytes)
+ {
+ case 3:
+ destination[destOffset] = ALPHABET[(inBuff >>> 18)];
+ destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f];
+ destination[destOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3f];
+ destination[destOffset + 3] = ALPHABET[(inBuff) & 0x3f];
+ return destination;
+
+ case 2:
+ destination[destOffset] = ALPHABET[(inBuff >>> 18)];
+ destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f];
+ destination[destOffset + 2] = ALPHABET[(inBuff >>> 6) & 0x3f];
+ destination[destOffset + 3] = PADDING_CHAR;
+ return destination;
+
+ case 1:
+ destination[destOffset] = ALPHABET[(inBuff >>> 18)];
+ destination[destOffset + 1] = ALPHABET[(inBuff >>> 12) & 0x3f];
+ destination[destOffset + 2] = PADDING_CHAR;
+ destination[destOffset + 3] = PADDING_CHAR;
+ return destination;
+
+ default:
+ return destination;
+ } // end switch
+ } // end encode3to4
+
+ /**
+ * Encodes a byte array into Base64 notation using the standard Base64 encoding.
+ *
+ * @param source The data to convert
+ */
+ public static String encodeBytes(byte[] source)
+ {
+ return encodeBytes(source, 0, source.length, false);
+ } // end encodeBytes
+
+
+ /**
+ * Encodes a byte array into Base64 notation.
+ *
+ * @param source The data to convert
+ * @param useURLSafeEncoding <code>true</code> to use '-', '_' instead of '+', '/' in the alphabet and '*' instead
+ * of '=' for padding to generate a URL-safe encoding. <i>Note: Technically, this makes
+ * your encoding non-compliant.</i>
+ */
+ public static String encodeBytes(byte[] source, boolean useURLSafeEncoding)
+ {
+ return encodeBytes(source, 0, source.length, useURLSafeEncoding);
+ } // end encodeBytes
+
+ /**
+ * Encodes a byte array into Base64 notation.
+ *
+ * @param source The data to convert
+ * @param off Offset in array where conversion should begin
+ * @param len Length of data to convert
+ * @param useURLSafeEncoding <code>true</code> to use '-', '_' instead of '+', '/' in the alphabet and '*' instead
+ * of '=' for padding to generate a URL-safe encoding. <i>Note: Technically, this makes
+ * your encoding non-compliant.</i>
+ */
+ public static String encodeBytes(byte[] source, int off, int len, boolean useURLSafeEncoding)
+ {
+ Base64 b64 = getBase64(useURLSafeEncoding);
+
+ int len43 = len * 4 / 3;
+ byte[] outBuff = new byte[(len43) // Main 4:3
+ + ((len % 3) > 0 ? 4 : 0) // Account for padding
+ + ((!useURLSafeEncoding) ? (len43 / MAX_LINE_LENGTH) : 0)]; // New lines
+ int d = 0;
+ int e = 0;
+ int len2 = len - 2;
+ int lineLength = 0;
+ for (; d < len2; d += 3, e += 4)
+ {
+ b64.encode3to4(source, d + off, 3, outBuff, e);
+
+ lineLength += 4;
+ if (!useURLSafeEncoding && lineLength == MAX_LINE_LENGTH)
+ {
+ outBuff[e + 4] = NEW_LINE;
+ e++;
+ lineLength = 0;
+ } // end if: end of line
+ } // en dfor: each piece of array
+
+ if (d < len)
+ {
+ b64.encode3to4(source, d + off, len - d, outBuff, e);
+ e += 4;
+ } // end if: some padding needed
+
+ // Return value according to relevant encoding.
+ try
+ {
+ return new String(outBuff, 0, e, PREFERRED_ENCODING);
+ } // end try
+ catch (java.io.UnsupportedEncodingException uue)
+ {
+ return new String(outBuff, 0, e);
+ } // end catch
+
+ } // end encodeBytes
+
+/* ******** D E C O D I N G M E T H O D S ******** */
+
+ /**
+ * Decodes four bytes from array <var>source</var>
+ * and writes the resulting bytes (up to three of them)
+ * to <var>destination</var>.
+ * The source and destination arrays can be manipulated
+ * anywhere along their length by specifying
+ * <var>srcOffset</var> and <var>destOffset</var>.
+ * This method does not check to make sure your arrays
+ * are large enough to accomodate <var>srcOffset</var> + 4 for
+ * the <var>source</var> array or <var>destOffset</var> + 3 for
+ * the <var>destination</var> array.
+ * This method returns the actual number of bytes that
+ * were converted from the Base64 encoding.
+ *
+ * @param source the array to convert
+ * @param srcOffset the index where conversion begins
+ * @param destination the array to hold the conversion
+ * @param destOffset the index where output will be put
+ * @return the number of decoded bytes converted
+ */
+ private int decode4to3(byte[] source, int srcOffset, byte[] destination, int destOffset)
+ {
+ // Example: Dk==
+ if (source[srcOffset + 2] == PADDING_CHAR)
+ {
+ // Two ways to do the same thing. Don't know which way I like best.
+ //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
+ // | ( ( DECODABET[ source[ srcOffset + 1] ] << 24 ) >>> 12 );
+ int outBuff = ((DECODABET[source[srcOffset]] & 0xFF) << 18)
+ | ((DECODABET[source[srcOffset + 1]] & 0xFF) << 12);
+
+ destination[destOffset] = (byte)(outBuff >>> 16);
+ return 1;
+ }
+
+ // Example: DkL=
+ else if (source[srcOffset + 3] == PADDING_CHAR)
+ {
+ // Two ways to do the same thing. Don't know which way I like best.
+ //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
+ // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
+ // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 );
+ int outBuff = ((DECODABET[source[srcOffset]] & 0xFF) << 18)
+ | ((DECODABET[source[srcOffset + 1]] & 0xFF) << 12)
+ | ((DECODABET[source[srcOffset + 2]] & 0xFF) << 6);
+
+ destination[destOffset] = (byte)(outBuff >>> 16);
+ destination[destOffset + 1] = (byte)(outBuff >>> 8);
+ return 2;
+ }
+
+ // Example: DkLE
+ else
+ {
+ try
+ {
+ // Two ways to do the same thing. Don't know which way I like best.
+ //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 )
+ // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 )
+ // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 )
+ // | ( ( DECODABET[ source[ srcOffset + 3 ] ] << 24 ) >>> 24 );
+ int outBuff = ((DECODABET[source[srcOffset]] & 0xFF) << 18)
+ | ((DECODABET[source[srcOffset + 1]] & 0xFF) << 12)
+ | ((DECODABET[source[srcOffset + 2]] & 0xFF) << 6)
+ | ((DECODABET[source[srcOffset + 3]] & 0xFF));
+
+
+ destination[destOffset] = (byte)(outBuff >> 16);
+ destination[destOffset + 1] = (byte)(outBuff >> 8);
+ destination[destOffset + 2] = (byte)(outBuff);
+
+ return 3;
+ }
+ catch (Exception e)
+ {
+ System.out.println("" + source[srcOffset] + ": " + (DECODABET[source[srcOffset]]));
+ System.out.println("" + source[srcOffset + 1] + ": " + (DECODABET[source[srcOffset + 1]]));
+ System.out.println("" + source[srcOffset + 2] + ": " + (DECODABET[source[srcOffset + 2]]));
+ System.out.println("" + source[srcOffset + 3] + ": " + (DECODABET[source[srcOffset + 3]]));
+ return -1;
+ } //e nd catch
+ }
+ } // end decodeToBytes
+
+ /**
+ * Very low-level access to decoding ASCII characters in
+ * the form of a byte array.
+ *
+ * @param source The Base64 encoded data
+ * @param off The offset of where to begin decoding
+ * @param len The length of characters to decode
+ * @return decoded data
+ */
+ private byte[] decode(int len, int off, byte[] source)
+ {
+ int len34 = len * 3 / 4;
+ byte[] outBuff = new byte[len34]; // Upper limit on size of output
+ int outBuffPosn = 0;
+
+ byte[] b4 = new byte[4];
+ int b4Posn = 0;
+ int i = 0;
+ byte sbiCrop = 0;
+ byte sbiDecode = 0;
+ for (i = off; i < off + len; i++)
+ {
+ sbiCrop = (byte)(source[i] & 0x7f); // Only the low seven bits
+ sbiDecode = DECODABET[sbiCrop];
+
+ if (sbiDecode >= WHITE_SPACE_ENC) // White space, padding character or better
+ {
+ if (sbiDecode >= PADDING_CHAR_ENC)
+ {
+ b4[b4Posn++] = sbiCrop;
+ if (b4Posn > 3)
+ {
+ outBuffPosn += decode4to3(b4, 0, outBuff, outBuffPosn);
+ b4Posn = 0;
+
+ // If that was the padding char, break out of 'for' loop
+ if (sbiCrop == PADDING_CHAR)
+ {
+ break;
+ }
+ } // end if: quartet built
+
+ } // end if: padding character or better
+
+ } // end if: white space, padding character or better
+ else
+ {
+ System.err.println("Bad Base64 input character at " + i + ": " + source[i] + "(decimal)");
+ return null;
+ } // end else:
+ } // each input character
+
+ byte[] out = new byte[outBuffPosn];
+ System.arraycopy(outBuff, 0, out, 0, outBuffPosn);
+ return out;
+ }
+
+ /**
+ * Very low-level access to decoding ASCII characters in
+ * the form of a byte array.
+ *
+ * @param source The Base64 encoded data
+ * @param off The offset of where to begin decoding
+ * @param len The length of characters to decode
+ * @param urlSafeEncodingWasUsed <code>true</code> if the URL-safe was used to encode the data to be decoded
+ * @return decoded data
+ */
+ public static byte[] decode(byte[] source, int off, int len, boolean urlSafeEncodingWasUsed)
+ {
+ return getBase64(urlSafeEncodingWasUsed).decode(len, off, source);
+ } // end decode
+
+ /**
+ * Decodes data from Base64 notation
+ *
+ * @param s the string to decode
+ * @param urlSafeEncodingWasUsed <code>true</code> if the URL-safe was used to encode the data to be decoded
+ * @return the decoded data
+ */
+ public static byte[] decode(String s, boolean urlSafeEncodingWasUsed)
+ {
+ byte[] bytes;
+ try
+ {
+ bytes = s.getBytes(PREFERRED_ENCODING);
+ } // end try
+ catch (java.io.UnsupportedEncodingException uee)
+ {
+ bytes = s.getBytes();
+ } // end catch
+
+ // Decode
+ bytes = decode(bytes, 0, bytes.length, urlSafeEncodingWasUsed);
+
+ return bytes;
+ } // end decode
+
+ /**
+ * Decodes data from Base64 notation
+ *
+ * @param s the string to decode
+ * @return the decoded data
+ */
+ public static byte[] decode(String s)
+ {
+ return decode(s, false);
+ } // end decode
+
+} // end class Base64
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Base64.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import org.jboss.portal.common.net.URLTools;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7379 $
+ */
+public class CLResourceLoader implements ResourceLoader
+{
+
+ private final ClassLoader loader;
+
+ public CLResourceLoader(ClassLoader loader)
+ {
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("No classloader provided");
+ }
+ this.loader = loader;
+ }
+
+ public CLResourceLoader()
+ {
+ this(Thread.currentThread().getContextClassLoader());
+ }
+
+ public InputStream load(String location)
+ {
+ return loader.getResourceAsStream(location);
+ }
+
+ public LoaderResource getResource(String location)
+ {
+ if (location == null)
+ {
+ throw new IllegalArgumentException("Location is null");
+ }
+ URL url = loader.getResource(location);
+ return new URLResource(location, url);
+ }
+
+ private static class URLResource extends LoaderResource
+ {
+
+ private final URL url;
+
+ public URLResource(String location, URL url)
+ {
+ super(location);
+ this.url = url;
+ }
+
+ public boolean exists()
+ {
+ return URLTools.exists(url);
+ }
+
+ public InputStream asInputStream() throws IllegalStateException
+ {
+ if (!exists())
+ {
+ throw new IllegalStateException("Resource " + location + " does not exist");
+ }
+ try
+ {
+ return url.openStream();
+ }
+ catch (IOException e)
+ {
+ throw new IllegalStateException("Cannot open resource stream " + location);
+ }
+ }
+
+ public String toString()
+ {
+ return "Resource[" + location + "," + url + "]";
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CLResourceLoader.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Collection;
+
+/**
+ * An helper to build collection of object in a simple manner.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7234 $
+ */
+public class CollectionBuilder<C extends Collection<V>, V>
+{
+
+ /** . */
+ private C collection;
+
+ private CollectionBuilder(C collection)
+ {
+ this.collection = collection;
+ }
+
+ public static <C extends Collection<V>, V> CollectionBuilder<C, V> create(C collection)
+ {
+ return new CollectionBuilder<C, V>(collection);
+ }
+
+ public static <V> CollectionBuilder<ArrayList<V>, V> arrayList()
+ {
+ return new CollectionBuilder<ArrayList<V>, V>(new ArrayList<V>());
+ }
+
+ public static <V> CollectionBuilder<ArrayList<V>, V> arrayList(V v)
+ {
+ CollectionBuilder<ArrayList<V>, V> builder = new CollectionBuilder<ArrayList<V>, V>(new ArrayList<V>());
+ builder.add(v);
+ return builder;
+ }
+
+ public static <V> CollectionBuilder<LinkedList<V>, V> linkedList()
+ {
+ return new CollectionBuilder<LinkedList<V>, V>(new LinkedList<V>());
+ }
+
+ public static <V> CollectionBuilder<LinkedList<V>, V> linkedList(V v)
+ {
+ CollectionBuilder<LinkedList<V>, V> builder = new CollectionBuilder<LinkedList<V>, V>(new LinkedList<V>());
+ builder.add(v);
+ return builder;
+ }
+
+ public static <V> CollectionBuilder<HashSet<V>, V> hashSet()
+ {
+ return new CollectionBuilder<HashSet<V>, V>(new HashSet<V>());
+ }
+
+ public static <V> CollectionBuilder<HashSet<V>, V> hashSet(V v)
+ {
+ CollectionBuilder<HashSet<V>, V> builder = new CollectionBuilder<HashSet<V>, V>(new HashSet<V>());
+ builder.add(v);
+ return builder;
+ }
+
+ /**
+ * Add the object to the collection.
+ *
+ * @param o the object to add
+ * @return the builder
+ */
+ public CollectionBuilder<C, V> add(V o)
+ {
+ collection.add(o);
+ return this;
+ }
+
+ /**
+ * Add all the objects to the collection.
+ *
+ * @param all the objects to add
+ * @return the builder
+ */
+ public CollectionBuilder<C, V> addAll(Collection<V> all)
+ {
+ collection.addAll(all);
+ return this;
+ }
+
+ public C get()
+ {
+ return collection;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionBuilder.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionMap.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionMap.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CollectionMap.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,247 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Map;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * A map of collections.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class CollectionMap<K, V> implements Serializable
+{
+
+ /** The underlying map. */
+ private final Map<K, Collection<V>> map;
+
+ public CollectionMap()
+ {
+ map = init(null);
+ }
+
+ public CollectionMap(SetMap<K, V> other) throws IllegalArgumentException
+ {
+ if (other == null)
+ {
+ throw new IllegalArgumentException("Cannot copy null argument");
+ }
+ map = init(other);
+ }
+
+ /**
+ * Add an object in the set keyed under the specified key.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final void put(K key, V o) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ Collection<V> collection = map.get(key);
+ if (collection == null)
+ {
+ collection = newCollection();
+ map.put(key, collection);
+ }
+ add(collection, o);
+ }
+
+ /**
+ * Return the set of keys.
+ */
+ public final Set<K> keySet()
+ {
+ return map.keySet();
+ }
+
+ /**
+ * Remove the entire set of objects specified by the key.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final void remove(K key) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ map.remove(key);
+ }
+
+ /**
+ * Remove an object in the set keyed under the specified key.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final void remove(K key, Object o) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ Collection<V> collection = map.get(key);
+
+ //
+ if (collection != null)
+ {
+ remove(collection, o);
+
+ //
+ if (collection.isEmpty())
+ {
+ map.remove(key);
+ }
+ }
+ }
+
+ /**
+ * Return true if the specified set contains the object o.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final boolean contains(K key, Object o) throws NullPointerException
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ Collection<V> collection = map.get(key);
+
+ //
+ if (collection == null)
+ {
+ return false;
+ }
+ else
+ {
+ return collection.contains(o);
+ }
+ }
+
+ /**
+ * Return the collection specified by the key.
+ */
+ public Collection<V> get(K key)
+ {
+ return map.get(key);
+ }
+
+ /**
+ * Return an iterator over the values in the set specified by the key.
+ *
+ * @throws NullPointerException if the key is null
+ */
+ public final Iterator<V> iterator(final K key)
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key");
+ }
+
+ //
+ Collection<V> set = map.get(key);
+
+ //
+ if (set == null)
+ {
+ Set<V> tmp = Collections.emptySet();
+ return tmp.iterator();
+ }
+ else
+ {
+ final Iterator<V> iterator = set.iterator();
+ return new Iterator<V>()
+ {
+ public boolean hasNext()
+ {
+ return iterator.hasNext();
+ }
+ public V next()
+ {
+ return iterator.next();
+ }
+ public void remove()
+ {
+ iterator.remove();
+ if (!iterator.hasNext())
+ {
+ map.remove(key);
+ }
+ }
+ };
+ }
+ }
+
+ private Map<K, Collection<V>> init(CollectionMap<K, V> other)
+ {
+ Map<K, Collection<V>> map = new HashMap<K, Collection<V>>();
+
+ //
+ if (other != null)
+ {
+ for (Map.Entry<K, Collection<V>> entry : other.map.entrySet())
+ {
+ K key = entry.getKey();
+ Collection<V> value = entry.getValue();
+ map.put(key, newCollection(value));
+ }
+ }
+
+ //
+ return map;
+ }
+
+ protected abstract void add(Collection<V> c, V o);
+
+ /**
+ * Removes an object from the collection. The type of the object to remove is intentionnally
+ * <code>Object</code> and not the parameterized type <code><V></code> because the Collection<V>
+ * interface is designed that way.
+ *
+ * @param c the collection to remove from
+ * @param o the object to remove
+ */
+ protected abstract void remove(Collection<V> c, Object o);
+
+ protected abstract Collection<V> newCollection();
+
+ protected abstract Collection<V> newCollection(Collection<V> other);
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * Describe how content should be interpreted.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6704 $
+ */
+public class ContentInfo
+{
+
+ /** The content type. */
+ private final MediaType contentType;
+
+ public ContentInfo(MediaType contentType)
+ {
+ if (contentType == null)
+ {
+ throw new IllegalArgumentException("Content type cannot be null");
+ }
+ this.contentType = contentType;
+ }
+
+ public MediaType getContentType()
+ {
+ return contentType;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ContentInfo.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * Signals that an error occured during a conversion.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public class ConversionException extends Exception
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 4647584036804084315L;
+
+ public ConversionException()
+ {
+ }
+
+ public ConversionException(String message)
+ {
+ super(message);
+ }
+
+ public ConversionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ConversionException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ConversionException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CopyOnWriteRegistry.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CopyOnWriteRegistry.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/CopyOnWriteRegistry.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,134 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Implementation of a registry that implements copy on write semantics.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class CopyOnWriteRegistry
+{
+
+ /** . */
+ private volatile Map content;
+
+ public CopyOnWriteRegistry()
+ {
+ content = new HashMap();
+ }
+
+ /**
+ * Register an object.
+ *
+ * @param key the registration key
+ * @param object the registered object
+ * @return true if the registration was made
+ * @throws IllegalArgumentException if the one argument is null
+ */
+ public synchronized boolean register(Object key, Object object) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (object == null)
+ {
+ throw new IllegalArgumentException("No null value accepted");
+ }
+ if (content.containsKey(key))
+ {
+ return false;
+ }
+ Map tmp = new HashMap(content);
+ tmp.put(key, object);
+ content = tmp;
+ return true;
+ }
+
+ /**
+ * Unregister an object.
+ *
+ * @param key the registration key
+ * @return true if the unregistration was made
+ * @throws IllegalArgumentException if the key is null
+ */
+ public synchronized Object unregister(Object key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ if (content.containsKey(key))
+ {
+ Map tmp = new HashMap(content);
+ Object registration = tmp.remove(key);
+ content = tmp;
+ return registration;
+ }
+ return null;
+ }
+
+ /**
+ * Return an unmodifiable set containing the keys.
+ *
+ * @return the keys
+ */
+ public Set getKeys()
+ {
+ return Collections.unmodifiableSet(content.keySet());
+ }
+
+ /**
+ * Return an unmodifable collection containing the registrations.
+ *
+ * @return the registrations
+ */
+ public Collection getRegistrations()
+ {
+ return Collections.unmodifiableCollection(content.values());
+ }
+
+ /**
+ * Return a registration or null if it does not exist.
+ *
+ * @param key the registration key
+ * @return the registeted object
+ * @throws IllegalArgumentException if the key is null
+ */
+ public Object getRegistration(Object key) throws IllegalArgumentException
+ {
+ if (key == null)
+ {
+ throw new IllegalArgumentException("No null key accepted");
+ }
+ return content.get(key);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.ResourceBundle;
+import java.util.Enumeration;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6817 $
+ */
+public class EmptyResourceBundle extends ResourceBundle
+{
+
+ /** . */
+ public static final EmptyResourceBundle INSTANCE = new EmptyResourceBundle();
+
+ protected Object handleGetObject(String key)
+ {
+ if (key == null)
+ {
+ throw new NullPointerException("No null key accepted");
+ }
+ return null;
+ }
+
+ public Enumeration getKeys()
+ {
+ return Tools.EMPTY_ENUMERATION;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/EmptyResourceBundle.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7395 $
+ */
+public class Exceptions
+{
+
+ public static Throwable unwrap(Throwable throwable) throws IllegalArgumentException
+ {
+ if (throwable == null)
+ {
+ throw new IllegalArgumentException("Cannot unwrap null throwable");
+ }
+ for (Throwable current = throwable;current != null;current = current.getCause())
+ {
+ throwable = current;
+ }
+ return throwable;
+ }
+
+ public static String toHTML(Throwable throwable)
+ {
+ return toHTML(throwable, false);
+ }
+
+ public static String toHTML(Throwable throwable, boolean deep)
+ {
+ StringBuffer tmp = new StringBuffer();
+ appendHTMLTo(tmp, throwable, deep);
+ return tmp.toString();
+ }
+
+ public static void appendHTMLTo(StringBuffer buffer, Throwable throwable)
+ {
+ appendHTMLTo(buffer, throwable, false);
+ }
+
+ public static void appendHTMLTo(StringBuffer buffer, Throwable throwable, boolean deep)
+ {
+ buffer.append("<div><pre style=\"text-align:left;\"><code>");
+ while (throwable != null)
+ {
+ buffer.append(throwable.toString()).append('\n');
+ StackTraceElement[] elts = throwable.getStackTrace();
+ for (int j = 0; j < elts.length; j++)
+ {
+ StackTraceElement elt = elts[j];
+ buffer.append("\tat ").append(elt).append("\n");
+ }
+ throwable = throwable.getCause();
+ }
+ buffer.append("</code></pre></div>");
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Exceptions.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * A non expected format prevents a conversion to happen.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public class FormatConversionException extends ConversionException
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6642578306452728356L;
+
+ public FormatConversionException()
+ {
+ }
+
+ public FormatConversionException(String message)
+ {
+ super(message);
+ }
+
+ public FormatConversionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public FormatConversionException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/FormatConversionException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/IteratorStatus.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/IteratorStatus.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/IteratorStatus.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,116 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * An java.util.Iterator wrapper which keep additional state associated with the wrapped iterator. The implementation of
+ * the Iterator interface delegates all operations to the wrapped iterator.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class IteratorStatus implements Iterator
+{
+
+ /** The real iterator. */
+ private final Iterator delegate;
+
+ /** The iterator index. */
+ private int index;
+
+ /**
+ * @param delegate the wrapped iterator
+ * @throws IllegalArgumentException if the wrapped iterator is null
+ */
+ public IteratorStatus(Iterator delegate) throws IllegalArgumentException
+ {
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException("No iterator is provided");
+ }
+ this.delegate = delegate;
+ this.index = -1;
+ }
+
+ /**
+ * @param c the collection to iterate
+ * @throws IllegalArgumentException if the collection is null
+ */
+ public IteratorStatus(Collection c) throws IllegalArgumentException
+ {
+ if (c == null)
+ {
+ throw new IllegalArgumentException("No collection is provided");
+ }
+ this.delegate = c.iterator();
+ this.index = -1;
+ }
+
+ /**
+ * Returns the index of the last element obtained or -1 if no element has been returned yet.
+ *
+ * @return the index of the last element obtained
+ */
+ public int getIndex()
+ {
+ return index;
+ }
+
+ /**
+ * Returns true if one element has been iterated.
+ *
+ * @return true if one element has been iterated.
+ * @throws IllegalStateException if no element has been iterated yet
+ */
+ public boolean isFirst() throws IllegalStateException
+ {
+ if (index == -1)
+ {
+ throw new IllegalStateException("No element has been iterated so far");
+ }
+ return index == 0;
+ }
+
+ public boolean hasNext()
+ {
+ return delegate.hasNext();
+ }
+
+ public Object next()
+ {
+ Object o = delegate.next();
+
+ // Increment after getting the next object since the call to the next() method
+ // can throw a NoSuchElementException
+ index++;
+ return o;
+ }
+
+ public void remove()
+ {
+ delegate.remove();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,391 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public abstract class LazyMap implements Map
+{
+
+ /** . */
+ private Map delegate;
+
+ /** . */
+ private boolean modified;
+
+ /**
+ * Create the delegate. There are no guarantees that this method will be called only once.
+ */
+ protected abstract Map createDelegate();
+
+ public boolean isModified()
+ {
+ return modified;
+ }
+
+ private Map getDelegate()
+ {
+ if (delegate == null)
+ {
+ delegate = createDelegate();
+ }
+ if (delegate == null)
+ {
+ throw new IllegalStateException("No delegate obtained");
+ }
+ return delegate;
+ }
+
+ public int size()
+ {
+ return getDelegate().size();
+ }
+
+ public boolean isEmpty()
+ {
+ return getDelegate().isEmpty();
+ }
+
+ public boolean containsKey(Object key)
+ {
+ return getDelegate().containsKey(key);
+ }
+
+ public boolean containsValue(Object value)
+ {
+ return getDelegate().containsValue(value);
+ }
+
+ public Object get(Object key)
+ {
+ return getDelegate().get(key);
+ }
+
+ public Object put(Object key, Object value)
+ {
+ modified = true;
+ return getDelegate().put(key, value);
+ }
+
+ public Object remove(Object key)
+ {
+ modified = true;
+ return getDelegate().remove(key);
+ }
+
+ public void putAll(Map t)
+ {
+ modified = true;
+ getDelegate().putAll(t);
+ }
+
+ public void clear()
+ {
+ modified = true;
+ getDelegate().clear();
+ }
+
+ public Set keySet()
+ {
+ return new Set()
+ {
+ Set keySet = getDelegate().keySet();
+
+ public int size()
+ {
+ return keySet.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return keySet.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ return keySet.contains(o);
+ }
+
+ public Iterator iterator()
+ {
+ return keySet.iterator();
+ }
+
+ public Object[] toArray()
+ {
+ return keySet.toArray();
+ }
+
+ public Object[] toArray(Object[] a)
+ {
+ return keySet.toArray(a);
+ }
+
+ public boolean add(Object o)
+ {
+ modified = true;
+ return keySet.add(o);
+ }
+
+ public boolean remove(Object o)
+ {
+ modified = true;
+ return keySet.remove(o);
+ }
+
+ public boolean containsAll(Collection c)
+ {
+ return keySet.containsAll(c);
+ }
+
+ public boolean addAll(Collection c)
+ {
+ modified = true;
+ return keySet.addAll(c);
+ }
+
+ public boolean retainAll(Collection c)
+ {
+ return keySet.retainAll(c);
+ }
+
+ public boolean removeAll(Collection c)
+ {
+ modified = true;
+ return keySet.removeAll(c);
+ }
+
+ public void clear()
+ {
+ modified = true;
+ keySet.clear();
+ }
+
+ public boolean equals(Object o)
+ {
+ return keySet.equals(o);
+ }
+
+ public int hashCode()
+ {
+ return keySet.hashCode();
+ }
+ };
+ }
+
+ public Collection values()
+ {
+ return new Collection()
+ {
+ /** . */
+ Collection values = getDelegate().values();
+
+ public int size()
+ {
+ return values.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return values.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ return values.contains(o);
+ }
+
+ public Iterator iterator()
+ {
+ return values.iterator();
+ }
+
+ public Object[] toArray()
+ {
+ return values.toArray();
+ }
+
+ public Object[] toArray(Object[] a)
+ {
+ return values.toArray(a);
+ }
+
+ public boolean add(Object o)
+ {
+ modified = true;
+ return values.add(o);
+ }
+
+ public boolean remove(Object o)
+ {
+ modified = true;
+ return values.remove(o);
+ }
+
+ public boolean containsAll(Collection c)
+ {
+ return values.containsAll(c);
+ }
+
+ public boolean addAll(Collection c)
+ {
+ modified = true;
+ return values.addAll(c);
+ }
+
+ public boolean removeAll(Collection c)
+ {
+ modified = true;
+ return values.removeAll(c);
+ }
+
+ public boolean retainAll(Collection c)
+ {
+ return values.retainAll(c);
+ }
+
+ public void clear()
+ {
+ modified = true;
+ values.clear();
+ }
+
+ public boolean equals(Object o)
+ {
+ return values.equals(o);
+ }
+
+ public int hashCode()
+ {
+ return values.hashCode();
+ }
+ };
+ }
+
+ public Set entrySet()
+ {
+ return new Set()
+ {
+ /** . */
+ Set entrySet = getDelegate().entrySet();
+
+ public int size()
+ {
+ return entrySet.size();
+ }
+
+ public boolean isEmpty()
+ {
+ return entrySet.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ return entrySet.contains(o);
+ }
+
+ public Iterator iterator()
+ {
+ return entrySet.iterator();
+ }
+
+ public Object[] toArray()
+ {
+ return entrySet.toArray();
+ }
+
+ public Object[] toArray(Object[] a)
+ {
+ return entrySet.toArray(a);
+ }
+
+ public boolean add(Object o)
+ {
+ modified = true;
+ return entrySet.add(o);
+ }
+
+ public boolean remove(Object o)
+ {
+ modified = true;
+ return entrySet.remove(o);
+ }
+
+ public boolean containsAll(Collection c)
+ {
+ return entrySet.containsAll(c);
+ }
+
+ public boolean addAll(Collection c)
+ {
+ modified = true;
+ return entrySet.addAll(c);
+ }
+
+ public boolean retainAll(Collection c)
+ {
+ modified = true;
+ return entrySet.retainAll(c);
+ }
+
+ public boolean removeAll(Collection c)
+ {
+ modified = true;
+ return entrySet.removeAll(c);
+ }
+
+ public void clear()
+ {
+ modified = true;
+ entrySet.clear();
+ }
+
+ public boolean equals(Object o)
+ {
+ return entrySet.equals(o);
+ }
+
+ public int hashCode()
+ {
+ return entrySet.hashCode();
+ }
+ };
+ }
+
+ public boolean equals(Object o)
+ {
+ return getDelegate().equals(o);
+ }
+
+ public int hashCode()
+ {
+ return getDelegate().hashCode();
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LazyMap.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ListMap.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ListMap.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ListMap.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ListMap<K, V> extends CollectionMap<K, V>
+{
+
+ /** An optional comparator. */
+ protected Comparator<V> comparator;
+
+ public ListMap()
+ {
+ }
+
+ public ListMap(SetMap<K, V> other) throws IllegalArgumentException
+ {
+ super(other);
+ }
+
+ public ListMap(SetMap<K, V> other, Comparator<V> comparator) throws IllegalArgumentException
+ {
+ super(other);
+
+ //
+ if (comparator == null)
+ {
+ throw new IllegalArgumentException("No null comparator allowed");
+ }
+
+ //
+ this.comparator = comparator;
+ }
+
+ public ListMap(Comparator<V> comparator)
+ {
+ super();
+
+ //
+ if (comparator == null)
+ {
+ throw new IllegalArgumentException("No null comparator allowed");
+ }
+
+ //
+ this.comparator = comparator;
+ }
+
+ /**
+ * Return the list specified by the key.
+ */
+ public List<V> get(K key)
+ {
+ return (List<V>)super.get(key);
+ }
+
+ protected void add(Collection<V> c, V o)
+ {
+ c.add(o);
+
+ //
+ if (comparator != null)
+ {
+ Collections.sort((List<V>)c, comparator);
+ }
+ }
+
+ protected void remove(Collection<V> c, Object o)
+ {
+ c.remove(o);
+
+ //
+ if (comparator != null)
+ {
+ Collections.sort((List<V>)c, comparator);
+ }
+ }
+
+ protected Collection<V> newCollection()
+ {
+ return new ArrayList<V>();
+ }
+
+ protected Collection<V> newCollection(Collection<V> other)
+ {
+ return new ArrayList<V>(other);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,194 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.xml.XMLTools;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Represent a resource that may or not exist.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7380 $
+ */
+public abstract class LoaderResource
+{
+
+ protected final String location;
+
+ private final Logger log = Logger.getLogger(getClass());
+
+ public LoaderResource(String location)
+ {
+ if (location == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.location = location;
+ }
+
+ public abstract boolean exists();
+
+ public abstract InputStream asInputStream() throws IllegalStateException;
+
+ public String getLocation()
+ {
+ return location;
+ }
+
+ public Document asDocument(DocumentBuilder builder) throws IllegalStateException
+ {
+ if (!exists())
+ {
+ throw new IllegalStateException("Resource " + location + " does not exist");
+ }
+ InputStream in = null;
+ try
+ {
+ in = IOTools.safeBufferedWrapper(asInputStream());
+ return builder.parse(in);
+ }
+ catch (SAXException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot parse stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ catch (IOException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot access stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ public Properties asProperties() throws IllegalStateException
+ {
+ return asProperties(false);
+ }
+
+ public Properties asProperties(boolean xml) throws IllegalStateException
+ {
+ if (!exists())
+ {
+ throw new IllegalStateException("Resource " + location + " does not exist");
+ }
+ InputStream in = null;
+
+ log.debug("Loading resource: " + location);
+
+ try
+ {
+ in = IOTools.safeBufferedWrapper(asInputStream());
+ Properties props;
+ if (xml)
+ {
+ DocumentBuilder builder = XMLTools.getDocumentBuilderFactory().newDocumentBuilder();
+ Document doc = asDocument(builder);
+ props = XMLTools.loadXMLProperties(doc);
+ }
+ else
+ {
+ props = new Properties();
+ props.load(in);
+ }
+ log.debug("Finished loading resource: " + location);
+ return props;
+ }
+ catch (ParserConfigurationException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot parse xml stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ catch (IOException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot access stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+
+ public String asString() throws IllegalStateException
+ {
+ return asString(null);
+ }
+
+ public String asString(String enc) throws IllegalStateException
+ {
+ if (!exists())
+ {
+ throw new IllegalStateException("Resource " + location + " does not exist");
+ }
+ InputStream in = null;
+
+ log.debug("Loading resource: " + location);
+
+ try
+ {
+ in = IOTools.safeBufferedWrapper(asInputStream());
+ ByteArrayOutputStream out = new ByteArrayOutputStream(in.available());
+ IOTools.copy(in, out);
+ String result;
+ if (enc == null)
+ {
+ result = out.toString();
+ }
+ else
+ {
+ result = out.toString(enc);
+ }
+
+ log.debug("Finished loading resource: " + location);
+ return result;
+ }
+ catch (IOException e)
+ {
+ IllegalStateException ex = new IllegalStateException("Cannot access stream " + location);
+ ex.initCause(e);
+ throw ex;
+ }
+ finally
+ {
+ IOTools.safeClose(in);
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/LoaderResource.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MapAccessor.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MapAccessor.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MapAccessor.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Map;
+
+/**
+ * An interface which defines how a map can be accessed.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public interface MapAccessor<K, V>
+{
+ /**
+ * Return the accessed map.
+ *
+ * @param writable whether or not the Map will be accessed for a write-type (e.g., put, remove...) operation.
+ * This allows for lazy initialization via a create-on-write mechanism.
+ * @return a non null map
+ */
+ Map<K, V> getMap(boolean writable);
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MapBuilder.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MapBuilder.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MapBuilder.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * An helper to build map in a simple manner.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MapBuilder<M extends Map<K, V>, K, V>
+{
+
+ /** . */
+ private final M map;
+
+ private MapBuilder(M map)
+ {
+ if (map == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.map = map;
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<HashMap<K, V>, K, V> hashMap()
+ {
+ return new MapBuilder<HashMap<K, V>, K, V>(new HashMap<K, V>());
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<HashMap<K, V>, K, V> hashMap(K k, V v)
+ {
+ MapBuilder<HashMap<K, V>, K, V> builder = new MapBuilder<HashMap<K, V>, K, V>(new HashMap<K, V>());
+ builder.put(k, v);
+ return builder;
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<TreeMap<K, V>, K, V> treeMap()
+ {
+ return new MapBuilder<TreeMap<K, V>, K, V>(new TreeMap<K, V>());
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<TreeMap<K, V>, K, V> treeMap(K k, V v)
+ {
+ MapBuilder<TreeMap<K, V>, K, V> builder = new MapBuilder<TreeMap<K, V>, K, V>(new TreeMap<K, V>());
+ builder.put(k, v);
+ return builder;
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<LinkedHashMap<K, V>, K, V> linkedHashMap()
+ {
+ return new MapBuilder<LinkedHashMap<K, V>, K, V>(new LinkedHashMap<K, V>());
+ }
+
+ /**
+ * Creates a new instance.
+ *
+ * @return a new instance
+ */
+ public static <K, V> MapBuilder<LinkedHashMap<K, V>, K, V> linkedHashMap(K k, V v)
+ {
+ MapBuilder<LinkedHashMap<K, V>, K, V> builder = new MapBuilder<LinkedHashMap<K, V>, K, V>(new LinkedHashMap<K, V>());
+ builder.put(k, v);
+ return builder;
+ }
+
+ public static <M extends Map<K, V>, K, V> MapBuilder<M, K, V> create(M m)
+ {
+ return new MapBuilder<M, K, V>(m);
+ }
+
+ /**
+ * Add the object to the collection.
+ *
+ * @param key the key
+ * @param value the value
+ * @return the builder
+ */
+ public MapBuilder<M, K, V> put(K key, V value)
+ {
+ map.put(key, value);
+ return this;
+ }
+
+ /**
+ * Add all the objects to the collection.
+ *
+ * @param all the entries to add
+ * @return the builder
+ */
+ public MapBuilder<M, K, V> putAll(M all)
+ {
+ map.putAll(all);
+ return this;
+ }
+
+ public M get()
+ {
+ return map;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MarkupInfo.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MarkupInfo.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MarkupInfo.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * Extends content to describe markup content.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class MarkupInfo extends ContentInfo
+{
+
+ /** The charset. */
+ private final String charset;
+
+ public MarkupInfo(MediaType contentType, String charset)
+ {
+ super(contentType);
+
+ //
+ if (charset == null)
+ {
+ throw new IllegalArgumentException("Charset cannot be null");
+ }
+
+ //
+ this.charset = charset;
+ }
+
+ public String getCharset()
+ {
+ return charset;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,342 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This is a immutable wrapper to the activation MimeTpye.
+ * <p>This class contains some extensions to the activation MimeType, such as the typesafe enum
+ * pattern, and allows for a mime type to specify allowed sub types.</p>
+ *
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @version $LastChangedRevision: 6704 $, $LastChangedDate: 2007-03-15 23:36:31 +0100 (Thu, 15 Mar 2007) $
+ * @see javax.activation.MimeType
+ * see also ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/
+ */
+public final class MediaType
+{
+ private static Map allowedTypes = new HashMap();
+ private static Map supportedExtensions = new HashMap();
+
+ /**
+ * Mime type 'Any' maps to an accept mime type of '*.*' (used by IE for css, images, etc.)
+ */
+ public static final MediaType ANY =
+ new MediaType("*", "*", new String[]{});
+
+ /**
+ * Mime type xhtml
+ */
+ public static final MediaType XHTML = new MediaType("application", "xhtml+xml",
+ new String[]{"xhtml"});
+
+ /**
+ * Mime type html
+ */
+ public static final MediaType HTML = new MediaType("text", "html",
+ new String[]{"html", "htm"},
+ new MediaType[]{XHTML});
+
+ /**
+ * Mime type form (application/x-www-form-urlencoded)
+ */
+ public static final MediaType FORM =
+ new MediaType("application", "x-www-form-urlencoded", new String[]{});
+
+ /**
+ * Mime type xml
+ */
+ public static final MediaType XML = new MediaType("text", "xml", new String[]{"xml"},
+ new MediaType[]{XHTML});
+
+ /**
+ * Mime type wml
+ */
+ public static final MediaType WML = new MediaType("text", "vnd.wap.wml",
+ new String[]{"wml"});
+
+ /**
+ * Mime type css
+ */
+ public static final MediaType CSS = new MediaType("text", "css",
+ new String[]{"css"});
+
+ /**
+ * Mime type text
+ */
+ public static final MediaType TEXT = new MediaType("text", "plain",
+ new String[]{"txt"});
+
+ /**
+ * Mime type js
+ */
+ public static final MediaType JS = new MediaType("text", "javascript",
+ new String[]{"js"});
+
+ /**
+ * Mime type svg
+ */
+ public static final MediaType SVG = new MediaType("image", "svg+xml",
+ new String[]{"svg"});
+
+ /**
+ * Mime type jpeg
+ */
+ public static final MediaType JPEG = new MediaType("image", "jpeg",
+ new String[]{"jpeg", "jpg"});
+
+ /**
+ * Mime type gif
+ */
+ public static final MediaType GIF = new MediaType("image", "gif",
+ new String[]{"gif"});
+
+ /**
+ * Mime type png
+ */
+ public static final MediaType PNG = new MediaType("image", "png",
+ new String[]{"png"});
+
+ /**
+ * Mime type wbmp
+ */
+ public static final MediaType WBMP = new MediaType("image", "vnd.wap.wbmp",
+ new String[]{"wbpm"});
+
+ /**
+ * Mime type rss
+ */
+ public static final MediaType RSS = new MediaType("application", "rss+xml",
+ new String[]{});
+
+ /**
+ * Mime type ico (see http://filext.com/detaillist.php?extdetail=ICO)
+ */
+ public static final MediaType ICO = new MediaType("application", "octet-stream",
+ new String[]{"ico"});
+ private MimeType m_mimeType = null;
+ private MediaType[] m_allowedSubTypes;
+ private Set allowSubTypeSet;
+
+ /**
+ * Construct a mime type instance without any allowed subtypes.
+ *
+ * @param primaryType the primary type of the mime type (i.e. 'text')
+ * @param subType the sub type of the mime type (i.e. 'html')
+ */
+ private MediaType(String primaryType, String subType, String[] extensions)
+ {
+ try
+ {
+ m_mimeType = new MimeType(primaryType, subType);
+ m_allowedSubTypes = null;
+ allowSubTypeSet = null;
+ allowedTypes.put(m_mimeType.getBaseType(), this);
+ for (int i = 0; i < extensions.length; i++)
+ {
+ supportedExtensions.put(extensions[i], this);
+ }
+ }
+ catch (MimeTypeParseException e)
+ {
+ // +++TODO handle this , but where ?
+ System.out.println(e.getMessage());
+ }
+ }
+
+ /**
+ * Construct a mime type with the provided allowed subtypes.
+ *
+ * @param primaryType the primary type of the mime type (i.e. 'text')
+ * @param subType the sub type of the mime type (i.e. 'html')
+ * @param allowedSubTypes an array of <code>MediaType</code>s to allow as valid subtypes of this type
+ */
+ private MediaType(String primaryType, String subType, String[] extensions, MediaType[] allowedSubTypes)
+ {
+ this(primaryType, subType, extensions);
+ // only if the mime type was sucessfully created
+ if (m_mimeType != null)
+ {
+ m_allowedSubTypes = allowedSubTypes;
+ allowSubTypeSet = new HashSet(Arrays.asList(allowedSubTypes));
+ }
+ }
+
+ /**
+ * Get the mime type for the presented string, if the string contains a valid mime type.
+ *
+ * @param mimeType the <code>java.lang.String</code> to parse into a <code>RegistryMimeTpye</code>
+ * @return the <code>RegistryMimeTpye</code> that matches with the presented string
+ * @throws MimeTypeParseException if the presented mimetype is not supported
+ * @throws IllegalArgumentException if the presented string is null or empty
+ */
+ public static MediaType parseMimeType(String mimeType) throws MimeTypeParseException
+ {
+ if (mimeType == null || "".equals(mimeType))
+ {
+ throw new IllegalArgumentException("no valid mime type provided");
+ }
+
+ String type = mimeType.trim().toLowerCase();
+ if (allowedTypes.keySet().contains(type))
+ {
+ return (MediaType)allowedTypes.get(type);
+ }
+
+ throw new MimeTypeParseException("Type [" + mimeType + "] not supported");
+ }
+
+ /**
+ * Get the mime type for the presented string.
+ * <p>The string is handles as a file name extension. example: 'xml' returns MediaType.XML</p>
+ *
+ * @param extension the <code>java.lang.String</code> to parse into a <code>RegistryMimeTpye</code>
+ * @return the <code>RegistryMimeTpye</code> that matches with the presented string
+ * @throws MimeTypeParseException if the presented mimetype is not supported
+ * @throws IllegalArgumentException if the presented string is null or empty
+ */
+ public static MediaType parseMimeTypeByExtension(String extension)
+ throws MimeTypeParseException
+ {
+ if (extension == null || "".equals(extension))
+ {
+ throw new IllegalArgumentException("no valid mime type provided [" + extension + "]");
+ }
+
+ String ext = extension.trim().toLowerCase();
+ if (supportedExtensions.keySet().contains(ext))
+ {
+ return (MediaType)supportedExtensions.get(ext);
+ }
+
+ throw new MimeTypeParseException("Extension [" + extension + "] not supported");
+ }
+
+ /**
+ * Get a list of allowed sub types for the passed mime type.
+ *
+ * @param mimeType the <code>RegistryMimeTpye</code> to get the list of allowed subtypes for
+ * @return a <code>java.util.List</code> of <code>PortalMimeTpye</code>s
+ */
+ public static List getAllowedSubTypes(MediaType mimeType)
+ {
+ if (mimeType.m_allowedSubTypes == null)
+ {
+ return Collections.EMPTY_LIST;
+ }
+ else
+ {
+ return Collections.unmodifiableList(Arrays.asList(mimeType.m_allowedSubTypes));
+ }
+ }
+
+ /**
+ * Get a list of allowed sub types for for this mime type.
+ *
+ * @return a <code>java.util.List</code> of <code>RegistryMimeTpye</code>s
+ */
+ public List getAllowedSubTypes()
+ {
+ if (m_allowedSubTypes == null)
+ {
+ return Collections.EMPTY_LIST;
+ }
+ else
+ {
+ return Collections.unmodifiableList(Arrays.asList(m_allowedSubTypes));
+ }
+ }
+
+ /**
+ * Return true if the allowed sub types contains the specified media type.
+ *
+ * @param other the sub type to test
+ * @return true if it is an allowed sub type
+ */
+ public boolean isAllowedSubType(MediaType other)
+ {
+ if (equals(other))
+ {
+ return true;
+ }
+ if (allowSubTypeSet == null)
+ {
+ return false;
+ }
+ return allowSubTypeSet.contains(other);
+ }
+
+ /**
+ * Get the String representation of the mime type (i.e. 'text/html').
+ *
+ * @return the mime type as a <code>java.lang.String</code>
+ * @see java.lang.Object#toString
+ */
+ public String toString()
+ {
+ return m_mimeType.getBaseType();
+ }
+
+ /**
+ * compare the parameter with this instance and see if they are equals.
+ *
+ * @param o the Object to compare this instance to
+ * @return true if this and the paramters o are equal
+ * @see java.lang.Object#equals
+ */
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (!(o instanceof MediaType))
+ {
+ return false;
+ }
+
+ final MediaType type = (MediaType)o;
+
+ return m_mimeType.equals(type.m_mimeType);
+ }
+
+ /**
+ * Get the hascode for this mime type.
+ *
+ * @return an int value representing this instance
+ * @see java.lang.Object#hashCode
+ */
+ public int hashCode()
+ {
+ return m_mimeType.hashCode();
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/MediaType.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * A null pointer prevents a conversion to happen.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public class NullConversionException extends ConversionException
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 5948866940278003857L;
+
+ public NullConversionException()
+ {
+ }
+
+ public NullConversionException(String message)
+ {
+ super(message);
+ }
+
+ public NullConversionException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public NullConversionException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/NullConversionException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,274 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * A decorator that enforce the map content to be <String,String[]>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6671 $
+ */
+public class ParameterMap extends TypedMap<String, String[], String, String[]>
+{
+
+ /** . */
+ private static final KeyConverter keyConv = new KeyConverter();
+
+ /** . */
+ private static final ValueConverter valueConv1 = new ValueConverter(false, false);
+
+ /** . */
+ private static final ValueConverter valueConv2 = new ValueConverter(false, true);
+
+ /** . */
+ private static final ValueConverter valueConv3 = new ValueConverter(true, false);
+
+ /** . */
+ private static final ValueConverter valueConv4 = new ValueConverter(true, true);
+
+ private static ValueConverter getValueConverter(boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ if (cloneInternalValue)
+ {
+ if (cloneExternalValue)
+ {
+ return valueConv4;
+ }
+ else
+ {
+ return valueConv3;
+ }
+ }
+ else
+ {
+ if (cloneExternalValue)
+ {
+ return valueConv2;
+ }
+ else
+ {
+ return valueConv1;
+ }
+ }
+ }
+
+ /** . */
+ private final boolean cloneInternalValue;
+
+ /** . */
+ private final boolean cloneExternalValue;
+
+ public ParameterMap(boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ this(new HashMap<String, String[]>(), cloneInternalValue, cloneExternalValue);
+ }
+
+ public ParameterMap(MapAccessor<String, String[]> accessor)
+ {
+ this(accessor, false, false);
+ }
+
+ public ParameterMap(Map<String, String[]> delegate)
+ {
+ this(delegate, false, false);
+ }
+
+ public ParameterMap()
+ {
+ this(false, false);
+ }
+
+ public ParameterMap(MapAccessor<String, String[]> accessor, boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ super(accessor, keyConv, getValueConverter(cloneInternalValue, cloneExternalValue));
+
+ //
+ this.cloneInternalValue = cloneInternalValue;
+ this.cloneExternalValue = cloneExternalValue;
+ }
+
+ public ParameterMap(Map<String, String[]> delegate, boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ super(delegate, keyConv, getValueConverter(cloneInternalValue, cloneExternalValue));
+
+ //
+ this.cloneInternalValue = cloneInternalValue;
+ this.cloneExternalValue = cloneExternalValue;
+ }
+
+ /**
+ * Return true if values returned by the map are cloned.
+ *
+ * @return true if returned values are cloned
+ */
+ public boolean isCloneInternalValue()
+ {
+ return cloneInternalValue;
+ }
+
+ public boolean isCloneExternalValue()
+ {
+ return cloneExternalValue;
+ }
+
+ private static class KeyConverter extends Converter<String, String>
+ {
+ protected String getInternal(String external) throws IllegalArgumentException, ClassCastException
+ {
+ return external;
+ }
+ protected String getExternal(String internal)
+ {
+ return internal;
+ }
+ protected boolean equals(String left, String right)
+ {
+ return left.equals(right);
+ }
+ }
+
+ private static class ValueConverter extends Converter<String[], String[]>
+ {
+
+ /** . */
+ private final boolean cloneInternalValue;
+
+ /** . */
+ private final boolean cloneExternalValue;
+
+ private ValueConverter(boolean cloneInternalValue, boolean cloneExternalValue)
+ {
+ this.cloneInternalValue = cloneInternalValue;
+ this.cloneExternalValue = cloneExternalValue;
+ }
+
+ /**
+ * Only check are made to the value. The only valid values accepted
+ * are string arrays with non zero length and containing non null
+ * values.
+ *
+ * @param external
+ * @return
+ * @throws NullPointerException if the value is null
+ * @throws ClassCastException if the value type is not an array of string
+ * @throws IllegalArgumentException if the array length is zero or one of the array value is null
+ */
+ protected String[] getInternal(String[] external) throws IllegalArgumentException, ClassCastException, NullPointerException
+ {
+ if (external.length == 0)
+ {
+ throw new IllegalArgumentException("Array must not be zero length");
+ }
+
+ //
+ for (int i = external.length - 1;i >= 0;i--)
+ {
+ if (external[i] == null)
+ {
+ throw new IllegalArgumentException("No null entries allowed in String[]");
+ }
+ }
+
+ //
+ if (cloneExternalValue)
+ {
+ external = external.clone();
+ }
+
+ //
+ return external;
+ }
+
+ protected String[] getExternal(String[] internal)
+ {
+ if (cloneInternalValue)
+ {
+ internal = internal.clone();
+ }
+ return internal;
+ }
+
+ protected boolean equals(String[] left, String[] right)
+ {
+ return Arrays.equals(left, right);
+ }
+ }
+
+ /**
+ * Return the parameter value or null if it does not exist.
+ *
+ * @param name the parameter name
+ * @return the parameter value or null if it does not exist
+ * @throws NullPointerException if the name is null
+ */
+ public String getValue(String name) throws IllegalArgumentException
+ {
+ String[] value = get(name);
+ return value == null ? null : value[0];
+ }
+
+ /**
+ * Return the parameter values or null if it does not exist.
+ *
+ * @param name the value to get
+ * @return the parameter values
+ * @throws NullPointerException if the name is null
+ */
+ public String[] getValues(String name) throws IllegalArgumentException
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No null name");
+ }
+ return get(name);
+ }
+
+ /**
+ * Set the a parameter value.
+ *
+ * @param name the parameter name
+ * @param value the parameter value
+ * @throws NullPointerException if the name or the value is null
+ */
+ public void setValue(String name, String value)
+ {
+ put(name, new String[]{value});
+ }
+
+ /**
+ * Set the parameter values. This method does not make a defensive copy of the values.
+ *
+ * @param name the parameter name
+ * @param values the parameter values
+ * @throws NullPointerException if the name or the value is null
+ * @throws IllegalArgumentException if the values length is zero or contains a null element
+ */
+ public void setValues(String name, String[] values) throws NullPointerException, IllegalArgumentException
+ {
+ put(name, values);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterMap.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 5757 $
+ * @since 2.4 (May 31, 2006)
+ */
+public class ParameterValidation
+{
+ public static void throwIllegalArgExceptionIfNullOrEmpty(String valueToCheck, String valueName, String contextName)
+ {
+ if (isNullOrEmpty(valueToCheck))
+ {
+ throw new IllegalArgumentException((contextName != null ? contextName + " r" : "R") + "equires a non-null, non-empty " + valueName);
+ }
+ }
+
+ /** @since 2.6 */
+ public static boolean isNullOrEmpty(String valueToCheck)
+ {
+ return valueToCheck == null || valueToCheck.length() == 0;
+ }
+
+ public static void throwIllegalArgExceptionIfNull(Object objectToTest, String name)
+ {
+ if (objectToTest == null)
+ {
+ throw new IllegalArgumentException("Must pass a non null " + name);
+ }
+ }
+
+ /** @since 2.4.1 */
+ public static void throwIllegalArgExceptionIfNullOrEmpty(Object[] array, String name)
+ {
+ if (array == null)
+ {
+ throw new IllegalArgumentException("Must pass a non-null " + name);
+ }
+ if (array.length == 0)
+ {
+ throw new IllegalArgumentException("Must pass a non-empty " + name);
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Encapsulate info about a proxy and provide a way to instantiate it.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ProxyInfo
+{
+
+ private static final Class[] EMPTY_SIGNATURE = new Class[0];
+ private static final Class[] EQUALS_SIGNATURE = new Class[]{Object.class};
+ private static final Class[] INVOCATION_HANDLER_SIGNATURE = new Class[]{InvocationHandler.class};
+
+ /** The proxy constructor. */
+ private final Constructor ctor;
+
+ /** The proxy toString method. */
+ private final Method toString;
+
+ /** The proxy hashCode method. */
+ private final Method hashCode;
+
+ /** The proxy equals method. */
+ private final Method equals;
+
+ public ProxyInfo(Class clazz) throws Exception
+ {
+ this.ctor = clazz.getConstructor(INVOCATION_HANDLER_SIGNATURE);
+
+ //
+ toString = Object.class.getMethod("toString", EMPTY_SIGNATURE);
+ hashCode = Object.class.getMethod("hashCode", EMPTY_SIGNATURE);
+ equals = Object.class.getMethod("equals", EQUALS_SIGNATURE);
+ }
+
+ /**
+ * Instantiate a proxy.
+ *
+ * @param handler the invocation handler
+ * @return the proxy
+ */
+ public Object instantiate(InvocationHandler handler) throws IllegalAccessException, InvocationTargetException, InstantiationException
+ {
+ return ctor.newInstance(new Object[]{handler});
+ }
+
+ public Method getToString()
+ {
+ return toString;
+ }
+
+ public Method getHashCode()
+ {
+ return hashCode;
+ }
+
+ public Method getEquals()
+ {
+ return equals;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ProxyInfo.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.io.InputStream;
+
+/**
+ * A generic interface which define loading capabilities of resources.
+ * The name format must follow the regular expression : ^(/[-a-zA-Z0-9_\.]+)+$
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6653 $
+ */
+public interface ResourceLoader
+{
+
+ /** Helper to validate name. */
+ String REGEX_NAME_VALIDATOR = "^(/[-a-zA-Z0-9_\\.]+)+$";
+
+ /**
+ * Returns an InputStream or null if not found.
+ */
+ InputStream load(String location);
+
+ /**
+ *
+ */
+ LoaderResource getResource(String location);
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/ResourceLoader.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,129 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Comparator;
+import java.util.TreeSet;
+import java.util.SortedSet;
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * A map of set. This object does not handle synchronization and use HashMap and HashSet
+ * as underlying data structures;
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7322 $
+ */
+public class SetMap<K, V> extends CollectionMap<K, V>
+{
+
+ /** Version. */
+ static final long serialVersionUID = -7239767000556095977L;
+
+ /** An optional comparator. */
+ protected Comparator<V> comparator;
+
+ public SetMap()
+ {
+ }
+
+ public SetMap(SetMap<K, V> other) throws IllegalArgumentException
+ {
+ super(other);
+ }
+
+ public SetMap(SetMap<K, V> other, Comparator<V> comparator) throws IllegalArgumentException
+ {
+ super(other);
+
+ //
+ if (comparator == null)
+ {
+ throw new IllegalArgumentException("No null comparator allowed");
+ }
+
+ //
+ this.comparator = comparator;
+ }
+
+ public SetMap(Comparator<V> comparator)
+ {
+ super();
+
+ //
+ if (comparator == null)
+ {
+ throw new IllegalArgumentException("No null comparator allowed");
+ }
+
+ //
+ this.comparator = comparator;
+ }
+
+ /**
+ * Return the set specified by the key.
+ */
+ public Set<V> get(K key)
+ {
+ return (Set<V>)super.get(key);
+ }
+
+ protected void add(Collection<V> c, V o)
+ {
+ c.add(o);
+ }
+
+ protected void remove(Collection<V> c, Object o)
+ {
+ c.remove(o);
+ }
+
+ protected Collection<V> newCollection()
+ {
+ if (comparator == null)
+ {
+ return new HashSet<V>();
+ }
+ else
+ {
+ return new TreeSet<V>(comparator);
+ }
+ }
+
+ protected Collection<V> newCollection(Collection<V> other)
+ {
+ if (comparator == null)
+ {
+ return new HashSet<V>(other);
+ }
+ else
+ {
+ SortedSet<V> set = new TreeSet<V>(comparator);
+ set.addAll(other);
+ return set;
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/SetMap.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/SimpleMapAccessor.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/SimpleMapAccessor.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/SimpleMapAccessor.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleMapAccessor<K, V> implements MapAccessor<K, V>
+{
+
+ /** . */
+ private Map<K, V> delegate;
+
+ public SimpleMapAccessor(Map<K, V> delegate)
+ {
+ if (delegate == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.delegate = delegate;
+ }
+
+ public Map<K, V> getMap(boolean writable)
+ {
+ return delegate;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,929 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.logging.Log4JWriter;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.lang.reflect.Array;
+import java.math.BigInteger;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.UnknownHostException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:boleslaw dot dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7377 $
+ */
+public class Tools
+{
+
+ public static final int DEFAULT_BUFFER_SIZE = 512;
+
+ public static final Logger log = Logger.getLogger(Tools.class);
+
+ /** 16 chars long VMID. */
+ public static final String VMID = VMID();
+
+ private static String VMID()
+ {
+ try
+ {
+ BigInteger bi = BigInteger.valueOf(0);
+ byte[] address = java.net.InetAddress.getLocalHost().getAddress();
+ for (int i = 0; i < 4; i++)
+ {
+ bi = bi.shiftLeft(8);
+ bi = bi.add(BigInteger.valueOf(address[i]));
+ }
+ bi = bi.shiftLeft(32);
+ int code = System.identityHashCode(new Object());
+ bi = bi.add(BigInteger.valueOf(code));
+ byte[] bytes = bi.toByteArray();
+ StringBuffer buffer = new StringBuffer();
+ char[] chars = "0123456789ABCDEF".toCharArray();
+ for (int i = 0; i < bytes.length; i++)
+ {
+ buffer.append(chars[(bytes[i] & 0xF0) >> 4]).append(chars[bytes[i] & 0xF]);
+ }
+ return buffer.toString();
+ }
+ catch (UnknownHostException e)
+ {
+ e.printStackTrace(System.err);
+ throw new Error("Cannot create VMID");
+ }
+ }
+
+ public static final Enumeration EMPTY_ENUMERATION = new Enumeration()
+ {
+ public boolean hasMoreElements()
+ {
+ return false;
+ }
+
+ public Object nextElement()
+ {
+ throw new NoSuchElementException();
+ }
+ };
+
+ public static final Iterator EMPTY_ITERATOR = new Iterator()
+ {
+ public boolean hasNext()
+ {
+ return false;
+ }
+
+ public Object next()
+ {
+ throw new NoSuchElementException();
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ };
+
+ public static final ResourceBundle EMPTY_BUNDLE = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ return null;
+ }
+
+ public Enumeration getKeys()
+ {
+ return EMPTY_ENUMERATION;
+ }
+ };
+
+ public static <E> Enumeration<E> toEnumeration(final Iterator<E> iterator)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return new Enumeration<E>()
+ {
+ public boolean hasMoreElements()
+ {
+ return iterator.hasNext();
+ }
+
+ public E nextElement()
+ {
+ return iterator.next();
+ }
+ };
+ }
+
+ public static <E> Enumeration<E> toEnumeration(final E[] objects)
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return new Enumeration<E>()
+ {
+ int index = 0;
+
+ public boolean hasMoreElements()
+ {
+ return index < objects.length;
+ }
+
+ public E nextElement()
+ {
+ if (index < objects.length)
+ {
+ return objects[index++];
+ }
+ else
+ {
+ throw new NoSuchElementException();
+ }
+ }
+ };
+ }
+
+ public static <E> Enumeration<E> toEnumeration(final E o)
+ {
+ return new Enumeration<E>()
+ {
+ boolean hasMore = true;
+
+ public boolean hasMoreElements()
+ {
+ return hasMore;
+ }
+
+ public E nextElement()
+ {
+ if (hasMore)
+ {
+ hasMore = false;
+ }
+ else
+ {
+ throw new NoSuchElementException();
+ }
+ return o;
+ }
+ };
+ }
+
+ public static <E> Set<E> toSet(Enumeration<E> e)
+ {
+ if (e == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ HashSet<E> set = new HashSet<E>();
+ while (e.hasMoreElements())
+ {
+ set.add(e.nextElement());
+ }
+ return set;
+ }
+
+ public static <E> Set<E> toSet(E... objects)
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ HashSet<E> set = new HashSet<E>();
+ for (E object : objects)
+ {
+ set.add(object);
+ }
+ return set;
+ }
+
+ /**
+ * Transforms an iterator into an unordered Set
+ *
+ * @param iterator The iterator to transform
+ * @return A HashSet
+ */
+ public static <E> Set<E> toSet(Iterator<E> iterator)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return toSet(iterator, false);
+ }
+
+ /**
+ * Transforms an iterator into a Set
+ *
+ * @param iterator The iterator to transform
+ * @param preserveOrder true if the set must respect the ordering of the iterator
+ * @return a LinkedHashSet if ordered is true, a HashSet otherwise
+ */
+ public static <E> Set<E> toSet(Iterator<E> iterator, boolean preserveOrder)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Set<E> set;
+ if (preserveOrder)
+ {
+ set = new LinkedHashSet<E>();
+ }
+ else
+ {
+ set = new HashSet<E>();
+ }
+ while (iterator.hasNext())
+ {
+ set.add(iterator.next());
+ }
+ return set;
+ }
+
+ public static <E> List<E> toList(Enumeration<E> e)
+ {
+ if (e == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<E> list = new ArrayList<E>();
+ while (e.hasMoreElements())
+ {
+ list.add(e.nextElement());
+ }
+ return list;
+ }
+
+ public static <E> List<E> toList(Iterator<E> iterator)
+ {
+ if (iterator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<E> list = new ArrayList<E>();
+ while (iterator.hasNext())
+ {
+ list.add(iterator.next());
+ }
+ return list;
+ }
+
+ public static <E> List<E> toList(E... objects)
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ List<E> list = new ArrayList<E>(objects.length);
+ for (E object : objects)
+ {
+ list.add(object);
+ }
+ return list;
+ }
+
+ /**
+ * Consider remove this method as it cannot be generified.
+ *
+ * @param i
+ * @return
+ */
+ @Deprecated
+ public static Object[] toArray(Iterator i)
+ {
+ // This method cannot be generified.
+ return toList(i).toArray();
+ }
+
+ /**
+ * Returns a singleton iterator.
+ *
+ * @param o the singleton object
+ * @return the iterator
+ */
+ public static <E> Iterator<E> iterator(final E o)
+ {
+ return new Iterator<E>()
+ {
+ /** The status of the iterator. */
+ boolean done = false;
+
+ public boolean hasNext()
+ {
+ return !done;
+ }
+
+ public E next()
+ {
+ if (done)
+ {
+ throw new NoSuchElementException("Already iterated");
+ }
+ done = true;
+ return o;
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("read only");
+ }
+ };
+ }
+
+ /**
+ * Returns an iterator over the array elements.
+ *
+ * @param objects the array containing the objects to iterate on
+ * @return the iterator
+ * @throws IllegalArgumentException if the object array is null or the specified range is not valid
+ */
+ public static <E> Iterator<E> iterator(final E... objects) throws IllegalArgumentException
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException("No null object array");
+ }
+ return iterator(objects, 0, objects.length);
+ }
+
+ /**
+ * Returns an iterator over the array elements within the specified range. The range is considered as valid
+ * if the from argument is greater or equals than zero, the to argument is lesser or equals than array size
+ * and the from argument is lesser or equals to the to argument.
+ *
+ * @param objects the array containing the objects to iterate on
+ * @param from the inclusive start index
+ * @param to the exclusive stop index
+ * @return the iterator
+ * @throws IllegalArgumentException if the object array is null or the specified range is not valid or if the range is not valid
+ */
+ public static <E> Iterator<E> iterator(final E[] objects, final int from, final int to) throws IllegalArgumentException
+ {
+ if (objects == null)
+ {
+ throw new IllegalArgumentException("No null object array");
+ }
+ if (from > to || from < 0 || to > objects.length)
+ {
+ throw new IllegalArgumentException("Invalid range [" + from + "," + to + "] for array of length " + objects.length);
+ }
+ return new Iterator<E>()
+ {
+ /** . */
+ int index = from;
+
+ public boolean hasNext()
+ {
+ return index < to;
+ }
+
+ public E next()
+ {
+ if (index >= to)
+ {
+ throw new NoSuchElementException("Index is greater than the array length");
+ }
+ return objects[index++];
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException("read only");
+ }
+ };
+ }
+
+ public static int computeStringHash(int hash, String s)
+ {
+ char[] chars = s.toCharArray();
+ int length = chars.length;
+ for (int i = 0; i < length; i++)
+ {
+ char c = chars[i];
+ hash = 31 * hash + c;
+ }
+ return hash;
+ }
+
+ /**
+ * Computes an md5 hash of a string.
+ *
+ * @param text the hashed string
+ * @return the string hash
+ * @throws NullPointerException if text is null
+ */
+ public static byte[] md5(String text)
+ {
+ // arguments check
+ if (text == null)
+ {
+ throw new NullPointerException("null text");
+ }
+
+ try
+ {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ md.update(text.getBytes());
+ return md.digest();
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ log.error("Cannot find MD5 algorithm", e);
+ throw new RuntimeException("Cannot find MD5 algorithm");
+ }
+ }
+
+ /**
+ * Computes an md5 hash and returns the result as a string in hexadecimal format.
+ *
+ * @param text the hashed string
+ * @return the string hash
+ * @throws NullPointerException if text is null
+ */
+ public static String md5AsHexString(String text)
+ {
+ return toHexString(md5(text));
+ }
+
+ /**
+ * Computes a hash with specified algorighm and returns the result as a string in hexadecimal format
+ *
+ * @param text
+ * @param algorithm
+ * @param encoding
+ * @return
+ * @throws NoSuchAlgorithmException
+ */
+ public static String hashAndEncodeString(String text, String algorithm, String encoding) throws NoSuchAlgorithmException
+ {
+ // arguments check
+ if (text == null)
+ {
+ throw new NullPointerException("null text");
+ }
+ if (algorithm == null)
+ {
+ throw new NullPointerException("null algorithm");
+ }
+ if (encoding == null)
+ {
+ throw new NullPointerException("null encoding");
+ }
+
+ MessageDigest md = MessageDigest.getInstance(algorithm);
+ md.update(text.getBytes());
+ byte[] encoded = md.digest();
+
+ if ("HEX".equalsIgnoreCase(encoding))
+ {
+ return toHexString(encoded);
+ }
+ //TODO: add base64 support here
+ else
+ {
+ throw new IllegalArgumentException("Not supported encoding: " + encoding);
+ }
+
+ }
+
+
+ /**
+ * Returns a string in the hexadecimal format.
+ *
+ * @param bytes the converted bytes
+ * @return the hexadecimal string representing the bytes data
+ * @throws IllegalArgumentException if the byte array is null
+ */
+ public static String toHexString(byte[] bytes)
+ {
+ if (bytes == null)
+ {
+ throw new IllegalArgumentException("byte array must not be null");
+ }
+ StringBuffer hex = new StringBuffer(bytes.length * 2);
+ for (int i = 0; i < bytes.length; i++)
+ {
+ hex.append(Character.forDigit((bytes[i] & 0XF0) >> 4, 16));
+ hex.append(Character.forDigit((bytes[i] & 0X0F), 16));
+ }
+ return hex.toString();
+ }
+
+ /**
+ * Returns a byte array converted from the hexadecimal format.
+ *
+ * @param hex the string to convert
+ * @return the byte array corresponding
+ * @throws IllegalArgumentException if the string is null or does not have the good format
+ */
+ public static byte[] fromHexString(String hex)
+ {
+ if (hex == null)
+ {
+ throw new IllegalArgumentException("Hex string must not be null");
+ }
+ if (hex.length() % 2 == 1)
+ {
+ throw new IllegalArgumentException("Hex string length is not even : " + hex.length());
+ }
+ int index = 0;
+ byte[] bytes = new byte[hex.length() / 2];
+ for (int i = 0; i < bytes.length; i++)
+ {
+ char chigh = hex.charAt(index++);
+ int high = Character.digit(chigh, 16);
+ if (high == -1)
+ {
+ throw new IllegalArgumentException("Hex string contains a bad char : " + chigh);
+ }
+ char clow = hex.charAt(index++);
+ int low = Character.digit(clow, 16);
+ if (low == -1)
+ {
+ throw new IllegalArgumentException("Hex string contains a bad char : " + clow);
+ }
+ byte value = (byte)((high << 4) + low);
+ bytes[i] = value;
+ }
+ return bytes;
+ }
+
+ /**
+ *
+ */
+ public static String generateTemporaryHash(String value, long time)
+ {
+ if (value == null)
+ {
+ throw new IllegalArgumentException("id must not be null");
+ }
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(time);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ return md5AsHexString(value + calendar.getTimeInMillis());
+ }
+
+ /**
+ *
+ */
+ public static boolean confirmTemporaryHash(String hash, String value, long time)
+ {
+ if (hash == null)
+ {
+ return false;
+ }
+ if (value == null)
+ {
+ throw new IllegalArgumentException("value must not be null");
+ }
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(time);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MILLISECOND, 0);
+ String expected = md5AsHexString(value + calendar.getTimeInMillis());
+ if (expected.equals(hash))
+ {
+ return true;
+ }
+ calendar.add(Calendar.HOUR_OF_DAY, -1);
+ expected = md5AsHexString(value + calendar.getTimeInMillis());
+ return expected.equals(hash);
+ }
+
+ public static String getShortNameOf(Class clazz)
+ {
+ return clazz.getSimpleName();
+ }
+
+ public static String getPackageOf(Class clazz)
+ {
+ String name = clazz.getName();
+ int index = name.lastIndexOf('.');
+ if (index != -1)
+ {
+ name = name.substring(0, index);
+ }
+ else
+ {
+ name = "";
+ }
+ return name;
+ }
+
+ public static String buildClassLoaderInfo(ClassLoader loader)
+ {
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("no loader");
+ }
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("ClassLoader[Name=").append(loader.getClass().getName());
+ buffer.append(",HashCode=").append(loader.hashCode());
+ buffer.append(",IdentityHashCode=").append(System.identityHashCode(loader));
+ if (loader instanceof URLClassLoader)
+ {
+ URLClassLoader urlLoader = (URLClassLoader)loader;
+ URL[] urls = urlLoader.getURLs();
+ for (int i = 0; i < urls.length; i++)
+ {
+ URL url = urls[i];
+ buffer.append(",URL(").append(i).append(")=").append(url);
+ }
+ }
+ try
+ {
+ Class uclClass = Thread.currentThread().getContextClassLoader().loadClass("org.jboss.mx.loading.UnifiedClassLoader");
+ Class loaderClass = loader.getClass();
+ if (uclClass.isAssignableFrom(loaderClass))
+ {
+ URL url = (URL)loaderClass.getMethod("getURL", new Class[0]).invoke(loader, new Object[0]);
+ buffer.append(",GetURL=").append(url);
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot get UCL infos", e);
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ public static String dumpClassLoaderHierarchyInfo(ClassLoader loader)
+ {
+ StringWriter writer = new StringWriter();
+ dumpClassLoaderHierarchyInfo(writer, loader);
+ return writer.toString();
+ }
+
+ public static void dumpClassLoaderHierarchyInfo(Writer writer, ClassLoader loader)
+ {
+ if (writer == null)
+ {
+ throw new IllegalArgumentException("no writer");
+ }
+ if (loader == null)
+ {
+ throw new IllegalArgumentException("no loader");
+ }
+
+ //
+ PrintWriter pw = null;
+ if (writer instanceof PrintWriter)
+ {
+ pw = (PrintWriter)writer;
+ }
+ else
+ {
+ pw = new PrintWriter(writer);
+ }
+
+ pw.println("<classloader-dump>");
+ while (loader != null)
+ {
+ pw.println(buildClassLoaderInfo(loader));
+ loader = loader.getParent();
+ }
+ pw.print("</classloader-dump>");
+ pw.flush();
+ }
+
+ public static void dumpClassLoaderHierarchyInfo(Logger log, ClassLoader loader)
+ {
+ Writer writer = new Log4JWriter(log, Level.DEBUG);
+ dumpClassLoaderHierarchyInfo(writer, loader);
+ }
+
+ public static void dumpClassLoaderHierarchyInfo(Logger log, Level level, ClassLoader loader)
+ {
+ Writer writer = new Log4JWriter(log, level);
+ dumpClassLoaderHierarchyInfo(writer, loader);
+ }
+
+ /**
+ * Replace occurence in a string.
+ *
+ * @param string the source string
+ * @param pattern the replaced pattern
+ * @param replacement the replacement text
+ * @return the new string
+ */
+ public static String replace(String string, String pattern, String replacement)
+ {
+ StringBuffer buffer = new StringBuffer(string.length());
+ int previous = 0;
+ int current = string.indexOf(pattern);
+ while (current != -1)
+ {
+ buffer.append(string.substring(previous, current));
+ buffer.append(replacement);
+ previous = current + pattern.length();
+ current = string.indexOf(pattern, previous);
+ }
+ buffer.append(string.substring(previous));
+ return buffer.toString();
+ }
+
+ /**
+ * Append an object to an array of objects. The original array is not modified. The returned array
+ * will be of the same component type of the provided array and its first n elements where n is the size
+ * of the provided array will be the elements of the provided array. The last element of the array will be
+ * the provided object to append.
+ *
+ * @param array the array to augment
+ * @param o the object to append
+ * @return a new array
+ * @throws IllegalArgumentException if the array is null
+ * @throws ClassCastException if the appended object class prevents it from being added to the array
+ */
+ public static <E> E[] appendTo(E[] array, E o) throws IllegalArgumentException, ClassCastException
+ {
+ if (array == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Class componentType = array.getClass().getComponentType();
+ if (o != null && !componentType.isAssignableFrom(o.getClass()))
+ {
+ throw new ClassCastException("Object with class " + o.getClass().getName() + " cannot be casted to class " + componentType.getName());
+ }
+
+ //
+ E[] copy = (E[])Array.newInstance(componentType, array.length + 1);
+ System.arraycopy(array, 0, copy, 0, array.length);
+ copy[array.length] = o;
+
+ //
+ return copy;
+ }
+
+ /**
+ * Return true if
+ * <ul>
+ * <li>o1 is null and o2 is null</li<
+ * <li>o1 is not null and the invocation of <code>equals(Object o)</code> on o1 wit o2 as argument returns true</li>
+ * </ul>
+ *
+ * @param o1 the first argument
+ * @param o2 the second argument
+ * @return if arguments are equals according to the semantic defined by the method contract
+ */
+ public static boolean safeEquals(Object o1, Object o2)
+ {
+ if (o1 == null)
+ {
+ return o2 == null;
+ }
+ else
+ {
+ return o1.equals(o2);
+ }
+ }
+
+ public static String replaceAllInstancesOfBoundedString(String initial, String prefix, String suffix, String replacement)
+ {
+ return replaceBoundedString(initial, prefix, suffix, replacement, true, false);
+ }
+
+ /**
+ * Todo : define what "bounded" means.
+ *
+ * @param initial
+ * @param prefix
+ * @param suffix
+ * @param replacement
+ * @param replaceIfBoundedStringEmpty
+ * @param keepBoundaries
+ * @return
+ */
+ public static String replaceBoundedString(String initial, String prefix, String suffix, String replacement,
+ boolean replaceIfBoundedStringEmpty, boolean keepBoundaries)
+ {
+ if (initial == null || initial.length() == 0)
+ {
+ return initial;
+ }
+
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(prefix, "prefix", "Tools.replaceBoundedString");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(suffix, "suffix", "Tools.replaceBoundedString");
+ ParameterValidation.throwIllegalArgExceptionIfNull(replacement, "replacement");
+
+ StringBuffer tmp = new StringBuffer(initial);
+ int prefixIndex = tmp.indexOf(prefix);
+ int suffixLength = suffix.length();
+ int prefixLength = prefix.length();
+
+ while (prefixIndex != -1)
+ {
+ int suffixIndex = tmp.indexOf(suffix, prefixIndex);
+
+ if (suffixIndex != -1)
+ {
+ // we don't care about empty bounded strings or prefix and suffix don't delimit an empty String => replace!
+ if (replaceIfBoundedStringEmpty || suffixIndex != prefixIndex + prefixLength)
+ {
+ if (keepBoundaries)
+ {
+ tmp.delete(prefixIndex + prefixLength, suffixIndex);
+ tmp.insert(prefixIndex + prefixLength, replacement);
+ }
+ else
+ {
+ tmp.delete(prefixIndex, suffixIndex + suffixLength);
+ tmp.insert(prefixIndex, replacement);
+ }
+ }
+ }
+
+ prefixIndex = tmp.indexOf(prefix, prefixIndex + prefixLength);
+ }
+
+ return tmp.toString();
+ }
+
+ /**
+ * Determines if value is contained in array.
+ *
+ * todo: correct this method contract in order to make it more reusable, it looks like for now like a method
+ * which has a contract convenient only for some kind of callers.
+ *
+ * 1/ null value should be accepted (or the method should be called isContainedInButNotForNullValue ?)
+ * 2/ null array should not be accepted (or the method should be called isContainedInExceptIfThePassedArrayIsNull ?)
+ *
+ * @param value
+ * @param array
+ * @return
+ * @since 2.4.2
+ */
+ public static boolean isContainedIn(Object value, Object[] array)
+ {
+ if (value == null)
+ {
+ return false;
+ }
+
+ //
+ if (array != null)
+ {
+ for (Object anArray : array)
+ {
+ if (value.equals(anArray))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Tools.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,783 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import org.jboss.portal.common.NotYetImplemented;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TypedMap<EK, EV, IK, IV> implements Map<EK, EV>
+{
+
+ public abstract static class Converter<E, I>
+ {
+
+ /**
+ * Unwraps the key to the the internal key that will be stored in the map. This method calls the
+ * <code>assertKeyValidity(Object key)</code> and returns the same key. It can be overriden to provide a customized
+ * key that will be used instead of the external key.
+ *
+ * @param external the key to unwrap
+ * @return the unwrapped key
+ * @throws ClassCastException if the class of the specified key prevents it from being stored in this map
+ * @throws IllegalArgumentException if some aspect of this key prevents it from being stored in this map
+ */
+ protected abstract I getInternal(E external) throws IllegalArgumentException, ClassCastException;
+
+ /**
+ * Wrap the internal key into its external representation, by default returns the same key. It can be overriden to
+ * provide a customized key that will be used instead of the internal key.
+ */
+ protected abstract E getExternal(I internal);
+
+ public I unwrap(E external) throws IllegalArgumentException, ClassCastException, NullPointerException
+ {
+ if (external == null)
+ {
+ throw new NullPointerException("No null key accepted");
+ }
+
+ //
+ I internal = getInternal(external);
+
+ //
+ if (internal == null)
+ {
+ throw new IllegalArgumentException("The provided key " + external + " was converted to a null key");
+ }
+
+ //
+ return internal;
+ }
+
+ public E wrap(I internal) throws IllegalStateException
+ {
+ if (internal == null)
+ {
+ throw new IllegalStateException("Got an internal null key");
+ }
+
+ //
+ E external = getExternal(internal);
+
+ //
+ if (external == null)
+ {
+ throw new IllegalStateException("Converted an internal key to a null key " + internal);
+ }
+
+ //
+ return external;
+ }
+
+ public boolean safeEquals(I left, I right)
+ {
+ // Check the internal value, it should not be null
+ return !(left == null || right == null) && equals(left, right);
+ }
+
+ /**
+ * Compare internal values, the passed argument are never null.
+ *
+ * @param left the left value
+ * @param right the right value
+ * @return true if the values are equals
+ */
+ protected abstract boolean equals(I left, I right);
+ }
+
+ /** The map accessor. */
+ private final MapAccessor<IK, IV> accessor;
+
+ /** The key converter. */
+ private final Converter<EK, IK> keyConverter;
+
+ /** The value converter. */
+ private final Converter<EV, IV> valueConverter;
+
+ public TypedMap(MapAccessor<IK, IV> accessor, Converter<EK, IK> keyConverter, Converter<EV, IV> valueConverter)
+ {
+ if (accessor == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (keyConverter == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (valueConverter == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+
+ this.accessor = accessor;
+ this.keyConverter = keyConverter;
+ this.valueConverter = valueConverter;
+ }
+
+ public TypedMap(Map<IK, IV> delegate, Converter<EK, IK> keyConv, Converter<EV, IV> valueConv)
+ {
+ this(new SimpleMapAccessor<IK, IV>(delegate), keyConv, valueConv);
+ }
+
+ public Converter<EK, IK> getKeyConverter()
+ {
+ return keyConverter;
+ }
+
+ public Converter<EV, IV> getValueConverter()
+ {
+ return valueConverter;
+ }
+
+ public final int size()
+ {
+ return accessor.getMap(false).size();
+ }
+
+ public final void clear()
+ {
+ if (!isEmpty())
+ {
+ accessor.getMap(true).clear();
+ }
+ }
+
+ public final boolean isEmpty()
+ {
+ return accessor.getMap(false).isEmpty();
+ }
+
+ public final boolean containsKey(Object key)
+ {
+ EK ek = (EK)key;
+ IK ik = keyConverter.unwrap(ek);
+ return accessor.getMap(false).containsKey(ik);
+ }
+
+ public final Set<EK> keySet()
+ {
+ return new KeySet();
+ }
+
+ public EV put(EK ek, EV ev)
+ {
+ IK ik = keyConverter.unwrap(ek);
+ IV iv = valueConverter.unwrap(ev);
+ iv = accessor.getMap(true).put(ik, iv);
+ return iv == null ? null : valueConverter.wrap(iv);
+ }
+
+ public final EV get(Object key)
+ {
+ EK ek = (EK)key;
+ IK ik = keyConverter.unwrap(ek);
+ IV iv = accessor.getMap(false).get(ik);
+ return iv == null ? null : valueConverter.wrap(iv);
+ }
+
+ public final EV remove(Object key)
+ {
+ EK ek = (EK)key;
+ IK ik = keyConverter.unwrap(ek);
+ IV iv = null;
+ if (!isEmpty())
+ {
+ iv = accessor.getMap(true).remove(ik);
+ }
+ return iv == null ? null : valueConverter.wrap(iv);
+ }
+
+ public final boolean containsValue(Object value)
+ {
+ EV ev = (EV)value;
+ IV iv = valueConverter.unwrap(ev);
+ return accessor.getMap(false).containsValue(iv);
+ }
+
+ public final Set<Entry<EK, EV>> entrySet()
+ {
+ return new TypedEntrySet();
+ }
+
+ public void putAll(Map<? extends EK, ? extends EV> em)
+ {
+ Map<IK, IV> im = convert(em);
+ accessor.getMap(true).putAll(im);
+ }
+
+ public Collection<EV> values()
+ {
+ return new ValueCollection();
+ }
+
+ /** Compare to parameters objects. */
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof Map)
+ {
+ Map<EK, EV> that = (Map<EK,EV>)o;
+ Map<IK, IV> delegate = this.accessor.getMap(false);
+
+ // Must have same sizes
+ if (that.size() != delegate.size())
+ {
+ return false;
+ }
+
+ //
+ for (Entry<EK, EV> thatEntry : that.entrySet())
+ {
+
+ EK thatKey = thatEntry.getKey();
+ EV thatValue = thatEntry.getValue();
+
+ //
+ try
+ {
+ // Unwrap key, mostly for checking its type is correct
+ keyConverter.unwrap(thatKey);
+
+ // Unwrap value
+ IV iv = valueConverter.unwrap(thatValue);
+
+ // Get the internal value
+ IV internalValue = delegate.get(thatKey);
+
+ // Perform value comparison
+ if (!valueConverter.safeEquals(internalValue, iv))
+ {
+ return false;
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ catch (ClassCastException e)
+ {
+ return false;
+ }
+ catch (NullPointerException e)
+ {
+ return false;
+ }
+ }
+
+ //
+ return true;
+ }
+
+ //
+ return false;
+ }
+
+ public String toString()
+ {
+ return accessor.getMap(false).toString();
+ }
+
+ /**
+ * Validates and unwraps the map.
+ *
+ * @param t
+ * @return
+ * @throws IllegalArgumentException
+ * @throws NullPointerException
+ * @throws ClassCastException
+ */
+ protected final Map<IK, IV> convert(Map<? extends EK, ? extends EV> t) throws IllegalArgumentException, NullPointerException, ClassCastException
+ {
+ if (t == null)
+ {
+ throw new NullPointerException("No null map can be accepted");
+ }
+ Map<IK, IV> u = new HashMap<IK, IV>(t.size());
+ for (Entry<? extends EK, ? extends EV> entry : t.entrySet())
+ {
+ IK ik = keyConverter.unwrap(entry.getKey());
+ IV iv = valueConverter.unwrap(entry.getValue());
+ u.put(ik, iv);
+ }
+ return u;
+ }
+
+ /**
+ * Replace the content with the new map which is validated before replacement.
+ *
+ * @param map the replacement map
+ * @throws ClassCastException
+ * @throws NullPointerException
+ * @throws IllegalArgumentException
+ */
+ public void replace(Map<EK, EV> map) throws ClassCastException, NullPointerException, IllegalArgumentException
+ {
+ if (!map.isEmpty())
+ {
+ Map<IK, IV> tmp = convert(map);
+
+ //
+ Map<IK, IV> delegate = accessor.getMap(true);
+ delegate.clear();
+ delegate.putAll(tmp);
+ }
+ }
+
+ /**
+ * Validate the content.
+ *
+ * @throws ClassCastException
+ * @throws NullPointerException
+ * @throws IllegalArgumentException
+ */
+ public void validate() throws ClassCastException, NullPointerException, IllegalArgumentException
+ {
+ for (Entry<IK, IV> entry : accessor.getMap(false).entrySet())
+ {
+ keyConverter.wrap(entry.getKey());
+ valueConverter.wrap(entry.getValue());
+ }
+ }
+
+ public class KeySet implements Set<EK>
+ {
+
+ /** . */
+ private final Set<IK> delegate;
+
+ public KeySet()
+ {
+ this.delegate = TypedMap.this.accessor.getMap(false).keySet();
+ }
+
+ public int size()
+ {
+ return delegate.size();
+ }
+
+ public void clear()
+ {
+ if (!isEmpty())
+ {
+ delegate.clear();
+ }
+ }
+
+ public boolean isEmpty()
+ {
+ return delegate.isEmpty();
+ }
+
+ public boolean contains(Object o)
+ {
+ EK ek;
+ try
+ {
+ ek = (EK)o;
+ }
+ catch (ClassCastException e)
+ {
+ return false;
+ }
+ try
+ {
+ IK ik = keyConverter.getInternal(ek);
+ return TypedMap.this.accessor.getMap(false).containsKey(ik);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ catch (ClassCastException e)
+ {
+ return false;
+ }
+ catch (NullPointerException e)
+ {
+ return false;
+ }
+ }
+
+ public Object[] toArray()
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray()");
+ }
+
+ public boolean add(EK ek)
+ {
+ throw new NotYetImplemented("TypedEntrySet.add(Object o)");
+ }
+
+ public boolean remove(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.remove(Object o)");
+ }
+
+ public boolean containsAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.addAll(Collection c)");
+ }
+
+ public boolean addAll(Collection<? extends EK> eks)
+ {
+ throw new NotYetImplemented("TypedEntrySet.containsAll(Collection c)");
+ }
+
+ public boolean removeAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.removeAll(Collection c)");
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ if (c == null)
+ {
+ throw new NullPointerException();
+ }
+
+ //
+ boolean changed = false;
+ for (Iterator i = iterator(); i.hasNext();)
+ {
+ Object key = i.next();
+ if (!c.contains(key))
+ {
+ i.remove();
+ changed = true;
+ }
+ }
+ return changed;
+ }
+
+ public Iterator<EK> iterator()
+ {
+ return new KeyIterator();
+ }
+
+ public <EK> EK[] toArray(EK a[])
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray(Object a[])");
+ }
+
+ public class KeyIterator implements Iterator<EK>
+ {
+
+ /** . */
+ private final Iterator<IK> delegate;
+
+ public KeyIterator()
+ {
+ this.delegate = KeySet.this.delegate.iterator();
+ }
+
+ public void remove()
+ {
+ delegate.remove();
+ }
+
+ public boolean hasNext()
+ {
+ return delegate.hasNext();
+ }
+
+ public EK next()
+ {
+ IK ik = delegate.next();
+ return keyConverter.wrap(ik);
+ }
+ }
+ }
+
+ public class ValueCollection implements Collection<EV>
+ {
+
+ /** . */
+ private final Collection<IV> delegate;
+
+ public ValueCollection()
+ {
+ this.delegate = TypedMap.this.accessor.getMap(false).values();
+ }
+
+ public int size()
+ {
+ return delegate.size();
+ }
+
+ public void clear()
+ {
+ delegate.clear();
+ }
+
+ public boolean isEmpty()
+ {
+ return delegate.isEmpty();
+ }
+
+ public Object[] toArray()
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray()");
+ }
+
+ public boolean add(EV ev)
+ {
+ throw new NotYetImplemented("TypedEntrySet.add(Object o)");
+ }
+
+ public boolean contains(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.contains(Object o)");
+ }
+
+ public boolean remove(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.remove(Object o)");
+ }
+
+ public boolean addAll(Collection<? extends EV> evs)
+ {
+ throw new NotYetImplemented("TypedEntrySet.addAll(Collection c)");
+ }
+
+ public boolean containsAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.containsAll(Collection c)");
+ }
+
+ public boolean removeAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.removeAll(Collection c)");
+ }
+
+ public boolean retainAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.retainAll(Collection c)");
+ }
+
+ public <T> T[] toArray(T[] ts)
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray(Object a[])");
+ }
+
+ public Iterator<EV> iterator()
+ {
+ return new ValueIterator();
+ }
+
+ public class ValueIterator implements Iterator<EV>
+ {
+
+ /** . */
+ private final Iterator<IV> delegate;
+
+ public ValueIterator()
+ {
+ this.delegate = ValueCollection.this.delegate.iterator();
+ }
+
+ public void remove()
+ {
+ delegate.remove();
+ }
+
+ public boolean hasNext()
+ {
+ return delegate.hasNext();
+ }
+
+ public EV next()
+ {
+ IV iv = delegate.next();
+ return valueConverter.wrap(iv);
+ }
+ }
+ }
+
+ public class TypedEntrySet implements Set<Entry<EK, EV>>
+ {
+
+ /** . */
+ private final Set<Entry<IK, IV>> delegate;
+
+ public TypedEntrySet()
+ {
+ this.delegate = TypedMap.this.accessor.getMap(false).entrySet();
+ }
+
+ public int size()
+ {
+ return delegate.size();
+ }
+
+ public void clear()
+ {
+ if (!isEmpty())
+ {
+ delegate.clear();
+ }
+ }
+
+ public boolean isEmpty()
+ {
+ return delegate.isEmpty();
+ }
+
+ public Object[] toArray()
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray()");
+ }
+
+ public boolean add(Entry<EK, EV> ekevEntry)
+ {
+ throw new NotYetImplemented("TypedEntrySet.add(Object o)");
+ }
+
+ public boolean contains(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.contains(Object o)");
+ }
+
+ public boolean remove(Object o)
+ {
+ throw new NotYetImplemented("TypedEntrySet.remove(Object o)");
+ }
+
+ public boolean addAll(Collection<? extends Entry<EK, EV>> entries)
+ {
+ throw new NotYetImplemented("TypedEntrySet.addAll(Collection c)");
+ }
+
+ public boolean containsAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.containsAll(Collection c)");
+ }
+
+ public boolean removeAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.removeAll(Collection c)");
+ }
+
+ public boolean retainAll(Collection<?> objects)
+ {
+ throw new NotYetImplemented("TypedEntrySet.retainAll(Collection c)");
+ }
+
+ public <T> T[] toArray(T[] ts)
+ {
+ throw new NotYetImplemented("TypedEntrySet.toArray(Object a[])");
+ }
+
+ public Iterator<Entry<EK, EV>> iterator()
+ {
+ return new TypedEntryIterator();
+ }
+
+ public class TypedEntryIterator implements Iterator<Entry<EK, EV>>
+ {
+
+ /** . */
+ private final Iterator<Entry<IK, IV>> delegate;
+
+ public TypedEntryIterator()
+ {
+ this.delegate = TypedEntrySet.this.delegate.iterator();
+ }
+
+ public void remove()
+ {
+ delegate.remove();
+ }
+
+ public boolean hasNext()
+ {
+ return delegate.hasNext();
+ }
+
+ public Entry<EK, EV> next()
+ {
+ Entry<IK, IV> entry = delegate.next();
+ return new TypedEntry(entry);
+ }
+ }
+
+ public class TypedEntry implements Entry<EK, EV>
+ {
+
+ /** . */
+ private final Entry<IK, IV> delegate;
+
+ public TypedEntry(Entry<IK, IV> delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public int hashCode()
+ {
+ return delegate.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ return delegate.equals(obj);
+ }
+
+ public String toString()
+ {
+ return delegate.toString();
+ }
+
+ public EK getKey()
+ {
+ IK ik = delegate.getKey();
+ return keyConverter.wrap(ik);
+ }
+
+ public EV getValue()
+ {
+ IV iv = delegate.getValue();
+ return valueConverter.wrap(iv);
+ }
+
+ public EV setValue(Object value)
+ {
+ EV ev = (EV)value;
+ IV iv = valueConverter.unwrap(ev);
+ iv = delegate.setValue(iv);
+ return valueConverter.wrap(iv);
+ }
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/TypedMap.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+import java.net.InetAddress;
+import java.security.SecureRandom;
+
+/**
+ * Adapted from ejb plugin key generated.
+ *
+ * The implementation of UUID key generator
+ * based on the algorithm from Floyd Marinescu's EJB Design Patterns.
+ *
+ * @author <a href="mailto:alex.loubyansky@jboss.org">Alex Loubyansky</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class UUIDGenerator
+{
+
+ // Attributes ---------------------------------------------------
+
+ /** Hex digits */
+ private static final char[] hexDigits = "0123456789ABCDEF".toCharArray();
+
+ // Static --------------------------------------------------------
+
+ /** secure random to provide nonrepeating seed */
+ private SecureRandom seeder;
+
+ /** cached middle value */
+ private String midValue;
+
+ // Constructor --------------------------------------------------
+
+ public UUIDGenerator()
+ {
+ try
+ {
+ // Cache the middle part for UUID
+ StringBuffer buffer = new StringBuffer( 16 );
+
+ // Construct host part of the uuid (8 hex digits)
+ byte[] addr = InetAddress.getLocalHost().getAddress();
+ buffer.append( toHex( toInt(addr), 8 ) );
+
+ // Append the hash code for this object (8 hex digits)
+ buffer.append( toHex( System.identityHashCode(this), 8 ) );
+
+ // Set up midValue
+ midValue = buffer.toString();
+
+ // Load up the randomizer
+ seeder = new SecureRandom();
+ int node = seeder.nextInt();
+ }
+ catch (Exception e)
+ {
+ throw new Error("Not possible");
+ }
+ }
+
+ public String generateKey()
+ {
+ StringBuffer buffer = new StringBuffer(32);
+
+ // Append current time as unsigned int value
+ buffer.append(toHex((int)(System.currentTimeMillis() & 0xFFFFFFFF), 8));
+
+ // Append cached midValue
+ buffer.append( midValue );
+
+ // Append the next random int
+ buffer.append( toHex( seeder.nextInt(), 8 ) );
+
+ // Return the result
+ return buffer.toString();
+ }
+
+ // Private ------------------------------------------------------
+
+ /**
+ * Converts int value to string hex representation
+ */
+ private String toHex(int value, int length)
+ {
+ StringBuffer buffer = new StringBuffer(length);
+ int shift = (length - 1) << 2;
+ int i = -1;
+ while(++i < length)
+ {
+ buffer.append(hexDigits[(value >> shift) & 0x0000000F]);
+ value <<= 4;
+ }
+ return buffer.toString();
+ }
+
+ /**
+ * Constructs int value from byte array
+ */
+ private static int toInt( byte[] bytes )
+ {
+ int value = 0;
+ int i = -1;
+ while (++i < bytes.length)
+ {
+ value <<= 8;
+ int b = bytes[ i ] & 0xff;
+ value |= b;
+ }
+ return value;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/UUIDGenerator.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,287 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.util;
+
+/**
+ * Version class conforming to JBoss Product Version Conventions post 2006-03-01. See
+ * http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProductVersioning.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7165 $
+ */
+public class Version
+{
+
+ /** . */
+ private final String codeName;
+
+ /** . */
+ private final String toString;
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final int major;
+
+ /** . */
+ private final int minor;
+
+ /** . */
+ private final int patch;
+
+ /** . */
+ private final Qualifier qualifier;
+
+ public Version(String name, int major, int minor, int patch, Qualifier qualifier, String codeName)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No name provided");
+ }
+ if (major < 0)
+ {
+ throw new IllegalArgumentException("Major cannot be negative");
+ }
+ if (minor < 0)
+ {
+ throw new IllegalArgumentException("Minor cannot be negative");
+ }
+ if (patch < 0)
+ {
+ throw new IllegalArgumentException("Patch cannot be negative");
+ }
+ if (qualifier == null)
+ {
+ throw new IllegalArgumentException("Qualifier cannot be null");
+ }
+ if (codeName == null)
+ {
+ throw new IllegalArgumentException("No code name provided");
+ }
+ this.name = name;
+ this.major = major;
+ this.minor = minor;
+ this.patch = patch;
+ this.qualifier = qualifier;
+ this.codeName = codeName;
+ this.toString = Format.JBOSS_PRODUCT_CONVENTION.toString(this);
+ }
+
+ public String getCodeName()
+ {
+ return codeName;
+ }
+
+ /** Return the name; */
+ public String getName()
+ {
+ return name;
+ }
+
+ /** Return the major. */
+ public int getMajor()
+ {
+ return major;
+ }
+
+ /** Return the minor. */
+ public int getMinor()
+ {
+ return minor;
+ }
+
+ /** Return the patch. */
+ public int getPatch()
+ {
+ return patch;
+ }
+
+ /** Return the intermediate major. */
+ public Qualifier getQualifier()
+ {
+ return qualifier;
+ }
+
+ public String toString()
+ {
+ return toString;
+ }
+
+ public String toString(Format format) throws IllegalArgumentException
+ {
+ if (format == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return format.toString(this);
+ }
+
+ /** Type safe enum for intermediate major. */
+ public static class Qualifier
+ {
+
+ public enum Prefix
+ {
+
+ SNAPSHOT("SNAPSHOT", false, "Snapshot"),
+ ALPHA("ALPHA", true, "Alpha"),
+ BETA("BETA", true, "Beta"),
+ CR("CR", true, "Candidate for release"),
+ GA("GA", false, "General Availability"),
+ SP("SP", true, "Service pack");
+
+ /** . */
+ private final String name;
+
+ /** . */
+ private final String description;
+
+ /** . */
+ private final boolean suffixable;
+
+ private Prefix(String name, boolean suffixable, String description)
+ {
+ this.name = name;
+ this.suffixable = suffixable;
+ this.description = description;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public boolean isSuffixable()
+ {
+ return suffixable;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+ }
+
+ public enum Suffix
+ {
+
+ EMPTY(""),
+ SUFFIX_1("1"),
+ SUFFIX_2("2"),
+ SUFFIX_3("3"),
+ SUFFIX_4("4"),
+ SUFFIX_5("5"),
+ SUFFIX_6("6");
+
+ /** . */
+ private final String value;
+
+ private Suffix(String value)
+ {
+ this.value = value;
+ }
+
+ public String toString()
+ {
+ return value;
+ }
+ }
+
+ /** . */
+ private final String toString;
+
+ /** . */
+ private final Prefix prefix;
+
+ /** . */
+ private final Suffix suffix;
+
+ public Qualifier(Prefix prefix)
+ {
+ this(prefix, Suffix.EMPTY);
+ }
+
+ public Qualifier(Prefix prefix, Suffix suffix)
+ {
+ if (prefix == null)
+ {
+ throw new IllegalArgumentException("No prefix provided");
+ }
+ if (suffix == null)
+ {
+ suffix = Suffix.EMPTY;
+ }
+ if (prefix.isSuffixable() == false && suffix.value.length() > 0)
+ {
+ throw new IllegalArgumentException("The prefix " + prefix + " is not suffixable");
+ }
+ this.toString = "" + prefix + suffix;
+ this.prefix = prefix;
+ this.suffix = suffix;
+ }
+
+ public Prefix getPrefix()
+ {
+ return prefix;
+ }
+
+ public Suffix getSuffix()
+ {
+ return suffix;
+ }
+
+ public String toString()
+ {
+ return toString;
+ }
+ }
+
+ public interface Format
+ {
+
+ /**
+ * Implement formatting as defined <a href="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossProductVersioning">here</a>
+ */
+ Format JBOSS_PRODUCT_CONVENTION = new Format()
+ {
+ public String toString(Version version)
+ {
+ StringBuffer buffer = new StringBuffer(version.getName());
+ buffer.append(" ")
+ .append(version.getMajor()).append('.')
+ .append(version.getMinor()).append('.')
+ .append(version.getPatch()).append('-')
+ .append(version.getQualifier());
+ return buffer.toString();
+ }
+ };
+
+ String toString(Version version);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/util/Version.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class BooleanValue extends Value
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -1478457007976203260L;
+
+ /** The Boolean array. */
+ private Boolean[] values;
+
+ public BooleanValue()
+ {
+ this((Boolean)null);
+ }
+
+ public BooleanValue(Boolean value)
+ {
+ this(new Boolean[]{value});
+ }
+
+ public BooleanValue(boolean value)
+ {
+ this(new boolean[]{value});
+ }
+
+ public BooleanValue(String value)
+ {
+ this(new String[]{value});
+ }
+
+ public BooleanValue(Boolean[] values)
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = values;
+ }
+
+ public BooleanValue(boolean[] _values)
+ {
+ if (_values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ values = new Boolean[_values.length];
+ for (int i = 0;i < _values.length;i++)
+ {
+ values[i] = Boolean.valueOf(_values[i]);
+ }
+ }
+
+ public BooleanValue(String[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = new Boolean[values.length];
+ for (int i = 0;i < values.length;i++)
+ {
+ String value = values[i];
+ if (value == null)
+ {
+ this.values[i] = null;
+ }
+ else if ("true".equals(value))
+ {
+ this.values[i] = Boolean.TRUE;
+ }
+ else if ("false".equals(value))
+ {
+ this.values[i] = Boolean.FALSE;
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+
+ public boolean isInstanceOf(Class clazz)
+ {
+ return clazz != null && clazz.isAssignableFrom(Boolean.class);
+ }
+
+ protected Object[] getObjectArray()
+ {
+ return values;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/BooleanValue.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,57 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.util.NullConversionException;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public interface Converter
+{
+ /**
+ * Return true if the converter accepts the class for conversion.
+ *
+ * @throws IllegalArgumentException if the class object is null
+ */
+ boolean accept(Class clazz);
+
+ /**
+ * String to object conversion.
+ *
+ * @throws NullConversionException if the value nullity prevent the conversion
+ * @throws org.jboss.portal.common.util.FormatConversionException if the value cannot be converted
+ */
+ Object toObject(String value) throws NullConversionException, FormatConversionException;
+
+ /**
+ * Convert the object to the stored value.
+ *
+ * @throws NullConversionException if the value nullity prevent the conversion
+ * @throws FormatConversionException if the value cannot be converted
+ */
+ String toString(Object value) throws NullConversionException, FormatConversionException;
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Converter.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class FloatValue extends Value
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -3069055353952983120L;
+
+ /** The Float array. */
+ private Float[] values;
+
+ public FloatValue()
+ {
+ this((Float)null);
+ }
+
+ public FloatValue(Float integer)
+ {
+ this(new Float[]{integer});
+ }
+
+ public FloatValue(float _value)
+ {
+ this(new float[]{_value});
+ }
+
+ public FloatValue(String value)
+ {
+ this(new String[]{value});
+ }
+
+ public FloatValue(Float[] values)
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = values;
+ }
+
+ public FloatValue(float[] _values)
+ {
+ if (_values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ values = new Float[_values.length];
+ for (int i = 0;i < _values.length;i++)
+ {
+ values[i] = new Float(_values[i]);
+ }
+ }
+
+ public FloatValue(String[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ this.values = new Float[values.length];
+ for (int i = 0;i < values.length;i++)
+ {
+ String value = values[i];
+ if (value != null)
+ {
+ this.values[i] = new Float(value);
+ }
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public boolean isInstanceOf(Class clazz)
+ {
+ return clazz != null && clazz.isAssignableFrom(Integer.class);
+ }
+
+ protected Object[] getObjectArray()
+ {
+ return values;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/FloatValue.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,243 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.util.NullConversionException;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7200 $
+ */
+public class Helper
+{
+
+ public static final int[] EMPTY_INT_ARRAY = new int[0];
+ public static final boolean[] EMPTY_BOOLEAN_ARRAY = new boolean[0];
+ public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
+ public static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ public static final Converter FLOAT_CONVERTER = new Converter()
+ {
+ public boolean accept(Class clazz)
+ {
+ return Float.class.equals(clazz);
+ }
+ public Object toObject(String value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ try
+ {
+ return Float.valueOf(value);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new FormatConversionException();
+ }
+ }
+ public String toString(Object value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ if (!(value instanceof Float))
+ {
+ throw new FormatConversionException();
+ }
+ return value.toString();
+ }
+ };
+
+ public static final Converter INTEGER_CONVERTER = new Converter()
+ {
+ public boolean accept(Class clazz)
+ {
+ return Integer.class.equals(clazz);
+ }
+ public Object toObject(String value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ try
+ {
+ return Integer.valueOf(value);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new FormatConversionException();
+ }
+ }
+ public String toString(Object value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ if (!(value instanceof Integer))
+ {
+ throw new FormatConversionException();
+ }
+ return value.toString();
+ }
+ };
+
+ public static final Converter BOOLEAN_CONVERTER = new Converter()
+ {
+ public boolean accept(Class clazz)
+ {
+ return Boolean.class.equals(clazz);
+ }
+ public Object toObject(String value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ return Boolean.valueOf(Helper.toBoolean(value));
+ }
+ public String toString(Object value) throws NullConversionException, FormatConversionException
+ {
+ if (value == null)
+ {
+ return null;
+ }
+ if (!(value instanceof Boolean))
+ {
+ throw new FormatConversionException();
+ }
+ return value.toString();
+ }
+ };
+
+ public static int toInt(String value) throws NullConversionException, FormatConversionException
+ {
+ try
+ {
+ if (value == null)
+ {
+ throw new NullConversionException();
+ }
+ return Integer.parseInt(value);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new FormatConversionException();
+ }
+ }
+
+ public static boolean toBoolean(String value) throws NullConversionException, FormatConversionException
+ {
+ if ("true".equals(value))
+ {
+ return true;
+ }
+ else if ("false".equals(value))
+ {
+ return false;
+ }
+ else if (value == null)
+ {
+ throw new NullConversionException();
+ }
+ else
+ {
+ throw new FormatConversionException();
+ }
+ }
+
+ public static String toString(int value)
+ {
+ return Integer.toString(value);
+ }
+
+ public static String toString(boolean value)
+ {
+ return Boolean.toString(value);
+ }
+
+ public static String toString(Object value, Converter converter) throws NullConversionException, FormatConversionException, IllegalArgumentException
+ {
+ if (converter == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return converter.toString(value);
+ }
+
+ public static String[] toStringArray(int[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ String[] strings = new String[values.length];
+ for (int i = 0;i < strings.length;i++)
+ {
+ strings[i] = Integer.toString(values[i]);
+ }
+ return strings;
+ }
+
+ public static String[] toStringArray(boolean[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ String[] strings = new String[values.length];
+ for (int i = 0;i < strings.length;i++)
+ {
+ strings[i] = Boolean.toString(values[i]);
+ }
+ return strings;
+ }
+
+ public static String[] toStringArray(Object[] values, Converter converter) throws NullConversionException, FormatConversionException, IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (converter == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ String[] strings = new String[values.length];
+ for (int i = 0;i < strings.length;i++)
+ {
+ Object value = values[i];
+ if (value != null)
+ {
+ strings[i] = converter.toString(values[i]);
+ }
+ }
+ return strings;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Helper.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,114 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class IntegerValue extends Value
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -3396982952223096067L;
+
+ /** The Integer array. */
+ private Integer[] values;
+
+ public IntegerValue()
+ {
+ this((Integer)null);
+ }
+
+ public IntegerValue(Integer integer)
+ {
+ this(new Integer[]{integer});
+ }
+
+ public IntegerValue(int _value)
+ {
+ this(new int[]{_value});
+ }
+
+ public IntegerValue(String value)
+ {
+ this(new String[]{value});
+ }
+
+ public IntegerValue(Integer[] values)
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = values;
+ }
+
+ public IntegerValue(int[] _values)
+ {
+ if (_values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ values = new Integer[_values.length];
+ for (int i = 0;i < _values.length;i++)
+ {
+ values[i] = new Integer(_values[i]);
+ }
+ }
+
+ public IntegerValue(String[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ try
+ {
+ this.values = new Integer[values.length];
+ for (int i = 0;i < values.length;i++)
+ {
+ String value = values[i];
+ if (value != null)
+ {
+ this.values[i] = new Integer(value);
+ }
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public boolean isInstanceOf(Class clazz)
+ {
+ return clazz != null && clazz.isAssignableFrom(Integer.class);
+ }
+
+ protected Object[] getObjectArray()
+ {
+ return values;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/IntegerValue.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class StringValue extends Value
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 4280801691629359883L;
+
+ /** The String array. */
+ private String[] values;
+
+ public StringValue()
+ {
+ this((String)null);
+ }
+
+ public StringValue(String value)
+ {
+ this(new String[]{value});
+ }
+
+ public StringValue(String[] values) throws IllegalArgumentException
+ {
+ if (values == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.values = values;
+ }
+
+ public boolean isInstanceOf(Class clazz)
+ {
+ return clazz != null && clazz.isAssignableFrom(String.class);
+ }
+
+ protected Object[] getObjectArray()
+ {
+ return values;
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/StringValue.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,314 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.value;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
+import java.util.AbstractList;
+import java.util.RandomAccess;
+
+/**
+ * A read only interface used to retrieve data. It represents both for
+ * mono value and multi values. It must implement equals and hashCode.
+ * <p/>
+ * The semantics :
+ * <p/>
+ * <table border="1">
+ * <tr>
+ * <th>storage</th><th>mono</th><th>multi</th>
+ * </tr>
+ * <tr>
+ * <td>xxx</td><td>xxx</td><td>[xxx]</td>
+ * </tr>
+ * <tr>
+ * <td>null</td><td>null</td><td>[null]</td>
+ * </tr>
+ * <tr>
+ * <td colspan="3"></td>
+ * </tr>
+ * <tr>
+ * <td>[]</td><td>null</td><td>[]</td>
+ * </tr>
+ * <tr>
+ * <td>[null,..]</td><td>null</td><td>[null,..]</td>
+ * </tr>
+ * <tr>
+ * <td>["1",..]</td><td>"1"</td><td>["1",..]</td>
+ * </tr>
+ * </table>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public abstract class Value implements Serializable, Cloneable
+{
+
+ /**
+ * The cached hashCode.
+ */
+ private transient int hashCode = 0;
+
+ /**
+ * The object list representation.
+ */
+ private transient List objectList;
+
+ /**
+ * The string list representation.
+ */
+ private transient List stringList;
+
+ // ******************************
+
+ /**
+ *
+ */
+ public abstract boolean isInstanceOf(Class clazz);
+
+ public final int hashCode()
+ {
+ if (isNull())
+ {
+ return 0;
+ }
+ else
+ {
+ if (hashCode == 0)
+ {
+ Object[] objects = getObjectArray();
+ for (int i = 0; i < objects.length; i++)
+ {
+ Object o = objects[i];
+ if (o != null)
+ {
+ hashCode *= 43 + o.hashCode();
+ }
+ }
+ }
+ else
+ {
+ return hashCode;
+ }
+ }
+ return hashCode;
+ }
+
+ public final boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+ if (obj.getClass().equals(getClass()))
+ {
+ Value other = (Value)obj;
+ switch ((other.isNull() ? 2 : 0) + (isNull() ? 1 : 0))
+ {
+ case 1:
+ case 2:
+ return false;
+ case 3:
+ return true;
+ }
+ return Arrays.equals(getObjectArray(), other.getObjectArray());
+ }
+ return false;
+ }
+
+ public final String toString()
+ {
+ StringBuffer buffer = new StringBuffer("[");
+ String[] strings = asStringArray();
+ for (int i = 0; i < strings.length; i++)
+ {
+ String s = strings[i];
+ buffer.append(i > 0 ? "," : "").
+ append(String.valueOf(s));
+ }
+ buffer.append("]");
+ return buffer.toString();
+ }
+
+ /**
+ * Clone this object.
+ *
+ * @return a clone of this object
+ */
+ public final Value clone()
+ {
+ try
+ {
+ return (Value)super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ throw new Error(e);
+ }
+ }
+
+ // ***********************
+ // * Mono valued methods *
+ // ***********************
+
+ /**
+ * Return true if the value is null.
+ */
+ public final boolean isNull()
+ {
+ return getObjectArray().length == 0 || getObjectArray()[0] == null;
+ }
+
+ /**
+ * Return the value as a string or null if the value is null.
+ */
+ public final String asString()
+ {
+ String string = null;
+ Object object = asObject();
+ if (object != null)
+ {
+ string = object.toString();
+ }
+ return string;
+ }
+
+ /**
+ * Return the value.
+ */
+ public final Object asObject()
+ {
+ if (isNull())
+ {
+ return null;
+ }
+ return getObjectArray()[0];
+ }
+
+ // ************************
+ // * Multi valued methods *
+ // ************************
+
+ /**
+ * Return true if it contains more than one value.
+ */
+ public final boolean isMultiValued()
+ {
+ return size() > 1;
+ }
+
+ /**
+ * Return true if it contains zero value.
+ */
+ public final boolean isEmpty()
+ {
+ return size() == 0;
+ }
+
+ /**
+ * Return the size.
+ */
+ public final int size()
+ {
+ return getObjectArray().length;
+ }
+
+ /**
+ * Creates a new array and fill it with the string values.
+ */
+ public final String[] asStringArray()
+ {
+ Object[] objects = getObjectArray();
+ String[] strings = new String[objects.length];
+ for (int i = 0; i < objects.length; i++)
+ {
+ Object object = objects[i];
+ if (object != null)
+ {
+ strings[i] = object.toString();
+ }
+ }
+ return strings;
+ }
+
+ /**
+ * Create a new array and fill it with the values.
+ */
+ public final Object[] asObjectArray()
+ {
+ return (Object[])getObjectArray().clone();
+ }
+
+ /**
+ * Return an immutable list of strings.
+ */
+ public final List asStringList()
+ {
+ if (stringList == null)
+ {
+ stringList = new ValueList(asStringArray());
+ }
+ return stringList;
+ }
+
+ /**
+ * Return an immutable list of objects.
+ */
+ public final List asObjectList()
+ {
+ if (objectList == null)
+ {
+ // Avoid to make a copy as the list is not mutable
+ objectList = new ValueList(getObjectArray());
+ }
+ return objectList;
+ }
+
+ /**
+ * Return the values as an array of converted object. It must always return a non null array.
+ */
+ protected abstract Object[] getObjectArray();
+
+ private static class ValueList extends AbstractList implements List, RandomAccess
+ {
+
+ /** . */
+ private final Object[] array;
+
+ private ValueList(Object[] array)
+ {
+ this.array = array;
+ }
+
+ public int size()
+ {
+ return array.length;
+ }
+
+ public Object get(int index)
+ {
+ return array[index];
+ }
+ }
+
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/value/Value.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.xml;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7380 $
+ */
+public class NoSuchElementException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -393378187931491442L;
+
+ public NoSuchElementException()
+ {
+ }
+
+ public NoSuchElementException(String message)
+ {
+ super(message);
+ }
+
+ public NoSuchElementException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public NoSuchElementException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/NoSuchElementException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/NullEntityResolver.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/NullEntityResolver.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/NullEntityResolver.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,41 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.xml;
+
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7228 $
+ */
+public class NullEntityResolver implements EntityResolver
+{
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
+ {
+ return null;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.xml;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7380 $
+ */
+public class TooManyElementException extends RuntimeException
+{
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -2381186243988987102L;
+
+ public TooManyElementException()
+ {
+ }
+
+ public TooManyElementException(String message)
+ {
+ super(message);
+ }
+
+ public TooManyElementException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public TooManyElementException(Throwable cause)
+ {
+ super(cause);
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/TooManyElementException.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,468 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.xml;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * Utilities for dealing with XML.
+ *
+ * @author <a href="mailto:mholzner@novell.com">Martin Holzner</a>
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7686 $
+ */
+public class XMLTools
+{
+
+ /** Namespace URI for XML lang. */
+ public static final String XML_LANG_NAMESPACE_URI = "http://www.w3.org/XML/1998/namespace";
+
+ /** Document builder factory. */
+ private static final DocumentBuilderFactory buildFactory = DocumentBuilderFactory.newInstance();
+
+ /** Transformer factory. */
+ private static final TransformerFactory transformerFactory = TransformerFactory.newInstance();
+
+ /** Default output format which is : no xml declaration, no document type, indent. */
+ private static Properties DEFAULT_FORMAT = createFormat(true, false, true, "utf-8");
+
+ /** . */
+ public static final String PARAM_YES = "yes";
+
+ /** . */
+ public static final String PARAM_NO = "no";
+
+ /** . */
+ public static final String ATTRIB_OMIT_XML_DECLARATION = "omit-xml-declaration";
+
+ /** . */
+ public static final String ATTRIB_CDATA_SECTION_ELEMENTS = "cdata-section-elements";
+
+ /** . */
+ public static final String ATTRIB_METHOD = "method";
+
+ /** . */
+ public static final String ATTRIB_INDENT = "indent";
+
+ /** . */
+ public static final String ATTRIB_HREF = "href";
+
+ /** . */
+ public static final String DIRECTIVE_IMPORT = "xsl:import";
+
+ /** . */
+ public static final String DIRECTIVE_INCLUDE = "xsl:include";
+
+ /** . */
+ public static final boolean DEFAULT_NAMESPACE_AWARE = true;
+
+ /** . */
+ public static final boolean DEFAULT_VALIDATION = false;
+
+ /** prevent instantiation */
+ private XMLTools()
+ {
+ }
+
+ /** Return the builder factory. */
+ public static DocumentBuilderFactory getDocumentBuilderFactory()
+ {
+ return buildFactory;
+ }
+
+ /**
+ *
+ */
+ private static Properties createFormat(boolean omitXMLDeclaration, boolean standalone, boolean indented, String encoding)
+ {
+ Properties format = new Properties();
+ format.setProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration ? "yes" : "no");
+ format.setProperty(OutputKeys.STANDALONE, standalone ? "yes" : "no");
+ format.setProperty(OutputKeys.INDENT, indented ? "yes" : "no");
+ format.setProperty(OutputKeys.ENCODING, encoding);
+ return format;
+ }
+
+ /**
+ *
+ */
+ public static String toString(Document doc, boolean omitXMLDeclaration, boolean standalone, boolean indented, String encoding) throws TransformerException
+ {
+ Properties format = createFormat(omitXMLDeclaration, standalone, indented, encoding);
+ return toString(doc, format);
+ }
+
+ /**
+ * Serialize the document with the default format : - No XML declaration - Indented - Encoding is UTF-8
+ *
+ * @see #toString(Document,Properties)
+ */
+ public static String toString(Document doc) throws TransformerException
+ {
+ return toString(doc, DEFAULT_FORMAT);
+ }
+
+ /** @see #toString(Document) */
+ public static String toString(Element element) throws ParserConfigurationException, TransformerException
+ {
+ return toString(element, DEFAULT_FORMAT);
+ }
+
+ /** Converts an element to a String representation. */
+ private static String toString(Element element, Properties properties) throws ParserConfigurationException, TransformerException
+ {
+ Document doc = buildFactory.newDocumentBuilder().newDocument();
+ element = (Element)doc.importNode(element, true);
+ doc.appendChild(element);
+ return toString(doc, properties);
+ }
+
+ /** Converts an document to a String representation. */
+ private static String toString(Document doc, Properties format) throws TransformerException
+ {
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setOutputProperties(format);
+ StringWriter writer = new StringWriter();
+ Source source = new DOMSource(doc);
+ Result result = new StreamResult(writer);
+ transformer.transform(source, result);
+ return writer.toString();
+ }
+
+ /** Parse a string into a document. */
+ public static Document toDocument(String text) throws ParserConfigurationException, SAXException, IOException
+ {
+ DocumentBuilder builder = buildFactory.newDocumentBuilder();
+ StringReader reader = new StringReader(text);
+ InputSource source = new InputSource();
+ source.setCharacterStream(reader);
+ return builder.parse(source);
+ }
+
+ /** Parse a string into an element. */
+ public static Element toElement(String text) throws ParserConfigurationException, SAXException, IOException
+ {
+ Document doc = toDocument(text);
+ return doc.getDocumentElement();
+ }
+
+ public static Document toDocument(Element element) throws ParserConfigurationException, SAXException, IOException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
+ Document doc = buildFactory.newDocumentBuilder().newDocument();
+ element = (Element)doc.importNode(element, true);
+ doc.appendChild(element);
+ return doc;
+ }
+
+ /**
+ * Perform trimming by default
+ *
+ * @param element
+ * @return
+ * @throws IllegalArgumentException
+ * @see #asString(org.w3c.dom.Element,boolean)
+ */
+ public static String asString(Element element) throws IllegalArgumentException
+ {
+ return asString(element, true);
+ }
+
+ /**
+ * Get the element's content as a string.
+ *
+ * @param element the container
+ * @param trim true if text should be trimmed before returning result
+ * @throws IllegalArgumentException if the element content is mixed or null
+ */
+ public static String asString(Element element, boolean trim) throws IllegalArgumentException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No null element allowed");
+ }
+
+ //
+ StringBuffer buffer = new StringBuffer();
+ NodeList children = element.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++)
+ {
+ Node child = children.item(i);
+ switch (child.getNodeType())
+ {
+ case Node.CDATA_SECTION_NODE:
+ case Node.TEXT_NODE:
+ buffer.append(((Text)child).getData());
+ break;
+ case Node.ELEMENT_NODE:
+ throw new IllegalArgumentException("Mixed content not allowed");
+ default:
+ break;
+ }
+ }
+ String result = buffer.toString();
+ if (trim)
+ {
+ result = result.trim();
+ }
+ return result;
+ }
+
+ /**
+ * Return the optional unique child of an element.
+ *
+ * @param element the parent element
+ * @param strict true if the element must be present
+ * @return the child element or null if it does not exist and strict is false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, boolean strict) throws IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No element specified");
+ }
+ Element childElt = null;
+ NodeList list = element.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node childNode = list.item(i);
+ if (childNode instanceof Element)
+ {
+ if (childElt == null)
+ {
+ childElt = (Element)childNode;
+ }
+ else
+ {
+ throw new TooManyElementException("More than one child element for element " + element.getNodeName());
+ }
+ }
+ }
+ if (strict && childElt == null)
+ {
+ throw new NoSuchElementException("No child element for element " + element.getNodeName());
+ }
+ return childElt;
+ }
+
+ /**
+ * Return an optional child of an element with the specified name.
+ *
+ * @param element the parent element
+ * @param name the child name
+ * @param strict if the child must be present
+ * @return the child element or null if it does not exist and strict is set to false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, String name, boolean strict) throws IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ return getUniqueChild(element, null, name, strict);
+ }
+
+ /**
+ * Return an optional child of an element with the specified name and the optionally specified namespace uri.
+ *
+ * @param element the parent element
+ * @param name the child name
+ * @param uri the child uri
+ * @param strict if the child must be present
+ * @return the child element or null if it does not exist and strict is set to false
+ * @throws IllegalArgumentException if an argument is null
+ * @throws NoSuchElementException if strict is true and the element is not present
+ * @throws TooManyElementException if more than one element is found
+ */
+ public static Element getUniqueChild(Element element, String uri, String name, boolean strict) throws IllegalArgumentException,
+ NoSuchElementException, TooManyElementException
+ {
+ List list = getChildren(element, uri, name);
+ switch (list.size())
+ {
+ case 0:
+ if (strict)
+ {
+ throw new NoSuchElementException("Missing child " + name + " of element " + element.getNodeName());
+ }
+ else
+ {
+ return null;
+ }
+ case 1:
+ return (Element)list.get(0);
+ default:
+ throw new TooManyElementException("Too many children for element " + element.getNodeName());
+ }
+ }
+
+ /**
+ * Return an iterator for all the children of the given element having the specified name.
+ *
+ * @param element the parent element
+ * @param name the child names
+ * @return an iterator for the designated elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static Iterator<Element> getChildrenIterator(Element element, String name) throws IllegalArgumentException
+ {
+ return getChildren(element, name).iterator();
+ }
+
+ /**
+ * Return an iterator for all the children of the given element having the specified name and the optionally
+ * specified namesspace uri.
+ *
+ * @param element the parent element
+ * @param uri the children uri
+ * @param name the children name
+ * @return an iterator for the designated elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static Iterator<Element> getChildrenIterator(Element element, String uri, String name) throws IllegalArgumentException
+ {
+ return getChildren(element, uri, name).iterator();
+ }
+
+ /**
+ * Return all the children of the given element having the specified name. The collection object can be modified.
+ *
+ * @param element the parent element
+ * @param name the child names
+ * @return a list of elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static List<Element> getChildren(Element element, String name) throws IllegalArgumentException
+ {
+ return getChildren(element, null, name);
+ }
+
+ /**
+ * Return all the children of the given element having the specified name and the optionally specified namespace URI.
+ * The collection object can be modified.
+ *
+ * @param element the parent element
+ * @param uri the children uri
+ * @param name the children name
+ * @return a list of elements
+ * @throws IllegalArgumentException if the element is null or the name is null
+ */
+ public static List<Element> getChildren(Element element, String uri, String name) throws IllegalArgumentException
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No element found");
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException("No name specified");
+ }
+ ArrayList<Element> result = new ArrayList<Element>();
+ NodeList list = element.getChildNodes();
+ for (int i = 0; i < list.getLength(); i++)
+ {
+ Node node = list.item(i);
+ if (node.getNodeType() == Node.ELEMENT_NODE)
+ {
+ Element childElt = (Element)node;
+
+ //
+ if (uri == null)
+ {
+ if (childElt.getTagName().equals(name))
+ {
+ result.add(childElt);
+ }
+ }
+ else if (uri.equals(childElt.getNamespaceURI()))
+ {
+ if (childElt.getLocalName().equals(name))
+ {
+ result.add(childElt);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static Properties loadXMLProperties(Element propertiesElt)
+ {
+ if (propertiesElt == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Properties props = new Properties();
+ for (Element entryElt : getChildren(propertiesElt, "entry"))
+ {
+ String key = entryElt.getAttribute("key");
+ String value = asString(entryElt);
+ props.put(key, value);
+ }
+ return props;
+ }
+
+ public static Properties loadXMLProperties(Document doc)
+ {
+ if (doc == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return loadXMLProperties(doc.getDocumentElement());
+ }
+
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/java/org/jboss/portal/common/xml/XMLTools.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_close.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_close.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_close.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<span style="font-weight: bold">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/b_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_close.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_close.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_close.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,3 @@
+ </pre></td></tr>
+</table>
+<span class="pn-text">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,7 @@
+</span>
+<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
+<tr>
+ <td><span class="pn-title"><b>{L_CODE}:</b></span></td>
+ </tr>
+ <tr>
+ <td class="pn-code"><pre>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/code_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_close.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_close.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_close.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<span style="color: {COLOR}">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/color_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/email.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/email.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/email.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<a href="mailto:{EMAIL}">{EMAIL}</a>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/email.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_close.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_close.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_close.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<span style="font-style: italic">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/i_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/img.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/img.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/img.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<img src="{URL}" border="0" />
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/img.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/listitem.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/listitem.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/listitem.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<li>
\ No newline at end of file
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/listitem.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_close.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_close.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_close.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+</ol>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<ol type="{LIST_TYPE}">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/olist_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_close.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_close.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_close.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,4 @@
+</td>
+ </tr>
+</table>
+<span class="pn-text">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,7 @@
+</span>
+<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
+<tr>
+ <td><span class="pn-title"><b>{L_QUOTE}:</b></span></td>
+ </tr>
+ <tr>
+ <td class="pn-quote">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_username_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_username_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_username_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,7 @@
+</span>
+<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
+<tr>
+ <td><span class="pn-title"><b>{USERNAME} {L_WROTE}:</b></span></td>
+ </tr>
+ <tr>
+ <td class="pn-quote">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/quote_username_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_close.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_close.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_close.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<span style="font-size: {SIZE}px; line-height: normal">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/size_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_close.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_close.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_close.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+</span>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<span style="text-decoration: underline">
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/u_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_close.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_close.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_close.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+</ul>
\ No newline at end of file
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_close.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_open.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_open.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_open.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<ul>
\ No newline at end of file
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/ulist_open.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/url.tpl
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/url.tpl (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/url.tpl 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<a href="{URL}" target="_blank">{DESCRIPTION}</a>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/main/resources/format/code/url.tpl
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/AbstractInvocationContextTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,252 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.invocation.AbstractInvocationContext;
+import org.jboss.portal.common.invocation.Scope;
+import org.jboss.portal.common.invocation.AttributeResolver;
+
+import java.util.HashMap;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractInvocationContextTestCase extends TestCase
+{
+
+ /** . */
+ private static final Scope TEST_SCOPE = new Scope("test");
+
+ public void testNonExistingScope()
+ {
+ AbstractInvocationContext ctx = new AbstractInvocationContext();
+ try
+ {
+ ctx.getAttribute(TEST_SCOPE, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ try
+ {
+ ctx.setAttribute(TEST_SCOPE, "foo", "bar");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ try
+ {
+ ctx.removeAttribute(TEST_SCOPE, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ try
+ {
+ ctx.getAttributeResolver(TEST_SCOPE);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+
+ }
+ }
+
+ public void testExistingScopeWithResolver()
+ {
+ final MapResolver resolver = new MapResolver();
+ AbstractInvocationContext ctx = new AbstractInvocationContext()
+ {
+ {
+ addResolver(TEST_SCOPE, resolver);
+ }
+ };
+ testExistingScope(ctx, resolver);
+ }
+
+ public void testExistingScopeDelegation()
+ {
+ final MapResolver resolver = new MapResolver();
+ final AbstractInvocationContext parent = new AbstractInvocationContext()
+ {
+ {
+ addResolver(TEST_SCOPE, resolver);
+ }
+ };
+ AbstractInvocationContext child = new AbstractInvocationContext()
+ {
+ {
+ addResolver(TEST_SCOPE, parent);
+ }
+ };
+ testExistingScope(child, resolver);
+ }
+
+
+ private void testExistingScope(AbstractInvocationContext ctx, MapResolver resolver)
+ {
+ // Assert empty does not exist
+ assertNull(ctx.getAttribute(TEST_SCOPE, "foo"));
+ assertEquals(0, resolver.size());
+
+ // Remove non existing
+ ctx.removeAttribute(TEST_SCOPE, "foo");
+ assertNull(ctx.getAttribute(TEST_SCOPE, "foo"));
+ assertEquals(0, resolver.size());
+
+ // Set non existing
+ ctx.setAttribute(TEST_SCOPE, "foo", "bar");
+ assertEquals("bar", resolver.getAttribute("foo"));
+ assertEquals(1, resolver.size());
+
+ // Overwrite existing
+ ctx.setAttribute(TEST_SCOPE, "foo", "bar2");
+ assertEquals("bar2", resolver.getAttribute("foo"));
+ assertEquals(1, resolver.size());
+
+ // Remove existing
+ ctx.removeAttribute(TEST_SCOPE, "foo");
+ assertNull(ctx.getAttribute(TEST_SCOPE, "foo"));
+ assertEquals(0, resolver.size());
+
+ // Get resolver
+ assertEquals(resolver, ctx.getAttributeResolver(TEST_SCOPE));
+ }
+
+ public void testAPI()
+ {
+ AbstractInvocationContext ctx = new AbstractInvocationContext();
+ try
+ {
+ ctx.getAttribute(null, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.getAttribute(TEST_SCOPE, null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(null, "foo", "bar");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(TEST_SCOPE, null, "bar");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(null, "foo", null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.setAttribute(TEST_SCOPE, null, null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.removeAttribute(null, "foo");
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.removeAttribute(TEST_SCOPE, null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ ctx.getAttributeResolver(null);
+ fail("was expecting an IllegalArgumentException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ private static class MapResolver extends HashMap implements AttributeResolver
+ {
+ public Set getKeys()
+ {
+ return keySet();
+ }
+ public Object getAttribute(Object attrKey) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ return get(attrKey);
+ }
+ public void setAttribute(Object attrKey, Object attrValue) throws IllegalArgumentException
+ {
+ if (attrKey == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (attrValue != null)
+ {
+ put(attrKey, attrValue);
+ }
+ else
+ {
+ remove(attrKey);
+ }
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BufferedStreamTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.io.IOTools;
+
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.io.BufferedInputStream;
+import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.BufferedOutputStream;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BufferedStreamTestCase extends TestCase
+{
+
+ public BufferedStreamTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testInputStream() throws Exception
+ {
+ assertNull(IOTools.safeBufferedWrapper((InputStream)null));
+ BufferedInputStream in = IOTools.safeBufferedWrapper(new ByteArrayInputStream("abc".getBytes("UTF8")));
+ assertEquals(System.identityHashCode(in), System.identityHashCode(IOTools.safeBufferedWrapper(in)));
+ assertNotNull(in);
+ byte[] bytes = "abc".getBytes("UTF8");
+ Arrays.fill(bytes, (byte)0);
+ assertEquals(bytes.length, in.read(bytes));
+ assertEquals(-1, in.read());
+ assertEquals("abc", new String(bytes, "UTF8"));
+ }
+
+ public void testOutputputStream() throws Exception
+ {
+ assertNull(IOTools.safeBufferedWrapper((OutputStream)null));
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ BufferedOutputStream buffered = IOTools.safeBufferedWrapper(out);
+ assertNotNull(buffered);
+ assertEquals(System.identityHashCode(buffered), System.identityHashCode(IOTools.safeBufferedWrapper(buffered)));
+ buffered.write("abc".getBytes("UTF8"));
+ buffered.close();
+ assertEquals("abc", out.toString("UTF8"));
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameIteratorTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,206 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.NoSuchElementException;
+
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameIteratorTestCase extends TestCase
+{
+
+ private final String A = new Locale("a", "b", "c").getLanguage();
+ private final String B = new Locale("a", "b", "c").getCountry();
+ private final String C = new Locale("a", "b", "c").getVariant();
+
+ public void testNameLookup1()
+ {
+ Locale l = new Locale("a", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B + "_" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup2()
+ {
+ Locale l = new Locale("a", "b");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup4()
+ {
+ Locale l = new Locale("a", "b", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "_" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup3()
+ {
+ Locale l = new Locale("a");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup5()
+ {
+ Locale l = new Locale("a", "", "");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup6()
+ {
+ Locale l = new Locale("a", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A + "__" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base_" + A, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup7()
+ {
+ Locale l = new Locale("", "b", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B + "_" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base__" + B, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ public void testNameLookup8()
+ {
+ Locale l = new Locale("", "", "c");
+ BundleName.Iterator iterator = new BundleName.Iterator("base", l);
+ assertTrue(iterator.hasNext());
+ assertEquals("base___" + C, iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals("base", iterator.next());
+ assertFalse(iterator.hasNext());
+ try
+ {
+ iterator.next();
+ fail("Was expecting NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/BundleNameParserTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.BundleName;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleNameParserTestCase extends TestCase
+{
+
+ /** . */
+ private final BundleName.Parser parser = new BundleName.Parser();
+
+
+ private static final Test[] tests = {
+ new Test("_", null),
+ new Test("__", null),
+ new Test("___", null),
+
+ //
+ new Test("a", new BundleName("a")),
+ new Test("a_b", new BundleName("a", "b")),
+ new Test("a_b_c", new BundleName("a", "b", "c")),
+ new Test("a__b", new BundleName("a", "", "b")),
+ new Test("a___b", new BundleName("a", "", "", "b")),
+ new Test("a__b_c", new BundleName("a", "", "b", "c")),
+ new Test("a_b__c", new BundleName("a", "b", "", "c")),
+ new Test("a_b_c_d", new BundleName("a", "b", "c", "d")),
+
+ //
+ new Test("", new BundleName("")),
+ new Test("_b", new BundleName("", "b")),
+ new Test("_b_c", new BundleName("", "b", "c")),
+ new Test("__b", new BundleName("", "", "b")),
+ new Test("___b", new BundleName("", "", "", "b")),
+ new Test("__b_c", new BundleName("", "", "b", "c")),
+ new Test("_b__c", new BundleName("", "b", "", "c")),
+ new Test("_b_c_d", new BundleName("", "b", "c", "d")),
+ };
+
+ public void testA()
+ {
+ for (int i = 0; i < tests.length; i++)
+ {
+ Test test = tests[i];
+ BundleName name = parser.parse(test.input, 0, test.input.length());
+ if (name == null)
+ {
+ assertNull(test.input, test.expectedName);
+ }
+ else
+ {
+ assertNotNull(test.input, test.expectedName);
+ assertEquals(test.input, test.expectedName.getBaseName(), name.getBaseName());
+ assertEquals(test.input, test.expectedName.getLanguage(), name.getLanguage());
+ assertEquals(test.input, test.expectedName.getCountry(), name.getCountry());
+ assertEquals(test.input, test.expectedName.getVariant(), name.getVariant());
+ }
+ }
+ }
+
+
+ private static class Test
+ {
+
+ /** . */
+ private String input;
+
+ /** . */
+ private BundleName expectedName;
+
+ public Test(String input, BundleName expectedName)
+ {
+ this.input = input;
+ this.expectedName = expectedName;
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ComplexResourceBundleFactoryTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,303 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.jboss.portal.common.i18n.ComplexResourceBundleFactory;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ComplexResourceBundleFactoryTestCase extends TestCase
+{
+
+ /** . */
+ private ClassLoader cl;
+
+ protected void setUp() throws Exception
+ {
+ URL bundleURL = Thread.currentThread().getContextClassLoader().getResource("bundle");
+ assertNotNull(bundleURL);
+ File f = new File(bundleURL.getFile());
+ assertTrue(f.exists());
+ assertTrue(f.isDirectory());
+ cl = new URLClassLoader(new URL[]{f.toURL()}, ClassLoader.getSystemClassLoader());
+ }
+
+ public void testExactMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "a");
+
+ //
+ ResourceBundle a_de_DE = factory.getBundle(new Locale("de", "DE"));
+ assertNotNull(a_de_DE);
+ assertEquals("a_de_DE", a_de_DE.getString("value"));
+
+ //
+ ResourceBundle a_fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(a_fr);
+ assertEquals("a_fr", a_fr.getString("value"));
+
+ //
+ ResourceBundle a_fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(a_fr_FR);
+ assertEquals("a_fr_FR", a_fr_FR.getString("value"));
+
+ //
+ ResourceBundle a_it = factory.getBundle(new Locale("it"));
+ assertNotNull(a_it);
+ assertEquals("a_it", a_it.getString("value"));
+ }
+
+ public void testNoMatch() throws Exception
+ {
+ Locale.setDefault(new Locale("ja"));
+
+ //
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "a");
+
+ //
+ ResourceBundle a_de = factory.getBundle(new Locale("de"));
+ assertNull(a_de);
+
+ //
+ ResourceBundle a_en = factory.getBundle(new Locale("en"));
+ assertNull(a_en);
+
+ //
+ ResourceBundle a_en_EN = factory.getBundle(new Locale("en", "EN"));
+ assertNull(a_en_EN);
+ }
+
+ public void testFallbackOnDefaultLocale1() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "b");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("b", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("b", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("b", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale2() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "c");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("c_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("c_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("c_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale3() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "d");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNull(de);
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNull(fr);
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("d_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("d_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("d_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale4() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "e");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("e_fr", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("e_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("e_fr", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale5() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "f");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("f_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("f_fr_FR", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("f_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale6() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "g");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("g_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("g_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("g_fr_FR", fr_FR.getString("value"));
+ }
+
+ public void testFallbackOnDefaultLocale7() throws Exception
+ {
+ ComplexResourceBundleFactory factory = new ComplexResourceBundleFactory(cl, "h");
+
+ //
+ Locale.setDefault(new Locale("fr"));
+ ResourceBundle de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr", de.getString("value"));
+ ResourceBundle fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ ResourceBundle fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+
+ //
+ Locale.setDefault(new Locale("fr", "FR"));
+ de = factory.getBundle(new Locale("de"));
+ assertNotNull(de);
+ assertEquals("h_fr_FR", de.getString("value"));
+ fr = factory.getBundle(new Locale("fr"));
+ assertNotNull(fr);
+ assertEquals("h_fr", fr.getString("value"));
+ fr_FR = factory.getBundle(new Locale("fr", "FR"));
+ assertNotNull(fr_FR);
+ assertEquals("h_fr_FR", fr_FR.getString("value"));
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/CopyOnWriteRegistryTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,187 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CopyOnWriteRegistry;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CopyOnWriteRegistryTestCase extends TestCase
+{
+
+ private CopyOnWriteRegistry registry;
+ Object key;
+ Object registered1;
+ Object registered2;
+
+
+ protected void setUp() throws Exception
+ {
+ registry = new CopyOnWriteRegistry();
+ key = new Object();
+ registered1 = new Object();
+ registered2 = new Object();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ registry = null;
+ key = null;
+ registered1 = null;
+ registered2 = null;
+ }
+
+ public void testRegisterThrowsIAE()
+ {
+ try
+ {
+ registry.register(null, registered1);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ registry.register(registered1, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ registry.register(null, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testUnregisterThrowsIAE()
+ {
+ try
+ {
+ registry.unregister(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testGetThrowsIAE()
+ {
+ try
+ {
+ registry.getRegistration(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testDualRegistration()
+ {
+ assertTrue(registry.register(key, registered1));
+ assertFalse(registry.register(key, registered2));
+ assertEquals(registered1, registry.getRegistration(key));
+ }
+
+ public void testUnregisterNonRegistered()
+ {
+ assertNull(registry.unregister(key));
+ }
+
+ public void testNormal()
+ {
+ assertEquals(Collections.EMPTY_SET, registry.getKeys());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(registry.getRegistrations()));
+ assertTrue(registry.register(key, registered1));
+ assertEquals(Collections.singleton(key), registry.getKeys());
+ assertEquals(Collections.singletonList(registered1), new ArrayList(registry.getRegistrations()));
+ assertEquals(registered1, registry.getRegistration(key));
+ assertEquals(registered1, registry.unregister(key));
+ assertEquals(null, registry.getRegistration(key));
+ assertEquals(Collections.EMPTY_SET, registry.getKeys());
+ assertEquals(Collections.EMPTY_LIST, new ArrayList(registry.getRegistrations()));
+ }
+
+ public void testCopyOnWrite()
+ {
+ Set keys = registry.getKeys();
+ List registrations = new ArrayList(registry.getRegistrations());
+ assertEquals(Collections.EMPTY_SET, keys);
+ assertEquals(Collections.EMPTY_LIST, registrations);
+ assertTrue(registry.register(key, registered1));
+ assertEquals(Collections.EMPTY_SET, keys);
+ assertEquals(Collections.EMPTY_LIST, registrations);
+ keys = registry.getKeys();
+ registrations = new ArrayList(registry.getRegistrations());
+ assertEquals(Collections.singleton(key), keys);
+ assertEquals(Collections.singletonList(registered1), registrations);
+ assertEquals(registered1, registry.unregister(key));
+ assertEquals(Collections.singleton(key), keys);
+ assertEquals(Collections.singletonList(registered1), registrations);
+ keys = registry.getKeys();
+ registrations = new ArrayList(registry.getRegistrations());
+ assertEquals(Collections.EMPTY_SET, keys);
+ assertEquals(Collections.EMPTY_LIST, registrations);
+ }
+
+ public void testKeysAreNotModifiable()
+ {
+ registry.register(key, registered1);
+ try
+ {
+ registry.getKeys().clear();
+ fail("Was expecting UnsupportedOperationException");
+ }
+ catch (UnsupportedOperationException expected)
+ {
+ }
+ }
+
+ public void testRegistrationsAreNotModifiable()
+ {
+ registry.register(key, registered1);
+ try
+ {
+ registry.getRegistrations().clear();
+ fail("Was expecting UnsupportedOperationException");
+ }
+ catch (UnsupportedOperationException expected)
+ {
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/DescriptionTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class DescriptionTestCase extends TestCase
+{
+
+ public DescriptionTestCase(String name)
+ {
+ super(name);
+ }
+
+ private Locale deflt = Locale.ENGLISH;
+ private Locale abc = new Locale("a", "b", "c");
+ private Locale ab = new Locale("a", "b");
+ private Locale a = new Locale("a");
+
+ public void testA()
+ {
+ Map map = new HashMap();
+ map.put(abc, "abc");
+ map.put(ab, "ab");
+ map.put(a, "a");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("abc", desc.getString(abc, true));
+ assertEquals("ab", desc.getString(ab, true));
+ assertEquals("a", desc.getString(a, true));
+ }
+
+ public void testB()
+ {
+ Map map = new HashMap();
+ map.put(abc, "abc");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("abc", desc.getString(abc, true));
+ assertEquals("deflt", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+
+ public void testC()
+ {
+ Map map = new HashMap();
+ map.put(ab, "ab");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("ab", desc.getString(abc, true));
+ assertEquals("ab", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+
+ public void testD()
+ {
+ Map map = new HashMap();
+ map.put(a, "a");
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("a", desc.getString(abc, true));
+ assertEquals("a", desc.getString(ab, true));
+ assertEquals("a", desc.getString(a, true));
+ }
+
+ public void testE()
+ {
+ Map map = new HashMap();
+ map.put(deflt, "deflt");
+ LocalizedString desc = new LocalizedString(map, deflt);
+ assertEquals("deflt", desc.getString(abc, true));
+ assertEquals("deflt", desc.getString(ab, true));
+ assertEquals("deflt", desc.getString(a, true));
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/HexTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Tools;
+
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class HexTestCase extends TestCase
+{
+ public HexTestCase(String s)
+ {
+ super(s);
+ System.out.println("BUILD");
+ System.out.println("BUILD");
+ System.out.println("BUILD");
+ }
+
+ public void testBasic()
+ {
+ byte[] original = new byte[]{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
+ String hex = Tools.toHexString(original);
+// assertEquals((String)"000102030405060708090a0b0c0d0e0f1011121314", (String)hex);
+ assertEquals("a", "a");
+ byte[] copy = Tools.fromHexString(hex);
+ assertTrue(Arrays.equals(original, copy));
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ImplodeTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.ant.Implode;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6289 $
+ */
+public class ImplodeTestCase extends TestCase
+{
+
+ public ImplodeTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testA() throws Exception
+ {
+ URL foo_sarURL = Thread.currentThread().getContextClassLoader().getResource("implode/foo.sar");
+ assertNotNull(foo_sarURL);
+ File foo_sarDir = new File(foo_sarURL.getFile());
+ assertTrue(foo_sarDir.exists());
+ assertTrue(foo_sarDir.isDirectory());
+
+ File tmp = File.createTempFile("foo", ".sar");
+ tmp.deleteOnExit();
+ tmp.setLastModified(foo_sarDir.lastModified() - 1);
+ assertTrue(foo_sarDir.lastModified() > tmp.lastModified());
+ Implode implode = new Implode();
+ implode.setDir(foo_sarDir);
+ implode.setTofile(tmp);
+ implode.execute();
+
+ // Test that the structure is correct
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/IteratorStatusTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.NoSuchElementException;
+
+import org.jboss.portal.common.util.IteratorStatus;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IteratorStatusTestCase extends TestCase
+{
+
+ public void testA()
+ {
+ ArrayList list = new ArrayList();
+ list.add("a");
+ list.add("b");
+ list.add("c");
+
+ //
+ test(new IteratorStatus(list));
+ test(new IteratorStatus(list.iterator()));
+ }
+
+ private void test(IteratorStatus iterator)
+ {
+ assertTrue(iterator.hasNext());
+ assertEquals(-1, iterator.getIndex());
+
+ //
+ assertEquals("a", iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals(0, iterator.getIndex());
+
+ //
+ assertEquals("b", iterator.next());
+ assertTrue(iterator.hasNext());
+ assertEquals(1, iterator.getIndex());
+
+ //
+ assertEquals("c", iterator.next());
+ assertFalse(iterator.hasNext());
+ assertEquals(2, iterator.getIndex());
+
+ //
+ try
+ {
+ iterator.next();
+ fail("Was expecting a NoSuchElementException");
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ assertFalse(iterator.hasNext());
+ assertEquals(2, iterator.getIndex());
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/JarTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,126 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Iterator;
+import java.util.Arrays;
+import java.util.jar.JarOutputStream;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import java.io.OutputStream;
+
+import org.jboss.portal.common.jar.JarEntryInfo;
+import org.jboss.portal.common.jar.JarInfo;
+import org.jboss.portal.common.io.IOTools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7425 $
+ */
+public class JarTestCase extends TestCase
+{
+
+ public JarTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testJarEntryInfo()
+ {
+ JarEntryInfo info1 = new JarEntryInfo(new JarEntry("a"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info1.getNames());
+
+ JarEntryInfo info2 = new JarEntryInfo(new JarEntry("a/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info2.getNames());
+
+ JarEntryInfo info3 = new JarEntryInfo(new JarEntry("/"));
+ assertEquals(Arrays.asList(new String[]{"/"}), info3.getNames());
+
+ JarEntryInfo info4 = new JarEntryInfo(new JarEntry("a/b"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info4.getNames());
+
+ JarEntryInfo info5 = new JarEntryInfo(new JarEntry("a/b/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info5.getNames());
+
+ JarEntryInfo info6 = new JarEntryInfo(new JarEntry("/a"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info6.getNames());
+
+ JarEntryInfo info7 = new JarEntryInfo(new JarEntry("/a/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a"}), info7.getNames());
+
+ JarEntryInfo info8 = new JarEntryInfo(new JarEntry("/a/b"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info8.getNames());
+
+ JarEntryInfo info9 = new JarEntryInfo(new JarEntry("/a/b/"));
+ assertEquals(Arrays.asList(new String[]{"/", "a","b"}), info9.getNames());
+ }
+
+ public void testEntryComparator() throws IOException
+ {
+ File jarFile = File.createTempFile("test", ".jar");
+
+ OutputStream out = IOTools.safeBufferedWrapper(new FileOutputStream(jarFile));
+ JarOutputStream jarOut = new JarOutputStream(out);
+ jarOut.putNextEntry(new JarEntry("a/c"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("c/d"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("a"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("b"));
+ jarOut.closeEntry();
+ jarOut.putNextEntry(new JarEntry("a/b"));
+ jarOut.closeEntry();
+ jarOut.close();
+
+ jarFile.deleteOnExit();
+
+ JarInputStream jarIn = new JarInputStream(IOTools.safeBufferedWrapper(new FileInputStream(jarFile)));
+ Iterator i = new JarInfo(jarIn).entries();
+ while (i.hasNext())
+ {
+ Object o = i.next();
+ System.out.println("o = " + o);
+ }
+ jarIn.close();
+ }
+
+ public void testIsChildOf()
+ {
+ assertFalse(new JarEntryInfo(new JarEntry("a")).isChildOf(new JarEntryInfo(new JarEntry(""))));
+ assertFalse(new JarEntryInfo(new JarEntry("/a")).isChildOf(new JarEntryInfo(new JarEntry(""))));
+ assertTrue(new JarEntryInfo(new JarEntry("a")).isChildOf(new JarEntryInfo(new JarEntry("/"))));
+ assertTrue(new JarEntryInfo(new JarEntry("/a")).isChildOf(new JarEntryInfo(new JarEntry("/"))));
+ assertFalse(new JarEntryInfo(new JarEntry("a/b")).isChildOf(new JarEntryInfo(new JarEntry("a"))));
+ assertFalse(new JarEntryInfo(new JarEntry("/a/b")).isChildOf(new JarEntryInfo(new JarEntry("a"))));
+ assertTrue(new JarEntryInfo(new JarEntry("a/b")).isChildOf(new JarEntryInfo(new JarEntry("a/"))));
+ assertTrue(new JarEntryInfo(new JarEntry("/a/b")).isChildOf(new JarEntryInfo(new JarEntry("a/"))));
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/JavaBeanModelMBeanBuilderTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,496 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.mx.JavaBeanModelMBeanBuilder;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.management.Attribute;
+import javax.management.Descriptor;
+import javax.management.modelmbean.ModelMBeanInfo;
+import javax.management.modelmbean.RequiredModelMBean;
+import javax.management.modelmbean.ModelMBeanOperationInfo;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7452 $
+ */
+public class JavaBeanModelMBeanBuilderTestCase extends TestCase
+{
+
+ public void testEmpty() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(Empty.class, Object.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ MBeanAttributeInfo[] attrs = info.getAttributes();
+ assertNotNull(attrs);
+ assertEquals(0, attrs.length);
+
+ //
+ MBeanOperationInfo[] ops = info.getOperations();
+ assertNotNull(ops);
+ assertEquals(0, ops.length);
+ }
+
+ public void testSimpleClass() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(TestClass.class, Object.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ assertNotNull(info.getAttributes());
+ Set attrs = getAttributes(info);
+
+ //
+ Set expectedAttrs = new HashSet();
+ expectedAttrs.add(new TestAttribute("java.lang.String", "String"));
+ expectedAttrs.add(new TestAttribute("boolean", "Boolean"));
+ assertEquals(expectedAttrs, attrs);
+
+ //
+ assertNotNull(info.getOperations());
+ Set ops = getOperations(info);
+
+ //
+ Set expectedOps = new HashSet();
+ expectedOps.add(TestOperation.newOperation("void", "operation", new String[]{}));
+ expectedOps.add(TestOperation.newOperation("void", "operation", new String[]{"java.lang.String"}));
+ expectedOps.add(TestOperation.newSetter("setString", "java.lang.String"));
+ expectedOps.add(TestOperation.newGetter("getString", "java.lang.String"));
+ expectedOps.add(TestOperation.newSetter("setBoolean", "boolean"));
+ expectedOps.add(TestOperation.newGetter("isBoolean", "boolean"));
+ assertEquals(expectedOps, ops);
+ }
+
+ public void testOperationOverride() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(Child.class, Parent.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ assertNotNull(info.getOperations());
+ Set ops = getOperations(info);
+
+ //
+ Set expectedOps = new HashSet();
+ expectedOps.add(TestOperation.newOperation("void", "overridenOperation", new String[]{}));
+ assertEquals(expectedOps, ops);
+ }
+
+ public void testSetterOverload() throws Exception
+ {
+ try
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(OverloadedSetter.class, Object.class);
+ fail();
+ }
+ catch (Exception expected)
+ {
+ // expected
+ }
+ }
+
+ public void testOverridenGetter() throws Exception
+ {
+ JavaBeanModelMBeanBuilder builder = new JavaBeanModelMBeanBuilder(TestOverridenExtend.class, Object.class);
+ ModelMBeanInfo info = builder.getInfo();
+
+ //
+ Set ops = getOperations(info);
+ Set expectedOps = new HashSet();
+ expectedOps.add(TestOperation.newGetter("getTest", "java.util.Set"));
+ assertEquals(expectedOps, ops);
+
+ }
+
+ public void testAttributesAreNotCached() throws Exception
+ {
+ AttributesAreNotCached aanc = new AttributesAreNotCached();
+ ModelMBeanInfo info = JavaBeanModelMBeanBuilder.build(aanc);
+
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ ObjectName name = new ObjectName(":a=b");
+ RequiredModelMBean mbean = new RequiredModelMBean(info);
+ mbean.setManagedResource(aanc, "ObjectReference");
+ server.registerMBean(mbean, name);
+ assertEquals(new Integer(0), server.getAttribute(name, "Count"));
+ assertEquals(new Integer(1), server.getAttribute(name, "Count"));
+
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ public void testStaticAttribute() throws Exception
+ {
+ StaticAttribute sa = new StaticAttribute();
+ ModelMBeanInfo info = JavaBeanModelMBeanBuilder.build(sa);
+
+ MBeanServer server = MBeanServerFactory.createMBeanServer();
+
+ ObjectName name = new ObjectName(":a=b");
+ RequiredModelMBean mbean = new RequiredModelMBean(info);
+ mbean.setManagedResource(sa, "ObjectReference");
+ server.registerMBean(mbean, name);
+ try
+ {
+ server.getAttribute(name, "Read");
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ try
+ {
+ server.getAttribute(name, "ReadWrite");
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ try
+ {
+ server.setAttribute(name, new Attribute("ReadWrite", new Integer(0)));
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ try
+ {
+ server.setAttribute(name, new Attribute("Write", new Integer(0)));
+ fail();
+ }
+ catch (AttributeNotFoundException expected)
+ {
+ }
+ MBeanServerFactory.releaseMBeanServer(server);
+ }
+
+ public Set getAttributes(ModelMBeanInfo info)
+ {
+ Set set = new HashSet();
+ MBeanAttributeInfo[] attrs = info.getAttributes();
+ for (int i = 0; i < attrs.length; i++)
+ {
+ MBeanAttributeInfo attr = attrs[i];
+ set.add(new TestAttribute(attr));
+ }
+ return set;
+ }
+
+ public Set getOperations(ModelMBeanInfo info)
+ {
+ MBeanOperationInfo[] ops = info.getOperations();
+ Set set = new HashSet();
+ for (int i = 0; i < ops.length; i++)
+ {
+ MBeanOperationInfo op = ops[i];
+ set.add(new TestOperation((ModelMBeanOperationInfo)op));
+ }
+ return set;
+ }
+
+ public static class StaticAttribute
+ {
+ public static int getRead()
+ {
+ return 0;
+ }
+
+ public static void setWrite(int a)
+ {
+ }
+
+ public static int getReadWrite()
+ {
+ return 0;
+ }
+
+ public static void setReadWrite(int a)
+ {
+ }
+ }
+
+ public static class OverloadedSetter
+ {
+ public void setA(int a)
+ {
+ }
+
+ public void setA(String a)
+ {
+ }
+
+ public boolean getA()
+ {
+ return false;
+ }
+
+ public boolean isA()
+ {
+ return false;
+ }
+ }
+
+ public static class Parent
+ {
+ public void operation()
+ {
+ }
+
+ public void overridenOperation()
+ {
+ }
+ }
+
+ public static class Child extends Parent
+ {
+ public void overridenOperation()
+ {
+ }
+ }
+
+ public static class Empty
+ {
+ }
+
+ public static class TestClass
+ {
+
+ public void operation()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void operation(String s)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getString()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setString(String s)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isBoolean()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBoolean(boolean b)
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public class AttributesAreNotCached
+ {
+ private int count;
+
+ public int getCount()
+ {
+ return count++;
+ }
+ }
+
+ public class TestOverridenBase
+ {
+ public Set getTest()
+ {
+ //nothing
+ return new HashSet();
+ }
+ }
+
+ public class TestOverridenExtend extends TestOverridenBase
+ {
+ public Set getTest()
+ {
+ //nothing
+ return new HashSet();
+ }
+ }
+
+ public static class TestAttribute
+ {
+
+ /** . */
+ public final String type;
+
+ /** . */
+ public final String name;
+
+ public TestAttribute(MBeanAttributeInfo info)
+ {
+ this.type = info.getType();
+ this.name = info.getName();
+ }
+
+ public TestAttribute(String type, String name)
+ {
+ if (type == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.type = type;
+ this.name = name;
+ }
+
+ public int hashCode()
+ {
+ return type.hashCode() * 43 + name.hashCode();
+ }
+
+ public boolean equals(Object obj)
+ {
+ TestAttribute that = (TestAttribute)obj;
+ return type.equals(that.type) && name.equals(that.name);
+ }
+
+ public String toString()
+ {
+ return "Attribute[" + type + "," + name + "]";
+ }
+ }
+
+ public static class TestOperation
+ {
+
+ /** . */
+ public final String returnType;
+
+ /** . */
+ public final String name;
+
+ /** . */
+ public final String[] argTypes;
+
+ /** . */
+ public final String role;
+
+ public TestOperation(ModelMBeanOperationInfo info)
+ {
+ Descriptor desc = info.getDescriptor();
+
+ this.returnType = info.getReturnType();
+ this.name = info.getName();
+ this.argTypes = new String[info.getSignature().length];
+ this.role = (String)desc.getFieldValue("role");
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ argTypes[i] = info.getSignature()[i].getType();
+ }
+ }
+
+ public static TestOperation newOperation(String returnType, String name, String[] argTypes)
+ {
+ return new TestOperation(returnType, name, argTypes, "operation");
+ }
+
+ public static TestOperation newGetter(String name, String type)
+ {
+ return new TestOperation(type, name, new String[0], "getter");
+ }
+
+ public static TestOperation newSetter(String name, String type)
+ {
+ return new TestOperation("void", name, new String[]{type}, "setter");
+ }
+
+ public TestOperation(String returnType, String name, String[] argTypes, String role)
+ {
+ if (returnType == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (name == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (argTypes == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ if (argTypes[i] == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ }
+ this.returnType = returnType;
+ this.name = name;
+ this.argTypes = argTypes;
+ this.role = role;
+ }
+
+ public int hashCode()
+ {
+ int code = (returnType.hashCode() * 43 + name.hashCode()) * 43 + role.hashCode();
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ String argType = argTypes[i];
+ code = code * 43 + argType.hashCode();
+ }
+ return code;
+ }
+
+ public boolean equals(Object obj)
+ {
+ TestOperation that = (TestOperation)obj;
+ return returnType.equals(that.returnType) && name.equals(that.name) && role.equals(that.role) && Arrays.equals(argTypes, that.argTypes);
+ }
+
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer("Operation[").append(returnType).append(",").append(name).append(",").append(role);
+ for (int i = 0; i < argTypes.length; i++)
+ {
+ tmp.append(",").append(argTypes[i]);
+ }
+ tmp.append(")");
+ return tmp.toString();
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/LocaleFormatTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,217 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.Writer;
+import java.io.IOException;
+
+import org.jboss.portal.common.i18n.LocaleFormat;
+import org.jboss.portal.common.i18n.CachingLocaleFormat;
+import org.jboss.portal.common.i18n.AbstractLocaleFormat;
+import org.jboss.portal.common.util.FormatConversionException;
+import org.jboss.portal.common.util.ConversionException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class LocaleFormatTestCase extends TestCase
+{
+
+ public void testgetLocaleFromDefaultFormat() throws ConversionException
+ {
+ assertEquals(new Locale("a"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a"));
+ assertEquals(new Locale("a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b"));
+ assertEquals(new Locale("", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_b"));
+ assertEquals(new Locale("a", "b", "c"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a_b_c"));
+ assertEquals(new Locale("a", "", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("a__b"));
+ assertEquals(new Locale("", "a", "b"), LocaleFormat.DEFAULT_NO_CACHE.getLocale("_a_b"));
+ assertEquals(new Locale(""), LocaleFormat.DEFAULT_NO_CACHE.getLocale(""));
+
+ //
+ try
+ {
+ assertEquals(new Locale("", "", "a"), LocaleFormat.DEFAULT.getLocale("__a"));
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ try
+ {
+ assertEquals(new Locale("", "", ""), LocaleFormat.DEFAULT_NO_CACHE.getLocale("__"));
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ try
+ {
+ LocaleFormat.DEFAULT.getLocale("_");
+ fail();
+ }
+ catch (ConversionException expected)
+ {
+ }
+ }
+
+ public void testToStringFromDefaultFormat() throws ConversionException
+ {
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("")));
+
+ //
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "")));
+ assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b")));
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "")));
+ assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a")));
+
+ //
+ assertEquals("a_B_c", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "c")));
+ assertEquals("_A_b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "b")));
+ assertEquals("a__b", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "b")));
+ assertEquals("a_B", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "b", "")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "a")));
+ assertEquals("a", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("a", "", "")));
+ assertEquals("_A", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "a", "")));
+ assertEquals("", LocaleFormat.DEFAULT_NO_CACHE.toString(new Locale("", "", "")));
+ }
+
+ public void testGetLocaleFromRFC3066LanguageTag() throws ConversionException
+ {
+ assertEquals(new Locale("en"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en"));
+ assertEquals(new Locale("en", "US"), LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("en-US"));
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("wrong");
+ fail("Should have failed since an invalid String was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("zz");
+ fail("Should have failed since an invalid language code was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ try
+ {
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-ZZ");
+ fail("Should have failed since an invalid country code was passed.");
+ }
+ catch (FormatConversionException e)
+ {
+ //expected
+ }
+
+ // weird combination should work as well
+ LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.getLocale("fr-US");
+ }
+
+ public void testGetRFC3066LanguageTagFromLocale() throws ConversionException
+ {
+ assertEquals("en", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en")));
+ assertEquals("en-US", LocaleFormat.RFC3066_LANGUAGE_TAG_NO_CACHE.toString(new Locale("en", "US")));
+ }
+
+ public void testCachingLocaleFormat() throws ConversionException
+ {
+ TestLocaleFormat delegate = new TestLocaleFormat();
+ delegate.put(new Locale("abc"), "abc");
+ CachingLocaleFormat format = new CachingLocaleFormat(delegate);
+
+ //
+ assertEquals(new Locale("abc"), format.getLocale("abc"));
+ assertEquals("abc", format.toString(new Locale("abc")));
+
+ //
+ try
+ {
+ format.getLocale("def");
+ fail();
+ }
+ catch (ConversionException e)
+ {
+ }
+
+ //
+ try
+ {
+ format.toString(new Locale("def"));
+ fail();
+ }
+ catch (ConversionException e)
+ {
+ }
+ }
+
+ private static class TestLocaleFormat extends AbstractLocaleFormat
+ {
+
+ /** . */
+ private final Map localeToString = new HashMap();
+
+ /** . */
+ private final Map stringToLocale = new HashMap();
+
+ private void put(Locale locale, String string)
+ {
+ localeToString.put(locale, string);
+ stringToLocale.put(string, locale);
+ }
+
+ protected Locale internalGetLocale(String value) throws ConversionException
+ {
+ Locale locale = (Locale)stringToLocale.get(value);
+ if (locale == null)
+ {
+ throw new ConversionException();
+ }
+ return locale;
+ }
+
+ protected void internalWrite(Locale locale, Writer writer) throws IOException, ConversionException
+ {
+ String string = (String)localeToString.get(locale);
+ if (string == null)
+ {
+ throw new ConversionException();
+ }
+ writer.write(string);
+ }
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/LocalizedStringTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,77 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.i18n.LocalizedString;
+
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 6818 $
+ */
+public class LocalizedStringTestCase extends TestCase
+{
+ private Map values = new HashMap();
+ private LocalizedString localizedString;
+
+ protected void setUp() throws Exception
+ {
+ values.put(Locale.ENGLISH, "labour");
+ values.put(Locale.FRENCH, "travail");
+ values.put(Locale.US, "labor");
+ localizedString = new LocalizedString(values, Locale.US);
+ }
+
+ public void testPreferredOrBestLocalizedMappingFor()
+ {
+ try
+ {
+ localizedString.getPreferredOrBestLocalizedMappingFor(null);
+ fail("LocalizedString get most appropriate value for should have thrown an IllegalArgumentException with a null argument");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ // no desired locales: should return default
+ checkValueAndLocale(Locale.US, new String[]{});
+
+ checkValueAndLocale(Locale.ENGLISH, new String[]{"en", "en-US", "aa"});
+ checkValueAndLocale(Locale.US, new String[]{"en-US", "en", "aa"});
+ checkValueAndLocale(Locale.FRENCH, new String[]{"fr-CA"});
+ }
+
+ private void checkValueAndLocale(Locale locale, String[] desiredLocales)
+ {
+ LocalizedString.Value mapping = localizedString.getPreferredOrBestLocalizedMappingFor(desiredLocales);
+
+ Locale foundLocale = mapping.getLocale();
+ assertEquals(locale, foundLocale);
+ assertEquals(values.get(foundLocale), mapping.getString());
+ assertEquals(mapping.getString(), localizedString.getMostAppropriateValueFor(desiredLocales));
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/MarkupTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.markup.MarkupAttribute;
+import org.jboss.portal.common.markup.MarkupElement;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MarkupTestCase extends TestCase
+{
+
+ public void testAttributeConstructor()
+ {
+ try
+ {
+ new MarkupAttribute(null, "value", MarkupAttribute.Type.CDATA);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupAttribute("name", null, MarkupAttribute.Type.CDATA);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupAttribute("name", "value", null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ MarkupAttribute attribute = new MarkupAttribute("name", "value", MarkupAttribute.Type.CDATA);
+ assertEquals("name", attribute.getName());
+ assertEquals("value", attribute.getValue());
+ assertEquals(MarkupAttribute.Type.CDATA, attribute.getType());
+ }
+
+ public void testElementContructor()
+ {
+ try
+ {
+ new MarkupElement(null, "body", false, new MarkupAttribute[0]);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupElement("name", "body", false, null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ new MarkupElement("name", "body", false, new MarkupAttribute[]{null});
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ MarkupElement element = new MarkupElement("elementname", "body", false, new MarkupAttribute[]{new MarkupAttribute("attributename", "attributevalue", MarkupAttribute.Type.CDATA)});
+ assertEquals("elementname", element.getName());
+ assertEquals("body", element.getBodyContent());
+ assertEquals(false, element.isNeverEmpty());
+ assertEquals(1, element.getAttributeSize());
+ MarkupAttribute attribute = element.getAttribute(0);
+ assertEquals("attributename", attribute.getName());
+ assertEquals("attributevalue", attribute.getValue());
+ assertEquals(MarkupAttribute.Type.CDATA, attribute.getType());
+ attribute = element.getAttribute("attributename");
+ assertEquals("attributename", attribute.getName());
+ assertEquals("attributevalue", attribute.getValue());
+ assertEquals(MarkupAttribute.Type.CDATA, attribute.getType());
+ assertEquals(null, element.getAttribute("someotherattributename"));
+ }
+
+ public void testAttributeURIEncoding()
+ {
+ MarkupAttribute attribute = new MarkupAttribute("name", "/-_.*ABCabc012# ", MarkupAttribute.Type.URI);
+ assertEquals("/-_.*ABCabc012%23+", attribute.getEncodedValue());
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/P3PConstantsTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/P3PConstantsTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/P3PConstantsTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,121 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import static org.jboss.portal.common.p3p.P3PConstants.*;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 9048 $
+ */
+public class P3PConstantsTestCase extends TestCase
+{
+ public void testGetPostalUserInfoKey()
+ {
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_CITY, getPostalUserInfoKey(PostalInfo.CITY, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_COUNTRY, getPostalUserInfoKey(PostalInfo.COUNTRY, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_NAME, getPostalUserInfoKey(PostalInfo.NAME, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_ORGANIZATION, getPostalUserInfoKey(PostalInfo.ORGANIZATION, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_POSTALCODE, getPostalUserInfoKey(PostalInfo.POSTALCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_STATEPROV, getPostalUserInfoKey(PostalInfo.STATEPROV, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_POSTAL_STREET, getPostalUserInfoKey(PostalInfo.STREET, true));
+
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_CITY, getPostalUserInfoKey(PostalInfo.CITY, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_COUNTRY, getPostalUserInfoKey(PostalInfo.COUNTRY, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_NAME, getPostalUserInfoKey(PostalInfo.NAME, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_ORGANIZATION, getPostalUserInfoKey(PostalInfo.ORGANIZATION, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_POSTALCODE, getPostalUserInfoKey(PostalInfo.POSTALCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_STATEPROV, getPostalUserInfoKey(PostalInfo.STATEPROV, false));
+ assertEquals(INFO_USER_HOME_INFO_POSTAL_STREET, getPostalUserInfoKey(PostalInfo.STREET, false));
+ }
+
+ public void testGetOnlineInfoKey()
+ {
+ assertEquals(INFO_USER_BUSINESS_INFO_ONLINE_EMAIL, getOnlineUserInfoKey(OnlineInfo.EMAIL, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_ONLINE_URI, getOnlineUserInfoKey(OnlineInfo.URI, true));
+
+ assertEquals(INFO_USER_HOME_INFO_ONLINE_EMAIL, getOnlineUserInfoKey(OnlineInfo.EMAIL, false));
+ assertEquals(INFO_USER_HOME_INFO_ONLINE_URI, getOnlineUserInfoKey(OnlineInfo.URI, false));
+ }
+
+
+ public void testGetTelecomInfoKey()
+ {
+ // business fax
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_COMMENT, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.COMMENT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_EXT, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.EXT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_INTCODE, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.INTCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_LOCCODE, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.LOCCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_FAX_NUMBER, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.NUMBER, true));
+
+ // home fax
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_COMMENT, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.COMMENT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_EXT, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.EXT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_INTCODE, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.INTCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_LOCCODE, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.LOCCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_FAX_NUMBER, getTelecomInfoKey(TelecomType.FAX, TelecomInfo.NUMBER, false));
+
+ // business mobile
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_COMMENT, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.COMMENT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_EXT, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.EXT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_INTCODE, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.INTCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_LOCCODE, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.LOCCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_MOBILE_NUMBER, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.NUMBER, true));
+
+ // home mobile
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_COMMENT, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.COMMENT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_EXT, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.EXT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_INTCODE, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.INTCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_LOCCODE, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.LOCCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_MOBILE_NUMBER, getTelecomInfoKey(TelecomType.MOBILE, TelecomInfo.NUMBER, false));
+
+ // business pager
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_COMMENT, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.COMMENT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_EXT, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.EXT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_INTCODE, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.INTCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_LOCCODE, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.LOCCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_PAGER_NUMBER, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.NUMBER, true));
+
+ // home pager
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_COMMENT, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.COMMENT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_EXT, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.EXT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_INTCODE, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.INTCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_LOCCODE, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.LOCCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_PAGER_NUMBER, getTelecomInfoKey(TelecomType.PAGER, TelecomInfo.NUMBER, false));
+
+ // business telephone
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_COMMENT, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.COMMENT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_EXT, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.EXT, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_INTCODE, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.INTCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_LOCCODE, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.LOCCODE, true));
+ assertEquals(INFO_USER_BUSINESS_INFO_TELECOM_TELEPHONE_NUMBER, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.NUMBER, true));
+
+ // home telephone
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_COMMENT, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.COMMENT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_EXT, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.EXT, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_INTCODE, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.INTCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_LOCCODE, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.LOCCODE, false));
+ assertEquals(INFO_USER_HOME_INFO_TELECOM_TELEPHONE_NUMBER, getTelecomInfoKey(TelecomType.TELEPHONE, TelecomInfo.NUMBER, false));
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ParameterMapTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,143 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.ParameterMap;
+
+import java.util.HashMap;
+import java.util.Set;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6643 $
+ */
+public class ParameterMapTestCase extends TestCase
+{
+
+ public void testPut()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ pm.put("foo", new String[]{"bar"});
+ // ExtendedAssert.assertEquals(new String[]{"bar"}, (Object[])pm.get("foo"));
+ }
+
+ public void testEntry()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ pm.put("foo", new String[]{"bar"});
+ Set entries = pm.entrySet();
+ assertNotNull(entries);
+ Iterator iterator = entries.iterator();
+ assertTrue(iterator.hasNext());
+ Object tmp = iterator.next();
+ assertTrue(tmp instanceof Map.Entry);
+ Map.Entry entry = (Map.Entry)tmp;
+ assertEquals("foo", entry.getKey());
+ // ExtendedAssert.assertEquals(new String[]{"bar"}, (Object[])entry.getValue());
+ }
+
+ public void testPutThrowsException()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ try
+ {
+ ((Map)pm).put(new Object(), new String[]{"bar"});
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ try
+ {
+ ((Map)pm).put("foo", new Object[]{});
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ try
+ {
+ pm.put("foo", new String[]{});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ pm.put("foo", new String[]{null});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEntrySetValueThrowsException()
+ {
+ ParameterMap pm = new ParameterMap(new HashMap());
+ pm.put("foo", new String[]{"bar"});
+ Set entries = pm.entrySet();
+ assertNotNull(entries);
+ Iterator iterator = entries.iterator();
+ assertTrue(iterator.hasNext());
+ Object tmp = iterator.next();
+ assertTrue(tmp instanceof Map.Entry);
+ Map.Entry entry = (Map.Entry)tmp;
+ try
+ {
+ entry.setValue(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ entry.setValue(new Object[]{});
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ try
+ {
+ entry.setValue(new String[]{});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ entry.setValue(new String[]{null});
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ParentChildResourceBundleTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,115 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.Set;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.i18n.ParentChildResourceBundle;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6818 $
+ */
+public class ParentChildResourceBundleTestCase extends TestCase
+{
+ public ParentChildResourceBundleTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testBasic()
+ {
+ ResourceBundle parent = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ if ("key-a".equals(key))
+ {
+ return "parent-a";
+ }
+ if ("key-b".equals(key))
+ {
+ return "parent-b";
+ }
+ return null;
+ }
+ public Enumeration getKeys()
+ {
+ Vector keys = new Vector();
+ keys.add("key-a");
+ keys.add("key-b");
+ return keys.elements();
+ }
+ public Locale getLocale()
+ {
+ return Locale.CHINA;
+ }
+ };
+ ResourceBundle child = new ResourceBundle()
+ {
+ protected Object handleGetObject(String key)
+ {
+ if ("key-a".equals(key))
+ {
+ return "child-a";
+ }
+ if ("key-c".equals(key))
+ {
+ return "child-c";
+ }
+ return null;
+ }
+ public Enumeration getKeys()
+ {
+ Vector keys = new Vector();
+ keys.add("key-a");
+ keys.add("key-c");
+ return keys.elements();
+ }
+ public Locale getLocale()
+ {
+ return Locale.GERMAN;
+ }
+ };
+ ResourceBundle bundle = new ParentChildResourceBundle(parent, child);
+ assertEquals(Locale.GERMAN, bundle.getLocale());
+ assertEquals("child-a", bundle.getString("key-a"));
+ assertEquals("parent-b", bundle.getString("key-b"));
+ assertEquals("child-c", bundle.getString("key-c"));
+ Set keys = new HashSet(Arrays.asList(new Object[]{"key-a","key-b","key-c"}));
+ for (Enumeration e = bundle.getKeys();e.hasMoreElements();)
+ {
+ assertTrue(keys.remove(e.nextElement()));
+ }
+ assertTrue(keys.isEmpty());
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/PathMapperTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,156 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.path.PathMapper;
+import org.jboss.portal.common.path.PathMapperContext;
+import org.jboss.portal.common.path.PathMapperResult;
+import org.jboss.portal.common.path.SimplePathMapper;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class PathMapperTestCase extends TestCase
+{
+
+ public PathMapperTestCase(String s)
+ {
+ super(s);
+ }
+
+ private PathMapper mapper;
+
+ protected void setUp() throws Exception
+ {
+ mapper = new SimplePathMapper();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ mapper = null;
+ }
+
+ public void testEmptyContext()
+ {
+ PathMapperContextImpl root = new PathMapperContextImpl(null);
+
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, null));
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, ""));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "/"));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "//"));
+
+ assertEquals(new PathMapperResult(null, null, "/a"), mapper.map(root, "/a"));
+ assertEquals(new PathMapperResult(null, null, "/a/"), mapper.map(root, "/a/"));
+ assertEquals(new PathMapperResult(null, null, "/a/b"), mapper.map(root, "/a/b"));
+ assertEquals(new PathMapperResult(null, null, "/a/b/"), mapper.map(root, "/a/b/"));
+ assertEquals(new PathMapperResult(null, null, "/a/b/c"), mapper.map(root, "/a/b/c"));
+ }
+
+ public void testOneChild()
+ {
+ PathMapperContextImpl root = new PathMapperContextImpl(null);
+ PathMapperContextImpl child = new PathMapperContextImpl(null);
+ root.addChild("a", child);
+
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, null));
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, ""));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "/"));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "//"));
+
+ assertEquals(new PathMapperResult(child, "/a", null), mapper.map(root, "/a"));
+ assertEquals(new PathMapperResult(child, "/a", "/"), mapper.map(root, "/a/"));
+ assertEquals(new PathMapperResult(child, "/a", "/b"), mapper.map(root, "/a/b"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/"), mapper.map(root, "/a/b/"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/c"), mapper.map(root, "/a/b/c"));
+
+ assertEquals(new PathMapperResult(null, null, "/b"), mapper.map(root, "/b"));
+ assertEquals(new PathMapperResult(null, null, "/b/"), mapper.map(root, "/b/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c"), mapper.map(root, "/b/c"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/"), mapper.map(root, "/b/c/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/d"), mapper.map(root, "/b/c/d"));
+ }
+
+ public void testOneChildHavingOneChild()
+ {
+ PathMapperContextImpl root = new PathMapperContextImpl(null);
+ PathMapperContextImpl child = new PathMapperContextImpl(null);
+ PathMapperContextImpl childOfChild = new PathMapperContextImpl(null);
+ root.addChild("a", child);
+ child.addChild("b", childOfChild);
+
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, null));
+ assertEquals(new PathMapperResult(null, null, null), mapper.map(root, ""));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "/"));
+ assertEquals(new PathMapperResult(null, null, "/"), mapper.map(root, "//"));
+
+ assertEquals(new PathMapperResult(child, "/a", null), mapper.map(root, "/a"));
+ assertEquals(new PathMapperResult(child, "/a", "/"), mapper.map(root, "/a/"));
+ assertEquals(new PathMapperResult(childOfChild, "/a/b", null), mapper.map(root, "/a/b"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/"), mapper.map(root, "/a/b/"));
+ assertEquals(new PathMapperResult(child, "/a", "/b/c"), mapper.map(root, "/a/b/c"));
+
+ assertEquals(new PathMapperResult(null, null, "/b"), mapper.map(root, "/b"));
+ assertEquals(new PathMapperResult(null, null, "/b/"), mapper.map(root, "/b/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c"), mapper.map(root, "/b/c"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/"), mapper.map(root, "/b/c/"));
+ assertEquals(new PathMapperResult(null, null, "/b/c/d"), mapper.map(root, "/b/c/d"));
+ }
+
+ private static class Context
+ {
+ private final Map children;
+
+ public Context(Object dflt)
+ {
+ children = new HashMap();
+ }
+
+ public void addChild(String name, Object child)
+ {
+ children.put(name, child);
+ }
+ }
+
+ private static class PathMapperContextImpl extends Context implements PathMapperContext
+ {
+ public PathMapperContextImpl(Object dflt)
+ {
+ super(dflt);
+ }
+
+ public Object getRoot()
+ {
+ return this;
+ }
+
+ public Object getChild(Object parent, String name)
+ {
+ return ((Context)parent).children.get(name);
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/PathTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.path.RelativePathParser;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class PathTestCase extends TestCase
+{
+
+ public void testSimpleDown()
+ {
+ String[] paths = {"abc","abc/","abc/."};
+ for (int i = 0; i < paths.length; i++)
+ {
+ String path = paths[i];
+ RelativePathParser cursor = new RelativePathParser(path);
+ assertEquals(RelativePathParser.DOWN, cursor.next());
+ assertEquals(0, cursor.getOffset());
+ assertEquals(3, cursor.getLength());
+ assertEquals("abc", path.substring(cursor.getOffset(), cursor.getLength()));
+ assertEquals(RelativePathParser.NONE, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ }
+ }
+
+ public void testSimpleNone()
+ {
+ String[] paths = {"",".","./","./."};
+ for (int i = 0; i < paths.length; i++)
+ {
+ String path = paths[i];
+ RelativePathParser cursor = new RelativePathParser(path);
+ assertEquals(RelativePathParser.NONE, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ }
+ }
+
+ public void testSimpleUp()
+ {
+ String[] paths = {"..","../","../."};
+ for (int i = 0; i < paths.length; i++)
+ {
+ String path = paths[i];
+ RelativePathParser cursor = new RelativePathParser(path);
+ assertEquals(RelativePathParser.UP, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ assertEquals(RelativePathParser.NONE, cursor.next());
+ assertEquals(-1, cursor.getOffset());
+ assertEquals(-1, cursor.getLength());
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/StringTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6305 $
+ */
+public class StringTestCase extends TestCase
+{
+
+ public StringTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testReplace()
+ {
+ assertEquals("", Tools.replace("", "abc", "def"));
+ assertEquals("defg", Tools.replace("abc", "abc", "defg"));
+ assertEquals("_defg_", Tools.replace("_abc_", "abc", "defg"));
+ assertEquals("_defgdefg_", Tools.replace("_abcabc_", "abc", "defg"));
+ assertEquals("_defg_defg_", Tools.replace("_abc_abc_", "abc", "defg"));
+ }
+
+ public void testReplaceBoundedString()
+ {
+ assertEquals("", Tools.replaceAllInstancesOfBoundedString("", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("REPLACEMENT", Tools.replaceAllInstancesOfBoundedString("PREFIXSUFFIX", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("PREFIXSUFFIX", Tools.replaceBoundedString("PREFIXSUFFIX", "PREFIX", "SUFFIX", "REPLACEMENT", false, true));
+ assertEquals("PREFIXSUFFIX", Tools.replaceBoundedString("PREFIXSUFFIX", "PREFIX", "SUFFIX", "REPLACEMENT", false, false));
+ assertEquals("aaaaREPLACEMENTccccc", Tools.replaceAllInstancesOfBoundedString("aaaaPREFIXbbbbbSUFFIXccccc", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("aaaPREFIXbbbbSUFF", Tools.replaceAllInstancesOfBoundedString("aaaPREFIXbbbbSUFF", "PREFIX", "SUFFIX", "REPLACEMENT"));
+ assertEquals("aRcccReeeR", Tools.replaceAllInstancesOfBoundedString("aPbbScccPdSeeePS", "P", "S", "R"));
+ assertEquals("PSaPScccReeePS", Tools.replaceBoundedString("PSaPScccPdSeeePS", "P", "S", "R", false, false));
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/TemporaryHashTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import java.util.Calendar;
+
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class TemporaryHashTestCase extends TestCase
+{
+
+ public TemporaryHashTestCase(String key)
+ {
+ super(key);
+ }
+
+ public void testBasic()
+ {
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(2004, 1, 1, 1, 30, 0);
+ String hash = Tools.generateTemporaryHash("blah", calendar.getTimeInMillis());
+
+ calendar.set(2004, 1, 1, 1, 0, 0);
+ assertTrue(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 0, 59, 59);
+ assertFalse(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 2, 0, 0);
+ assertTrue(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 2, 59, 59);
+ assertTrue(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+
+ calendar.set(2004, 1, 1, 3, 0, 0);
+ assertFalse(Tools.confirmTemporaryHash(hash, "blah", calendar.getTimeInMillis()));
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ToolsTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,421 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.util.Tools;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.Vector;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 6384 $
+ * @since 2.6
+ */
+public class ToolsTestCase extends TestCase
+{
+ public void testIsContainedIn()
+ {
+ String value = "value";
+ String[] array = new String[]{"foo", "bar", value, "baz"};
+
+ assertTrue(Tools.isContainedIn(value, array));
+ assertFalse(Tools.isContainedIn(null, array));
+ assertFalse(Tools.isContainedIn(value, null));
+ assertFalse(Tools.isContainedIn(null, null));
+ assertFalse(Tools.isContainedIn("bat", array));
+ }
+
+ public void testIteratorToEnumerationThrowsIAE()
+ {
+ try
+ {
+ Tools.toEnumeration((Iterator)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIteratorToEnumeration1()
+ {
+ assertEnumeration(Tools.toEnumeration(new ArrayList<String>().iterator()));
+ }
+
+ public void testIteratorToEnumeration2()
+ {
+ List<String> tmp = new ArrayList<String>();
+ tmp.add("a");
+ assertEnumeration(Tools.toEnumeration(tmp.iterator()), "a");
+ }
+
+ public void testIteratorToEnumeration3()
+ {
+ List<String> tmp = new ArrayList<String>();
+ tmp.add("a");
+ tmp.add("b");
+ assertEnumeration(Tools.toEnumeration(tmp.iterator()), "a", "b");
+ }
+
+ public void testArrayToEnumerationThrowsIAE()
+ {
+ try
+ {
+ Tools.toEnumeration((Object[])null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayToEnumeration1()
+ {
+ assertEnumeration(Tools.toEnumeration(new String[]{}));
+ }
+
+ public void testArrayToEnumeration2()
+ {
+ assertEnumeration(Tools.toEnumeration(new String[]{"a"}), "a");
+ }
+
+ public void testArrayToEnumeration3()
+ {
+ assertEnumeration(Tools.toEnumeration(new String[]{"a","b"}), "a", "b");
+ }
+
+ public void testElementToEnumeration()
+ {
+ assertEnumeration(Tools.toEnumeration("a"), "a");
+ }
+
+ public void testEnumerationToSetThrowsIAE()
+ {
+ try
+ {
+ Tools.toSet((Enumeration)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testEnumerationToSet()
+ {
+ Vector<String> v = new Vector<String>();
+ v.add("a");
+ v.add("b");
+ v.add("a");
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, Tools.toSet(v.elements()));
+ }
+
+ public void testArrayToSetThrowsIAE()
+ {
+ try
+ {
+ Tools.toSet((Object[])null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayToSet()
+ {
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, Tools.toSet(new String[]{"a","b","a"}));
+ }
+
+ public void testIteratorToSetThrowsIAE()
+ {
+ try
+ {
+ Tools.toSet((Iterator)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIteratorToSet()
+ {
+ List<String> list = new ArrayList<String>();
+ list.add("a");
+ list.add("b");
+ list.add("a");
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, Tools.toSet(list.iterator()));
+ }
+
+ public void testEnumerationToListThrowsIAE()
+ {
+ try
+ {
+ Tools.toList((Enumeration)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testEnumerationToList()
+ {
+ Vector<String> v = new Vector<String>();
+ v.add("a");
+ v.add("b");
+ v.add("a");
+ List<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, Tools.toList(v.elements()));
+ }
+
+ public void testArrayToListThrowsIAE()
+ {
+ try
+ {
+ Tools.toList((Object[])null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayToList()
+ {
+ List<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, Tools.toList(new String[]{"a","b","a"}));
+ }
+
+ public void testIteratorToListThrowsIAE()
+ {
+ try
+ {
+ Tools.toList((Iterator)null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIteratorToList()
+ {
+ List<String> list = new ArrayList<String>();
+ list.add("a");
+ list.add("b");
+ list.add("a");
+ List<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, Tools.toList(list.iterator()));
+ }
+
+
+ public void testArrayIteratorThrowsIAE()
+ {
+ try
+ {
+ Tools.iterator((Object[])null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayIterator1()
+ {
+ assertIterator(Tools.iterator(new String[]{}));
+ }
+
+ public void testArrayIterator2()
+ {
+ assertIterator(Tools.iterator(new String[]{"a"}), "a");
+ }
+
+ public void testArrayIterator3()
+ {
+ assertIterator(Tools.iterator(new String[]{"a","b"}), "a", "b");
+ }
+
+ public void testElementIterator()
+ {
+ assertIterator(Tools.iterator("a"), "a");
+ }
+
+ public void testArrayRangeIteratorThrowsIAE()
+ {
+ try
+ {
+ Tools.iterator(null, 0, 0);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testArrayRangeIterator1()
+ {
+ assertIteratorMethodThrowIAE(new String[]{}, -1, 0);
+ assertIteratorMethodThrowIAE(new String[]{}, 0, 1);
+ assertIteratorMethodThrowIAE(new String[]{}, 1, 0);
+ assertIterator(Tools.iterator(new String[]{}, 0, 0));
+ }
+
+ public void testArrayRangeIterator2()
+ {
+ assertIteratorMethodThrowIAE(new String[]{"a"}, -1, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a"}, 1, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a"}, 1, 2);
+ assertIterator(Tools.iterator(new String[]{"a"}, 0, 0));
+ assertIterator(Tools.iterator(new String[]{"a"}, 1, 1));
+ assertIterator(Tools.iterator(new String[]{"a"}, 0, 1), "a");
+ }
+
+ public void testArrayRangeIterator3()
+ {
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, -1, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, 1, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, 2, 0);
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, 2, 1);
+ assertIteratorMethodThrowIAE(new String[]{"a", "b"}, 2, 3);
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 0, 0));
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 1, 1));
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 2, 2));
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 0, 1), "a");
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 1, 2), "b");
+ assertIterator(Tools.iterator(new String[]{"a","b"}, 0, 2), "a", "b");
+ }
+
+ public void testArrayAppendToThrowsIAE()
+ {
+ try
+ {
+ Tools.appendTo(null, "a");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testEmptyEnumeration()
+ {
+ assertEnumeration(Tools.EMPTY_ENUMERATION);
+ }
+
+ public void testEmptyIterator()
+ {
+ assertIterator(Tools.EMPTY_ITERATOR);
+ }
+
+ public void testArrayAppendTo()
+ {
+ ExtendedAssert.assertEquals(new String[]{"a"}, Tools.appendTo(new String[0], "a"));
+ ExtendedAssert.assertEquals(new String[]{null}, Tools.appendTo(new String[0], null));
+ ExtendedAssert.assertEquals(new String[]{"a", "b"}, Tools.appendTo(new String[]{"a"}, "b"));
+ ExtendedAssert.assertEquals(new String[]{null, "b"}, Tools.appendTo(new String[]{null}, "b"));
+ ExtendedAssert.assertEquals(new String[]{"a", null}, Tools.appendTo(new String[]{"a"}, null));
+ }
+
+ private <E> void assertEnumeration(Enumeration<E> elements, E... expectedElements)
+ {
+ assertNotNull(elements);
+ for (E expectedElement : expectedElements)
+ {
+ assertTrue(elements.hasMoreElements());
+ E element = elements.nextElement();
+ assertEquals(expectedElement, element);
+ }
+ assertFalse(elements.hasMoreElements());
+ try
+ {
+ elements.nextElement();
+ fail();
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+
+ private void assertIteratorMethodThrowIAE(Object[] array, int from, int to)
+ {
+ try
+ {
+ Tools.iterator(array, from, to);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ private <E> void assertIterator(Iterator<E> elements, E... expectedElements)
+ {
+ assertNotNull(elements);
+ for (E expectedElement : expectedElements)
+ {
+ assertTrue(elements.hasNext());
+ E element = elements.next();
+ assertEquals(expectedElement, element);
+ }
+ assertFalse(elements.hasNext());
+ try
+ {
+ elements.next();
+ fail();
+ }
+ catch (NoSuchElementException expected)
+ {
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ValueTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,222 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.value.Value;
+import org.jboss.portal.common.value.IntegerValue;
+import org.jboss.portal.common.value.StringValue;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ValueTestCase extends TestCase
+{
+ public ValueTestCase(String s)
+ {
+ super(s);
+ }
+
+
+ public void testIntegerValueWithNull() throws Exception
+ {
+ _testNullInteger(new IntegerValue());
+ _testNullInteger(new IntegerValue((Integer)null));
+ _testNullInteger(new IntegerValue((String)null));
+ _testNullInteger(new IntegerValue(new Integer[1]));
+ _testNullInteger(new IntegerValue(new String[1]));
+ }
+
+ private void _testNullInteger(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertTrue(value.isNull());
+ assertEquals(1, value.size());
+ assertFalse(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertNull(value.asString());
+ assertEquals(null, value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(1, value.asStringArray().length);
+ assertNull(value.asStringArray()[0]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(1, value.asObjectArray().length);
+ assertNull(value.asObjectArray()[0]);
+ }
+
+ public void testIntegerValueEmptyArray() throws Exception
+ {
+ _testIntegerValueEmptyArray(new IntegerValue(new Integer[0]));
+ _testIntegerValueEmptyArray(new IntegerValue(new int[0]));
+ _testIntegerValueEmptyArray(new IntegerValue(new String[0]));
+ }
+
+ public void _testIntegerValueEmptyArray(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertTrue(value.isNull());
+ assertEquals(0, value.size());
+ assertFalse(value.isMultiValued());
+ assertTrue(value.isEmpty());
+ assertNull(value.asString());
+ assertNull(value.asObject());
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(0, value.asObjectArray().length);
+ assertNotNull(value.asStringArray());
+ assertEquals(0, value.asStringArray().length);
+ }
+
+ public void testIntegerValueNonNullInteger() throws Exception
+ {
+ _testIntegerValueNonNullInteger(new IntegerValue(1));
+ _testIntegerValueNonNullInteger(new IntegerValue(new Integer(1)));
+ _testIntegerValueNonNullInteger(new IntegerValue(new int[]{1}));
+ _testIntegerValueNonNullInteger(new IntegerValue(new Integer[]{new Integer(1)}));
+ _testIntegerValueNonNullInteger(new IntegerValue("1"));
+ _testIntegerValueNonNullInteger(new IntegerValue(new String[]{"1"}));
+ }
+
+ private void _testIntegerValueNonNullInteger(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertFalse(value.isNull());
+ assertEquals(1, value.size());
+ assertFalse(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertEquals("1", value.asString());
+ assertEquals(new Integer(1), value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(1, value.asStringArray().length);
+ assertEquals("1", value.asStringArray()[0]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(1, value.asObjectArray().length);
+ assertEquals(new Integer(1), value.asObjectArray()[0]);
+ }
+
+ public void testIntegerValueIntegerArray() throws Exception
+ {
+ _testIntegerValueIntegerArray(new IntegerValue(new int[]{1,2}));
+ _testIntegerValueIntegerArray(new IntegerValue(new Integer[]{new Integer(1), new Integer(2)}));
+ _testIntegerValueIntegerArray(new IntegerValue(new String[]{"1","2"}));
+ }
+
+ private void _testIntegerValueIntegerArray(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertFalse(value.isNull());
+ assertEquals(2, value.size());
+ assertTrue(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertEquals("1", value.asString());
+ assertEquals(new Integer(1), value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(2, value.asStringArray().length);
+ assertEquals("1", value.asStringArray()[0]);
+ assertEquals("2", value.asStringArray()[1]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(2, value.asObjectArray().length);
+ assertEquals(new Integer(1), value.asObjectArray()[0]);
+ assertEquals(new Integer(2), value.asObjectArray()[1]);
+ }
+
+ public void testIntegerValueIntegerArrayWithNull() throws Exception
+ {
+ _testIntegerValueIntegerArrayWithNull(new IntegerValue(new Integer[]{null, new Integer(1)}));
+ _testIntegerValueIntegerArrayWithNull(new IntegerValue(new String[]{null, "1"}));
+ }
+
+ private void _testIntegerValueIntegerArrayWithNull(Value value) throws Exception
+ {
+ assertFalse(value.isInstanceOf(String.class));
+ assertTrue(value.isInstanceOf(Number.class));
+ assertTrue(value.isInstanceOf(Integer.class));
+ assertTrue(value.isNull());
+ assertEquals(2, value.size());
+ assertTrue(value.isMultiValued());
+ assertFalse(value.isEmpty());
+ assertEquals(null, value.asString());
+ assertEquals(null, value.asObject());
+ assertNotNull(value.asStringArray());
+ assertEquals(2, value.asStringArray().length);
+ assertEquals(null, value.asStringArray()[0]);
+ assertEquals("1", value.asStringArray()[1]);
+ assertTrue(value.asObjectArray() instanceof Integer[]);
+ assertEquals(2, value.asObjectArray().length);
+ assertEquals(null, value.asObjectArray()[0]);
+ assertEquals(new Integer(1), value.asObjectArray()[1]);
+ }
+
+ public void testClone() throws Exception
+ {
+ StringValue a = new StringValue("abc");
+ Object b = a.clone();
+ assertTrue(b instanceof StringValue);
+ StringValue c = (StringValue)b;
+ assertEquals(a, c);
+
+ //
+ StringValue d = new StringValue(new String[]{"abc","def"});
+ Object e = d.clone();
+ assertTrue(e instanceof StringValue);
+ StringValue f = (StringValue)e;
+ assertEquals(d, f);
+ }
+
+ public void testEqualsOnStringValues()
+ {
+ assertEquals(new StringValue(), new StringValue());
+ assertEquals(new StringValue(), new StringValue((String)null));
+ assertEquals(new StringValue(), new StringValue(new String[0]));
+ assertEquals(new StringValue(), new StringValue(new String[]{null}));
+ assertEquals(new StringValue((String)null), new StringValue());
+ assertEquals(new StringValue((String)null), new StringValue((String)null));
+ assertEquals(new StringValue((String)null), new StringValue(new String[0]));
+ assertEquals(new StringValue((String)null), new StringValue(new String[]{null}));
+ assertEquals(new StringValue(new String[0]), new StringValue());
+ assertEquals(new StringValue(new String[0]), new StringValue((String)null));
+ assertEquals(new StringValue(new String[0]), new StringValue(new String[0]));
+ assertEquals(new StringValue(new String[0]), new StringValue(new String[]{null}));
+ assertEquals(new StringValue(new String[]{null}), new StringValue());
+ assertEquals(new StringValue(new String[]{null}), new StringValue((String)null));
+ assertEquals(new StringValue(new String[]{null}), new StringValue(new String[0]));
+ assertEquals(new StringValue(new String[]{null}), new StringValue(new String[]{null}));
+ }
+
+ public void testUnmodifiable()
+ {
+ StringValue a = new StringValue("abc");
+ String[] b = (String[])a.asObjectArray();
+ b[0] = "def";
+ assertEquals("abc", a.asString());
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/ValveTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,189 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common;
+
+import java.io.PrintStream;
+
+import junit.framework.TestCase;
+
+import org.jboss.portal.common.concurrent.Valve;
+
+import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5451 $
+ */
+public class ValveTestCase extends TestCase
+{
+
+ public ValveTestCase(String key)
+ {
+ super(key);
+ }
+
+ public static final PrintStream out = System.out;
+
+ public void testTransitions()
+ {
+ Valve valve = new Valve();
+ assertEquals(Valve.CLOSED, valve.getState());
+ assertFalse(valve.beforeInvocation());
+ try
+ {
+ valve.closing(10);
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ try
+ {
+ valve.closing();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+ try
+ {
+ valve.closed();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ }
+
+ // Open the valve
+ valve.open();
+ try
+ {
+ assertTrue(valve.beforeInvocation());
+ }
+ finally
+ {
+ valve.afterInvocation();
+ }
+ try
+ {
+ valve.open();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ try
+ {
+ valve.closed();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+
+
+ // Closing the valve
+ valve.closing();
+ assertEquals(Valve.CLOSING, valve.getState());
+ assertFalse(valve.beforeInvocation());
+ try
+ {
+ valve.open();
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ valve.closing();
+
+ // Close the valve
+ valve.closed();
+ assertEquals(Valve.CLOSED, valve.getState());
+ }
+
+ public void testTimeOut() throws Exception
+ {
+ final Valve valve = new Valve();
+ final CyclicBarrier barrier = new CyclicBarrier(2);
+
+ Thread thread = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ assertTrue(valve.beforeInvocation());
+
+ // The valve is enterred
+ barrier.barrier();
+
+ // Wait
+ barrier.barrier();
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+ finally
+ {
+ valve.afterInvocation();
+ try
+ {
+ // Tell the other thread we have finished
+ barrier.barrier();
+ }
+ catch (InterruptedException ignore)
+ {
+ }
+ }
+ }
+ };
+
+ // Open valve and start thread
+ valve.open();
+ thread.start();
+
+ // Wait until the thread called beforeInvocation
+ barrier.barrier();
+
+ // Attemtp to close
+ assertFalse(valve.closing(100));
+
+ // Check it is in closing state
+ assertEquals(Valve.CLOSING, valve.getState());
+
+ // Ask the invoker thread to finish
+ barrier.barrier();
+
+ // Wait until invocation is finished
+ barrier.barrier();
+
+ // Close, no thread are inside
+ valve.closing();
+ assertEquals(Valve.CLOSING, valve.getState());
+
+ //
+ valve.closed();
+ assertEquals(Valve.CLOSED, valve.getState());
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted1.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Adapted1 implements Business1
+{
+
+ /** . */
+ int business1MethodCount;
+
+ /** . */
+ int commonMethodCount;
+
+ public void business1Method()
+ {
+ business1MethodCount++;
+ }
+
+ public void commonMethod()
+ {
+ commonMethodCount++;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Adapted2.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Adapted2 implements Business2
+{
+
+ /** . */
+ int business2MethodCount;
+
+ /** . */
+ int commonMethodCount;
+
+ public void business2Method()
+ {
+ business2MethodCount++;
+ }
+
+ public void commonMethod()
+ {
+ commonMethodCount++;
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/AdapterTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,162 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.adapter.ClassAdapter;
+import org.jboss.portal.common.adapter.ClassAdapted;
+import org.jboss.portal.common.adapter.ClassAdaptable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AdapterTestCase extends TestCase
+{
+
+ Adapted1 adapted1;
+ Adapted2 adapted2;
+ ObjectAdapted objectAdapted;
+ ClassAdaptable adaptable;
+
+ protected void setUp() throws Exception
+ {
+ adapted1 = new Adapted1();
+ adapted2 = new Adapted2();
+ objectAdapted = new ObjectAdapted();
+ ClassAdapted[] adapteds = new ClassAdapted[]{new ClassAdapted(Business1.class, adapted1),new ClassAdapted(Business2.class, adapted2)};
+ ClassAdapter adapter = new ClassAdapter(Thread.currentThread().getContextClassLoader(), adapteds, objectAdapted);
+ adaptable = adapter.getAdaptable();
+ }
+
+
+ protected void tearDown() throws Exception
+ {
+ adapted1 = null;
+ adapted2 = null;
+ objectAdapted = null;
+ adaptable = null;
+ }
+
+ public void testImplementedInterfaces()
+ {
+ assertTrue(adaptable instanceof Business1);
+ assertTrue(adaptable instanceof Business2);
+ }
+
+ public void testObjectMethodCall() throws Exception
+ {
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ assertEquals("Foo", adaptable.toString());
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ assertEquals(1234, adaptable.hashCode());
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(1, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ assertEquals(true, adaptable.equals(Boolean.TRUE));
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(1, objectAdapted.hashCodeCount);
+ assertEquals(1, objectAdapted.equalsCount);
+
+ //
+ assertEquals(false, adaptable.equals(Boolean.FALSE));
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(1, objectAdapted.toStringCount);
+ assertEquals(1, objectAdapted.hashCodeCount);
+ assertEquals(2, objectAdapted.equalsCount);
+ }
+
+ public void testBusinessMethodCall() throws Exception
+ {
+ assertEquals(0, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ Business1 business1Adapter = (Business1)adaptable;
+ Business2 business2Adapter = (Business2)adaptable;
+
+ //
+ business1Adapter.business1Method();
+ assertEquals(1, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(0, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ business2Adapter.business2Method();
+ assertEquals(1, adapted1.business1MethodCount);
+ assertEquals(0, adapted1.commonMethodCount);
+ assertEquals(1, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+
+ //
+ business1Adapter.commonMethod();
+ assertEquals(1, adapted1.business1MethodCount);
+ assertEquals(1, adapted1.commonMethodCount);
+ assertEquals(1, adapted2.business2MethodCount);
+ assertEquals(0, adapted2.commonMethodCount);
+ assertEquals(0, objectAdapted.toStringCount);
+ assertEquals(0, objectAdapted.hashCodeCount);
+ assertEquals(0, objectAdapted.equalsCount);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business1.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Business1
+{
+ void business1Method();
+ void commonMethod();
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/Business2.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Business2
+{
+ void business2Method();
+ void commonMethod();
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/adapter/ObjectAdapted.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.adapter;
+
+import org.jboss.portal.common.adapter.JavaLangObjectAdapted;
+import org.jboss.portal.common.adapter.ClassAdaptable;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ObjectAdapted implements JavaLangObjectAdapted
+{
+
+ int toStringCount;
+ int hashCodeCount;
+ int equalsCount;
+
+ public String toString(ClassAdaptable adaptable)
+ {
+ toStringCount++;
+ return "Foo";
+ }
+
+ public int hashCode(ClassAdaptable adaptable)
+ {
+ hashCodeCount++;
+ return 1234;
+ }
+
+ public boolean equals(ClassAdaptable adaptable, Object obj)
+ {
+ equalsCount++;
+ return ((Boolean)obj).booleanValue();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/http/QueryStringParserTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.http;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.http.QueryStringParser;
+import org.jboss.portal.common.util.MapBuilder;
+import org.jboss.portal.common.util.ParameterMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class QueryStringParserTestCase extends TestCase
+{
+
+ /** . */
+ private final QueryStringParser parser = new QueryStringParser();
+
+ public void testConstructorThrowsIAE()
+ {
+ try
+ {
+ new QueryStringParser(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testParseThrowsIAE()
+ {
+ try
+ {
+ QueryStringParser.getInstance().parseQueryString(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEmpty()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString(""));
+ }
+
+ public void testOneParam()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar"}).get(), parser.parseQueryString("f=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("foo=bar"));
+ }
+
+ public void testTwoValues()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"","bar2"}).get(), parser.parseQueryString("f&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"","bar2"}).get(), parser.parseQueryString("f=&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b","bar2"}).get(), parser.parseQueryString("f=b&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar","bar2"}).get(), parser.parseQueryString("f=bar&f=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"","bar2"}).get(), parser.parseQueryString("foo&foo=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"","bar2"}).get(), parser.parseQueryString("foo=&foo=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b","bar2"}).get(), parser.parseQueryString("foo=b&foo=bar2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar","bar2"}).get(), parser.parseQueryString("foo=bar&foo=bar2"));
+
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2",""}).get(), parser.parseQueryString("f=bar2&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2",""}).get(), parser.parseQueryString("f=bar2&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2","b"}).get(), parser.parseQueryString("f=bar2&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar2","bar"}).get(), parser.parseQueryString("f=bar2&f=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2",""}).get(), parser.parseQueryString("foo=bar2&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2",""}).get(), parser.parseQueryString("foo=bar2&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2","b"}).get(), parser.parseQueryString("foo=bar2&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar2","bar"}).get(), parser.parseQueryString("foo=bar2&foo=bar"));
+ }
+
+ public void testEncodedValue()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{" "}).get(), parser.parseQueryString("foo=+"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"."}).get(), parser.parseQueryString("foo=."));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"-"}).get(), parser.parseQueryString("foo=-"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"*"}).get(), parser.parseQueryString("foo=*"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"_"}).get(), parser.parseQueryString("foo=_"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"/"}).get(), parser.parseQueryString("foo=%2F"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"/"}).get(), parser.parseQueryString("foo=/"));
+ }
+
+ public void testMalformedValue()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("foo=%2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo&foo=%2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("foo=bar&foo=%2"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("foo=%2&foo"));
+ }
+
+ public void testTwoParams()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{""}).get(), parser.parseQueryString("x=y&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{""}).get(), parser.parseQueryString("x=y&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{"b"}).get(), parser.parseQueryString("x=y&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("f", new String[]{"bar"}).get(), parser.parseQueryString("x=y&f=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{""}).get(), parser.parseQueryString("x=y&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{""}).get(), parser.parseQueryString("x=y&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{"b"}).get(), parser.parseQueryString("x=y&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("x", new String[]{"y"}).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("x=y&foo=bar"));
+ }
+
+ public void testValueContainingEqual()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b=j"}).get(), parser.parseQueryString("f=b=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar=j"}).get(), parser.parseQueryString("f=bar=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b=juu"}).get(), parser.parseQueryString("f=b=juu"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"bar=juu"}).get(), parser.parseQueryString("f=bar=juu"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b=j"}).get(), parser.parseQueryString("foo=b=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar=j"}).get(), parser.parseQueryString("foo=bar=j"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b=juu"}).get(), parser.parseQueryString("foo=b=juu"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar=juu"}).get(), parser.parseQueryString("foo=bar=juu"));
+ }
+
+ public void testInvalidChunck()
+ {
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("="));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x="));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x=y"));
+ }
+
+ public void testInvalidChunckWithAmpersand()
+ {
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=&"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x&"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x=&"));
+ assertEquals(MapBuilder.create(new ParameterMap()).get(), parser.parseQueryString("=x=y&"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=&f"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=y&f"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=&f="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{""}).get(), parser.parseQueryString("=x=y&f="));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=x&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=x=&f=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("f", new String[]{"b"}).get(), parser.parseQueryString("=x=y&f=b"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=&foo"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=y&foo"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=&foo="));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{""}).get(), parser.parseQueryString("=x=y&foo="));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=x&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=x=&foo=b"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"b"}).get(), parser.parseQueryString("=x=y&foo=b"));
+
+ //
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=&foo=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=x&foo=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=x=&foo=bar"));
+ assertEquals(MapBuilder.create(new ParameterMap()).put("foo", new String[]{"bar"}).get(), parser.parseQueryString("=x=y&foo=bar"));
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/io/IOToolsTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,667 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.io;
+
+import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import junit.framework.TestCase;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.CharArrayWriter;
+import java.io.CharArrayReader;
+import java.util.Random;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * todo:
+ * <ul>
+ * <li>test safeBufferedWrapper</li>
+ * <li>test serialize</li>
+ * <li>test unserialize</li>
+ * <li>test clone</li>
+ * </ul>
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IOToolsTestCase extends TestCase
+{
+
+ public void testGenericSafeClose()
+ {
+ IOTools.safeClose((Object)null);
+ IOTools.safeClose(new Object());
+
+ //
+ assertTrue(new GenericPublicSafeClose().apply().called);
+ assertFalse(new GenericProtectedSafeClose().apply().called);
+ assertFalse(new GenericPackageProtectedSafeClose().apply().called);
+ assertFalse(new GenericPrivateSafeClose().apply().called);
+
+ //
+ IOTools.safeClose(new GenericPublicStaticSafeClose());
+ assertFalse(GenericPublicStaticSafeClose.called);
+ IOTools.safeClose(new GenericProtectedStaticSafeClose());
+ assertFalse(GenericProtectedStaticSafeClose.called);
+ IOTools.safeClose(new GenericPackageProtectedStaticSafeClose());
+ assertFalse(GenericPackageProtectedStaticSafeClose.called);
+ IOTools.safeClose(new GenericPrivateStaticSafeClose());
+ assertFalse(GenericPrivateStaticSafeClose.called);
+ }
+
+ public static class GenericSafeClose
+ {
+ boolean called = false;
+ public GenericSafeClose apply()
+ {
+ IOTools.safeClose(this);
+ return this;
+ }
+ }
+
+ public static class GenericPublicSafeClose extends GenericSafeClose
+ {
+ public void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericProtectedSafeClose extends GenericSafeClose
+ {
+ protected void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPackageProtectedSafeClose extends GenericSafeClose
+ {
+ protected void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPrivateSafeClose extends GenericSafeClose
+ {
+ private void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPublicStaticSafeClose
+ {
+ static boolean called = false;
+ public static void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericProtectedStaticSafeClose
+ {
+ static boolean called = false;
+ protected static void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPackageProtectedStaticSafeClose
+ {
+ static boolean called = false;
+ static void close()
+ {
+ called = true;
+ }
+ }
+
+ public static class GenericPrivateStaticSafeClose
+ {
+ static boolean called = false;
+ private static void close()
+ {
+ called = true;
+ }
+ }
+
+
+ public void testGenericSafeCloseWithThrowable()
+ {
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw new Exception();
+ }
+ }.apply(null);
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw new Throwable();
+ }
+ }.apply(null);
+ final RuntimeException runtimeException = new RuntimeException();
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw runtimeException;
+ }
+ }.apply(runtimeException);
+ final Error error = new Error();
+ new FailingGenericSafeClose()
+ {
+ protected void internalClose() throws Throwable
+ {
+ throw error;
+ }
+ }.apply(error);
+ }
+
+ public abstract static class FailingGenericSafeClose
+ {
+ public void apply(Throwable expectedThrowable)
+ {
+ try
+ {
+ IOTools.safeClose(this);
+ assertNull(expectedThrowable);
+ }
+ catch (Throwable t)
+ {
+ assertEquals(expectedThrowable, t);
+ }
+ }
+
+ public void close() throws Throwable
+ {
+ internalClose();
+ }
+
+ protected abstract void internalClose() throws Throwable;
+ }
+
+ public void testOutputStreamSafeClose()
+ {
+ IOTools.safeClose((OutputStream)null);
+ final SynchronizedBoolean called = new SynchronizedBoolean(false);
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractOutputStream extends OutputStream
+ {
+ public void write(int b) throws IOException
+ {
+ }
+ }
+
+ public void testInputStreamSafeClose()
+ {
+ IOTools.safeClose((InputStream)null);
+ final SynchronizedBoolean called = new SynchronizedBoolean(false);
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractInputStream()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractInputStream extends InputStream
+ {
+ public int read() throws IOException
+ {
+ return 0;
+ }
+ }
+
+ public void testReaderSafeClose()
+ {
+ IOTools.safeClose((Reader)null);
+ final SynchronizedBoolean called = new SynchronizedBoolean(false);
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractReader()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractReader extends Reader
+ {
+ public int read(char cbuf[], int off, int len) throws IOException
+ {
+ return 0;
+ }
+ }
+
+ public void testWriterSafeClose()
+ {
+ IOTools.safeClose((Writer)null);
+ final SynchronizedBoolean called = new SynchronizedBoolean(false);
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ called.set(true);
+ }
+ });
+ assertTrue(called.get());
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ });
+ final Error error = new Error();
+ try
+ {
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ throw error;
+ }
+ });
+ fail("Was expecting an error exception");
+ }
+ catch (Error expected)
+ {
+ assertEquals(error, expected);
+ }
+ final RuntimeException runtimeException = new RuntimeException();
+ try
+ {
+ IOTools.safeClose(new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ throw runtimeException;
+ }
+ });
+ fail("Was expecting a runtime exception");
+ }
+ catch (RuntimeException expected)
+ {
+ assertEquals(runtimeException, expected);
+ }
+ }
+
+ public abstract static class AbstractWriter extends Writer
+ {
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ }
+ public void flush() throws IOException
+ {
+ }
+ }
+
+ public void testCopyInputStreamToOutputStream() throws IOException
+ {
+ try
+ {
+ IOTools.copy(null, new ByteArrayOutputStream());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ IOTools.copy(new ByteArrayInputStream(new byte[0]), null);
+ fail("Was expecting an IOException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ final SynchronizedBoolean closeCalled1 = new SynchronizedBoolean(false);
+ final IOException ioException1 = new IOException();
+ try
+ {
+ IOTools.copy(new AbstractInputStream()
+ {
+ public int read() throws IOException
+ {
+ throw ioException1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled1.set(true);
+ }
+ }, new ByteArrayOutputStream());
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException1, expected);
+ assertFalse(closeCalled1.get());
+ }
+
+ //
+ final SynchronizedBoolean closeCalled2 = new SynchronizedBoolean(false);
+ IOTools.copy(new AbstractInputStream()
+ {
+ public int read() throws IOException
+ {
+ return -1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled2.set(true);
+ }
+ }, new ByteArrayOutputStream());
+ assertFalse(closeCalled2.get());
+
+ //
+ final IOException ioException2 = new IOException();
+ final SynchronizedBoolean closeCalled3 = new SynchronizedBoolean(false);
+ try
+ {
+ IOTools.copy(new ByteArrayInputStream(new byte[1]), new AbstractOutputStream()
+ {
+ public void write(int b) throws IOException
+ {
+ throw ioException2;
+ }
+ public void close() throws IOException
+ {
+ closeCalled3.set(true);
+ }
+ });
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException2, expected);
+ }
+
+ //
+ final SynchronizedBoolean closeCalled4 = new SynchronizedBoolean(false);
+ IOTools.copy(new ByteArrayInputStream(new byte[1]), new AbstractOutputStream()
+ {
+ public void close() throws IOException
+ {
+ closeCalled4.set(true);
+ }
+ });
+
+ //
+ Random random = new Random();
+ byte[] bytes = new byte[2000];
+ random.nextBytes(bytes);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length);
+ IOTools.copy(new ByteArrayInputStream((byte[])bytes.clone()), baos);
+ ExtendedAssert.assertEquals(bytes, baos.toByteArray());
+ }
+
+ public void testCopyReaderToWriter() throws IOException
+ {
+ try
+ {
+ IOTools.copy(null, new CharArrayWriter());
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ IOTools.copy(new CharArrayReader(new char[0]), null);
+ fail("Was expecting an IOException");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ final SynchronizedBoolean closeCalled1 = new SynchronizedBoolean(false);
+ final IOException ioException1 = new IOException();
+ try
+ {
+ IOTools.copy(new AbstractReader()
+ {
+ public int read(char cbuf[], int off, int len) throws IOException
+ {
+ throw ioException1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled1.set(true);
+ }
+ }, new CharArrayWriter());
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException1, expected);
+ assertFalse(closeCalled1.get());
+ }
+
+ //
+ final SynchronizedBoolean closeCalled2 = new SynchronizedBoolean(false);
+ IOTools.copy(new AbstractReader()
+ {
+ public int read(char cbuf[], int off, int len) throws IOException
+ {
+ return -1;
+ }
+ public void close() throws IOException
+ {
+ closeCalled2.set(true);
+ }
+ }, new CharArrayWriter());
+ assertFalse(closeCalled2.get());
+
+ //
+ final IOException ioException2 = new IOException();
+ final SynchronizedBoolean closeCalled3 = new SynchronizedBoolean(false);
+ try
+ {
+ IOTools.copy(new CharArrayReader(new char[1]), new AbstractWriter()
+ {
+ public void write(char cbuf[], int off, int len) throws IOException
+ {
+ throw ioException2;
+ }
+ public void close() throws IOException
+ {
+ closeCalled3.set(true);
+ }
+ });
+ fail("Was expecting an IOException");
+ }
+ catch (IOException expected)
+ {
+ assertEquals(ioException2, expected);
+ }
+
+ //
+ final SynchronizedBoolean closeCalled4 = new SynchronizedBoolean(false);
+ IOTools.copy(new CharArrayReader(new char[1]), new AbstractWriter()
+ {
+ public void close() throws IOException
+ {
+ closeCalled4.set(true);
+ }
+ });
+
+ //
+ Random random = new Random();
+ char[] chars = new char[2000];
+ for (int i = 0; i < chars.length; i++)
+ {
+ chars[i] = (char)random.nextInt();
+
+ }
+ CharArrayWriter caw = new CharArrayWriter(chars.length);
+ IOTools.copy(new CharArrayReader((char[])chars.clone()), caw);
+ ExtendedAssert.assertEquals(chars, caw.toCharArray());
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/io/WriterCharWriterTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,203 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.io;
+
+import org.jboss.portal.common.io.WriterCharWriter;
+import org.jboss.portal.common.io.UndeclaredIOException;
+
+import java.io.StringWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WriterCharWriterTestCase extends TestCase
+{
+
+ public void testAppend1() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append('a');
+ s.close();
+ assertEquals("a", s.toString());
+ }
+
+ public void testAppend2() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append("abc".toCharArray());
+ s.close();
+ assertEquals("abc", s.toString());
+ }
+
+ public void testAppend3() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append("abcdef".toCharArray(), 1, 3);
+ s.close();
+ assertEquals("bcd", s.toString());
+ }
+
+ public void testAppend4() throws IOException
+ {
+ StringWriter s = new StringWriter();
+ WriterCharWriter writer = new WriterCharWriter(s);
+ writer.append("abc");
+ s.close();
+ assertEquals("abc", s.toString());
+ }
+
+ private Writer failingWriter = new Writer()
+ {
+ public void write(char[] chars, int i, int i1) throws IOException
+ {
+ throw new IOException();
+ }
+
+ public void flush() throws IOException
+ {
+ throw new IOException();
+ }
+
+ public void close() throws IOException
+ {
+ throw new IOException();
+ }
+ };
+
+ public void testWrappedIOException()
+ {
+ WriterCharWriter writer = new WriterCharWriter(failingWriter);
+ try
+ {
+ writer.append('c');
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ try
+ {
+ writer.append("abc".toCharArray());
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ try
+ {
+ writer.append("abcdef".toCharArray(), 1, 3);
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ try
+ {
+ writer.append("abc");
+ fail("Was expecting an UndeclaredIOException");
+ }
+ catch (UndeclaredIOException expected)
+ {
+ }
+ }
+
+ public void testAppendThrowsIAE()
+ {
+ try
+ {
+ new WriterCharWriter(null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ WriterCharWriter writer = new WriterCharWriter(new StringWriter());
+ try
+ {
+ writer.append(new char[10], -1, 0);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(new char[10], 5, -1);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(new char[10], 15, 0);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(new char[10], 5, 6);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append(null, 0, 5);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append((char[])null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ writer.append((CharSequence)null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractServer.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractServer.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractServer.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.net;
+
+import java.net.ServerSocket;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractServer implements Runnable
+{
+
+ /** . */
+ private int port;
+
+ /** . */
+ private ServerSocket server;
+
+ public AbstractServer(int port)
+ {
+ this.port = port;
+ }
+
+ public final void start() throws Exception
+ {
+ server = new ServerSocket(port, 1);
+ new Thread(this).start();
+ }
+
+ public final void run()
+ {
+ try
+ {
+ run(server);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ if (!server.isClosed())
+ {
+ try
+ {
+ server.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+ }
+
+ protected abstract void run(ServerSocket server) throws Exception;
+
+ public final void stop()
+ {
+ if (server != null)
+ {
+ try
+ {
+ server.close();
+ }
+ catch (IOException ignore)
+ {
+ }
+ }
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractSynchronizedServer.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractSynchronizedServer.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/AbstractSynchronizedServer.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,180 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.net;
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.junit.ExtendedAssert;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.io.BufferedInputStream;
+import java.io.LineNumberReader;
+import java.io.InputStreamReader;
+import java.io.BufferedOutputStream;
+import java.io.OutputStreamWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractSynchronizedServer extends AbstractServer
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(AbstractSynchronizedServer.class);
+
+ /** . */
+ private final Object lock = new Object();
+
+ /** . */
+ private final AtomicInteger b = new AtomicInteger(0);
+
+ /** . */
+ private Throwable failure;
+
+ protected AbstractSynchronizedServer(int port)
+ {
+ super(port);
+ }
+
+ protected void run(ServerSocket server) throws Exception
+ {
+ synchronized (lock)
+ {
+ b.set(1);
+ lock.notifyAll();
+ }
+
+ //
+ log.debug("Ready for accept");
+
+ //
+ try
+ {
+ doServer(server);
+ }
+ catch (Throwable throwable)
+ {
+ failure = throwable;
+ }
+
+ //
+ synchronized (lock)
+ {
+ lock.wait();
+ }
+
+ //
+ log.debug("Shutting down");
+ }
+
+ protected abstract void doServer(ServerSocket server) throws Exception;
+
+ protected abstract void doClient() throws Exception;
+
+ public void performInteraction() throws Exception
+ {
+ try
+ {
+ start();
+
+ // Wait until the we know the server will accept
+ synchronized (lock)
+ {
+ while (b.get() != 1)
+ {
+ lock.wait();
+ }
+ }
+
+ // Perform client action
+ doClient();
+ }
+ finally
+ {
+ synchronized (lock)
+ {
+ lock.notify();
+ }
+ stop();
+ }
+
+ //
+ if (failure != null)
+ {
+ log.error("The server reported a failure", failure);
+
+ ExtendedAssert.fail("The server reported a failure");
+ }
+ }
+
+ public static abstract class AbstractTimeoutServer extends AbstractSynchronizedServer
+ {
+
+ protected AbstractTimeoutServer(int port)
+ {
+ super(port);
+ }
+
+ protected void doServer(ServerSocket server) throws Exception
+ {
+ server.accept();
+ }
+
+ }
+
+ public static abstract class AbstractOKServer extends AbstractSynchronizedServer
+ {
+
+ protected AbstractOKServer(int port)
+ {
+ super(port);
+ }
+
+ protected void doServer(ServerSocket server) throws Exception
+ {
+ //
+ Socket s = server.accept();
+ BufferedInputStream in = new BufferedInputStream(s.getInputStream());
+ LineNumberReader reader = new LineNumberReader(new InputStreamReader(in, "ISO-8859-1"));
+ for (String line = reader.readLine();line.length() > 0;line = reader.readLine())
+ {
+ log.debug("server received = " + line);
+ }
+
+ //
+ log.debug("Finished reading");
+
+ //
+ BufferedOutputStream out = new BufferedOutputStream(s.getOutputStream());
+ OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
+ writer.write("HTTP/1.1 200 OK\r\n");
+ writer.write("\r\n");
+ writer.flush();
+ out.write("CAFEBABE".getBytes("UTF-8"));
+ out.close();
+ }
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLNavigatorTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,628 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.net;
+
+import junit.framework.TestCase;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jboss.portal.common.net.URLFilter;
+import org.jboss.portal.common.net.URLNavigator;
+import org.jboss.portal.common.net.URLVisitor;
+import org.jboss.portal.common.net.URLTools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7448 $
+ */
+public class URLNavigatorTestCase extends TestCase
+{
+
+ public URLNavigatorTestCase(String name)
+ {
+ super(name);
+ }
+
+ // the name of the jar that contains the tests
+ private final String TEST_JAR_NAME="test.jar";
+
+
+ ArrayList expectedAtomsC1 = new ArrayList();
+ ArrayList expectedAtomsB1 = new ArrayList();
+ ArrayList expectedAtomsA1 = new ArrayList();
+ ArrayList expectedAtomsB1Dash = new ArrayList();
+ ArrayList expectedAtomsD1txt = new ArrayList();
+ ArrayList expectedAtomsC1txt = new ArrayList();
+ ArrayList expectedAtomsB1txt = new ArrayList();
+ ArrayList expectedAtomsB2txt = new ArrayList();
+ ArrayList expectedAtomsA3txt = new ArrayList();
+
+ ArrayList expectedURLsC1 = new ArrayList();
+ ArrayList expectedURLsB1 = new ArrayList();
+ ArrayList expectedURLsA1 = new ArrayList();
+ ArrayList expectedURLsB1Dash = new ArrayList();
+ ArrayList expectedURLsD1txt = new ArrayList();
+ ArrayList expectedURLsC1txt = new ArrayList();
+ ArrayList expectedURLsB1txt = new ArrayList();
+ ArrayList expectedURLsB2txt = new ArrayList();
+ ArrayList expectedURLsA3txt = new ArrayList();
+
+ Filter noFilter;
+ Filter fullFilter;
+ Filter noDirFilter;
+ Filter noFileFilter;
+
+ protected void setUp() throws Exception
+ {
+
+ expectedURLsD1txt = new ArrayList();
+ expectedURLsD1txt.add("/a1/b1/c1/d1.txt");
+
+ expectedURLsC1 = new ArrayList();
+ expectedURLsC1.add("/a1/b1/c1/");
+ expectedURLsC1.addAll(expectedURLsD1txt);
+ expectedURLsC1.add("/a1/b1/c1/");
+
+ expectedURLsC1txt = new ArrayList();
+ expectedURLsC1txt.add("/a1/b1/c1.txt");
+
+ expectedURLsB1 = new ArrayList();
+ expectedURLsB1.add("/a1/b1/");
+ expectedURLsB1.addAll(expectedURLsC1);
+ expectedURLsB1.addAll(expectedURLsC1txt);
+ expectedURLsB1.add("/a1/b1/");
+
+ expectedURLsB1Dash = new ArrayList();
+ expectedURLsB1Dash.add("/a1/b1-/");
+ expectedURLsB1Dash.add("/a1/b1-/");
+
+ expectedURLsB1txt = new ArrayList();
+ expectedURLsB1txt.add("/a1/b1.txt");
+
+ expectedURLsB2txt = new ArrayList();
+ expectedURLsB2txt.add("/a1/b2.txt");
+
+ expectedURLsA1 = new ArrayList();
+ expectedURLsA1.add("/a1/");
+ expectedURLsA1.addAll(expectedURLsB1);
+ expectedURLsA1.addAll(expectedURLsB1Dash);
+ expectedURLsA1.addAll(expectedURLsB1txt);
+ expectedURLsA1.addAll(expectedURLsB2txt);
+ expectedURLsA1.add("/a1/");
+
+ expectedURLsA3txt = new ArrayList();
+ expectedURLsA3txt.add("a3.txt");
+
+ expectedAtomsD1txt = new ArrayList();
+ expectedAtomsD1txt.add("d1.txt");
+
+ expectedAtomsC1 = new ArrayList();
+ expectedAtomsC1.add("<c1>");
+ expectedAtomsC1.addAll(expectedAtomsD1txt);
+ expectedAtomsC1.add("</c1>");
+
+ expectedAtomsC1txt = new ArrayList();
+ expectedAtomsC1txt.add("c1.txt");
+
+ expectedAtomsB1 = new ArrayList();
+ expectedAtomsB1.add("<b1>");
+ expectedAtomsB1.addAll(expectedAtomsC1);
+ expectedAtomsB1.addAll(expectedAtomsC1txt);
+ expectedAtomsB1.add("</b1>");
+
+ expectedAtomsB1Dash = new ArrayList();
+ expectedAtomsB1Dash.add("<b1->");
+ expectedAtomsB1Dash.add("</b1->");
+
+ expectedAtomsB1txt = new ArrayList();
+ expectedAtomsB1txt.add("b1.txt");
+
+ expectedAtomsB2txt = new ArrayList();
+ expectedAtomsB2txt.add("b2.txt");
+
+ expectedAtomsA1 = new ArrayList();
+ expectedAtomsA1.add("<a1>");
+ expectedAtomsA1.addAll(expectedAtomsB1);
+ expectedAtomsA1.addAll(expectedAtomsB1Dash);
+ expectedAtomsA1.addAll(expectedAtomsB1txt);
+ expectedAtomsA1.addAll(expectedAtomsB2txt);
+ expectedAtomsA1.add("</a1>");
+
+ expectedAtomsA3txt = new ArrayList();
+ expectedAtomsA3txt.add("a3.txt");
+
+ noFilter = new Filter(true, true);
+ fullFilter = new Filter(false, false);
+ noDirFilter = new Filter(true, false);
+ noFileFilter = new Filter(false, true);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ }
+
+
+//// Root tests
+
+ public void testRootWithFile() throws Exception
+ {
+ URL fileURL = getFileURL ("test-jar");
+
+ ArrayList expectedAtoms = new ArrayList();
+ expectedAtoms.add("<test-jar>");
+ expectedAtoms.addAll(expectedAtomsA1);
+ expectedAtoms.addAll(expectedAtomsA3txt);
+ expectedAtoms.add("</test-jar>");
+
+ ArrayList expectedURLs = new ArrayList();
+ expectedURLs.add("test-jar/");
+ expectedURLs.addAll(expectedURLsA1);
+ expectedURLs.addAll(expectedURLsA3txt);
+ expectedURLs.add("test-jar/");
+
+ doTest (fileURL, expectedAtoms, expectedURLs, noFilter);
+ doTest (fileURL, expectedAtoms, expectedURLs, null);
+ doTest (fileURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (fileURL, removeFiles(expectedAtoms), removeFiles(expectedURLs), noFileFilter);
+ //since we pass it a directory, we can't enter the directory
+ doTest (fileURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ }
+
+ public void testRootWithJar() throws Exception
+ {
+ URL jarURL = getJarURL ("/");
+
+ ArrayList expectedAtoms = new ArrayList();
+ expectedAtoms.add("</>");
+ expectedAtoms.add("<META-INF>");
+ expectedAtoms.add("MANIFEST.MF");
+ expectedAtoms.add("</META-INF>");
+ expectedAtoms.addAll(expectedAtomsA1);
+ expectedAtoms.addAll(expectedAtomsA3txt);
+ //TODO: should this really be //?
+ expectedAtoms.add("<//>");
+
+ ArrayList expectedURLs = new ArrayList();
+ expectedURLs.add("/");
+ expectedURLs.add("/META-INF/");
+ expectedURLs.add("/META-INF/MANIFEST.MF");
+ expectedURLs.add("/META-INF/");
+ expectedURLs.addAll(expectedURLsA1);
+ expectedURLs.addAll(expectedURLsA3txt);
+ expectedURLs.add("/");
+
+ doTest (jarURL, expectedAtoms, expectedURLs, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtoms), removeFiles(expectedURLs), noFileFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), noDirFilter);
+
+ }
+
+//// Directory Test
+
+ public void testDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test-jar/a1/");
+ doDirectoryTest(fileURL);
+ }
+
+ public void testDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/");
+ doDirectoryTest(jarURL);
+ }
+
+ private void doDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (url, expectedAtomsA1, expectedURLsA1, new Filter());
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (url, new ArrayList(), new ArrayList(),noDirFilter);
+
+ Filter mixFilter = new Filter();
+ List dirSeq = new ArrayList();
+ dirSeq.add(Boolean.TRUE); //a1
+ dirSeq.add(Boolean.TRUE); //b1
+ dirSeq.add(Boolean.TRUE); //c1
+ dirSeq.add(Boolean.FALSE); //b1-
+
+ List fileSeq = new ArrayList();
+ fileSeq.add(Boolean.TRUE); //d1.txt
+ fileSeq.add(Boolean.FALSE); //c1.txt
+ fileSeq.add(Boolean.FALSE); //b1.txt
+ fileSeq.add(Boolean.FALSE); //b2.txt
+
+ mixFilter.setAcceptDir(dirSeq);
+ mixFilter.setAcceptFile(fileSeq);
+
+ ArrayList expectedMixAtoms = new ArrayList();
+ expectedMixAtoms.add("<a1>");
+ expectedMixAtoms.add("<b1>");
+ expectedMixAtoms.add("<c1>");
+ expectedMixAtoms.add("d1.txt");
+ expectedMixAtoms.add("</c1>");
+ expectedMixAtoms.add("</b1>");
+ expectedMixAtoms.add("</a1>");
+
+ ArrayList expectedMixURLs = new ArrayList();
+ expectedMixURLs.add("/a1/");
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/b1/c1/");
+ expectedMixURLs.add("/a1/b1/c1/d1.txt");
+ expectedMixURLs.add("/a1/b1/c1/");
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/");
+
+ doTest (url, expectedMixAtoms, expectedMixURLs, mixFilter);
+ }
+
+//// SubDirectory Test
+
+ public void testSubDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL ("test-jar/a1/b1");
+ doSubDirectoryTest(fileURL);
+ }
+
+ public void testSubDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1/");
+ doSubDirectoryTest(jarURL);
+ }
+
+ private void doSubDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsB1, expectedURLsB1, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsB1), removeFiles(expectedURLsB1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (url, new ArrayList(), new ArrayList(),noDirFilter);
+
+ Filter mixFilter = new Filter();
+ List dirSeq = new ArrayList();
+ dirSeq.add(Boolean.TRUE); //b1
+ dirSeq.add(Boolean.FALSE); //c1
+
+ List fileSeq = new ArrayList();
+ fileSeq.add (Boolean.TRUE); //c1.txt
+
+ mixFilter.setAcceptDir(dirSeq);
+ mixFilter.setAcceptFile(fileSeq);
+
+ ArrayList expectedMixAtoms = new ArrayList();
+ expectedMixAtoms.add("<b1>");
+ expectedMixAtoms.addAll(expectedAtomsC1txt);
+ expectedMixAtoms.add("</b1>");
+
+ ArrayList expectedMixURLs = new ArrayList();
+ expectedMixURLs.add("/a1/b1/");
+ expectedMixURLs.add("/a1/b1/c1.txt");
+ expectedMixURLs.add("/a1/b1/");
+
+ doTest (url, expectedMixAtoms, expectedMixURLs, mixFilter);
+ }
+
+/// SingleFileTest
+
+ public void testSingleFileWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test-jar/a1/b1/c1/d1.txt");
+ doSingleFileTest(fileURL);
+ }
+
+ public void testSingleFileWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1/c1/d1.txt");
+ doSingleFileTest(jarURL);
+ }
+
+ private void doSingleFileTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsD1txt, expectedURLsD1txt, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, removeFiles(expectedAtomsD1txt), removeFiles(expectedAtomsD1txt), noFileFilter);
+ doTest (url, expectedAtomsD1txt, expectedURLsD1txt, noDirFilter);
+ }
+
+//// Empty Directory Test
+
+ public void testEmptyDirectoryWithFile() throws Exception
+ {
+ URL fileURL = getFileURL("test-jar/a1/b1-");
+ doEmptyDirectoryTest(fileURL);
+ }
+
+ public void testEmptyDirectoryWithJar() throws Exception
+ {
+ URL jarURL = getJarURL("/a1/b1-/");
+ doEmptyDirectoryTest(jarURL);
+ }
+
+ private void doEmptyDirectoryTest(URL url) throws Exception
+ {
+ doTest (url, expectedAtomsB1Dash, expectedURLsB1Dash, noFilter);
+ doTest (url, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (url, expectedAtomsB1Dash, expectedURLsB1Dash, noFileFilter);
+ doTest (url, new ArrayList(), new ArrayList(), noDirFilter);
+ }
+
+////
+
+ public void testJarURLs() throws Exception
+ {
+ //Note no / at the end
+ URL jarURL = getJarURL("/a1");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (jarURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ try
+ {
+ //Note extra / at front
+ jarURL = getJarURL("//a1");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (jarURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (jarURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (jarURL, new ArrayList(), new ArrayList(),noDirFilter);
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+
+ try
+ {
+ jarURL = getJarURL("/foobar/");
+ doTest (jarURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ fail ("An invalid jar url did not cause a FileNotFoundException");
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+ }
+
+ public void testFileURLs() throws Exception
+ {
+ //Note no / at the end
+ URL fileURL = getFileURL("test-jar/a1");
+
+ doTest (fileURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ doTest (fileURL, new ArrayList(), new ArrayList(), fullFilter);
+ doTest (fileURL, removeFiles(expectedAtomsA1), removeFiles(expectedURLsA1), noFileFilter);
+ // since we pass it a directory, we can't enter the directory
+ doTest (fileURL, new ArrayList(), new ArrayList(),noDirFilter);
+
+ try
+ {
+ fileURL = new URL("file:foobar");
+ doTest (fileURL, expectedAtomsA1, expectedURLsA1, noFilter);
+ fail ("An invalid file url did not cause a FileNotFoundException");
+ }
+ catch (FileNotFoundException fnfe)
+ {
+ //expected result
+ }
+ }
+
+
+/*----------Utility Metods and Classes ---------------*/
+
+ private URL getFileURL(String name) throws MalformedURLException
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource(name);
+ assertNotNull("Could not load URL for file " + name, url);
+ assertTrue(URLTools.exists(url));
+ return url;
+ }
+
+ private URL getJarURL(String name) throws MalformedURLException
+ {
+ URL url = getFileURL(TEST_JAR_NAME);
+ File jarFile = new File(url.getFile());
+ assertTrue(jarFile.exists());
+ return new URL("jar", "", jarFile.toURL() + "!" + name);
+ }
+
+ public List removeFiles(ArrayList list)
+ {
+ ArrayList newList = (ArrayList)list.clone();
+ ArrayList fileList = new ArrayList();
+
+ Iterator iterator = newList.iterator();
+ while (iterator.hasNext())
+ {
+ String element = (String)(iterator.next());
+ if (element.endsWith(".txt") || element.endsWith(".MF"))
+ {
+ fileList.add(element);
+ }
+ }
+
+ newList.removeAll(fileList);
+
+ return newList;
+ }
+
+ private void doTest(URL url, List expectedAtoms, List expectedURLs, Filter filter) throws Exception
+ {
+ final List atoms = new ArrayList();
+ final List urls = new ArrayList();
+ URLNavigator.visit(url, new URLVisitor()
+ {
+ public void startDir(URL url, String name)
+ {
+ atoms.add("<" + name + ">");
+ urls.add(url);
+ }
+ public void endDir(URL url, String name)
+ {
+ atoms.add("</" + name + ">");
+ urls.add(url);
+ }
+ public void file(URL url, String name)
+ {
+ atoms.add(name);
+ urls.add(url);
+ }
+ }, filter);
+
+ //
+ if (urls.size() != expectedURLs.size())
+ {
+ assertEquals(expectedURLs, urls);
+ fail("URLs size does not match " + urls.size() + "!=" + expectedURLs.size());
+ }
+
+ //
+ assertEquals(expectedAtoms, atoms);
+
+ //
+ for (int i = 0;i < urls.size();i++)
+ {
+ URL entryURL = (URL)urls.get(i);
+ String suffix = (String)expectedURLs.get(i);
+ if (!entryURL.getPath().endsWith(suffix))
+ {
+ fail("URL " + entryURL + " does not end with the suffix " + suffix + " at index " + i);
+ }
+ if (entryURL.getPath().endsWith ("//" + suffix.substring(1)))
+ {
+ fail("URL " + entryURL + " ends with /" + suffix + " at index " + i);
+ }
+ }
+
+ if (filter != null)
+ {
+ assertTrue("The Sequence never completed", filter.SequenceComplete());
+ }
+ }
+
+ /**
+ * Class used to setup URLFilter behavior for tests
+ * @author Matt Wringe
+ */
+ private static class Filter implements URLFilter
+ {
+ private boolean acceptFile;
+ private boolean acceptDir;
+
+ private List acceptFileSequence = null;
+ private Iterator fileIterator = null;
+
+ private List acceptDirSequence = null;
+ private Iterator dirIterator = null;
+
+ /**
+ * Method used to setup URLFilter behavior
+ * @param acceptFile Always accept files
+ * @param acceptDir Always accept files
+ */
+ public Filter (boolean acceptFile, boolean acceptDir)
+ {
+ this.acceptFile = acceptFile;
+ this.acceptDir = acceptDir;
+ }
+
+ /**
+ * Method to setup URLFilter behavior which by default always accepts
+ * files and directories
+ */
+ public Filter()
+ {
+ this.acceptDir = true;
+ this.acceptFile = true;
+ }
+
+ /**
+ * Set the sequence to accept or reject files
+ * @param acceptFileSequence Sequence for accepting files
+ */
+ public void setAcceptFile (List acceptFileSequence)
+ {
+ this.acceptFileSequence = acceptFileSequence;
+ this.fileIterator = acceptFileSequence.iterator();
+ }
+
+ /**
+ * Set the sequence to accept or reject directories
+ * @param acceptDirSequence Sequence for accepting directories
+ */
+ public void setAcceptDir (List acceptDirSequence)
+ {
+ this.acceptDirSequence = acceptDirSequence;
+ this.dirIterator = acceptDirSequence.iterator();
+ }
+
+ /**
+ * Returns true if the sequence is complete or if no sequence has been setup
+ * @return True if the sequence is complete
+ */
+ public boolean SequenceComplete()
+ {
+ if ((dirIterator == null || !dirIterator.hasNext()) && (fileIterator == null || !fileIterator.hasNext()))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public boolean acceptFile(URL url)
+ {
+ if (fileIterator != null)
+ {
+ return ((Boolean)fileIterator.next()).booleanValue();
+ }
+ else
+ {
+ return acceptFile;
+ }
+ }
+
+ public boolean acceptDir(URL url)
+ {
+ if (dirIterator != null)
+ {
+ return ((Boolean)dirIterator.next()).booleanValue();
+ }
+ return acceptDir;
+ }
+ }
+}
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/net/URLToolsTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,267 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.net;
+
+import junit.framework.TestCase;
+import org.apache.log4j.Logger;
+import org.jboss.portal.common.junit.ExtendedAssert;
+import org.jboss.portal.common.net.URLTools;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
+ * @version $Revision: 7379 $
+ * @since 2.4 (May 29, 2006)
+ */
+public class URLToolsTestCase extends TestCase
+{
+
+ /** . */
+ private static final Logger log = Logger.getLogger(URLToolsTestCase.class);
+
+ private static final String MARKUP = "Hello, Anonymous!\n" +
+ "Counter: 0<a href='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmc" +
+ "uamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphd" +
+ "mEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXI" +
+ "AE1tMamF2YS5sYW5nLlN0cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite'>My name is Julien</a><a hr" +
+ "ef='wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci" +
+ "51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMW" +
+ "YNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0cmluZz" +
+ "ut0lbn6R17RwIAAHhwAAAAAXQAA1JveXg*/wsrp_rewrite'>My name is Roy</a><action='wsrp_rewrite?wsrp-urlType=bloc" +
+ "kingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQ" +
+ "ZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQA" +
+ "JdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK" +
+ "3g*/wsrp_rewrite'>counter++</a><a href='wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState" +
+ "=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvT" +
+ "WFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAA" +
+ "AAAF0AAJvcHVyABNbTGphdmEubGFuZy5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAItLXg*/wsrp_rewrite'>counter--</a>";
+
+ public void testExtractURLs()
+ {
+ String markup = MARKUP;
+
+ URLTools.URLMatch[] links = URLTools.extractURLsFrom(markup);
+ assertEquals(4, links.length);
+ URLTools.URLMatch link = links[0];
+ assertEquals("wsrp_rewrite?wsrp-urlType=render&wsrp-navigationalState=rO0ABXNyACdvcmcuamJvc3MucG9ydGFsLnNl" +
+ "cnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXNoTWFwBQ" +
+ "fawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AARuYW1ldXIAE1tMamF2YS5sYW5nLlN0" +
+ "cmluZzut0lbn6R17RwIAAHhwAAAAAXQABkp1bGllbng*/wsrp_rewrite", link.getURLAsString());
+ assertEquals("wsrp_rewrite?wsrp-urlType=blockingAction&wsrp-interactionState=rO0ABXNyACdvcmcuamJvc3MucG9yd" +
+ "GFsLnNlcnZlci51dGlsLlBhcmFtZXRlcnOJoAlMQZGhngIAAUwAA21hcHQAD0xqYXZhL3V0aWwvTWFwO3hwc3IAEWphdmEudXRpbC5IYXN" +
+ "oTWFwBQfawcMWYNEDAAJGAApsb2FkRmFjdG9ySQAJdGhyZXNob2xkeHA_QAAAAAAADHcIAAAAEAAAAAF0AAJvcHVyABNbTGphdmEubGFuZ" +
+ "y5TdHJpbmc7rdJW5-kde0cCAAB4cAAAAAF0AAIrK3g*/wsrp_rewrite", links[2].getURLAsString());
+
+ String url = "wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite";
+ markup = "12345href='" + url + "'76";
+ links = URLTools.extractURLsFrom(markup);
+ link = links[0];
+ int startIndex = 11;
+ assertEquals(startIndex, link.getStart());
+ assertEquals(url.length() + startIndex, link.getEnd());
+ assertEquals(url, markup.substring(link.getStart(), link.getEnd()));
+ assertEquals(url, link.getURLAsString());
+ }
+
+ public void testReplaceURLs()
+ {
+ String markup = URLTools.replaceURLsBy(MARKUP, new String[]{"foo", "bar", "baz", "buz"});
+ String replaced = "Hello, Anonymous!\nCounter: 0<a href='foo'>My name is Julien</a><a href='bar'>My name is Roy</a>" +
+ "<action='baz'>counter++</a><a href='buz'>counter--</a>";
+ assertEquals(replaced, markup);
+ assertEquals(replaced, URLTools.replaceURLsBy(replaced, (String[])null));
+
+ String mixed = "<a href='wsrp_rewrite?wsrp-urlType=render&wsrp-mode=help/wsrp_rewrite'>My name is Julien</a>" +
+ "<a href='bar'>My name is Roy</a>";
+ assertEquals("<a href='foo'>My name is Julien</a><a href='bar'>My name is Roy</a>",
+ URLTools.replaceURLsBy(mixed, new URLTools.URLReplacementGenerator()
+ {
+ public String getReplacementFor(int currentIndex, URLTools.URLMatch currentMatch)
+ {
+ String urlAsString = currentMatch.getURLAsString();
+ if (urlAsString.startsWith("wsrp_rewrite"))
+ {
+ return "foo";
+ }
+ return urlAsString;
+ }
+ }));
+ }
+
+ public void testReplaceAllPorts()
+ {
+ String original = "<wsdl:definitions targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
+ " xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
+ " xmlns='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
+ " xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
+ " xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
+ " <import namespace='urn:oasis:names:tc:wsrp:v1:bind' location='wsrp_v1_bindings.wsdl'/>\n" +
+ " <wsdl:service name='WSRPService'>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP' name='WSRPBaseService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/ServiceDescriptionService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP' name='WSRPServiceDescriptionService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/MarkupService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Registration_Binding_SOAP' name='WSRPRegistrationService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/RegistrationService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_PortletManagement_Binding_SOAP' name='WSRPPortletManagementService'>\n" +
+ " <soap:address location='http://localhost/portal-wsrp/PortletManagementService'/>\n" +
+ " </wsdl:port>\n" +
+ " </wsdl:service>\n" +
+ "</wsdl:definitions>";
+ String result = "<wsdl:definitions targetNamespace='urn:oasis:names:tc:wsrp:v1:wsdl'\n" +
+ " xmlns:bind='urn:oasis:names:tc:wsrp:v1:bind'\n" +
+ " xmlns='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'\n" +
+ " xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'\n" +
+ " xmlns:intf='urn:oasis:names:tc:wsrp:v1:intf'\n" +
+ " xmlns:tns='urn:oasis:names:tc:wsrp:v1:wsdl'>\n" +
+ " <import namespace='urn:oasis:names:tc:wsrp:v1:bind' location='wsrp_v1_bindings.wsdl'/>\n" +
+ " <wsdl:service name='WSRPService'>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Markup_Binding_SOAP' name='WSRPBaseService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/ServiceDescriptionService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_ServiceDescription_Binding_SOAP' name='WSRPServiceDescriptionService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/MarkupService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_Registration_Binding_SOAP' name='WSRPRegistrationService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/RegistrationService'/>\n" +
+ " </wsdl:port>\n" +
+ " <wsdl:port binding='bind:WSRP_v1_PortletManagement_Binding_SOAP' name='WSRPPortletManagementService'>\n" +
+ " <soap:address location='http://localhost:8888/portal-wsrp/PortletManagementService'/>\n" +
+ " </wsdl:port>\n" +
+ " </wsdl:service>\n" +
+ "</wsdl:definitions>";
+
+ assertEquals(result, URLTools.replaceURLsBy(original, new URLTools.PortReplacementGenerator(8888)));
+ }
+
+ public void testReplaceServerPort()
+ {
+ assertEquals("http://hostname:8088/some/path", URLTools.replaceServerPortInURL("http://hostname:8080/some/path", 8088));
+ assertEquals("https://hostname:8088/some/path", URLTools.replaceServerPortInURL("https://hostname:8080/some/path", 8088));
+ assertEquals("http://hostname:8088/some/path", URLTools.replaceServerPortInURL("http://hostname/some/path", 8088));
+ assertEquals("https://hostname:8088/some/path", URLTools.replaceServerPortInURL("https://hostname/some/path", 8088));
+ }
+
+ public void testExistsURL()
+ {
+ assertFalse(URLTools.exists(null, true));
+
+
+ }
+
+ public void testURLExistsTimeout() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractTimeoutServer(8080)
+ {
+ protected void doClient()
+ {
+ boolean exist = true;
+ try
+ {
+ URL url = new URL("http://localhost:8080/");
+ exist = URLTools.exists(url, 500);
+ }
+ catch (MalformedURLException e)
+ {
+ log.error("Cannot create URL", e);
+ fail("Cannot create URL " + e.getMessage());
+ }
+
+ //
+ assertFalse("Was not expecting the URL to exist", exist);
+ }
+ };
+
+ //
+ server.performInteraction();
+ }
+
+ public void testURLPerformGETTimeout() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractTimeoutServer(8080)
+ {
+ protected void doClient()
+ {
+ byte[] bytes = null;
+ try
+ {
+ URL url = new URL("http://localhost:8080/");
+ bytes = URLTools.getContent(url, 500, 500);
+ }
+ catch (MalformedURLException e)
+ {
+ log.error("Cannot create URL", e);
+ fail("Cannot create URL " + e.getMessage());
+ }
+
+ //
+ assertNull("Was not expecting the URL GET to return a non null value", bytes);
+ }
+ };
+
+ //
+ server.performInteraction();
+ }
+
+ public void testURLPerformGET() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractOKServer(8080)
+ {
+
+ protected void doClient() throws Exception
+ {
+ URL url = new URL("http://localhost:8080/");
+ byte[] bytes = URLTools.getContent(url, 5000, 5000);
+ ExtendedAssert.assertEquals("CAFEBABE".getBytes("UTF-8"), bytes);
+ }
+ };
+
+ //
+ server.performInteraction();
+ }
+
+ public void testURLExists() throws Exception
+ {
+ AbstractSynchronizedServer server = new AbstractSynchronizedServer.AbstractOKServer(8080)
+ {
+
+ protected void doClient() throws Exception
+ {
+ URL url = new URL("http://localhost:8080/");
+ boolean exists = URLTools.exists(url, 5000);
+ ExtendedAssert.assertTrue("Was expecting the URL to exist", exists);
+ }
+ };
+
+ //
+ server.performInteraction();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class1.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class Class1
+{
+
+ private void privateMethod()
+ {
+ }
+
+ public abstract void publicAbstractMethodOfClass1();
+
+ protected abstract void protectedAbstractMethodOfClass1();
+
+ private void privateMethodOfClass1()
+ {
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class2.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Class2 extends Class1
+{
+
+ private void privateMethod()
+ {
+ }
+
+ public void publicAbstractMethodOfClass1()
+ {
+ }
+
+ protected void protectedAbstractMethodOfClass1()
+ {
+ }
+
+ public void publicMethodOfClass2()
+ {
+ }
+
+ protected void protectedMethodOfClass2()
+ {
+ }
+
+ private void privateMethodOfClass2()
+ {
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/Class3.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Class3 extends Class2
+{
+ private void privateMethod()
+ {
+ }
+
+ private void privateMethodOfClass3()
+ {
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ModifierTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.reflect.Modifier;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ModifierTestCase extends TestCase
+{
+
+ public void testIsReadableProperty() throws Exception
+ {
+ try
+ {
+ Modifier.isReadableProperty(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ assertTrue(Modifier.isReadableProperty(Bean.class.getDeclaredField("publicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("privateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("protectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("packageProtectedField")));
+
+ assertTrue(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalPublicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalPrivateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalProtectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalPackageProtectedField")));
+
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticPublicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticPrivateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticProtectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("staticPackageProtectedField")));
+
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticPublicField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticPrivateField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticProtectedField")));
+ assertFalse(Modifier.isReadableProperty(Bean.class.getDeclaredField("finalStaticPackageProtectedField")));
+ }
+
+ public void testIsWritableProperty() throws Exception
+ {
+ try
+ {
+ Modifier.isWritableProperty(null);
+ fail("Was expecting an IAE");
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ assertTrue(Modifier.isWritableProperty(Bean.class.getDeclaredField("publicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("privateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("protectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("packageProtectedField")));
+
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalPublicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalPrivateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalProtectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalPackageProtectedField")));
+
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticPublicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticPrivateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticProtectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("staticPackageProtectedField")));
+
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticPublicField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticPrivateField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticProtectedField")));
+ assertFalse(Modifier.isWritableProperty(Bean.class.getDeclaredField("finalStaticPackageProtectedField")));
+ }
+
+ private static class Bean
+ {
+ public Object publicField;
+ private Object privateField;
+ protected Object protectedField;
+ Object packageProtectedField;
+
+ final public Object finalPublicField = new Object();
+ final private Object finalPrivateField = new Object();
+ final protected Object finalProtectedField = new Object();
+ final Object finalPackageProtectedField = new Object();
+
+ static public Object staticPublicField;
+ static private Object staticPrivateField;
+ static protected Object staticProtectedField;
+ static Object staticPackageProtectedField;
+
+ final static public Object finalStaticPublicField = new Object();
+ final static private Object finalStaticPrivateField = new Object();
+ final static protected Object finalStaticProtectedField = new Object();
+ final static Object finalStaticPackageProtectedField = new Object();
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/reflect/ReflectionTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.reflect;
+
+import junit.framework.TestCase;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.jboss.portal.common.reflect.Reflection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ReflectionTestCase extends TestCase
+{
+
+ public void testClass1()
+ {
+ assertEquals(Class1.class, "privateMethod", Modifier.PRIVATE, Reflection.findMethod(Class1.class, "privateMethod", new Class[0]));
+
+ //
+ assertEquals(Class1.class, "privateMethodOfClass1", Modifier.PRIVATE, Reflection.findMethod(Class1.class, "privateMethodOfClass1", new Class[0]));
+ assertEquals(Class1.class, "publicAbstractMethodOfClass1", Modifier.PUBLIC | Modifier.ABSTRACT, Reflection.findMethod(Class1.class, "publicAbstractMethodOfClass1", new Class[0]));
+ assertEquals(Class1.class, "protectedAbstractMethodOfClass1", Modifier.PROTECTED | Modifier.ABSTRACT, Reflection.findMethod(Class1.class, "protectedAbstractMethodOfClass1", new Class[0]));
+ }
+
+ public void testClass2()
+ {
+ assertEquals(Class2.class, "privateMethod", Modifier.PRIVATE, Reflection.findMethod(Class2.class, "privateMethod", new Class[0]));
+
+ //
+ assertEquals(Class1.class, "privateMethodOfClass1", Modifier.PRIVATE, Reflection.findMethod(Class2.class, "privateMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "publicAbstractMethodOfClass1", Modifier.PUBLIC, Reflection.findMethod(Class2.class, "publicAbstractMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "protectedAbstractMethodOfClass1", Modifier.PROTECTED, Reflection.findMethod(Class2.class, "protectedAbstractMethodOfClass1", new Class[0]));
+
+ //
+ assertEquals(Class2.class, "privateMethodOfClass2", Modifier.PRIVATE, Reflection.findMethod(Class2.class, "privateMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "publicMethodOfClass2", Modifier.PUBLIC, Reflection.findMethod(Class2.class, "publicMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "protectedMethodOfClass2", Modifier.PROTECTED, Reflection.findMethod(Class2.class, "protectedMethodOfClass2", new Class[0]));
+ }
+
+ public void testClass3()
+ {
+ assertEquals(Class3.class, "privateMethod", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethod", new Class[0]));
+
+ //
+ assertEquals(Class1.class, "privateMethodOfClass1", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "publicAbstractMethodOfClass1", Modifier.PUBLIC, Reflection.findMethod(Class3.class, "publicAbstractMethodOfClass1", new Class[0]));
+ assertEquals(Class2.class, "protectedAbstractMethodOfClass1", Modifier.PROTECTED, Reflection.findMethod(Class3.class, "protectedAbstractMethodOfClass1", new Class[0]));
+
+ //
+ assertEquals(Class2.class, "privateMethodOfClass2", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "publicMethodOfClass2", Modifier.PUBLIC, Reflection.findMethod(Class3.class, "publicMethodOfClass2", new Class[0]));
+ assertEquals(Class2.class, "protectedMethodOfClass2", Modifier.PROTECTED, Reflection.findMethod(Class3.class, "protectedMethodOfClass2", new Class[0]));
+
+ //
+ assertEquals(Class3.class, "privateMethodOfClass3", Modifier.PRIVATE, Reflection.findMethod(Class3.class, "privateMethodOfClass3", new Class[0]));
+ }
+
+ private void assertEquals(Class declaringClass, String methodName, int modifiers, Method effectiveMethod)
+ {
+ assertNotNull(effectiveMethod);
+ assertEquals(declaringClass, effectiveMethod.getDeclaringClass());
+ assertEquals(modifiers, effectiveMethod.getModifiers());
+ assertEquals(methodName, effectiveMethod.getName());
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CharBufferTestCase extends TestCase
+{
+
+ private FastURLEncoder encoder = FastURLEncoder.getUTF8Instance();
+
+ public void testUTF8EncodedStringAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("/ a$\u0400", encoder);
+ assertEquals("%2F+a%24%D0%80", buffer.asString());
+ }
+
+ public void testStringAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("abc");
+ assertEquals("abc", buffer.asString());
+ }
+
+ public void testCharArrayAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("abc".toCharArray());
+ assertEquals("abc", buffer.asString());
+ }
+
+ public void testCharsAppend()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append('a').append('b').append('c');
+ assertEquals("abc", buffer.asString());
+ }
+
+ public void testReset()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ buffer.append("abc".toCharArray());
+ assertEquals("abc", buffer.asString());
+ buffer.reset();
+ buffer.append("def".toCharArray());
+ assertEquals("def", buffer.asString());
+ }
+
+ public void testCharArrayAppendThrowsIAE()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ try
+ {
+ buffer.append((char[])null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testStringAppendThrowsIAE()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ try
+ {
+ buffer.append((String)null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testUTF8EncodedAppendThrowsIAE()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+ try
+ {
+ buffer.append(null, encoder);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ try
+ {
+ buffer.append("abc", null);
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/CharToByteEncoderTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.CharToByteEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CharToByteEncoderTestCase extends TestCase
+{
+
+ public void testCorrectness()
+ {
+ CharToByteEncoder encoder = new CharToByteEncoder.Generic("UTF8");
+
+ //
+ for (int i = 0;i <= 0x10FFFD;i++)
+ {
+ char c = (char)i;
+ int type = Character.getType(c);
+ byte[] r = encoder.encode(c);
+ if (type == Character.SURROGATE || type == Character.PRIVATE_USE)
+ {
+ if (r.length != 0)
+ {
+ fail("Char " + i + " has length " + r.length);
+ }
+ }
+ else
+ {
+ if (r.length < 1)
+ {
+ fail("Char " + i + " has length " + r.length);
+ }
+ }
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLDecoderTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,249 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.FastURLDecoder;
+import org.jboss.portal.common.text.CharEncoder;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.MalformedInputException;
+
+import java.net.URLEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FastURLDecoderTestCase extends TestCase
+{
+
+ public void testEncodeThrowsIAE() throws Exception
+ {
+ CharEncoder encoder = FastURLDecoder.getUTF8Instance();
+ try
+ {
+ encoder.encode(new char[10], -1, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, -1, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 15, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, 6, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(null, 0, 5, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((char[])null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((CharSequence)null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ encoder.encode(new char[10], 0, 10, null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode('A', null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("abc", null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEncode() throws Exception
+ {
+ FastURLDecoder encoder = FastURLDecoder.getUTF8Instance();
+ StringBuffer tmp = new StringBuffer();
+ for (int i = 0;i < 512;i++)
+ {
+ tmp.append((char)i);
+ }
+ CharBuffer out = new CharBuffer();
+ String s = tmp.toString();
+ String t = URLEncoder.encode(s, "UTF8");
+ encoder.encode(t, out);
+ assertEquals(s, out.asString());
+ }
+
+ public void testEncodeMalformedInput()
+ {
+ testEncodeMalformedInput(FastURLDecoder.getUTF8StrictInstance(), true);
+ testEncodeMalformedInput(FastURLDecoder.getUTF8Instance(), false);
+ }
+
+ private void testEncodeMalformedInput(FastURLDecoder encoder, boolean strict)
+ {
+ try
+ {
+ encoder.encode("%0T", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%T0", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%0\u0100", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%\u01000", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%0", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("%FC", new CharBuffer());
+ fail();
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+
+ //
+ if (strict)
+ {
+ try
+ {
+ encoder.encode(";", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("\u0100", new CharBuffer());
+ fail("Was expecting a malformed input exception");
+ }
+ catch (MalformedInputException expected)
+ {
+ }
+ }
+ else
+ {
+ CharBuffer tmp = new CharBuffer();
+
+ //
+ encoder.encode(";", tmp);
+ assertEquals(";", tmp.asString());
+
+ //
+ tmp.reset();
+ encoder.encode("\u0100", tmp);
+ assertEquals("\u0100", tmp.asString());
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/FastURLEncoderTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,147 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.CharBuffer;
+import org.jboss.portal.common.text.CharEncoder;
+import org.jboss.portal.common.text.FastURLEncoder;
+
+import java.net.URLEncoder;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class FastURLEncoderTestCase extends TestCase
+{
+
+ public void testEncodeThrowsIAE() throws Exception
+ {
+ CharEncoder encoder = FastURLEncoder.getUTF8Instance();
+ try
+ {
+ encoder.encode(new char[10], -1, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, -1, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 15, 0, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], 5, 6, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(null, 0, 5, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((char[])null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode((CharSequence)null, new CharBuffer());
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+
+ //
+ try
+ {
+ encoder.encode(new char[10], 0, 10, null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode(new char[10], null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode('A', null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ try
+ {
+ encoder.encode("abc", null);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+
+ public void testEncode() throws Exception
+ {
+ FastURLEncoder encoder = FastURLEncoder.getUTF8Instance();
+ StringBuffer tmp = new StringBuffer();
+ for (int i = 0; i < 512; i++)
+ {
+ tmp.append((char)i);
+ }
+ String s = tmp.toString();
+ String u1 = encoder.encode(s);
+ String u2 = URLEncoder.encode(s, "UTF8");
+ assertEquals(u2, u1);
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/text/TextToolsTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.text;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.text.TextTools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TextToolsTestCase extends TestCase
+{
+
+ public void testIsAlphaNumeric()
+ {
+ assertForChar(false, 0, '0');
+ assertForChar(true, '0', '9' + 1);
+ assertForChar(false, '9' + 1, 'A');
+ assertForChar(true, 'A', 'Z' + 1);
+ assertForChar(false, 'Z' + 1, 'a');
+ assertForChar(true, 'a', 'z' + 1);
+ assertForChar(false, 'z' + 1, 512);
+ }
+
+ private void assertForChar(boolean result, int from, int to)
+ {
+ while (from < to)
+ {
+ assertEquals(result, TextTools.isAlphaNumeric((char)(from++)));
+ }
+ }
+
+ public void testToHex()
+ {
+ assertEquals('0', TextTools.toHex(0));
+ assertEquals('1', TextTools.toHex(1));
+ assertEquals('2', TextTools.toHex(2));
+ assertEquals('3', TextTools.toHex(3));
+ assertEquals('4', TextTools.toHex(4));
+ assertEquals('5', TextTools.toHex(5));
+ assertEquals('6', TextTools.toHex(6));
+ assertEquals('7', TextTools.toHex(7));
+ assertEquals('8', TextTools.toHex(8));
+ assertEquals('9', TextTools.toHex(9));
+ assertEquals('A', TextTools.toHex(10));
+ assertEquals('B', TextTools.toHex(11));
+ assertEquals('C', TextTools.toHex(12));
+ assertEquals('D', TextTools.toHex(13));
+ assertEquals('E', TextTools.toHex(14));
+ assertEquals('F', TextTools.toHex(15));
+ for (int i = 16;i < 512;i++)
+ {
+ try
+ {
+ TextTools.toHex(i);
+ fail("Was expecting an IAE at index=" + i);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+ for (int i = -512;i < 0;i++)
+ {
+ try
+ {
+ TextTools.toHex(i);
+ fail("Was expecting an IAE at index=" + i);
+ }
+ catch (IllegalArgumentException expected)
+ {
+ }
+ }
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionBuilderTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionBuilderTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionBuilderTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,158 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CollectionBuilder;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CollectionBuilderTestCase extends TestCase
+{
+
+ public void testHashSet1()
+ {
+ HashSet expected = new HashSet();
+ assertEquals(expected, CollectionBuilder.hashSet().get());
+ }
+
+ public void testHashSet2()
+ {
+ HashSet<String> expected = new HashSet<String>();
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.hashSet("a").get());
+ }
+
+ public void testHashSet3()
+ {
+ HashSet<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.hashSet("a").add("b").get());
+ }
+
+ public void testHashSet4()
+ {
+ HashSet<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.hashSet("a").add("b").add("a").get());
+ }
+
+ public void testArrayList1()
+ {
+ ArrayList expected = new ArrayList();
+ assertEquals(expected, CollectionBuilder.arrayList().get());
+ }
+
+ public void testArrayList2()
+ {
+ ArrayList<String> expected = new ArrayList<String>();
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.arrayList("a").get());
+ }
+
+ public void testArrayList3()
+ {
+ ArrayList<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.arrayList("a").add("b").get());
+ }
+
+ public void testArrayList4()
+ {
+ ArrayList<String> expected = new ArrayList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.arrayList("a").add("b").add("a").get());
+ }
+
+ public void testLinkedList1()
+ {
+ LinkedList expected = new LinkedList();
+ assertEquals(expected, CollectionBuilder.linkedList().get());
+ }
+
+ public void testLinkedList2()
+ {
+ LinkedList<String> expected = new LinkedList<String>();
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.linkedList("a").get());
+ }
+
+ public void testLinkedList3()
+ {
+ LinkedList<String> expected = new LinkedList<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.linkedList("a").add("b").get());
+ }
+
+ public void testLinkedList4()
+ {
+ LinkedList<String> expected = new LinkedList<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.linkedList("a").add("b").add("a").get());
+ }
+
+ public void testSet1()
+ {
+ Set<String> expected = new HashSet<String>();
+ assertEquals(expected, CollectionBuilder.create(new HashSet<String>()).get());
+ }
+
+ public void testSet2()
+ {
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.create(new HashSet<String>()).add("a").get());
+ }
+
+ public void testSet3()
+ {
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ assertEquals(expected, CollectionBuilder.create(new HashSet<String>()).add("a").add("b").get());
+ }
+
+ public void testSet4()
+ {
+ Set<String> expected = new HashSet<String>();
+ expected.add("a");
+ expected.add("b");
+ expected.add("a");
+ assertEquals(expected, CollectionBuilder.create(new HashSet<String>()).add("a").add("b").add("a").get());
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionMapTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionMapTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/CollectionMapTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,220 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CollectionMap;
+import org.jboss.portal.common.util.ListMap;
+import org.jboss.portal.common.util.SetMap;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class CollectionMapTestCase extends TestCase
+{
+
+ private Key k1 = new Key();
+ private Value v1 = new Value();
+ private Value v2 = new Value();
+ private ValueExt ve1 = new ValueExt();
+ private ValueExt ve2 = new ValueExt();
+
+ public void testNormal()
+ {
+ testNormal(new SetMap<Key, Value>());
+ testNormal(new ListMap<Key, Value>());
+ }
+
+ public void testRemoveAbsent()
+ {
+ testRemoveAbsent(new SetMap<Key, Value>());
+ testRemoveAbsent(new ListMap<Key, Value>());
+ }
+
+ public void testRemoveNull()
+ {
+ testRemoveNull(new SetMap<Key, Value>());
+ testRemoveNull(new ListMap<Key, Value>());
+ }
+
+ public void testWithNullValue()
+ {
+ testWithNullValue(new SetMap<Key, Value>());
+ testWithNullValue(new ListMap<Key, Value>());
+ }
+
+ public void testClassCastException()
+ {
+ testClassCastException(new SetMap<Key, Value>());
+ testClassCastException(new ListMap<Key, Value>());
+ }
+
+ public void testThrowNPE()
+ {
+ testThrowNPE(new SetMap<Key, Value>());
+ testThrowNPE(new ListMap<Key, Value>());
+ }
+
+ private void testNormal(CollectionMap<Key, Value> map)
+ {
+ assertFalse(map.contains(k1, v1));
+ assertFalse(map.contains(k1, ve1));
+ map.put(k1, v1);
+ assertTrue(map.contains(k1, v1));
+ assertFalse(map.contains(k1, ve1));
+ map.put(k1, ve1);
+ assertTrue(map.contains(k1, v1));
+ assertTrue(map.contains(k1, ve1));
+ map.remove(k1, v1);
+ assertFalse(map.contains(k1, v1));
+ assertTrue(map.contains(k1, ve1));
+ map.remove(k1, ve1);
+ assertFalse(map.contains(k1, v1));
+ assertFalse(map.contains(k1, ve1));
+ }
+
+ private void testRemoveAbsent(CollectionMap<Key, Value> map)
+ {
+ map.put(k1, v1);
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(v1));
+ map.remove(k1, v2);
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(v1));
+ }
+
+ private void testRemoveNull(CollectionMap<Key, Value> map)
+ {
+ map.put(k1, v1);
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(v1));
+ map.remove(k1, null);
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(v1));
+ }
+
+ private void testWithNullValue(CollectionMap<Key, Value> map)
+ {
+ assertFalse(map.contains(k1, null));
+ map.put(k1, null);
+ assertTrue(map.contains(k1, null));
+ assertNotNull(map.get(k1));
+ assertEquals(1, map.get(k1).size());
+ assertTrue(map.get(k1).contains(null));
+ map.remove(k1, null);
+ assertFalse(map.contains(k1, null));
+ assertEquals(null, map.get(k1));
+ }
+
+ private void testClassCastException(CollectionMap<Key, Value> map)
+ {
+ CollectionMap sm2 = map;
+ sm2.put(k1, new Object());
+ Iterator<Value> i = map.iterator(k1);
+ List<Value> lst = get(i);
+ try
+ {
+ Value v = lst.get(0);
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ private void testThrowNPE(CollectionMap<Key, Value> map)
+ {
+ try
+ {
+ map.put(null, v1);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.remove(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.remove(null, v1);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.contains(null, v1);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.iterator(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ }
+
+ private <V> List<V> get(Iterator<V> i)
+ {
+ List<V> list = new ArrayList<V>();
+ while (i.hasNext())
+ {
+ V v = i.next();
+ list.add(v);
+ }
+ return list;
+ }
+
+ private static final class Key
+ {
+ }
+
+ private static class Value
+ {
+ }
+
+ private static class ValueExt extends Value
+ {
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/MapBuilderTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/MapBuilderTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/MapBuilderTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,151 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.MapBuilder;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class MapBuilderTestCase extends TestCase
+{
+
+ public void testHashMap1()
+ {
+ assertEquals(new HashMap(), MapBuilder.hashMap().get());
+ }
+
+ public void testHashMap2()
+ {
+ HashMap<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "b");
+ assertEquals(expected, MapBuilder.hashMap("a", "b").get());
+ }
+
+ public void testHashMap3()
+ {
+ HashMap<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "b");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.hashMap("a", "b").put("c", "d").get());
+ }
+
+ public void testHashMap4()
+ {
+ HashMap<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "d");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.hashMap("a", "b").put("c", "d").put("a", "d").get());
+ }
+
+ public void testLinkedHashMap1()
+ {
+ assertEquals(new LinkedHashMap(), MapBuilder.linkedHashMap().get());
+ }
+
+ public void testLinkedHashMap2()
+ {
+ LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>();
+ expected.put("a", "b");
+ assertEquals(expected, MapBuilder.linkedHashMap("a", "b").get());
+ }
+
+ public void testLinkedHashMap3()
+ {
+ LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>();
+ expected.put("a", "b");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.linkedHashMap("a", "b").put("c", "d").get());
+ }
+
+ public void testLinkedHashMap4()
+ {
+ LinkedHashMap<String, String> expected = new LinkedHashMap<String, String>();
+ expected.put("a", "d");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.linkedHashMap("a", "b").put("c", "d").put("a", "d").get());
+ }
+
+ public void testTreeMap1()
+ {
+ assertEquals(new TreeMap(), MapBuilder.treeMap().get());
+ }
+
+ public void testTreeMap2()
+ {
+ TreeMap<String, String> expected = new TreeMap<String, String>();
+ expected.put("a", "b");
+ assertEquals(expected, MapBuilder.treeMap("a", "b").get());
+ }
+
+ public void testTreeMap3()
+ {
+ TreeMap<String, String> expected = new TreeMap<String, String>();
+ expected.put("a", "b");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.treeMap("a", "b").put("c", "d").get());
+ }
+
+ public void testTreeMap4()
+ {
+ TreeMap<String, String> expected = new TreeMap<String, String>();
+ expected.put("a", "d");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.treeMap("a", "b").put("c", "d").put("a", "d").get());
+ }
+
+ public void testMap1()
+ {
+ assertEquals(new HashMap(), MapBuilder.create(new HashMap<String, String>()).get());
+ }
+
+ public void testMap2()
+ {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "b");
+ assertEquals(expected, MapBuilder.create(new HashMap<String, String>()).put("a", "b").get());
+ }
+
+ public void testMap3()
+ {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "b");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.create(new HashMap<String, String>()).put("a", "b").put("c", "d").get());
+ }
+
+ public void testMap4()
+ {
+ Map<String, String> expected = new HashMap<String, String>();
+ expected.put("a", "d");
+ expected.put("c", "d");
+ assertEquals(expected, MapBuilder.create(new HashMap<String, String>()).put("a", "b").put("c", "d").put("a", "d").get());
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/TypedMapTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/TypedMapTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/TypedMapTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,462 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.CollectionBuilder;
+import org.jboss.portal.common.util.TypedMap;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class TypedMapTestCase extends TestCase
+{
+
+ private StringToInteger sti;
+
+ private Map<String, Integer> delegate;
+
+ private StringToIntegerMap map;
+
+ public TypedMapTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ delegate = new HashMap<String, Integer>();
+ sti = new StringToInteger();
+ map = new StringToIntegerMap(delegate, sti);
+ }
+
+ public void testGetWithBrokenGetInternalValue()
+ {
+ sti.internalValueReturnsNull = true;
+ map.get("abc");
+ delegate.put("abc", new Integer(0));
+ map.get("abc");
+ }
+
+ public void testPutWithBrokenGetInternalValue()
+ {
+ sti.internalValueReturnsNull = true;
+ try
+ {
+ map.put("abc", "0");
+ fail();
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ }
+
+ public void testRemoveWithBrokenGetInternalValue()
+ {
+ sti.internalValueReturnsNull = true;
+ map.remove("abc");
+ }
+
+ public void testRemoveWithBrokenGetExternalValue()
+ {
+ sti.externalValueReturnsNull = true;
+ map.remove("abc");
+ delegate.put("abc", new Integer(0));
+ try
+ {
+ map.remove("abc");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testGetWithBrokenGetExternalValue()
+ {
+ sti.externalValueReturnsNull = true;
+ map.get("abc");
+ delegate.put("abc", new Integer(0));
+ try
+ {
+ map.get("abc");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testPutWithBrokenGetExternalValue()
+ {
+ sti.externalValueReturnsNull = true;
+ map.put("abc", "0");
+ try
+ {
+ map.put("abc", "0");
+ fail();
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ }
+
+ public void testGetWithInvalidInternalValue()
+ {
+ ((Map)delegate).put("abc", "0");
+ try
+ {
+ map.get("abc");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testPutWithInvalidInternalValue()
+ {
+ ((Map)delegate).put("abc", "0");
+ try
+ {
+ map.put("abc", "0");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testRemoveWithInvalidInternalValue()
+ {
+ ((Map)delegate).put("abc", "0");
+ try
+ {
+ map.remove("abc");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testRemove()
+ {
+ assertNull(map.remove("abc"));
+ delegate.put("abc", new Integer(0));
+ assertEquals("0", map.remove("abc"));
+ assertTrue(delegate.isEmpty());
+ }
+
+ public void testPut()
+ {
+ map.put("abc", "0");
+ assertEquals(Collections.singletonMap("abc", new Integer(0)), delegate);
+ }
+
+ public void testGet()
+ {
+ assertNull(map.get("abc"));
+ delegate.put("abc", new Integer(0));
+ assertEquals(Collections.singletonMap("abc", "0"), map);
+ }
+
+ public void testContainsKeyWithInvalidKey()
+ {
+ try
+ {
+ map.containsKey(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.containsKey(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testContainsValueWithInvalidValue()
+ {
+ try
+ {
+ map.containsValue(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.containsValue(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testRemoveWithInvalidKey()
+ {
+ try
+ {
+ map.remove(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.remove(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testGetWithInvalidKey()
+ {
+ try
+ {
+ map.get(null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ map.get(new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testPutWithInvalidKey()
+ {
+ try
+ {
+ map.put(null, "0");
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ ((Map)map).put(new Object(), "0");
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testWithPutInvalidValue()
+ {
+ try
+ {
+ map.put("", null);
+ fail();
+ }
+ catch (NullPointerException expected)
+ {
+ }
+ try
+ {
+ ((Map)map).put("", new Object());
+ fail();
+ }
+ catch (ClassCastException expected)
+ {
+ }
+ }
+
+ public void testEquals()
+ {
+ Map<String, Integer> leftDelegate = new HashMap<String, Integer>();
+ StringToIntegerMap left = new StringToIntegerMap(leftDelegate, sti);
+ leftDelegate.put("abc", new Integer(0));
+ Map right = new HashMap();
+
+ //
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.put("abc", new Object());
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.put("abc", "abc");
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.put("abc", "0");
+ assertTrue(left.equals(right));
+ assertTrue(right.equals(left));
+
+ //
+ right.put("def", "1");
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.remove("def");
+ right.put(null, "0");
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+
+ //
+ right.remove(null);
+ right.put("def", null);
+ assertFalse(left.equals(right));
+ assertFalse(right.equals(left));
+ }
+
+ public void testEntrySetRetainAll()
+ {
+ Map right = new HashMap();
+ right.put("abc", new Integer(0));
+ right.put("def", new Integer(1));
+ right.put("ghi", new Integer(2));
+
+ //
+ Map<String, Integer> leftDelegate = new HashMap<String, Integer>();
+ StringToIntegerMap left = new StringToIntegerMap(leftDelegate, sti);
+ leftDelegate.putAll(right);
+
+ try
+ {
+ left.keySet().retainAll(null);
+ fail("Was expecting NPE");
+ }
+ catch (NullPointerException expected)
+ {
+ }
+
+ //
+ boolean changed = left.keySet().retainAll(CollectionBuilder.hashSet().add("abc").add("def").add("ghi").get());
+ assertFalse(changed);
+ assertEquals(right, leftDelegate);
+
+ //
+ changed = left.keySet().retainAll(CollectionBuilder.hashSet().add("def").get());
+ assertTrue(changed);
+ right.remove("abc");
+ right.remove("ghi");
+ assertEquals(right, leftDelegate);
+ }
+
+ public static class StringToIntegerMap extends TypedMap<String, String, String, Integer>
+ {
+ public StringToIntegerMap(Map<String, Integer> map, StringToInteger sti)
+ {
+ super(map, new StringToString(), sti);
+ }
+ }
+
+ private static class StringToString extends TypedMap.Converter<String, String>
+ {
+ protected String getInternal(String external) throws IllegalArgumentException, ClassCastException
+ {
+ return external;
+ }
+ protected String getExternal(String internal)
+ {
+ return internal;
+ }
+ protected boolean equals(String left, String right)
+ {
+ return left.equals(right);
+ }
+ }
+
+ private static class StringToInteger extends TypedMap.Converter<String, Integer>
+ {
+
+ /** . */
+ boolean internalValueReturnsNull = false;
+
+ /** . */
+ boolean externalValueReturnsNull = false;
+
+ protected Integer getInternal(String external) throws IllegalArgumentException, ClassCastException
+ {
+ assertNotNull(external);
+
+ //
+ if (internalValueReturnsNull)
+ {
+ return null;
+ }
+ try
+ {
+ return new Integer(external);
+ }
+ catch (NumberFormatException e)
+ {
+ IllegalArgumentException iae = new IllegalArgumentException();
+ iae.initCause(e);
+ throw iae;
+ }
+ }
+
+ protected String getExternal(Integer internal)
+ {
+ assertNotNull(internal);
+
+ //
+ if (externalValueReturnsNull)
+ {
+ return null;
+ }
+
+ //
+ return internal.toString();
+ }
+
+ protected boolean equals(Integer left, Integer right)
+ {
+ assertNotNull(left);
+ assertNotNull(right);
+ return left.intValue() == right.intValue();
+ }
+ }
+}
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/VersionTestCase.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/VersionTestCase.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/java/org/jboss/portal/test/common/util/VersionTestCase.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.test.common.util;
+
+import junit.framework.TestCase;
+import org.jboss.portal.common.util.Version;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class VersionTestCase extends TestCase
+{
+
+ /** . */
+ private final Version.Qualifier GAQualifer = new Version.Qualifier(Version.Qualifier.Prefix.GA);
+
+ public void testIllegalNameThrowsIAE()
+ {
+ try
+ {
+ new Version(null, 0, 0, 0, GAQualifer, "code");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIllegalMajorThrowsIAE()
+ {
+ try
+ {
+ new Version("name", -1, 0, 0, GAQualifer, "code");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIllegalMinorThrowsIAE()
+ {
+ try
+ {
+ new Version("name", 0, -1, 0, GAQualifer, "code");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIllegalQualifierThrowsIAE()
+ {
+ try
+ {
+ new Version("name", 0, 0, 0, null, "code");
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+
+ //
+ try
+ {
+ new Version.Qualifier(null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+
+ //
+ try
+ {
+ new Version.Qualifier(null, Version.Qualifier.Suffix.EMPTY);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+
+ //
+ try
+ {
+ new Version.Qualifier(Version.Qualifier.Prefix.GA, Version.Qualifier.Suffix.SUFFIX_1);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testIllegalCodeNameThrowsIAE()
+ {
+ try
+ {
+ new Version("name", 0, 0, 0, GAQualifer, null);
+ fail();
+ }
+ catch (IllegalArgumentException ignore)
+ {
+ }
+ }
+
+ public void testState()
+ {
+ Version version = new Version("foo", 1, 2, 3, new Version.Qualifier(Version.Qualifier.Prefix.CR, Version.Qualifier.Suffix.SUFFIX_3), "bar");
+ assertEquals("foo", version.getName());
+ assertEquals(1, version.getMajor());
+ assertEquals(2, version.getMinor());
+ assertEquals(3, version.getPatch());
+ assertEquals(Version.Qualifier.Prefix.CR, version.getQualifier().getPrefix());
+ assertEquals(Version.Qualifier.Suffix.SUFFIX_3, version.getQualifier().getSuffix());
+ assertEquals("bar", version.getCodeName());
+ }
+
+ public void testQualifier()
+ {
+
+ }
+
+ public void testFormat()
+ {
+ Version version = new Version("foo", 1, 2, 3, new Version.Qualifier(Version.Qualifier.Prefix.CR, Version.Qualifier.Suffix.SUFFIX_3), "bar");
+ assertEquals("foo 1.2.3-CR3", version.toString());
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_de_DE.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_de_DE.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_de_DE.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=a_de_DE
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_fr.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_fr.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_fr.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=a_fr
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_fr_FR.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_fr_FR.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_fr_FR.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=a_fr_FR
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_it.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_it.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/a_it.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=a_it
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/b.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/b.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/b.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=b
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/c_fr.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/c_fr.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/c_fr.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=c_fr
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/d_fr_FR.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/d_fr_FR.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/d_fr_FR.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=d_fr_FR
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/e.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/e.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/e.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=e
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/e_fr.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/e_fr.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/e_fr.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=e_fr
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/f.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/f.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/f.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=f
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/f_fr_FR.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/f_fr_FR.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/f_fr_FR.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=f_fr_FR
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/g_fr.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/g_fr.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/g_fr.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=g_fr
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/g_fr_FR.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/g_fr_FR.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/g_fr_FR.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=g_fr_FR
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=h
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h_fr.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h_fr.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h_fr.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=h_fr
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h_fr_FR.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h_fr_FR.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/bundle/h_fr_FR.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+value=h_fr_FR
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/META-INF/jboss-service.xml
===================================================================
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/META-INF/jboss-service.xml
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar/bar.txt
===================================================================
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar/bar.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/web.xml
===================================================================
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/WEB-INF/web.xml
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1 @@
+<%@ page language="java" %>
\ No newline at end of file
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/implode/foo.sar/bar.war/index.jsp
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/log4j.properties
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/log4j.properties (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/log4j.properties 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,7 @@
+log4j.rootCategory=DEBUG, CONSOLE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=INFO
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
\ No newline at end of file
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1/c1/d1.txt
===================================================================
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1/c1/d1.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1/c1.txt
===================================================================
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1/c1.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1.txt
===================================================================
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b1.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b2.txt
===================================================================
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a1/b2.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a3.txt
===================================================================
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test-jar/a3.txt
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test01.code
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test01.code (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test01.code 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,82 @@
+this is some plain text
+<table><tr><td>I love to write entities like < or > to see how the renderer interprets that
+check the line break around this line
+here we check the wellformdness of the HTML stuff because we enter a code section
+which must terminates any open HTML tag
+[b]bold[/b]
+[i]italic[/i]
+
+the next line is a quote of myself which contains code
+[quote=julien]
+[code]
+this is an XML sample, so the great than etc... should be displayed instead of
+being treated as entities
+<?xml version="1.0"?>
+[b]<root>[/b] the root element is bold
+</root>
+[/code]
+
+the code is closed, we are going to test the nested quotes
+[quote]
+this is a nested quote
+[/quote]
+the next line is code that contains no breaks
+[code]public static void[/code]
+[/quote]
+
+next one is a quote with no line break
+[quote]quote with no line break[/quote]
+
+
+we are going to test if the renderer closes the unclosed statements
+[b][i][u]bold, italic, underline[/b]
+
+[url]http://www.test.com[/url]
+
+[list]
+[*]first item
+[/list]
+
+[list]
+[*]first item
+[*]second item
+[/list]
+
+[list=1]
+[*]first item
+[*]second item
+[/list]
+
+[list=a]
+[*]first item
+[*]second item
+[/list]
+
+[size=25][color=#FF0000]big red[/color][/size]
+
+<code><pre>
+a
+ a
+ a
+ a
+</pre></code>
+<code>
+a
+ a
+ a
+ a
+</code>
+<pre>
+a
+ a
+ a
+ a
+</pre>
+[code]
+a
+ a
+ a
+ a
+[/code]
+
+this is the end of the message
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/common/src/test/resources/test01.code
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/mc/.classpath
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/mc/.classpath (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/mc/.classpath 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/mc/.classpath
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/mc/.cvsignore
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/mc/.cvsignore (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/mc/.cvsignore 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,2 @@
+bin
+output
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/mc/.cvsignore
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/mc/.project
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/mc/.project (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/mc/.project 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>api</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/mc/.project
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/mc/pom.xml
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/mc/pom.xml (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/mc/pom.xml 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,46 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.1.1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-mc</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common MC</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>2.0.0.Beta4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>apache-log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+
+ <properties/>
+
+</project>
Added: modules/common/tags/JBP_COMMON_1_1_1/mc/src/etc/portal-common-mc-lib-jar.mf
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/mc/src/etc/portal-common-mc-lib-jar.mf (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/mc/src/etc/portal-common-mc-lib-jar.mf 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/mc/src/etc/portal-common-mc-lib-jar.mf
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/ActualBootstrap.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/ActualBootstrap.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/ActualBootstrap.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mc.bootstrap;
+
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ActualBootstrap extends BasicBootstrap
+{
+
+ /** . */
+ private final WebBootstrap callback;
+
+ // I don't know why we need to declare it since super() does not declare it
+ public ActualBootstrap(WebBootstrap callback) throws Exception
+ {
+ super();
+
+ //
+ this.callback = callback;
+ }
+
+ protected void bootstrap() throws Throwable
+ {
+ super.bootstrap();
+
+ //
+ callback.boostrap();
+ }
+
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/WebBootstrap.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/WebBootstrap.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/mc/src/main/java/org/jboss/portal/common/mc/bootstrap/WebBootstrap.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,245 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal.common.mc.bootstrap;
+
+import org.jboss.kernel.plugins.deployment.xml.BeanXMLDeployer;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.spi.event.KernelEventListener;
+import org.jboss.kernel.spi.event.KernelEvent;
+import org.jboss.kernel.spi.registry.KernelRegistry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.apache.log4j.Logger;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * A kernel bootstrap with a life cycle triggered by the <code>ServletContextListener</code> interface.
+ * All beans will be injected as servlet context attributes. The bean xml file must be available as
+ * a servlet context resource under the path <i>/WEB-INF/jboss-beans.xml</i>.
+ *
+ * @todo specify an alternative logger name
+ * @todo implement the specification of an alternative xml file path
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class WebBootstrap implements ServletContextListener, KernelEventListener
+{
+
+ /**
+ * The servlet context init parameter name for the bean resource location. For instance for a web application
+ * resource it could be <i>/WEB-INF/my-beans.xml</i>, for the web application classloader resource it could be
+ * <i>org/jboss/portal/my-beans.xml</i>. If no init parameter is declared then the litteral value
+ * <i>/WEB-INF/jboss-beans.xml</i> is used and the lookup is done in the servlet context resourcees.
+ */
+ public static final String BEANS_RESOURCE_LOCATION_KEY = "jboss.portal.mc.beans_resource_location";
+
+ /**
+ * The servlet context init parameter name for the bean resource type which can be the servlet context
+ * or the web application classloader. If no value is specified the servlet context will be used for
+ * resource lookup. The legal values are <i>context</i> for the servlet context and <i>classloader</i>
+ * for the web application classloader.
+ */
+ public static final String BEANS_RESOURCE_TYPE_KEY = "jboss.portal.mc.beans_resource_type";
+
+ /** Default value for the bean resource location. */
+ public static final String DEFAULT_JBOSS_BEANS_RESOURCE_LOCATION = "/WEB-INF/jboss-beans.xml";
+
+ /** Servlet context resource type. */
+ public static final String CONTEXT_RESOURCE_TYPE = "context";
+
+ /** Classloader resource type. */
+ public static final String CLASSLOADER_RESOURCE_TYPE = "classloader";
+
+ /** . */
+ private final static Logger log = Logger.getLogger(WebBootstrap.class);
+
+ /** . */
+ private ServletContext servletContext;
+
+ /** . */
+ private BeanXMLDeployer deployer;
+
+ /** . */
+ private KernelDeployment deployment;
+
+ /** . */
+ private boolean registered;
+
+ /** . */
+ private ActualBootstrap bootstrap;
+
+ public void contextInitialized(ServletContextEvent event)
+ {
+ servletContext = event.getServletContext();
+
+ //
+ try
+ {
+ bootstrap = new ActualBootstrap(this);
+
+ //
+ bootstrap.run();
+
+ //
+ log.info("Web kernel started");
+ }
+ catch (Exception e)
+ {
+ log.info("Web kernel boostrap failed", e);
+ }
+ }
+
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ log.info("Web kernel shutdown");
+
+ //
+ if (deployment != null)
+ {
+ deployer.undeploy(deployment);
+ }
+
+ //
+ if (registered)
+ {
+ registered = false;
+ try
+ {
+ KernelRegistry registry = bootstrap.getKernel().getRegistry();
+ registry.unregisterListener(this, null, "ABC");
+ }
+ catch (Throwable throwable)
+ {
+ log.error("Cannot unregister kernel registry listener", throwable);
+ }
+ }
+
+ //
+ servletContext = null;
+
+ //
+ log.info("Web kernel stopped");
+ }
+
+ public void onEvent(KernelEvent event, Object object)
+ {
+ Object context = event.getContext();
+ if (context instanceof String)
+ {
+ String key = (String)context;
+ String type = event.getType();
+ if ("KERNEL_REGISTRY_REGISTERED".equals(type))
+ {
+ KernelRegistryEntry entry = bootstrap.getKernel().getRegistry().getEntry(context);
+ Object target = entry.getTarget();
+ servletContext.setAttribute(key, target);
+ }
+ else if ("KERNEL_REGISTRY_UNREGISTERED".equals(type))
+ {
+ servletContext.removeAttribute(key);
+ }
+ }
+ }
+
+ void boostrap() throws Throwable
+ {
+ //
+ bootstrap.getKernel().getRegistry().registerListener(WebBootstrap.this, null, "ABC");
+ registered = true;
+
+ //
+ deployer = new BeanXMLDeployer(bootstrap.getKernel());
+
+ //
+ URL url = getBeansURL();
+
+ //
+ if (url != null)
+ {
+ log.debug("About to deploy beans url=" + url);
+ deployment = deployer.deploy(url);
+ }
+ else
+ {
+ log.error("No valid beans URL was determined");
+ }
+ }
+
+ protected URL getBeansURL()
+ {
+ String location = servletContext.getInitParameter(BEANS_RESOURCE_LOCATION_KEY);
+ String type = servletContext.getInitParameter(BEANS_RESOURCE_TYPE_KEY);
+
+ //
+ if (location == null)
+ {
+ location = DEFAULT_JBOSS_BEANS_RESOURCE_LOCATION;
+ type = CONTEXT_RESOURCE_TYPE;
+ }
+ else if (type == null)
+ {
+ type = CONTEXT_RESOURCE_TYPE;
+ }
+
+ //
+ if (CONTEXT_RESOURCE_TYPE.equals(type))
+ {
+ try
+ {
+ return servletContext.getResource(location);
+ }
+ catch (MalformedURLException e)
+ {
+ log.error("Cannot obtain beans definition file from servlet context with location=" + location, e);
+
+ //
+ return null;
+ }
+ }
+ else if (CLASSLOADER_RESOURCE_TYPE.equals(type))
+ {
+ URL resource = Thread.currentThread().getContextClassLoader().getResource(location);
+
+ //
+ if (resource == null)
+ {
+ log.error("Cannot obtain bean definition file from thread context classloader with location=" + location);
+ }
+
+ //
+ return resource;
+ }
+ else
+ {
+ log.error("Cannot obtain bean definition file since the context type cannot be determined type=" + type);
+
+ //
+ return null;
+ }
+ }
+}
Added: modules/common/tags/JBP_COMMON_1_1_1/pom.xml
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/pom.xml (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/pom.xml 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,205 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <packaging>pom</packaging>
+ <name>JBoss Portal Modules Common</name>
+ <version>1.1.1</version>
+ <url>http://labs.jboss.com/jbossportal</url>
+
+ <dependencies/>
+
+ <repositories>
+ <repository>
+ <id>repository.maven.org</id>
+ <name>Maven Repository</name>
+ <layout>default</layout>
+ <url>http://repo1.maven.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ <version>1.0-beta-2</version>
+ </extension>
+ </extensions>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <inherited>true</inherited>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <showDeprecation>true</showDeprecation>
+ <showWarnings>true</showWarnings>
+ <optimize>true</optimize>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jboss-packaging-maven-plugin</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-idea-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jboss-deploy-plugin</artifactId>
+ <version>1.3</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jboss-deploy</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <jbossDeployRoot>${jboss.repository.root}</jbossDeployRoot>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-source</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <distributionManagement>
+ <repository>
+ <!--Copy the distribution jar file to a local checkout of the maven repository
+ - This variable can be set in $MAVEN_HOME/conf/settings.xml-->
+ <id>repository.jboss.org</id>
+ <url>file://${jboss.repository.root}</url>
+ </repository>
+ <snapshotRepository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <url>dav:https://snapshots.jboss.org/maven2</url>
+ <uniqueVersion>true</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <modules>
+ <module>common</module>
+ <module>mc</module>
+ <module>portal</module>
+ </modules>
+
+
+ <issueManagement>
+ <system>JIRA</system>
+ <url>http://jira.jboss.com/jira/browse/JBPORTAL</url>
+ </issueManagement>
+ <ciManagement>
+ <system>cruisecontrol</system>
+ </ciManagement>
+
+ <licenses>
+ <license>
+ <name>LGPL 2.1</name>
+ <url>http://www.gnu.org/licenses/lgpl.html</url>
+ <distribution>repo</distribution>
+ <comments>
+ GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
+ </comments>
+ </license>
+ </licenses>
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/portal/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/portal/trunk</developerConnection>
+ <url>https://svn.jboss.org/repos/portal/trunk</url>
+ </scm>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-changes-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <aggregate>true</aggregate>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <linkXref>true</linkXref>
+ <targetJdk>1.5</targetJdk>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-report-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <properties/>
+
+</project>
Added: modules/common/tags/JBP_COMMON_1_1_1/portal/.classpath
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/portal/.classpath (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/portal/.classpath 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/portal/.classpath
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/portal/.cvsignore
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/portal/.cvsignore (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/portal/.cvsignore 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,2 @@
+bin
+output
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/portal/.cvsignore
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/portal/.project
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/portal/.project (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/portal/.project 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>api</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/portal/.project
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/portal/pom.xml
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/portal/pom.xml (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/portal/pom.xml 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,27 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.portal.common</groupId>
+ <artifactId>module-parent</artifactId>
+ <version>1.1.1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>common-portal</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Portal Modules Common Portal</name>
+
+ <dependencies/>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+
+ </properties>
+</project>
+
Added: modules/common/tags/JBP_COMMON_1_1_1/portal/src/etc/portal-common-portal-lib-jar.mf
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/portal/src/etc/portal-common-portal-lib-jar.mf (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/portal/src/etc/portal-common-portal-lib-jar.mf 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/portal/src/etc/portal-common-portal-lib-jar.mf
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/Mode.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/Mode.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/Mode.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,162 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 7867 $
+ */
+public final class Mode implements Serializable
+{
+
+ /** The serialVersionUID. */
+ private static final long serialVersionUID = 6033765240710422050L;
+
+ /** . */
+ public static final Mode EDIT = new Mode("edit");
+
+ /** . */
+ public static final Mode HELP = new Mode("help");
+
+ /** . */
+ public static final Mode VIEW = new Mode("view");
+
+ /** . */
+ public static final Mode EDIT_DEFAULTS = new Mode("edit_defaults");
+
+ /** . */
+ public static final Mode ADMIN = new Mode("admin");
+
+ /** . */
+ private String name;
+
+ public Mode(String name)
+ {
+ this(name, false);
+ }
+
+ /**
+ * @param name
+ * @param preserveCase
+ * @since 2.4.2
+ */
+ private Mode(String name, boolean preserveCase)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Mode cannot be null");
+ }
+ this.name = (preserveCase ? name : name.toLowerCase(Locale.ENGLISH));
+ }
+
+
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof Mode)
+ {
+ Mode that = (Mode)o;
+ return name.equals(that.name);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+
+ private Object readResolve()
+ {
+ if (VIEW.name.equals(name))
+ {
+ return VIEW;
+ }
+ else if (EDIT.name.equals(name))
+ {
+ return EDIT;
+ }
+ else if (HELP.name.equals(name))
+ {
+ return HELP;
+ }
+ else if (EDIT_DEFAULTS.name.equals(name))
+ {
+ return EDIT_DEFAULTS;
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ public static Mode create(String name)
+ {
+ return create(name, false);
+ }
+
+ /**
+ * @param name
+ * @param preserveCase
+ * @return
+ * @since 2.4.2
+ */
+ public static Mode create(String name, boolean preserveCase)
+ {
+ if (Mode.VIEW.name.equals(name))
+ {
+ return Mode.VIEW;
+ }
+ else if (Mode.EDIT.name.equals(name))
+ {
+ return Mode.EDIT;
+ }
+ else if (Mode.HELP.name.equals(name))
+ {
+ return Mode.HELP;
+ }
+ else if (Mode.ADMIN.name.equals(name))
+ {
+ return Mode.ADMIN;
+ }
+ else if (Mode.EDIT_DEFAULTS.name.equals(name))
+ {
+ return Mode.EDIT_DEFAULTS;
+ }
+ else
+ {
+ return new Mode(name, preserveCase);
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/Mode.java
___________________________________________________________________
Name: svn:executable
+
Added: modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/WindowState.java
===================================================================
--- modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/WindowState.java (rev 0)
+++ modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/WindowState.java 2008-05-01 20:31:41 UTC (rev 10731)
@@ -0,0 +1,144 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt 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.portal;
+
+import java.io.Serializable;
+import java.util.Locale;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 6901 $
+ */
+public final class WindowState implements Serializable
+{
+
+ /** The serialVersionUID */
+ private static final long serialVersionUID = -6305311518934458562L;
+
+ /** . */
+ public static final WindowState NORMAL = new WindowState("normal");
+
+ /** . */
+ public static final WindowState MINIMIZED = new WindowState("minimized");
+
+ /** . */
+ public static final WindowState MAXIMIZED = new WindowState("maximized");
+
+ /** . */
+ private String name;
+
+ public WindowState(String name)
+ {
+ this(name, false);
+ }
+
+ /**
+ * @param name
+ * @param preserveCase
+ * @since 2.4.2
+ */
+ private WindowState(String name, boolean preserveCase)
+ {
+ if (name == null)
+ {
+ throw new IllegalArgumentException("Window state name cannot be null");
+ }
+
+ this.name = (preserveCase ? name : name.toLowerCase(Locale.ENGLISH));
+ }
+
+ public boolean equals(Object o)
+ {
+ if (o == this)
+ {
+ return true;
+ }
+ if (o instanceof WindowState)
+ {
+ WindowState that = (WindowState)o;
+ return name.equals(that.name);
+ }
+ return false;
+ }
+
+ public int hashCode()
+ {
+ return name.hashCode();
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+
+ private Object readResolve()
+ {
+ if (NORMAL.name.equals(name))
+ {
+ return NORMAL;
+ }
+ else if (MAXIMIZED.name.equals(name))
+ {
+ return MAXIMIZED;
+ }
+ else if (MINIMIZED.name.equals(name))
+ {
+ return MINIMIZED;
+ }
+ else
+ {
+ return this;
+ }
+ }
+
+ public static WindowState create(String name)
+ {
+ return create(name, false);
+ }
+
+ /**
+ * @param name
+ * @param preserveCase
+ * @return
+ * @since 2.4.2
+ */
+ public static WindowState create(String name, boolean preserveCase)
+ {
+ if (WindowState.NORMAL.name.equals(name))
+ {
+ return WindowState.NORMAL;
+ }
+ else if (WindowState.MINIMIZED.name.equals(name))
+ {
+ return WindowState.MINIMIZED;
+ }
+ else if (WindowState.MAXIMIZED.name.equals(name))
+ {
+ return WindowState.MAXIMIZED;
+ }
+ else
+ {
+ return new WindowState(name, preserveCase);
+ }
+ }
+}
Property changes on: modules/common/tags/JBP_COMMON_1_1_1/portal/src/main/java/org/jboss/portal/WindowState.java
___________________________________________________________________
Name: svn:executable
+
16 years, 1 month