You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by gs...@apache.org on 2007/10/15 23:23:31 UTC
svn commit: r584925 [12/34] - in /wicket/trunk/jdk-1.4/wicket/src:
main/java/org/apache/wicket/ main/java/org/apache/wicket/ajax/
main/java/org/apache/wicket/ajax/calldecorator/
main/java/org/apache/wicket/ajax/form/ main/java/org/apache/wicket/ajax/ma...
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/HtmlDocumentValidator.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/HtmlDocumentValidator.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/HtmlDocumentValidator.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/HtmlDocumentValidator.java Mon Oct 15 14:21:25 2007
@@ -27,488 +27,482 @@
/**
- * Simple class that provides a convenient programmatic way to define what an
- * expected HTML document should look like and then to validate a supplied
- * document against this template. Note that this validator expects very clean
- * HTML (which should not be a problem during testing). In particular it expects
- * tags to be matched and that the following tags with optional close tags are
- * actually closed: p, td, th, li and option.
- *
+ * Simple class that provides a convenient programmatic way to define what an expected HTML document
+ * should look like and then to validate a supplied document against this template. Note that this
+ * validator expects very clean HTML (which should not be a problem during testing). In particular
+ * it expects tags to be matched and that the following tags with optional close tags are actually
+ * closed: p, td, th, li and option.
+ *
* @author Chris Turner
*/
public class HtmlDocumentValidator
{
private static final Logger log = LoggerFactory.getLogger(HtmlDocumentValidator.class);
- private final List elements = new ArrayList();
+ private final List elements = new ArrayList();
- private boolean skipComments = true;
+ private boolean skipComments = true;
- private Tag workingTag;
+ private Tag workingTag;
- /**
- * Create the validator.
- */
- public HtmlDocumentValidator()
- {
- }
-
- /**
- * Add a root element to the validator. This will generally be the HTML
- * element to which all children are added. However, it may also be other
- * elements to represent comments or similar.
- *
- * @param e
- * The element to add
- */
- public void addRootElement(final DocumentElement e)
- {
- elements.add(e);
- }
-
- /**
- * Check whether the supplied document is valid against the spec that has
- * been built up within the validator.
- *
- * @param document
- * The document to validate
- * @return Whether the document is valid or not
- */
- public boolean isDocumentValid(final String document)
- {
- HtmlDocumentParser parser = new HtmlDocumentParser(document);
- Iterator expectedElements = elements.iterator();
- ArrayListStack iteratorStack = new ArrayListStack();
- ArrayListStack tagNameStack = new ArrayListStack();
-
- boolean end = false;
- boolean valid = true;
- while (!end)
- {
- int token = parser.getNextToken();
- switch (token)
- {
- case HtmlDocumentParser.UNKNOWN :
- // Error is already recorded by the parser
- return false;
- case HtmlDocumentParser.END :
- end = true;
- break;
- case HtmlDocumentParser.COMMENT :
- valid = validateComment(expectedElements, parser);
- if (!valid)
+ /**
+ * Create the validator.
+ */
+ public HtmlDocumentValidator()
+ {
+ }
+
+ /**
+ * Add a root element to the validator. This will generally be the HTML element to which all
+ * children are added. However, it may also be other elements to represent comments or similar.
+ *
+ * @param e
+ * The element to add
+ */
+ public void addRootElement(final DocumentElement e)
+ {
+ elements.add(e);
+ }
+
+ /**
+ * Check whether the supplied document is valid against the spec that has been built up within
+ * the validator.
+ *
+ * @param document
+ * The document to validate
+ * @return Whether the document is valid or not
+ */
+ public boolean isDocumentValid(final String document)
+ {
+ HtmlDocumentParser parser = new HtmlDocumentParser(document);
+ Iterator expectedElements = elements.iterator();
+ ArrayListStack iteratorStack = new ArrayListStack();
+ ArrayListStack tagNameStack = new ArrayListStack();
+
+ boolean end = false;
+ boolean valid = true;
+ while (!end)
+ {
+ int token = parser.getNextToken();
+ switch (token)
+ {
+ case HtmlDocumentParser.UNKNOWN :
+ // Error is already recorded by the parser
+ return false;
+ case HtmlDocumentParser.END :
+ end = true;
+ break;
+ case HtmlDocumentParser.COMMENT :
+ valid = validateComment(expectedElements, parser);
+ if (!valid)
{
end = true;
}
- break;
- case HtmlDocumentParser.OPEN_TAG :
- valid = validateTag(expectedElements, parser);
- if (!valid)
+ break;
+ case HtmlDocumentParser.OPEN_TAG :
+ valid = validateTag(expectedElements, parser);
+ if (!valid)
{
end = true;
}
else
{
expectedElements = saveOpenTagState(iteratorStack, expectedElements,
- tagNameStack);
+ tagNameStack);
}
- break;
- case HtmlDocumentParser.OPENCLOSE_TAG :
- valid = validateTag(expectedElements, parser);
- if (valid)
+ break;
+ case HtmlDocumentParser.OPENCLOSE_TAG :
+ valid = validateTag(expectedElements, parser);
+ if (valid)
{
valid = checkOpenCloseTag();
}
- if (!valid)
+ if (!valid)
{
end = true;
}
- break;
- case HtmlDocumentParser.CLOSE_TAG :
- expectedElements = validateCloseTag(tagNameStack, parser, expectedElements,
- iteratorStack);
- if (expectedElements == null)
- {
- valid = false;
- end = true;
- }
- break;
- case HtmlDocumentParser.TEXT :
- valid = validateText(expectedElements, parser);
- if (!valid)
+ break;
+ case HtmlDocumentParser.CLOSE_TAG :
+ expectedElements = validateCloseTag(tagNameStack, parser, expectedElements,
+ iteratorStack);
+ if (expectedElements == null)
{
+ valid = false;
end = true;
}
- break;
- }
- }
-
- // Return the valid result
- return valid;
- }
-
- /**
- * Set whether to skip comments of not when validating. The default is true.
- * If this is set to false then Comment elements must be added to represent
- * each comment to be validated.
- *
- * @param skipComments
- * Whether to skip comments or not
- */
- public void setSkipComments(final boolean skipComments)
- {
- this.skipComments = skipComments;
- }
-
- /**
- * Check whether the open close tag was actually expected to have children.
- *
- * @return Whether valid or not
- */
- private boolean checkOpenCloseTag()
- {
- boolean valid = true;
- if (!workingTag.getExpectedChildren().isEmpty())
- {
- log.error("Found tag <" + workingTag.getTag() + "/> was expected to have "
- + workingTag.getExpectedChildren().size() + " child elements");
- valid = false;
- }
- return valid;
- }
-
- /**
- * Check if the supplied tag is one that expects to be closed or not.
- *
- * @param tag
- * The tag
- * @return Whether the tag requires closing or not
- */
- private boolean isNonClosedTag(String tag)
- {
- tag = workingTag.getTag().toLowerCase();
- if (tag.equals("area"))
- {
- return true;
- }
- if (tag.equals("base"))
- {
- return true;
- }
- if (tag.equals("basefont"))
- {
- return true;
- }
- if (tag.equals("bgsound"))
- {
- return true;
- }
- if (tag.equals("br"))
- {
- return true;
- }
- if (tag.equals("col"))
- {
- return true;
- }
- if (tag.equals("frame"))
- {
- return true;
- }
- if (tag.equals("hr"))
- {
- return true;
- }
- if (tag.equals("img"))
- {
- return true;
- }
- if (tag.equals("input"))
- {
- return true;
- }
- if (tag.equals("isindex"))
- {
- return true;
- }
- if (tag.equals("keygen"))
- {
- return true;
- }
- if (tag.equals("link"))
- {
- return true;
- }
- if (tag.equals("meta"))
- {
- return true;
- }
- if (tag.equals("param"))
- {
- return true;
- }
- if (tag.equals("spacer"))
- {
- return true;
- }
- if (tag.equals("wbr"))
- {
- return true;
- }
- return false;
- }
-
- /**
- * Save the new open tag state and find the iterator to continue to use for
- * processing.
- *
- * @param iteratorStack
- * The current stack of iterators
- * @param expectedElements
- * The current iterator of elements
- * @param tagNameStack
- * The stack of open tags
- * @return The iterator to continue to use
- */
- private Iterator saveOpenTagState(ArrayListStack iteratorStack, Iterator expectedElements,
- ArrayListStack tagNameStack)
- {
- if (!isNonClosedTag(workingTag.getTag()))
- {
- iteratorStack.push(expectedElements);
- expectedElements = workingTag.getExpectedChildren().iterator();
- tagNameStack.push(workingTag.getTag());
- }
- return expectedElements;
- }
-
- /**
- * Validate the close tag that was found.
- *
- * @param tagNameStack
- * The stack of tag names
- * @param parser
- * The parser
- * @param expectedElements
- * The current iterator of expected elements
- * @param iteratorStack
- * The stack of previous iterators
- * @return The next iterator to use, or null
- */
- private Iterator validateCloseTag(ArrayListStack tagNameStack, HtmlDocumentParser parser,
- Iterator expectedElements, ArrayListStack iteratorStack)
- {
- if (tagNameStack.isEmpty())
- {
- log.error("Found closing tag </" + parser.getTag() + "> when there are no "
- + "tags currently open");
- expectedElements = null;
- }
- else
- {
- String expectedTag = (String)tagNameStack.pop();
- if (!expectedTag.equals(parser.getTag()))
- {
- log.error("Found closing tag </" + parser.getTag() + "> when we expecting "
- + "the closing tag </" + expectedTag + "> instead");
- expectedElements = null;
- }
- else
- {
- if (expectedElements.hasNext())
- {
- DocumentElement e = (DocumentElement)expectedElements.next();
- log.error("Found closing tag </" + parser.getTag() + "> but we were "
- + "expecting to find another child element: " + e.toString());
- expectedElements = null;
- }
- else
- {
- if (iteratorStack.isEmpty())
- {
- log.error("Unexpected parsing error");
- expectedElements = null;
- }
- else
- {
- expectedElements = (Iterator)iteratorStack.pop();
- }
- }
- }
- }
- return expectedElements;
- }
-
- /**
- * Validate the comment token that was found.
- *
- * @param expectedElements
- * The iterator of expected elements
- * @param parser
- * The parser
- * @return Whether the comment is valid or not
- */
- private boolean validateComment(Iterator expectedElements, HtmlDocumentParser parser)
- {
- boolean valid = true;
- if (!skipComments)
- {
- if (expectedElements.hasNext())
- {
- DocumentElement e = (DocumentElement)expectedElements.next();
- if (e instanceof Comment)
- {
- if (!((Comment)e).getText().equals(parser.getComment()))
- {
- log.error("Found comment '" + parser.getComment()
- + "' does not match " + "expected comment '"
- + ((Comment)e).getText() + "'");
- valid = false;
- }
- }
- else
- {
- log.error("Found comment '" + parser.getComment()
- + "' was not expected. " + "We were expecting: " + e.toString());
- valid = false;
- }
- }
- else
- {
- log.error("Found comment '" + parser.getComment() + "' was not expected. "
- + "We were not expecting any more elements within the current tag");
- valid = false;
- }
- }
- return valid;
- }
-
- /**
- * Validate the tag token that was found.
- *
- * @param expectedElements
- * The iterator of expected elements
- * @param parser
- * The parser
- * @return Whether the tag is valid or not
- */
- private boolean validateTag(Iterator expectedElements, HtmlDocumentParser parser)
- {
- boolean valid = true;
- if (expectedElements.hasNext())
- {
- DocumentElement e = (DocumentElement)expectedElements.next();
- if (e instanceof Tag)
- {
- workingTag = (Tag)e;
- if (!workingTag.getTag().equals(parser.getTag()))
- {
- log.error("Found tag <" + parser.getTag() + "> does not match "
- + "expected tag <" + workingTag.getTag() + ">");
- valid = false;
- }
- else
- {
- Map actualAttributes = parser.getAttributes();
-
- Map expectedAttributes = workingTag.getExpectedAttributes();
- for (Iterator it = expectedAttributes.keySet().iterator(); it.hasNext();)
- {
- String name = (String)it.next();
- String pattern = (String)expectedAttributes.get(name);
- if (!actualAttributes.containsKey(name))
- {
- log.error("Tag <" + workingTag.getTag()
- + "> was expected to have a '" + name + "' attribute "
- + "but this was not present");
- valid = false;
- }
-
- String value = (String)actualAttributes.get(name);
- if (value == null)
- {
- log.error("Attribute " + name + " was expected but not found");
- valid = false;
- }
- else
- {
- if (!value.matches(pattern))
- {
- log.error("The value '" + value + "' of attribute '" + name
- + "' of tag <" + workingTag.getTag()
- + "> was expected to match the pattern '" + pattern
- + "' but it does not");
- valid = false;
- }
- }
- }
-
- for (Iterator it = workingTag.getIllegalAttributes().iterator(); it.hasNext();)
- {
- String name = (String)it.next();
- if (actualAttributes.containsKey(name))
- {
- log.error("Tag <" + workingTag.getTag()
- + "> should not have an attributed named '" + name + "'");
- valid = false;
- }
- }
- }
- }
- else
- {
- log.error("Found tag <" + parser.getTag() + "> was not expected. "
- + "We were expecting: " + e.toString());
- valid = false;
- }
- }
- else
- {
- log.error("Found tag <" + parser.getTag() + "> was not expected. "
- + "We were not expecting any more elements within the current tag");
- valid = false;
- }
- return valid;
- }
-
- /**
- * Validate the text token that was found.
- *
- * @param expectedElements
- * The iterator of expected elements
- * @param parser
- * The parser
- * @return Whether the text is valid or not
- */
- private boolean validateText(Iterator expectedElements, HtmlDocumentParser parser)
- {
- boolean valid = true;
- if (expectedElements.hasNext())
- {
- DocumentElement e = (DocumentElement)expectedElements.next();
- if (e instanceof TextContent)
- {
- if (!parser.getText().matches(((TextContent)e).getValue()))
- {
- log.error("Found text '" + parser.getText() + "' does not match "
- + "expected text '" + ((TextContent)e).getValue() + "'");
- valid = false;
- }
- }
- else
- {
- log.error("Found text '" + parser.getText() + "' was not expected. "
- + "We were expecting: " + e.toString());
- valid = false;
- }
- }
- else
- {
- log.error("Found text '" + parser.getText() + "' was not expected. "
- + "We were not expecting any more elements within the current tag");
- valid = false;
- }
- return valid;
- }
+ break;
+ case HtmlDocumentParser.TEXT :
+ valid = validateText(expectedElements, parser);
+ if (!valid)
+ {
+ end = true;
+ }
+ break;
+ }
+ }
+
+ // Return the valid result
+ return valid;
+ }
+
+ /**
+ * Set whether to skip comments of not when validating. The default is true. If this is set to
+ * false then Comment elements must be added to represent each comment to be validated.
+ *
+ * @param skipComments
+ * Whether to skip comments or not
+ */
+ public void setSkipComments(final boolean skipComments)
+ {
+ this.skipComments = skipComments;
+ }
+
+ /**
+ * Check whether the open close tag was actually expected to have children.
+ *
+ * @return Whether valid or not
+ */
+ private boolean checkOpenCloseTag()
+ {
+ boolean valid = true;
+ if (!workingTag.getExpectedChildren().isEmpty())
+ {
+ log.error("Found tag <" + workingTag.getTag() + "/> was expected to have " +
+ workingTag.getExpectedChildren().size() + " child elements");
+ valid = false;
+ }
+ return valid;
+ }
+
+ /**
+ * Check if the supplied tag is one that expects to be closed or not.
+ *
+ * @param tag
+ * The tag
+ * @return Whether the tag requires closing or not
+ */
+ private boolean isNonClosedTag(String tag)
+ {
+ tag = workingTag.getTag().toLowerCase();
+ if (tag.equals("area"))
+ {
+ return true;
+ }
+ if (tag.equals("base"))
+ {
+ return true;
+ }
+ if (tag.equals("basefont"))
+ {
+ return true;
+ }
+ if (tag.equals("bgsound"))
+ {
+ return true;
+ }
+ if (tag.equals("br"))
+ {
+ return true;
+ }
+ if (tag.equals("col"))
+ {
+ return true;
+ }
+ if (tag.equals("frame"))
+ {
+ return true;
+ }
+ if (tag.equals("hr"))
+ {
+ return true;
+ }
+ if (tag.equals("img"))
+ {
+ return true;
+ }
+ if (tag.equals("input"))
+ {
+ return true;
+ }
+ if (tag.equals("isindex"))
+ {
+ return true;
+ }
+ if (tag.equals("keygen"))
+ {
+ return true;
+ }
+ if (tag.equals("link"))
+ {
+ return true;
+ }
+ if (tag.equals("meta"))
+ {
+ return true;
+ }
+ if (tag.equals("param"))
+ {
+ return true;
+ }
+ if (tag.equals("spacer"))
+ {
+ return true;
+ }
+ if (tag.equals("wbr"))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Save the new open tag state and find the iterator to continue to use for processing.
+ *
+ * @param iteratorStack
+ * The current stack of iterators
+ * @param expectedElements
+ * The current iterator of elements
+ * @param tagNameStack
+ * The stack of open tags
+ * @return The iterator to continue to use
+ */
+ private Iterator saveOpenTagState(ArrayListStack iteratorStack, Iterator expectedElements,
+ ArrayListStack tagNameStack)
+ {
+ if (!isNonClosedTag(workingTag.getTag()))
+ {
+ iteratorStack.push(expectedElements);
+ expectedElements = workingTag.getExpectedChildren().iterator();
+ tagNameStack.push(workingTag.getTag());
+ }
+ return expectedElements;
+ }
+
+ /**
+ * Validate the close tag that was found.
+ *
+ * @param tagNameStack
+ * The stack of tag names
+ * @param parser
+ * The parser
+ * @param expectedElements
+ * The current iterator of expected elements
+ * @param iteratorStack
+ * The stack of previous iterators
+ * @return The next iterator to use, or null
+ */
+ private Iterator validateCloseTag(ArrayListStack tagNameStack, HtmlDocumentParser parser,
+ Iterator expectedElements, ArrayListStack iteratorStack)
+ {
+ if (tagNameStack.isEmpty())
+ {
+ log.error("Found closing tag </" + parser.getTag() + "> when there are no " +
+ "tags currently open");
+ expectedElements = null;
+ }
+ else
+ {
+ String expectedTag = (String)tagNameStack.pop();
+ if (!expectedTag.equals(parser.getTag()))
+ {
+ log.error("Found closing tag </" + parser.getTag() + "> when we expecting " +
+ "the closing tag </" + expectedTag + "> instead");
+ expectedElements = null;
+ }
+ else
+ {
+ if (expectedElements.hasNext())
+ {
+ DocumentElement e = (DocumentElement)expectedElements.next();
+ log.error("Found closing tag </" + parser.getTag() + "> but we were " +
+ "expecting to find another child element: " + e.toString());
+ expectedElements = null;
+ }
+ else
+ {
+ if (iteratorStack.isEmpty())
+ {
+ log.error("Unexpected parsing error");
+ expectedElements = null;
+ }
+ else
+ {
+ expectedElements = (Iterator)iteratorStack.pop();
+ }
+ }
+ }
+ }
+ return expectedElements;
+ }
+
+ /**
+ * Validate the comment token that was found.
+ *
+ * @param expectedElements
+ * The iterator of expected elements
+ * @param parser
+ * The parser
+ * @return Whether the comment is valid or not
+ */
+ private boolean validateComment(Iterator expectedElements, HtmlDocumentParser parser)
+ {
+ boolean valid = true;
+ if (!skipComments)
+ {
+ if (expectedElements.hasNext())
+ {
+ DocumentElement e = (DocumentElement)expectedElements.next();
+ if (e instanceof Comment)
+ {
+ if (!((Comment)e).getText().equals(parser.getComment()))
+ {
+ log.error("Found comment '" + parser.getComment() + "' does not match " +
+ "expected comment '" + ((Comment)e).getText() + "'");
+ valid = false;
+ }
+ }
+ else
+ {
+ log.error("Found comment '" + parser.getComment() + "' was not expected. " +
+ "We were expecting: " + e.toString());
+ valid = false;
+ }
+ }
+ else
+ {
+ log.error("Found comment '" + parser.getComment() + "' was not expected. " +
+ "We were not expecting any more elements within the current tag");
+ valid = false;
+ }
+ }
+ return valid;
+ }
+
+ /**
+ * Validate the tag token that was found.
+ *
+ * @param expectedElements
+ * The iterator of expected elements
+ * @param parser
+ * The parser
+ * @return Whether the tag is valid or not
+ */
+ private boolean validateTag(Iterator expectedElements, HtmlDocumentParser parser)
+ {
+ boolean valid = true;
+ if (expectedElements.hasNext())
+ {
+ DocumentElement e = (DocumentElement)expectedElements.next();
+ if (e instanceof Tag)
+ {
+ workingTag = (Tag)e;
+ if (!workingTag.getTag().equals(parser.getTag()))
+ {
+ log.error("Found tag <" + parser.getTag() + "> does not match " +
+ "expected tag <" + workingTag.getTag() + ">");
+ valid = false;
+ }
+ else
+ {
+ Map actualAttributes = parser.getAttributes();
+
+ Map expectedAttributes = workingTag.getExpectedAttributes();
+ for (Iterator it = expectedAttributes.keySet().iterator(); it.hasNext();)
+ {
+ String name = (String)it.next();
+ String pattern = (String)expectedAttributes.get(name);
+ if (!actualAttributes.containsKey(name))
+ {
+ log.error("Tag <" + workingTag.getTag() + "> was expected to have a '" +
+ name + "' attribute " + "but this was not present");
+ valid = false;
+ }
+
+ String value = (String)actualAttributes.get(name);
+ if (value == null)
+ {
+ log.error("Attribute " + name + " was expected but not found");
+ valid = false;
+ }
+ else
+ {
+ if (!value.matches(pattern))
+ {
+ log.error("The value '" + value + "' of attribute '" + name +
+ "' of tag <" + workingTag.getTag() +
+ "> was expected to match the pattern '" + pattern +
+ "' but it does not");
+ valid = false;
+ }
+ }
+ }
+
+ for (Iterator it = workingTag.getIllegalAttributes().iterator(); it.hasNext();)
+ {
+ String name = (String)it.next();
+ if (actualAttributes.containsKey(name))
+ {
+ log.error("Tag <" + workingTag.getTag() +
+ "> should not have an attributed named '" + name + "'");
+ valid = false;
+ }
+ }
+ }
+ }
+ else
+ {
+ log.error("Found tag <" + parser.getTag() + "> was not expected. " +
+ "We were expecting: " + e.toString());
+ valid = false;
+ }
+ }
+ else
+ {
+ log.error("Found tag <" + parser.getTag() + "> was not expected. " +
+ "We were not expecting any more elements within the current tag");
+ valid = false;
+ }
+ return valid;
+ }
+
+ /**
+ * Validate the text token that was found.
+ *
+ * @param expectedElements
+ * The iterator of expected elements
+ * @param parser
+ * The parser
+ * @return Whether the text is valid or not
+ */
+ private boolean validateText(Iterator expectedElements, HtmlDocumentParser parser)
+ {
+ boolean valid = true;
+ if (expectedElements.hasNext())
+ {
+ DocumentElement e = (DocumentElement)expectedElements.next();
+ if (e instanceof TextContent)
+ {
+ if (!parser.getText().matches(((TextContent)e).getValue()))
+ {
+ log.error("Found text '" + parser.getText() + "' does not match " +
+ "expected text '" + ((TextContent)e).getValue() + "'");
+ valid = false;
+ }
+ }
+ else
+ {
+ log.error("Found text '" + parser.getText() + "' was not expected. " +
+ "We were expecting: " + e.toString());
+ valid = false;
+ }
+ }
+ else
+ {
+ log.error("Found text '" + parser.getText() + "' was not expected. " +
+ "We were not expecting any more elements within the current tag");
+ valid = false;
+ }
+ return valid;
+ }
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/Tag.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/Tag.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/Tag.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/Tag.java Mon Oct 15 14:21:25 2007
@@ -30,112 +30,112 @@
*/
public class Tag implements DocumentElement
{
- private final Map expectedAttributes = new HashMap();
+ private final Map expectedAttributes = new HashMap();
- private final List expectedChildren = new ArrayList();
+ private final List expectedChildren = new ArrayList();
- private final Set illegalAttributes = new HashSet();
+ private final Set illegalAttributes = new HashSet();
- private final String tag;
+ private final String tag;
- /**
- * Create the tag element.
- *
- * @param tag
- * The tag name
- */
- public Tag(final String tag)
- {
- this.tag = tag.toLowerCase();
- }
-
- /**
- * Add an expected attribute to this tag. The second parameter is a regexp
- * pattern on which to match the value of the tag.
- *
- * @param name
- * The name of the attribute
- * @param pattern
- * The pattern to match
- */
- public void addExpectedAttribute(final String name, final String pattern)
- {
- expectedAttributes.put(name.toLowerCase(), pattern);
- }
-
- /**
- * Add an expected child to this tag. Children must be added in the order
- * they are expected to appear.
- *
- * @param e
- * The element to add
- * @return This
- */
- public Tag addExpectedChild(final DocumentElement e)
- {
- expectedChildren.add(e);
- return this;
- }
-
- /**
- * Add the name of an attribute that is NOT expected for this tag.
- *
- * @param name
- * The name of the attribute
- */
- public void addIllegalAttribute(final String name)
- {
- illegalAttributes.add(name.toLowerCase());
- }
-
- /**
- * Get the map of expected attributes.
- *
- * @return The expected attribute map
- */
- public Map getExpectedAttributes()
- {
- return expectedAttributes;
- }
-
- /**
- * Get the list of expected children.
- *
- * @return The expected children
- */
- public List getExpectedChildren()
- {
- return expectedChildren;
- }
-
- /**
- * Get the set of illegal attributes.
- *
- * @return The illegal attributes
- */
- public Set getIllegalAttributes()
- {
- return illegalAttributes;
- }
-
- /**
- * Get the tag that this element represents.
- *
- * @return The tag
- */
- public String getTag()
- {
- return tag;
- }
-
- /**
- * Output a descriptive string.
- *
- * @return The string
- */
- public String toString()
- {
- return "[tag = '" + tag + "']";
- }
+ /**
+ * Create the tag element.
+ *
+ * @param tag
+ * The tag name
+ */
+ public Tag(final String tag)
+ {
+ this.tag = tag.toLowerCase();
+ }
+
+ /**
+ * Add an expected attribute to this tag. The second parameter is a regexp pattern on which to
+ * match the value of the tag.
+ *
+ * @param name
+ * The name of the attribute
+ * @param pattern
+ * The pattern to match
+ */
+ public void addExpectedAttribute(final String name, final String pattern)
+ {
+ expectedAttributes.put(name.toLowerCase(), pattern);
+ }
+
+ /**
+ * Add an expected child to this tag. Children must be added in the order they are expected to
+ * appear.
+ *
+ * @param e
+ * The element to add
+ * @return This
+ */
+ public Tag addExpectedChild(final DocumentElement e)
+ {
+ expectedChildren.add(e);
+ return this;
+ }
+
+ /**
+ * Add the name of an attribute that is NOT expected for this tag.
+ *
+ * @param name
+ * The name of the attribute
+ */
+ public void addIllegalAttribute(final String name)
+ {
+ illegalAttributes.add(name.toLowerCase());
+ }
+
+ /**
+ * Get the map of expected attributes.
+ *
+ * @return The expected attribute map
+ */
+ public Map getExpectedAttributes()
+ {
+ return expectedAttributes;
+ }
+
+ /**
+ * Get the list of expected children.
+ *
+ * @return The expected children
+ */
+ public List getExpectedChildren()
+ {
+ return expectedChildren;
+ }
+
+ /**
+ * Get the set of illegal attributes.
+ *
+ * @return The illegal attributes
+ */
+ public Set getIllegalAttributes()
+ {
+ return illegalAttributes;
+ }
+
+ /**
+ * Get the tag that this element represents.
+ *
+ * @return The tag
+ */
+ public String getTag()
+ {
+ return tag;
+ }
+
+ /**
+ * Output a descriptive string.
+ *
+ * @return The string
+ */
+ public String toString()
+ {
+ return "[tag = '" + tag + "']";
+ }
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/TextContent.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/TextContent.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/TextContent.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/documentvalidation/TextContent.java Mon Oct 15 14:21:25 2007
@@ -23,36 +23,36 @@
*/
public class TextContent implements DocumentElement
{
- private final String value;
+ private final String value;
- /**
- * Construct the text content with the expected value.
- *
- * @param value
- * The value
- */
- public TextContent(final String value)
- {
- this.value = value;
- }
+ /**
+ * Construct the text content with the expected value.
+ *
+ * @param value
+ * The value
+ */
+ public TextContent(final String value)
+ {
+ this.value = value;
+ }
- /**
- * Get the value of this text content.
- *
- * @return The value
- */
- public String getValue()
- {
- return value;
- }
+ /**
+ * Get the value of this text content.
+ *
+ * @return The value
+ */
+ public String getValue()
+ {
+ return value;
+ }
- /**
- * Output a descriptive string.
- *
- * @return The string
- */
- public String toString()
- {
- return "[text = '" + value + "']";
- }
+ /**
+ * Output a descriptive string.
+ *
+ * @return The string
+ */
+ public String toString()
+ {
+ return "[text = '" + value + "']";
+ }
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/AbstractPageStore.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/AbstractPageStore.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/AbstractPageStore.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/AbstractPageStore.java Mon Oct 15 14:21:25 2007
@@ -34,8 +34,8 @@
import org.apache.wicket.util.lang.Objects;
/**
- * Abstract page store that implements the serialization logic so that the
- * subclasses can concentrate on actual storing of serialized page instances.
+ * Abstract page store that implements the serialization logic so that the subclasses can
+ * concentrate on actual storing of serialized page instances.
*
* @author Matej Knopp
*/
@@ -161,18 +161,16 @@
};
/**
- * Creates a list of {@link SerializedPage} instances obtained from
- * serializing the provided page.
+ * Creates a list of {@link SerializedPage} instances obtained from serializing the provided
+ * page.
* <p>
- * One page instance can be serialized to multiple {@link SerializedPage}
- * instances, because each referenced page is serialized separately and
- * should also be separately saved On deserialization wicket detects a page
- * instance placeholder and loads the appropriate page.
+ * One page instance can be serialized to multiple {@link SerializedPage} instances, because
+ * each referenced page is serialized separately and should also be separately saved On
+ * deserialization wicket detects a page instance placeholder and loads the appropriate page.
* <p>
- * As an example, when there is PageA that has a member variable of type
- * PageB, serializing instanceof PageA will result in a list of two
- * {@link SerializedPage} instances, one for PageA and another one for the
- * referenced PageB.
+ * As an example, when there is PageA that has a member variable of type PageB, serializing
+ * instanceof PageA will result in a list of two {@link SerializedPage} instances, one for PageA
+ * and another one for the referenced PageB.
*
* @param page
* page to be serialized
@@ -208,14 +206,14 @@
}
/**
- * Creates a page instance from given byte array. Optionally gets the
- * specified version of the page.
+ * Creates a page instance from given byte array. Optionally gets the specified version of the
+ * page.
*
* @param data
* Serialized page instance data as byte array
* @param versionNumber
- * Requested page version or -1 if original version (the one
- * serialized) should be kept
+ * Requested page version or -1 if original version (the one serialized) should be
+ * kept
* @return page instance
*/
protected Page deserializePage(byte[] data, int versionNumber)
@@ -250,6 +248,7 @@
/**
* Internal class for page serialization and deserialization
+ *
* @author Matej Knopp
* @author Johan Compagner
*/
@@ -278,7 +277,8 @@
/**
* @throws IOException
- * @see org.apache.wicket.Page.IPageSerializer#serializePage(org.apache.wicket.Page, java.io.ObjectOutputStream)
+ * @see org.apache.wicket.Page.IPageSerializer#serializePage(org.apache.wicket.Page,
+ * java.io.ObjectOutputStream)
*/
public void serializePage(Page page, ObjectOutputStream stream) throws IOException
{
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/DiskPageStore.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/DiskPageStore.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/DiskPageStore.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/DiskPageStore.java Mon Oct 15 14:21:25 2007
@@ -51,14 +51,14 @@
* <p>
* {@link DiskPageStore} allows to set maximum size for pagemap file and maximum size for session.
* If the maximum size for session is exceeded, the last recently used pagemap file is removed.
- *
+ *
* @author Matej Knopp
*/
public class DiskPageStore extends AbstractPageStore implements ISerializationAwarePageStore
{
/**
* Each PageMap is represented by this class.
- *
+ *
* @author Matej Knopp
*/
protected static class PageMapEntry
@@ -94,7 +94,7 @@
/**
* Represents a session,
- *
+ *
* @author Matej Knopp
*/
protected class SessionEntry
@@ -138,7 +138,7 @@
/**
* Returns a {@link PageMapEntry} for specified pagemap. If the create attribute is set and
* the pagemap does not exist, new {@link PageMapEntry} will be created.
- *
+ *
* @param pageMapName
* @param create
* @return
@@ -169,7 +169,7 @@
/**
* Removes the pagemap entry and deletes the file.
- *
+ *
* @param entry
*/
private void removePageMapEntry(PageMapEntry entry)
@@ -180,7 +180,7 @@
/**
* Removes the specified pagemap and deletes the file.
- *
+ *
* @param pageMapName
*/
public synchronized void removePageMap(String pageMapName)
@@ -194,7 +194,7 @@
/**
* Saves the serialized page to appropriate pagemap file.
- *
+ *
* @param page
*/
public synchronized void savePage(SerializedPage page)
@@ -241,7 +241,7 @@
/**
* Removes the page from pagemap file.
- *
+ *
* @param pageMapName
* @param pageId
*/
@@ -256,7 +256,7 @@
/**
* Loads the part of pagemap file specified by the given PageWindow.
- *
+ *
* @param window
* @param pageMapFileName
* @return
@@ -290,7 +290,7 @@
/**
* Loads the specified page data.
- *
+ *
* @param pageMapName
* @param id
* @param versionNumber
@@ -332,7 +332,7 @@
/**
* Returns true if the given page exists for specified pageMap
- *
+ *
* @param pageMapName
* @param pageId
* @param versionNumber
@@ -349,7 +349,7 @@
/**
* Returns the folder for the specified sessions. If the folder doesn't exist and the create
* flag is set, the folder will be created.
- *
+ *
* @param sessionId
* @param create
* @return
@@ -368,7 +368,7 @@
/**
* Utility method for creating a directory
- *
+ *
* @param file
*/
private void mkdirs(File file)
@@ -397,7 +397,7 @@
/**
* Returns the file name for specified pagemap. If the session folder (folder that contains the
* file) does not exist and createSessionFolder is true, the folder will be created.
- *
+ *
* @param sessionId
* @param pageMapName
* @param createSessionFolder
@@ -414,7 +414,7 @@
/**
* Return maximum pagemap file size (in bytes).
- *
+ *
* @return
*/
protected int getMaxSizePerPageMap()
@@ -427,7 +427,7 @@
/**
* Returns maximum size per session (in bytes). After the session exceeds this size, appropriate
* number of last recently used pagemap files will be removed.
- *
+ *
* @return
*/
protected int getMaxSizePerSession()
@@ -441,7 +441,7 @@
/**
* Returns the "root" file store folder.
- *
+ *
* @return
*/
protected File getFileStoreFolder()
@@ -453,7 +453,7 @@
/**
* Creates a new {@link DiskPageStore} instance.
- *
+ *
* @param fileStoreFolder
* folder in which the session folders containing pagemap files will be stored
* @param maxSizePerPagemap
@@ -507,7 +507,7 @@
/**
* Creates a new {@link DiskPageStore} instance.
- *
+ *
* @param maxSizePerPagemap
* the maximum size of pagemap file (in bytes)
* @param maxSizePerSession
@@ -515,7 +515,7 @@
* @param fileChannelPoolCapacity
* the maximum number of concurrently opened files (higher number improves
* performance under heavy load).
- *
+ *
*/
public DiskPageStore(int maxSizePerPagemap, int maxSizePerSession, int fileChannelPoolCapacity)
{
@@ -548,7 +548,7 @@
/**
* Returns the SessionEntry for session with given id. If the entry does not yet exist and the
* createIfDoesNotExist attribute is set, new SessionEntry will be created.
- *
+ *
* @param sessionId
* @param createIfDoesNotExist
* @return
@@ -619,7 +619,7 @@
/**
* Removes the page (or entire pagemap) from specified session.
- *
+ *
* @param entry
* @param pageMap
* @param id
@@ -667,7 +667,7 @@
/**
* Stores the serialized pages. The storing is done either immediately (in synchronous mode) or
* it's scheduled to be stored by the worker thread.
- *
+ *
* @param sessionId
* @param pages
*/
@@ -691,7 +691,7 @@
/**
* Hook for processing serialized pages (e.g. sending those across cluster)
- *
+ *
* @param sessionId
* @param pages
*/
@@ -750,7 +750,7 @@
/**
* Returns the list of pages to be saved for the specified session id. If the list is not found,
* new list is created.
- *
+ *
* @param sessionId
* @return
*/
@@ -774,7 +774,7 @@
/**
* Saves all entries from the specified list.
- *
+ *
* @param sessionId
* @param list
*/
@@ -793,7 +793,7 @@
/**
* Schedules the pages to be saved by the worker thread.
- *
+ *
* @param sessionId
* @param pages
*/
@@ -814,7 +814,7 @@
/**
* Worker thread that saves the serialized pages. Saving pages in the separate thread results in
* smoother performance under load.
- *
+ *
* @author Matej Knopp
*/
private class PageSavingThread implements Runnable
@@ -892,7 +892,7 @@
/**
* Returns the amount time in milliseconds for the saving thread to sleep between checking
* whether there are pending serialized pages to be saved.
- *
+ *
* @return
*/
protected int getSavingThreadSleepTime()
@@ -903,7 +903,7 @@
/**
* Returns whether the {@link DiskPageStore} should work in synchronous or asynchronous mode.
* Asynchronous mode uses a worker thread to save pages, which results in smoother performance.
- *
+ *
* @return
*/
protected boolean isSynchronous()
@@ -916,7 +916,7 @@
/**
* Sets the number of last recently serialized pages kept in cache. The cache is used to aid
* performance on session replication.
- *
+ *
* @param lastRecentlySerializedPagesCacheSize
*/
public void setLastRecentlySerializedPagesCacheSize(int lastRecentlySerializedPagesCacheSize)
@@ -951,7 +951,7 @@
/**
* Store the serialized page in the request metadata,.
- *
+ *
* @param sessionId
* @param page
* @param pagesList
@@ -977,7 +977,7 @@
}
/**
- *
+ *
* @author Matej Knopp
*/
private static class SerializedPageWithSession implements Serializable
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/FileChannelPool.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/FileChannelPool.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/FileChannelPool.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/FileChannelPool.java Mon Oct 15 14:21:25 2007
@@ -45,7 +45,7 @@
* Note that under certain circumstances (when there are no empty slots in pool) the initial
* capacity can be exceeded (more files are opened then the specified capacity is). If this happens,
* a warning is written to log, as this probably means that there is a problem with page store.
- *
+ *
* @author Matej Knopp
*/
public class FileChannelPool
@@ -61,7 +61,7 @@
/**
* Construct.
- *
+ *
* @param capacity
* Maximum number of opened file channels.
*/
@@ -79,7 +79,7 @@
/**
* Creates a new file channel with specified file name.
- *
+ *
* @param fileName
* @param createIfDoesNotExist
* in case the file does not exist this parameter determines if the file should be
@@ -154,10 +154,10 @@
/**
* Returns a channel for given file. If the file doesn't exist, the createIfDoesNotExit
* attribute specifies if the file should be created.
- *
+ *
* Do NOT call close on the returned chanel. Instead call
* {@link #returnFileChannel(FileChannel)}
- *
+ *
* @param fileName
* @param createIfDoesNotExist
* @return
@@ -207,7 +207,7 @@
/**
* Returns the channel to the pool. It is necessary to call this for every channel obtained by
* calling {@link #getFileChannel(String, boolean)}.
- *
+ *
* @param channel
*/
public synchronized void returnFileChannel(FileChannel channel)
@@ -267,7 +267,7 @@
* Closes the file channel with given name and removes it from pool. Also removes the file from
* file system. If the channel is in use, the pool first waits until the chanel is returned to
* the pool and then closes it.
- *
+ *
* @param name
*/
public synchronized void closeAndDeleteFileChannel(String name)
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/PageWindowManager.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/PageWindowManager.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/PageWindowManager.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/PageWindowManager.java Mon Oct 15 14:21:25 2007
@@ -28,14 +28,14 @@
* The pages are stored inside the file in a cyclic way. Newer pages are placed after older ones,
* until the maximum file size is reached. After that, the next page is stored in the beginning of
* the file.
- *
+ *
* @author Matej Knopp
*/
public class PageWindowManager
{
/**
* Contains information about a page inside the file.
- *
+ *
* @author Matej Knopp
*/
private static class PageWindowInternal
@@ -170,7 +170,7 @@
/**
* Returns the index of the given page in the {@link #windows} list.
- *
+ *
* @param pageId
* @param versionNumber
* @param ajaxVersionNumber
@@ -199,7 +199,7 @@
/**
* Increments the {@link #indexPointer}. If the maximum file size has been reached, the
* {@link #indexPointer} is set to 0.
- *
+ *
* @return
*/
private int incrementIndexPointer()
@@ -218,7 +218,7 @@
/**
* Returns the offset in file of the window on given index. The offset is counted by getting the
* previous page offset and adding the previous page size to it.
- *
+ *
* @param index
* @return
*/
@@ -238,7 +238,7 @@
/**
* Splits the window with given index to two windows. First of those will have size specified by
* the argument, the other one will fill up the rest of the original window.
- *
+ *
* @param index
* @param size
*/
@@ -271,7 +271,7 @@
/**
* Merges the window with given index with the next window. The resulting window will have size
* of the two windows summed together.
- *
+ *
* @param index
*/
private void mergeWindowWithNext(int index)
@@ -292,7 +292,7 @@
* window size, the window will be split. Otherwise the window will be merged with as many
* subsequent window as necessary. In case the window is last window in the file, the size will
* be adjusted without splitting or merging.
- *
+ *
* @param index
* @param size
*/
@@ -338,7 +338,7 @@
* Allocates window on given index with to size. If the index is pointing to existing window,
* the window size will be adjusted. Otherwise a new window with appropriated size will be
* created.
- *
+ *
* @param index
* @param size
* @return
@@ -375,7 +375,7 @@
/**
* Public (read only) version of page window.
- *
+ *
* @author Matej Knopp
*/
public static class PageWindow
@@ -384,7 +384,7 @@
/**
* Construct.
- *
+ *
* @param pageWindowInternal
*/
private PageWindow(PageWindowInternal pageWindowInternal)
@@ -435,7 +435,7 @@
/**
* Creates and returns a new page window for given page.
- *
+ *
* @param pageId
* @param versionNumber
* @param ajaxVersionNumber
@@ -473,7 +473,7 @@
/**
* Returns the page window for given page or null if no window was found.
- *
+ *
* @param pageId
* @param versionNumber
* @param ajaxVersionNumber
@@ -494,7 +494,7 @@
/**
* Removes the page window for given page.
- *
+ *
* @param pageId
* @param versionNumber
* @param ajaxVersionNumber
@@ -524,7 +524,7 @@
/**
* Removes all page windows for given page. Removes all page versions.
- *
+ *
* @param pageId
*/
public void removePage(int pageId)
@@ -553,7 +553,7 @@
/**
* Returns last n saved page windows.
- *
+ *
* @param count
* @return
*/
@@ -591,7 +591,7 @@
/**
* Creates a new PageWindowManager.
- *
+ *
* @param maxSize
* maximum page size. After this size is exceeded, the pages will be saved starting
* at the beginning of file
@@ -603,7 +603,7 @@
/**
* Returns the size of all saved pages
- *
+ *
* @return
*/
public int getTotalSize()
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/SimpleSynchronousFilePageStore.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/SimpleSynchronousFilePageStore.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/SimpleSynchronousFilePageStore.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/pagestore/SimpleSynchronousFilePageStore.java Mon Oct 15 14:21:25 2007
@@ -34,12 +34,11 @@
import org.slf4j.LoggerFactory;
/**
- * Very simple page store that uses separate file for each serialized page
- * instance. Also this store doesn't use any worker threads.
+ * Very simple page store that uses separate file for each serialized page instance. Also this store
+ * doesn't use any worker threads.
* <p>
- * This store is for demonstration purposes only and will perform badly in
- * production.
- *
+ * This store is for demonstration purposes only and will perform badly in production.
+ *
* @author Matej Knopp
*/
public class SimpleSynchronousFilePageStore extends AbstractPageStore
@@ -49,7 +48,7 @@
/**
* Construct.
- *
+ *
* @param workDir
*/
public SimpleSynchronousFilePageStore(File workDir)
@@ -91,12 +90,11 @@
}
/**
- * Returns the file for specified page. The specification might be
- * incomplete (-1 set as versionNumber or ajaxVersionNumber). In that case,
- * it search for the correct file. The search traverses the session folder
- * which is inefficient and should not be used in production. It's good to
- * manage/cache this information in page store implementations.
- *
+ * Returns the file for specified page. The specification might be incomplete (-1 set as
+ * versionNumber or ajaxVersionNumber). In that case, it search for the correct file. The search
+ * traverses the session folder which is inefficient and should not be used in production. It's
+ * good to manage/cache this information in page store implementations.
+ *
* @param sessionDir
* @param pageMapName
* @param pageId
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/EmbeddedPortletHeaderResponse.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/EmbeddedPortletHeaderResponse.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/EmbeddedPortletHeaderResponse.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/EmbeddedPortletHeaderResponse.java Mon Oct 15 14:21:25 2007
@@ -31,7 +31,7 @@
{
private Response realResponse;
private StringResponse bufferedResponse;
-
+
public EmbeddedPortletHeaderResponse(Response realResponse)
{
this.realResponse = realResponse;
@@ -49,19 +49,20 @@
getResponse().write("var elem=document.createElement(\"link\");");
getResponse().write("elem.setAttribute(\"rel\",\"stylesheet\");");
getResponse().write("elem.setAttribute(\"type\",\"text/css\");");
- getResponse().write("elem.setAttribute(\"href\",\""+url+"\");");
+ getResponse().write("elem.setAttribute(\"href\",\"" + url + "\");");
if (media != null)
{
- getResponse().write("elem.setAttribute(\"media\",\""+media+"\");");
+ getResponse().write("elem.setAttribute(\"media\",\"" + media + "\");");
}
- getResponse().write("document.getElementsByTagName(\"head\")[0].appendChild(elem);");
+ getResponse()
+ .write("document.getElementsByTagName(\"head\")[0].appendChild(elem);");
getResponse().println("</script>");
markRendered(token);
}
}
}
-
+
/**
* @see org.apache.wicket.markup.html.internal.HeaderResponse#close()
*/
@@ -99,7 +100,8 @@
}
if (output.length() > 0)
{
- realResponse.write("<span id=\""+RequestContext.get().getNamespace()+"_embedded_head\" style=\"display:none\">");
+ realResponse.write("<span id=\"" + RequestContext.get().getNamespace() +
+ "_embedded_head\" style=\"display:none\">");
realResponse.write(output);
realResponse.write("</span>");
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/FilterRequestContext.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/FilterRequestContext.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/FilterRequestContext.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/FilterRequestContext.java Mon Oct 15 14:21:25 2007
@@ -29,19 +29,22 @@
this.request = request;
this.response = response;
}
-
+
public HttpServletRequest getRequest()
{
return request;
}
+
public void setRequest(HttpServletRequest request)
{
this.request = request;
}
+
public HttpServletResponse getResponse()
{
return response;
}
+
public void setResponse(HttpServletResponse response)
{
this.response = response;
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletActionServletResponseWrapper.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletActionServletResponseWrapper.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletActionServletResponseWrapper.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletActionServletResponseWrapper.java Mon Oct 15 14:21:25 2007
@@ -30,9 +30,10 @@
public class PortletActionServletResponseWrapper extends PortletServletResponseWrapper
{
- public PortletActionServletResponseWrapper(HttpServletResponse response, WicketResponseState responseState)
- {
- super(response, responseState);
+ public PortletActionServletResponseWrapper(HttpServletResponse response,
+ WicketResponseState responseState)
+ {
+ super(response, responseState);
}
public void addCookie(Cookie cookie)
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletInvalidMarkupFilter.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletInvalidMarkupFilter.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletInvalidMarkupFilter.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletInvalidMarkupFilter.java Mon Oct 15 14:21:25 2007
@@ -22,8 +22,9 @@
/**
- * This filter removes html page top level markup elements like <html>, <head> and <body>.
- * The filter is configured automatically by WicketFilter if it detects the application is (potentially) invoked as a Portlet.
+ * This filter removes html page top level markup elements like <html>, <head> and <body>. The
+ * filter is configured automatically by WicketFilter if it detects the application is (potentially)
+ * invoked as a Portlet.
*
* @author Ate Douma
*/
@@ -43,36 +44,36 @@
deleteOpenTag(responseBuffer, "head");
deleteOpenTag(responseBuffer, "body");
}
-
+
return responseBuffer;
}
-
+
private void deleteFragment(AppendingStringBuffer responseBuffer, String prefix, String postfix)
{
int startIndex, endIndex;
- if ((startIndex = responseBuffer.indexOf(prefix)) > -1)
+ if ((startIndex = responseBuffer.indexOf(prefix)) > -1)
{
- if ((endIndex = responseBuffer.indexOf(postfix, startIndex)) >-1)
+ if ((endIndex = responseBuffer.indexOf(postfix, startIndex)) > -1)
{
- responseBuffer.delete(startIndex, endIndex+postfix.length());
- }
+ responseBuffer.delete(startIndex, endIndex + postfix.length());
+ }
}
}
-
+
private void deleteOpenTag(AppendingStringBuffer responseBuffer, String tagName)
{
int startIndex, endIndex;
// find and remove opening tag
- if ((startIndex = responseBuffer.indexOf("<"+tagName)) > -1)
+ if ((startIndex = responseBuffer.indexOf("<" + tagName)) > -1)
{
- if ((endIndex = responseBuffer.indexOf(">", startIndex)) >-1)
+ if ((endIndex = responseBuffer.indexOf(">", startIndex)) > -1)
{
- responseBuffer.delete(startIndex, endIndex+1);
+ responseBuffer.delete(startIndex, endIndex + 1);
}
// remove closing tag
- if ((startIndex = responseBuffer.indexOf("</"+tagName+">")) > -1)
+ if ((startIndex = responseBuffer.indexOf("</" + tagName + ">")) > -1)
{
- responseBuffer.delete(startIndex, startIndex+tagName.length()+3);
+ responseBuffer.delete(startIndex, startIndex + tagName.length() + 3);
}
}
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRenderServletResponseWrapper.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRenderServletResponseWrapper.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRenderServletResponseWrapper.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRenderServletResponseWrapper.java Mon Oct 15 14:21:25 2007
@@ -29,12 +29,13 @@
public class PortletRenderServletResponseWrapper extends PortletServletResponseWrapper
{
RenderResponse renderResponse;
-
- public PortletRenderServletResponseWrapper(HttpServletResponse response, RenderResponse renderResponse, WicketResponseState responseState)
- {
- super(response, responseState);
- this.renderResponse = renderResponse;
- }
+
+ public PortletRenderServletResponseWrapper(HttpServletResponse response,
+ RenderResponse renderResponse, WicketResponseState responseState)
+ {
+ super(response, responseState);
+ this.renderResponse = renderResponse;
+ }
/**
* @see javax.servlet.ServletResponseWrapper#setContentType(java.lang.String)
@@ -44,29 +45,30 @@
renderResponse.setContentType(arg0);
}
- public void sendRedirect(String redirectLocation) throws IOException
+ public void sendRedirect(String redirectLocation) throws IOException
{
- RequestContext rc = RequestContext.get();
- if (rc instanceof PortletRequestContext)
- {
- String wicketUrl = ((PortletRequestContext)rc).getLastEncodedPath(redirectLocation);
- if (wicketUrl != null)
- {
- redirectLocation = wicketUrl;
- }
- else
- {
- String contextPath = ((PortletRequestContext)rc).getPortletRequest().getContextPath();
- if (redirectLocation.startsWith(contextPath+"/"))
- {
- redirectLocation = redirectLocation.substring(contextPath.length());
- if (redirectLocation.length() == 0)
- {
- redirectLocation = "/";
- }
- }
- }
- }
+ RequestContext rc = RequestContext.get();
+ if (rc instanceof PortletRequestContext)
+ {
+ String wicketUrl = ((PortletRequestContext)rc).getLastEncodedPath(redirectLocation);
+ if (wicketUrl != null)
+ {
+ redirectLocation = wicketUrl;
+ }
+ else
+ {
+ String contextPath = ((PortletRequestContext)rc).getPortletRequest()
+ .getContextPath();
+ if (redirectLocation.startsWith(contextPath + "/"))
+ {
+ redirectLocation = redirectLocation.substring(contextPath.length());
+ if (redirectLocation.length() == 0)
+ {
+ redirectLocation = "/";
+ }
+ }
+ }
+ }
super.sendRedirect(redirectLocation);
}
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletRequestContext.java Mon Oct 15 14:21:25 2007
@@ -46,10 +46,11 @@
private final PortletConfig portletConfig;
private final PortletRequest portletRequest;
private final PortletResponse portletResponse;
- // needed for JSR-168 support which only allows PortletURLs to be created by RenderResponse, with JSR-286 PortletResponse can do that too
+ // needed for JSR-168 support which only allows PortletURLs to be created by RenderResponse,
+ // with JSR-286 PortletResponse can do that too
private final RenderResponse renderResponse;
private final PortletResourceURLFactory resourceURLFactory;
- private final IHeaderResponse headerResponse;
+ private final IHeaderResponse headerResponse;
private String portletWindowId;
private String wicketUrlPortletParameter;
private final boolean ajax;
@@ -57,36 +58,43 @@
private final boolean resourceRequest;
private String[] lastEncodedUrl = new String[2];
- public PortletRequestContext(WicketFilterPortletContext filterContext, ServletWebRequest request, WebResponse response)
- {
- this.filterContext = filterContext;
- HttpServletRequest servletRequest = request.getHttpServletRequest();
- this.portletConfig = (PortletConfig)servletRequest.getAttribute("javax.portlet.config");
- this.portletRequest = (PortletRequest)servletRequest.getAttribute("javax.portlet.request");
- this.portletResponse = (PortletResponse)servletRequest.getAttribute("javax.portlet.response");
- this.renderResponse = (portletResponse instanceof RenderResponse) ? (RenderResponse)portletResponse : null;
- this.resourceURLFactory = (PortletResourceURLFactory)portletRequest.getAttribute(WicketPortlet.RESOURCE_URL_FACTORY_ATTR);
- this.wicketUrlPortletParameter = (String)portletRequest.getAttribute(WicketPortlet.WICKET_URL_PORTLET_PARAMETER_ATTR);
- this.ajax = request.isAjax();
- this.resourceRequest = "true".equals(servletRequest.getAttribute(WicketPortlet.PORTLET_RESOURCE_URL_ATTR));
- this.embedded = !(ajax || resourceRequest);
- this.headerResponse = embedded ? newPortletHeaderResponse(response) : null;
- }
-
+ public PortletRequestContext(WicketFilterPortletContext filterContext,
+ ServletWebRequest request, WebResponse response)
+ {
+ this.filterContext = filterContext;
+ HttpServletRequest servletRequest = request.getHttpServletRequest();
+ this.portletConfig = (PortletConfig)servletRequest.getAttribute("javax.portlet.config");
+ this.portletRequest = (PortletRequest)servletRequest.getAttribute("javax.portlet.request");
+ this.portletResponse = (PortletResponse)servletRequest
+ .getAttribute("javax.portlet.response");
+ this.renderResponse = (portletResponse instanceof RenderResponse)
+ ? (RenderResponse)portletResponse
+ : null;
+ this.resourceURLFactory = (PortletResourceURLFactory)portletRequest
+ .getAttribute(WicketPortlet.RESOURCE_URL_FACTORY_ATTR);
+ this.wicketUrlPortletParameter = (String)portletRequest
+ .getAttribute(WicketPortlet.WICKET_URL_PORTLET_PARAMETER_ATTR);
+ this.ajax = request.isAjax();
+ this.resourceRequest = "true".equals(servletRequest
+ .getAttribute(WicketPortlet.PORTLET_RESOURCE_URL_ATTR));
+ this.embedded = !(ajax || resourceRequest);
+ this.headerResponse = embedded ? newPortletHeaderResponse(response) : null;
+ }
+
protected IHeaderResponse newPortletHeaderResponse(Response response)
{
return new EmbeddedPortletHeaderResponse(response);
}
- public String getLastEncodedPath()
- {
- if (lastEncodedUrl != null)
- {
- return lastEncodedUrl[1];
- }
- return null;
- }
-
+ public String getLastEncodedPath()
+ {
+ if (lastEncodedUrl != null)
+ {
+ return lastEncodedUrl[1];
+ }
+ return null;
+ }
+
public String getLastEncodedPath(String url)
{
if (url != null && lastEncodedUrl != null && url.equals(lastEncodedUrl[0]))
@@ -95,29 +103,29 @@
}
return null;
}
-
+
protected String saveLastEncodedUrl(String url, String path)
{
lastEncodedUrl[0] = url;
lastEncodedUrl[1] = path;
return url;
}
-
+
/**
* @see org.apache.wicket.RequestContext#encodeActionURL(java.lang.CharSequence)
*/
public CharSequence encodeActionURL(CharSequence path)
{
- return encodeActionURL(path, false);
- }
-
- public CharSequence encodeActionURL(CharSequence path, boolean forceActionURL)
- {
- if ((!forceActionURL && resourceRequest) || RequestCycle.get().isUrlForNewWindowEncoding())
+ return encodeActionURL(path, false);
+ }
+
+ public CharSequence encodeActionURL(CharSequence path, boolean forceActionURL)
+ {
+ if ((!forceActionURL && resourceRequest) || RequestCycle.get().isUrlForNewWindowEncoding())
{
return encodeResourceURL(path);
}
- if ( path != null )
+ if (path != null)
{
path = getQualifiedPath(path);
if (renderResponse != null)
@@ -135,7 +143,7 @@
*/
public String encodeMarkupId(String markupId)
{
- if ( markupId != null )
+ if (markupId != null)
{
markupId = getNamespace() + "_" + markupId;
}
@@ -147,22 +155,23 @@
*/
public CharSequence encodeRenderURL(CharSequence path)
{
- return encodeRenderURL(path, false);
- }
-
- public CharSequence encodeRenderURL(CharSequence path, boolean forceRenderURL)
- {
- if ((!forceRenderURL && resourceRequest) || RequestCycle.get().isUrlForNewWindowEncoding())
+ return encodeRenderURL(path, false);
+ }
+
+ public CharSequence encodeRenderURL(CharSequence path, boolean forceRenderURL)
+ {
+ if ((!forceRenderURL && resourceRequest) || RequestCycle.get().isUrlForNewWindowEncoding())
{
return encodeResourceURL(path);
}
- if ( path != null )
- {
+ if (path != null)
+ {
path = getQualifiedPath(path);
if (renderResponse != null)
{
PortletURL url = renderResponse.createRenderURL();
- url.setParameter(wicketUrlPortletParameter+portletRequest.getPortletMode().toString(), path.toString());
+ url.setParameter(wicketUrlPortletParameter +
+ portletRequest.getPortletMode().toString(), path.toString());
path = saveLastEncodedUrl(url.toString(), path.toString());
}
}
@@ -174,7 +183,7 @@
*/
public CharSequence encodeResourceURL(CharSequence path)
{
- if ( path != null )
+ if (path != null)
{
path = getQualifiedPath(path);
if (renderResponse != null)
@@ -182,9 +191,14 @@
try
{
HashMap parameters = new HashMap(2);
- parameters.put(wicketUrlPortletParameter+portletRequest.getPortletMode().toString(), new String[]{path.toString()});
- parameters.put(WicketPortlet.PORTLET_RESOURCE_URL_PARAMETER, new String[]{"true"});
- path = saveLastEncodedUrl(resourceURLFactory.createResourceURL(portletConfig, (RenderRequest)portletRequest, renderResponse, parameters), path.toString());
+ parameters.put(wicketUrlPortletParameter +
+ portletRequest.getPortletMode().toString(), new String[] { path
+ .toString() });
+ parameters.put(WicketPortlet.PORTLET_RESOURCE_URL_PARAMETER,
+ new String[] { "true" });
+ path = saveLastEncodedUrl(resourceURLFactory.createResourceURL(portletConfig,
+ (RenderRequest)portletRequest, renderResponse, parameters), path
+ .toString());
}
catch (PortletException e)
{
@@ -200,10 +214,10 @@
*/
public CharSequence encodeSharedResourceURL(CharSequence path)
{
- if ( path != null )
+ if (path != null)
{
String url = filterContext.encodeWindowIdInPath(getPortletWindowId(), path);
- return saveLastEncodedUrl(url,url);
+ return saveLastEncodedUrl(url, url);
}
return null;
}
@@ -223,7 +237,7 @@
{
return renderResponse != null ? renderResponse.getNamespace() : "";
}
-
+
/**
* @see org.apache.wicket.RequestContext#isPortletRequest()
*/
@@ -231,27 +245,29 @@
{
return true;
}
-
+
public boolean isEmbedded()
{
return embedded;
}
-
+
protected String getQualifiedPath(CharSequence path)
- {
- HttpServletRequest request = ((WebRequest)RequestCycle.get().getRequest()).getHttpServletRequest();
+ {
+ HttpServletRequest request = ((WebRequest)RequestCycle.get().getRequest())
+ .getHttpServletRequest();
return request.getServletPath() + "/" + path;
}
-
+
protected String getPortletWindowId()
{
if (portletWindowId == null)
{
- portletWindowId = PortletWindowUtils.getPortletWindowId(portletRequest.getPortletSession());
+ portletWindowId = PortletWindowUtils.getPortletWindowId(portletRequest
+ .getPortletSession());
}
return portletWindowId;
}
-
+
public PortletConfig getPortletConfig()
{
return portletConfig;
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletRequestWrapper.java Mon Oct 15 14:21:25 2007
@@ -26,113 +26,121 @@
*/
public class PortletServletRequestWrapper extends HttpServletRequestWrapper
{
- private ServletContext context;
- private String contextPath;
- private String servletPath;
- private String pathInfo;
- private String requestURI;
- private String queryString;
- private HttpSession session;
-
- private static String decodePathInfo(HttpServletRequest request, String filterPath)
- {
- String pathInfo = request.getRequestURI().substring(request.getContextPath().length()+filterPath.length());
- return pathInfo == null || pathInfo.length() < 2 ? null : pathInfo;
- }
-
- private static String makeServletPath(String filterPath)
- {
- return "/"+filterPath.substring(0,filterPath.length()-1);
- }
-
- protected PortletServletRequestWrapper(ServletContext context, HttpSession proxiedSession, HttpServletRequest request, String filterPath)
- {
- super(request);
- this.context = context;
- this.session = proxiedSession;
- if ( proxiedSession == null )
- {
- this.session = request.getSession(false);
- }
- this.servletPath = makeServletPath(filterPath);
- if ((this.contextPath = (String) request.getAttribute("javax.servlet.include.context_path")) != null)
- {
- this.requestURI = (String) request.getAttribute("javax.servlet.include.request_uri");
- this.queryString = (String) request.getAttribute("javax.servlet.include.query_string");
- }
- else if ((this.contextPath = (String) request.getAttribute("javax.servlet.forward.context_path")) != null)
- {
- this.requestURI = (String) request.getAttribute("javax.servlet.forward.request_uri");
- this.queryString = (String) request.getAttribute("javax.servlet.forward.query_string");
- }
- else
- {
- this.contextPath = request.getContextPath();
- this.requestURI = request.getRequestURI();
- this.queryString = request.getQueryString();
- }
- }
-
- public PortletServletRequestWrapper(ServletContext context, HttpServletRequest request, HttpSession proxiedSession, String filterPath)
- {
- this(context, proxiedSession, request, filterPath);
-
- String pathInfo = this.requestURI.substring(this.contextPath.length()+filterPath.length());
- this.pathInfo = pathInfo == null || pathInfo.length() < 2 ? null : pathInfo;
- }
-
- public PortletServletRequestWrapper(ServletContext context, HttpServletRequest request, HttpSession proxiedSession, String filterPath, String pathInfo)
- {
- this(context, proxiedSession, request, filterPath);
-
- this.pathInfo = pathInfo;
- // override requestURI
- this.requestURI = this.contextPath+this.servletPath+(pathInfo!=null?pathInfo:"");
- }
-
- public String getContextPath()
- {
- return contextPath;
- }
-
+ private ServletContext context;
+ private String contextPath;
+ private String servletPath;
+ private String pathInfo;
+ private String requestURI;
+ private String queryString;
+ private HttpSession session;
+
+ private static String decodePathInfo(HttpServletRequest request, String filterPath)
+ {
+ String pathInfo = request.getRequestURI().substring(
+ request.getContextPath().length() + filterPath.length());
+ return pathInfo == null || pathInfo.length() < 2 ? null : pathInfo;
+ }
+
+ private static String makeServletPath(String filterPath)
+ {
+ return "/" + filterPath.substring(0, filterPath.length() - 1);
+ }
+
+ protected PortletServletRequestWrapper(ServletContext context, HttpSession proxiedSession,
+ HttpServletRequest request, String filterPath)
+ {
+ super(request);
+ this.context = context;
+ this.session = proxiedSession;
+ if (proxiedSession == null)
+ {
+ this.session = request.getSession(false);
+ }
+ this.servletPath = makeServletPath(filterPath);
+ if ((this.contextPath = (String)request.getAttribute("javax.servlet.include.context_path")) != null)
+ {
+ this.requestURI = (String)request.getAttribute("javax.servlet.include.request_uri");
+ this.queryString = (String)request.getAttribute("javax.servlet.include.query_string");
+ }
+ else if ((this.contextPath = (String)request
+ .getAttribute("javax.servlet.forward.context_path")) != null)
+ {
+ this.requestURI = (String)request.getAttribute("javax.servlet.forward.request_uri");
+ this.queryString = (String)request.getAttribute("javax.servlet.forward.query_string");
+ }
+ else
+ {
+ this.contextPath = request.getContextPath();
+ this.requestURI = request.getRequestURI();
+ this.queryString = request.getQueryString();
+ }
+ }
+
+ public PortletServletRequestWrapper(ServletContext context, HttpServletRequest request,
+ HttpSession proxiedSession, String filterPath)
+ {
+ this(context, proxiedSession, request, filterPath);
+
+ String pathInfo = this.requestURI
+ .substring(this.contextPath.length() + filterPath.length());
+ this.pathInfo = pathInfo == null || pathInfo.length() < 2 ? null : pathInfo;
+ }
+
+ public PortletServletRequestWrapper(ServletContext context, HttpServletRequest request,
+ HttpSession proxiedSession, String filterPath, String pathInfo)
+ {
+ this(context, proxiedSession, request, filterPath);
+
+ this.pathInfo = pathInfo;
+ // override requestURI
+ this.requestURI = this.contextPath + this.servletPath + (pathInfo != null ? pathInfo : "");
+ }
+
+ public String getContextPath()
+ {
+ return contextPath;
+ }
+
public String getServletPath()
- {
- return servletPath;
- }
-
- public String getPathInfo()
- {
- return pathInfo;
- }
-
- public String getRequestURI()
- {
- return requestURI;
- }
-
- public String getQueryString()
- {
- return queryString;
- }
-
- public HttpSession getSession()
- {
- return getSession(true);
- }
-
- public HttpSession getSession(boolean create)
- {
- return session != null ? session : super.getSession(create);
- }
-
- public Object getAttribute(String name)
- {
- // TODO: check if these can possibly be set/handled
- // nullifying these for now to prevent Wicket ServletWebRequest.getRelativePathPrefixToWicketHandler() going the wrong route
- if ("javax.servlet.error.request_uri".equals(name) || "javax.servlet.forward.servlet_path".equals(name))
- {
- return null;
- }
- return super.getAttribute(name);
- }
+ {
+ return servletPath;
+ }
+
+ public String getPathInfo()
+ {
+ return pathInfo;
+ }
+
+ public String getRequestURI()
+ {
+ return requestURI;
+ }
+
+ public String getQueryString()
+ {
+ return queryString;
+ }
+
+ public HttpSession getSession()
+ {
+ return getSession(true);
+ }
+
+ public HttpSession getSession(boolean create)
+ {
+ return session != null ? session : super.getSession(create);
+ }
+
+ public Object getAttribute(String name)
+ {
+ // TODO: check if these can possibly be set/handled
+ // nullifying these for now to prevent Wicket
+ // ServletWebRequest.getRelativePathPrefixToWicketHandler() going the wrong route
+ if ("javax.servlet.error.request_uri".equals(name) ||
+ "javax.servlet.forward.servlet_path".equals(name))
+ {
+ return null;
+ }
+ return super.getAttribute(name);
+ }
}
Modified: wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java
URL: http://svn.apache.org/viewvc/wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java?rev=584925&r1=584924&r2=584925&view=diff
==============================================================================
--- wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java (original)
+++ wicket/trunk/jdk-1.4/wicket/src/main/java/org/apache/wicket/protocol/http/portlet/PortletServletResponseWrapper.java Mon Oct 15 14:21:25 2007
@@ -27,8 +27,9 @@
public class PortletServletResponseWrapper extends HttpServletResponseWrapper
{
private WicketResponseState responseState;
-
- public PortletServletResponseWrapper(HttpServletResponse response, WicketResponseState responseState)
+
+ public PortletServletResponseWrapper(HttpServletResponse response,
+ WicketResponseState responseState)
{
super(response);
this.responseState = responseState;
@@ -42,7 +43,7 @@
responseState.setErrorCode(errorCode);
responseState.setErrorMessage(errorMessage);
}
-
+
/**
* @see javax.servlet.http.HttpServletResponseWrapper#sendError(int)
*/