[Yanel-commits] rev 21078 - in
public/yanel/trunk/src/contributions/resources:
atom-entry/src/java/org/wyona/yanel/impl/resources
davcollection/src/java/org/wyona/yanel/impl/resources
nutch/src/java/org/wyona/yanel/impl/resources
michi at wyona.com
michi at wyona.com
Thu Dec 21 17:39:05 CET 2006
Author: michi
Date: 2006-12-21 17:39:04 +0100 (Thu, 21 Dec 2006)
New Revision: 21078
Modified:
public/yanel/trunk/src/contributions/resources/atom-entry/src/java/org/wyona/yanel/impl/resources/AtomEntryResource.java
public/yanel/trunk/src/contributions/resources/davcollection/src/java/org/wyona/yanel/impl/resources/DavCollection.java
public/yanel/trunk/src/contributions/resources/davcollection/src/java/org/wyona/yanel/impl/resources/XmlViewResource.java
public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/NutchResource.java
Log:
use getPath method instead path variable
Modified: public/yanel/trunk/src/contributions/resources/atom-entry/src/java/org/wyona/yanel/impl/resources/AtomEntryResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/atom-entry/src/java/org/wyona/yanel/impl/resources/AtomEntryResource.java 2006-12-21 15:09:49 UTC (rev 21077)
+++ public/yanel/trunk/src/contributions/resources/atom-entry/src/java/org/wyona/yanel/impl/resources/AtomEntryResource.java 2006-12-21 16:39:04 UTC (rev 21078)
@@ -74,11 +74,11 @@
*/
public View getView(String viewId) {
View defaultView = new View();
- String mimeType = getMimeType(path, viewId);
+ String mimeType = getMimeType(getPath(), viewId);
defaultView.setMimeType(mimeType);
try {
- RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+ RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(getPath().toString()), getRepositoryFactory());
if (mimeType.equals("application/xml")) {
defaultView.setInputStream(getContentXML(rp));
@@ -86,10 +86,11 @@
} else if (mimeType.equals("application/xhtml+xml") || mimeType.equals("text/html")) {
TransformerFactory tf = TransformerFactory.newInstance();
//tf.setURIResolver(null);
- Transformer transformer = tf.newTransformer(new StreamSource(rp.getRepo().getInputStream(new org.wyona.yarep.core.Path(getXSLTPath(path).toString()))));
- transformer.setParameter("yanel.path.name", path.getName());
- transformer.setParameter("yanel.path", path.toString());
- transformer.setParameter("yanel.back2context", backToRoot(path, ""));
+ Transformer transformer = tf.newTransformer(new StreamSource(rp.getRepo().getInputStream(new org.wyona.yarep.core.Path(getXSLTPath(getPath()).toString()))));
+ transformer.setParameter("yanel.path.name", getPath().getName());
+ transformer.setParameter("yanel.path", getPath().toString());
+ // TODO: There seems to be a bug re back2context
+ transformer.setParameter("yanel.back2context", backToRoot(getPath(), ""));
transformer.setParameter("yarep.back2realm", backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
// TODO: Is this the best way to generate an InputStream from an OutputStream?
java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
@@ -164,7 +165,7 @@
*
*/
public Reader getReader() throws Exception {
- RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+ RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(getPath().toString()), getRepositoryFactory());
return rp.getRepo().getReader(new org.wyona.yarep.core.Path(rp.getPath().toString()));
}
@@ -173,7 +174,7 @@
*/
public InputStream getInputStream() throws Exception {
// TODO: Reuse stuff from getReader ...
- RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+ RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(getPath().toString()), getRepositoryFactory());
return rp.getRepo().getInputStream(new org.wyona.yarep.core.Path(rp.getPath().toString()));
}
@@ -189,7 +190,7 @@
*
*/
public OutputStream getOutputStream() throws Exception {
- RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+ RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(getPath().toString()), getRepositoryFactory());
return rp.getRepo().getOutputStream(new org.wyona.yarep.core.Path(rp.getPath().toString()));
}
@@ -209,20 +210,20 @@
entry.setPublished(date);
}
- RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+ RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(getPath().toString()), getRepositoryFactory());
OutputStream out = rp.getRepo().getOutputStream(new org.wyona.yarep.core.Path(rp.getPath().toString()));
org.apache.abdera.writer.Writer writer = abdera.getWriter();
writer.writeTo(entry, out);
- log.error("DEBUG: Atom entry has been written: " + path);
+ log.error("DEBUG: Atom entry has been written: " + getPath());
}
/**
*
*/
public long getLastModified() throws Exception {
- RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+ RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(getPath().toString()), getRepositoryFactory());
return rp.getRepo().getLastModified(new org.wyona.yarep.core.Path(rp.getPath().toString()));
}
@@ -274,7 +275,7 @@
*
*/
public boolean delete() throws Exception {
- RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
+ RepoPath rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(getPath().toString()), getRepositoryFactory());
return rp.getRepo().delete(new org.wyona.yarep.core.Path(rp.getPath().toString()));
}
@@ -291,7 +292,7 @@
*
*/
public long getSize() throws Exception {
- return getRealm().getRepository().getSize(path);
+ return getRealm().getRepository().getSize(getPath());
}
}
Modified: public/yanel/trunk/src/contributions/resources/davcollection/src/java/org/wyona/yanel/impl/resources/DavCollection.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/davcollection/src/java/org/wyona/yanel/impl/resources/DavCollection.java 2006-12-21 15:09:49 UTC (rev 21077)
+++ public/yanel/trunk/src/contributions/resources/davcollection/src/java/org/wyona/yanel/impl/resources/DavCollection.java 2006-12-21 16:39:04 UTC (rev 21078)
@@ -183,6 +183,6 @@
*
*/
public long getSize() throws Exception {
- return getRealm().getRepository().getSize(path);
+ return getRealm().getRepository().getSize(getPath());
}
}
Modified: public/yanel/trunk/src/contributions/resources/davcollection/src/java/org/wyona/yanel/impl/resources/XmlViewResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/davcollection/src/java/org/wyona/yanel/impl/resources/XmlViewResource.java 2006-12-21 15:09:49 UTC (rev 21077)
+++ public/yanel/trunk/src/contributions/resources/davcollection/src/java/org/wyona/yanel/impl/resources/XmlViewResource.java 2006-12-21 16:39:04 UTC (rev 21078)
@@ -77,7 +77,7 @@
this.contentHandler = xmlSerializer.asContentHandler();
- buildXmlView(path, viewId);
+ buildXmlView(getPath(), viewId);
View view = new View();
view.setResponse(false); // this resource writes the response itself
Modified: public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/NutchResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/NutchResource.java 2006-12-21 15:09:49 UTC (rev 21077)
+++ public/yanel/trunk/src/contributions/resources/nutch/src/java/org/wyona/yanel/impl/resources/NutchResource.java 2006-12-21 16:39:04 UTC (rev 21078)
@@ -94,7 +94,6 @@
private String searchTerm = "";
private String show = "";//default is empty, else show either CACHE, EXPLAIN, ANCHORS
private String resourceBundle = "nutch";
- private RepoPath rp = null;
private NutchBean nutchBean = null;
private ServletContext servletContext = null;
private String cachedMimeType = null;
@@ -126,17 +125,12 @@
*/
public View getView(Path path, String viewId, int idx, int id) {
View nutchView = null;
- this.path = path;
try {
- // Get repository
- rp = new org.wyona.yarep.util.YarepUtil().getRepositoryPath(new org.wyona.yarep.core.Path(path.toString()), getRepositoryFactory());
- Repository repository = rp.getRepo();
-
getNutchConfiguration();
resourceBundle = getRTI().getProperty("messageBundle");
nutchView = new View();
- nutchView.setInputStream(getInputStream(viewId, show, idx, id, repository));
+ nutchView.setInputStream(getInputStream(viewId, show, idx, id));
// Set Mime Type
if(show.equals("cache")) {
@@ -259,16 +253,16 @@
* Generate response depending on show parameter
* @param show cache, explain, anchors and actual search results
*/
- private InputStream getInputStream(String viewId, String show, int idx, int id, Repository repository) {
+ private InputStream getInputStream(String viewId, String show, int idx, int id) {
if(show.equals("cache")){
return new StringBufferInputStream(getCachedContent(idx, id));
} else if(show.equals("explain")) {
- return createExplanationDocument4SearchResult(idx, id, searchTerm, language, repository);
+ return createExplanationDocument4SearchResult(idx, id, searchTerm, language);
} else if(show.equals("anchors")) {
- return createAnchorsDocument4SearchResult(idx, id, searchTerm, language, repository);
+ return createAnchorsDocument4SearchResult(idx, id, searchTerm, language);
} else {
getDOMDocument(searchTerm);
- return transformedInputStream(viewId, searchTerm, repository);
+ return transformedInputStream(viewId, searchTerm);
}
}
@@ -278,7 +272,7 @@
* @param searchTerm
* @return
*/
- private InputStream transformedInputStream(String viewId, String searchTerm, Repository repository) {
+ private InputStream transformedInputStream(String viewId, String searchTerm) {
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
if (viewId != null && viewId.equals("source")) {
@@ -289,16 +283,20 @@
File xsltFile = org.wyona.commons.io.FileUtil.file(rtd.getConfigFile().getParentFile()
.getAbsolutePath(), "xslt" + File.separator + "result2xhtml.xsl");
transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xsltFile));
- transformer.setParameter("yanel.path.name", path.getName());
- transformer.setParameter("yanel.path", path.toString());
- transformer.setParameter("yanel.back2context", backToRoot(path, ""));
- transformer.setParameter("yarep.back2realm", backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
+ transformer.setParameter("yanel.path.name", getPath().getName());
+ // TODO: Remove the trailing slash ...
+ transformer.setParameter("yanel.path", getRealm().getMountPoint() + getPath().toString());
+ log.debug("Yanel Path: " + getRealm().getMountPoint() + getPath());
+ transformer.setParameter("yanel.back2context", backToRoot(new Path(getRealm().getMountPoint().toString() + getPath().toString()), ""));
+ log.debug("Back 2 context: " + getRealm().getMountPoint() + getPath() + ", " + backToRoot(new Path(getRealm().getMountPoint().toString() + getPath().toString()), ""));
+ transformer.setParameter("yarep.back2realm", backToRoot(getPath(), ""));
+ log.debug("Back 2 realm: " + getPath() + ", " + backToRoot(getPath(), ""));
transformer.transform(new javax.xml.transform.dom.DOMSource(document), new StreamResult(byteArrayOutputStream));
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
i18nTransformer = new I18nTransformer(resourceBundle, language);
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(inputStream, i18nTransformer);
- return applyGlobalXslIfExists(i18nTransformer.getInputStream(), searchTerm, repository);
+ return applyGlobalXslIfExists(i18nTransformer.getInputStream(), searchTerm);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
@@ -312,16 +310,16 @@
* @param searchTerm
* @return
*/
- private InputStream applyGlobalXslIfExists(InputStream inputStream, String searchTerm, Repository repository) {
+ private InputStream applyGlobalXslIfExists(InputStream inputStream, String searchTerm) {
StreamSource streamSource = null;
try {
- streamSource = getXSLTStreamSource(path, repository);
+ streamSource = getXSLTStreamSource();
if(streamSource != null) {
transformer = TransformerFactory.newInstance().newTransformer(streamSource);
- transformer.setParameter("yanel.path.name", path.getName());
- transformer.setParameter("yanel.path", path.toString());
- transformer.setParameter("yanel.back2context", backToRoot(path, ""));
- transformer.setParameter("yarep.back2realm", backToRoot(new org.wyona.yanel.core.Path(rp.getPath().toString()), ""));
+ transformer.setParameter("yanel.path.name", getPath().getName());
+ transformer.setParameter("yanel.path", getPath().toString());
+ transformer.setParameter("yanel.back2context", backToRoot(getPath(), ""));
+ transformer.setParameter("yarep.back2realm", backToRoot(getPath(), ""));
transformer.setParameter("hitsPerPage", "" + hitsPerPage);
transformer.setParameter("totalHits", "" + totalHits);
transformer.setParameter("query", "" + searchTerm);
@@ -393,7 +391,7 @@
* @param language
* @return
*/
- private InputStream createExplanationDocument4SearchResult(int idx, int id, String searchTerm, String language, Repository repository) {
+ private InputStream createExplanationDocument4SearchResult(int idx, int id, String searchTerm, String language) {
try {
nutchBean = NutchBean.get(servletContext, configuration);
Hit hit = new Hit(idx, id);
@@ -410,7 +408,7 @@
I18nTransformer i18nTransformer = new I18nTransformer(resourceBundle, language);
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(new StringBufferInputStream(content), i18nTransformer);
- return applyGlobalXslIfExists(i18nTransformer.getInputStream(), searchTerm, repository);
+ return applyGlobalXslIfExists(i18nTransformer.getInputStream(), searchTerm);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
@@ -425,7 +423,7 @@
* @param language
* @return
*/
- private InputStream createAnchorsDocument4SearchResult(int idx, int id, String searchTerm, String language, Repository repository) {
+ private InputStream createAnchorsDocument4SearchResult(int idx, int id, String searchTerm, String language) {
try {
nutchBean = NutchBean.get(servletContext, configuration);
Hit hit = new Hit(idx, id);
@@ -450,7 +448,7 @@
I18nTransformer i18nTransformer = new I18nTransformer(resourceBundle, language);
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
saxParser.parse(new StringBufferInputStream(content), i18nTransformer);
- return applyGlobalXslIfExists(i18nTransformer.getInputStream(), searchTerm, repository);
+ return applyGlobalXslIfExists(i18nTransformer.getInputStream(), searchTerm);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
@@ -606,14 +604,13 @@
* Get XSLT Stream Source of global xslt
* @param path
* @param repo
- * @return
- * @throws RepositoryException
+ * @return StreamSource
*/
- private StreamSource getXSLTStreamSource(Path path, Repository repo) throws RepositoryException {
+ private StreamSource getXSLTStreamSource() throws Exception {
String xsltPath = getRTI().getProperty("xslt");
log.error("DEBUG: XSLT: " + xsltPath);
if (xsltPath != null) {
- return new StreamSource(repo.getInputStream(new org.wyona.yarep.core.Path(xsltPath)));
+ return new StreamSource(getRealm().getRepository().getInputStream(new org.wyona.yarep.core.Path(xsltPath)));
} else {
return null;
}
More information about the Yanel-commits
mailing list