Author: andreas
Date: Tue Mar 21 04:58:16 2006
New Revision: 387515
URL: http://svn.apache.org/viewcvs?rev=387515&view=rev
Log:
[minor change] Added some debug statements.
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java?rev=387515&r1=387514&r2=387515&view=diff
==============================================================================
---
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
(original)
+++
lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
Tue Mar 21 04:58:16 2006
@@ -88,6 +88,12 @@
Request request = ObjectModelHelper.getRequest(this.objectModel);
String contextPath = request.getContextPath();
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Rewriting source: [" + originalTargetDocument +
"]");
+ getLogger().debug("Rewriting target: [" + newTargetDocument + "]");
+ getLogger().debug("Rewriting context path: [" + contextPath + "]");
+ }
+
try {
for (int documentIndex = 0; documentIndex < documents.length;
documentIndex++) {
@@ -103,12 +109,21 @@
ResourceType doctype = examinedDocument.getResourceType();
String[] xPaths = doctype.getLinkAttributeXPaths();
- if (xPaths.length > 0) {
+ if (xPaths.length == 0) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Rewriting: No XPaths for
resource type ["
+ + doctype.getName() + "]");
+ }
+ } else {
try {
org.w3c.dom.Document xmlDocument =
SourceUtil.readDOM(examinedDocument.getSourceURI(),
this.manager);
for (int xPathIndex = 0; xPathIndex <
xPaths.length; xPathIndex++) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Rewriting: Check XPath
["
+ + xPaths[xPathIndex] + "]");
+ }
NodeList nodes =
XPathAPI.selectNodeList(xmlDocument,
xPaths[xPathIndex]);
for (int nodeIndex = 0; nodeIndex <
nodes.getLength(); nodeIndex++) {
@@ -120,17 +135,27 @@
}
Attr attribute = (Attr) node;
final String url = attribute.getValue();
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Rewriting: Check
URL [" + url + "]");
+ }
if (url.startsWith(contextPath + "/" +
publication.getId())) {
final String webappUrl =
url.substring(contextPath.length());
-
if (identityMap.isDocument(webappUrl))
{
Document targetDocument =
identityMap.getFromURL(webappUrl);
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Rewriting:
Check webapp URL ["
+ + webappUrl + "]");
+ }
if (matches(targetDocument,
originalTargetDocument)) {
String newTargetUrl =
getNewTargetURL(targetDocument,
originalTargetDocument,
newTargetDocument);
+ if
(getLogger().isDebugEnabled()) {
+ getLogger().debug("Rewrite
URL [" + webappUrl
+ + "] to [" +
newTargetUrl + "]");
+ }
attribute.setValue(contextPath
+ newTargetUrl);
linksRewritten = true;
}
|