[Yanel-commits] rev 20278 -
public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources
david at wyona.com
david at wyona.com
Thu Nov 23 19:12:16 CET 2006
Author: david
Date: 2006-11-23 19:12:15 +0100 (Thu, 23 Nov 2006)
New Revision: 20278
Modified:
public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/LinkChecker.java
public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java
Log:
bug#5013 fixed. another bug found on JSPWiki see bug#5062
Modified: public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/LinkChecker.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/LinkChecker.java 2006-11-23 18:10:31 UTC (rev 20277)
+++ public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/LinkChecker.java 2006-11-23 18:12:15 UTC (rev 20278)
@@ -13,8 +13,10 @@
private static Category log = Category.getInstance(LinkChecker.class);
private ByteArrayInputStream byteArrayInputStream = null;
private StringBuffer transformedXmlAsBuffer = null;
-
- public LinkChecker() {
+ private String path2Resource = null;
+
+ public LinkChecker(String path2Resource) {
+ this.path2Resource = path2Resource;
}
public void startDocument() throws SAXException {
@@ -81,7 +83,10 @@
}
private boolean resourceExists(String path) {
-
+ if(!path.startsWith("/")) {
+ path = path2Resource + path;
+ }
+ log.debug("checking link --> " + path);
RepoPath rp;
try {
rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path), new RepositoryFactory());
Modified: public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java 2006-11-23 18:10:31 UTC (rev 20277)
+++ public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java 2006-11-23 18:12:15 UTC (rev 20278)
@@ -41,7 +41,6 @@
import org.wyona.yanel.core.attributes.viewable.View;
import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
-import org.wyona.yarep.core.NoSuchNodeException;
import org.wyona.yarep.core.RepositoryException;
import org.wyona.yarep.core.Repository;
import org.wyona.yarep.core.RepositoryFactory;
@@ -56,6 +55,7 @@
private final String XML_MIME_TYPE = "application/xml";
private DocumentBuilderFactory dbf = null;
private Repository repository = null;
+ private String context = null;
/**
*
@@ -81,6 +81,10 @@
RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), new RepositoryFactory());
repository = rp.getRepo();
+
+ String path2Resource = path.toString();
+ path2Resource = path2Resource.substring(0, path2Resource.lastIndexOf("/") + 1);
+
//these fields are specified via interface
int type = 1;//is the jspWikiParser
InputStream inputStream = rp.getRepo().getInputStream(new org.wyona.yarep.core.Path(rp.getPath().toString()));
@@ -102,12 +106,14 @@
defaultView.setMimeType("application/xhtml+xml");
}
- LinkChecker linkChecker = new LinkChecker();
+ LinkChecker linkChecker = new LinkChecker(path2Resource);
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(wikiParser.getInputStream(), linkChecker);
-
+ //transformer.setParameter("yanel.contextPath", context);
+ //transformer.setParameter("yanel.path2Resource", path2Resource);
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
transformer.transform(new StreamSource(linkChecker.getInputStream()), new StreamResult(baos));
+
defaultView.setInputStream(new java.io.ByteArrayInputStream(baos.toByteArray()));
return defaultView;
@@ -121,6 +127,7 @@
*
*/
public View getView(HttpServletRequest request, String viewId) {
+ context = request.getContextPath();
return getView(new Path(request.getServletPath()), viewId);
}
@@ -147,43 +154,6 @@
}
/**
- * @return the empty wiki resource as String
- */
- private String getEmptyWikiXml() {
- StringBuffer emptyWikiXml = new StringBuffer();
- emptyWikiXml.append("<?xml version=\"1.0\"?>");
- emptyWikiXml.append("\n");
- emptyWikiXml.append("<wiki xmlns=\"http://www.wyona.org/neutron/1.0\">");
- emptyWikiXml.append("\n");
- emptyWikiXml.append("</wiki>");
-
- return emptyWikiXml.toString();
- }
-
- /**
- * @param newWikiPage
- * @return the empty wiki introspection as String
- */
- private String getEmptyWikiIntrospection(String newWikiPage) {
- StringBuffer emptyWikiPageContent = new StringBuffer();
- emptyWikiPageContent.append("<?xml version=\"1.0\"?>");
- emptyWikiPageContent.append("\n");
- emptyWikiPageContent.append("<introspection xmlns=\"http://www.wyona.org/neutron/1.0\">");
- emptyWikiPageContent.append("\n\t");
- emptyWikiPageContent.append("<edit mime-type=\"application/xml\" name=\"" + newWikiPage + "\">");
- emptyWikiPageContent.append("\n\t\t");
- emptyWikiPageContent.append("<checkout url=\"/wiki/" + newWikiPage + ".html\" method=\"GET\"/>");
- emptyWikiPageContent.append("\n\t\t");
- emptyWikiPageContent.append("<checkin url=\"/wiki/" + newWikiPage + ".html?yanel.resource.usecase=checkin\" method=\"PUT\"/>");
- emptyWikiPageContent.append("\n\t");
- emptyWikiPageContent.append("</edit>");
- emptyWikiPageContent.append("\n");
- emptyWikiPageContent.append("</introspection>");
-
- return emptyWikiPageContent.toString();
- }
-
- /**
*
*/
private Path getXSLTPath(Path path) {
More information about the Yanel-commits
mailing list