You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by mi...@apache.org on 2006/03/17 13:46:04 UTC
svn commit: r386634 -
/lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
Author: michi
Date: Fri Mar 17 04:46:03 2006
New Revision: 386634
URL: http://svn.apache.org/viewcvs?rev=386634&view=rev
Log:
ignore non-XML files
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=386634&r1=386633&r2=386634&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 Fri Mar 17 04:46:03 2006
@@ -41,6 +41,7 @@
import org.w3c.dom.Attr;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.SAXParseException;
/**
* Rewrite the links in a publication. This is used after renaming / moving a document.
@@ -104,9 +105,7 @@
String[] xPaths = doctype.getLinkAttributeXPaths();
try {
-
- org.w3c.dom.Document xmlDocument = SourceUtil.readDOM(examinedDocument.getSourceURI(),
- this.manager);
+ org.w3c.dom.Document xmlDocument = SourceUtil.readDOM(examinedDocument.getSourceURI(), this.manager);
for (int xPathIndex = 0; xPathIndex < xPaths.length; xPathIndex++) {
NodeList nodes = XPathAPI.selectNodeList(xmlDocument,
@@ -144,10 +143,14 @@
examinedDocument.getSourceURI(),
this.manager);
}
-
+ } catch (SAXParseException e) {
+ getLogger().warn("Document [" + examinedDocument + "] is not XML and will be ignored!");
+ } catch (Exception e) {
+ getLogger().error(e.getMessage(), e);
} finally {
}
-
+ } else {
+ getLogger().warn("HUGO: No such document: " + examinedDocument.getSourceURI());
}
}
} catch (final Exception e) {
@@ -225,4 +228,4 @@
}
-}
\ No newline at end of file
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org
Re: De-centralizing link rewriting
Posted by Andreas Hartmann <an...@apache.org>.
Michael Wechner wrote:
> Andreas Hartmann wrote:
>
>> michi@apache.org wrote:
>>
>>> Author: michi
>>> Date: Fri Mar 17 04:46:03 2006
>>> New Revision: 386634
>>>
>>> URL: http://svn.apache.org/viewcvs?rev=386634&view=rev
>>> Log:
>>> ignore non-XML files
>>>
>>> Modified:
>>>
>>> lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
>>>
>>
>>
>> [...]
>>
>>> + } catch (SAXParseException e) {
>>> + getLogger().warn("Document [" +
>>> examinedDocument + "] is not XML and will be ignored!");
>>
>>
>> There should be a more elegant way to do this. A SAXParseException
>> could have multiple causes, not only that the source is not an XML
>> document.
>>
>> We could ask the resource type for the link-rewriting service to
>> use. Resource types for binary resources could use a service which
>> just ignores the document.
>>
>> WDYT?
>
>
> yes, makes sense
For the moment, it would be even easier not to re-write a document if
the resource type doesn't provide any link rewriting XPaths.
-- Andreas
--
Andreas Hartmann
Wyona Inc. - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
andreas.hartmann@wyona.com andreas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org
Re: De-centralizing link rewriting
Posted by Michael Wechner <mi...@wyona.com>.
Andreas Hartmann wrote:
> michi@apache.org wrote:
>
>> Author: michi
>> Date: Fri Mar 17 04:46:03 2006
>> New Revision: 386634
>>
>> URL: http://svn.apache.org/viewcvs?rev=386634&view=rev
>> Log:
>> ignore non-XML files
>>
>> Modified:
>>
>> lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
>>
>
>
> [...]
>
>> + } catch (SAXParseException e) {
>> + getLogger().warn("Document [" +
>> examinedDocument + "] is not XML and will be ignored!");
>
>
> There should be a more elegant way to do this. A SAXParseException
> could have multiple causes, not only that the source is not an XML
> document.
>
> We could ask the resource type for the link-rewriting service to
> use. Resource types for binary resources could use a service which
> just ignores the document.
>
> WDYT?
yes, makes sense
>
>
>> + } else {
>> + getLogger().warn("HUGO: No such document: " +
>> examinedDocument.getSourceURI());
>
>
> Hmmm, why should Hugo be particularly interested in this message? :)
sorry for that. I have just removed it.
Michi
>
> -- Andreas
>
--
Michael Wechner
Wyona - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
michael.wechner@wyona.com michi@apache.org
+41 44 272 91 61
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org
De-centralizing link rewriting (was: svn commit: r386634 - /lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java)
Posted by Andreas Hartmann <an...@apache.org>.
michi@apache.org wrote:
> Author: michi
> Date: Fri Mar 17 04:46:03 2006
> New Revision: 386634
>
> URL: http://svn.apache.org/viewcvs?rev=386634&view=rev
> Log:
> ignore non-XML files
>
> Modified:
> lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
[...]
> + } catch (SAXParseException e) {
> + getLogger().warn("Document [" + examinedDocument + "] is not XML and will be ignored!");
There should be a more elegant way to do this. A SAXParseException
could have multiple causes, not only that the source is not an XML document.
We could ask the resource type for the link-rewriting service to
use. Resource types for binary resources could use a service which
just ignores the document.
WDYT?
> + } else {
> + getLogger().warn("HUGO: No such document: " + examinedDocument.getSourceURI());
Hmmm, why should Hugo be particularly interested in this message? :)
-- Andreas
--
Andreas Hartmann
Wyona Inc. - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
andreas.hartmann@wyona.com andreas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org
Re: Tab stops
Posted by Michael Wechner <mi...@wyona.com>.
Andreas Hartmann wrote:
>> Modified:
>> lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
>>
>
>
>> + } catch (SAXParseException e) {
>
>
>
> Please try to avoid tab stops ...
fixed
Michi
>
> -- Andreas
>
>
--
Michael Wechner
Wyona - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
michael.wechner@wyona.com michi@apache.org
+41 44 272 91 61
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org
Tab stops (was: svn commit: r386634 - /lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java)
Posted by Andreas Hartmann <an...@apache.org>.
> Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/usecases/LinkRewriterImpl.java
> + } catch (SAXParseException e) {
Please try to avoid tab stops ...
-- Andreas
--
Andreas Hartmann
Wyona Inc. - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
andreas.hartmann@wyona.com andreas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org