[Yanel-commits] rev 22207 - in public/yanel/trunk/src/resources:
file/src/java/org/wyona/yanel/impl/resources
xml/src/java/org/wyona/yanel/impl/resources
josias at wyona.com
josias at wyona.com
Fri Jan 26 15:36:48 CET 2007
Author: josias
Date: 2007-01-26 15:36:47 +0100 (Fri, 26 Jan 2007)
New Revision: 22207
Modified:
public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java
public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
Log:
switched to node based repository methods
Modified: public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java
===================================================================
--- public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java 2007-01-26 14:26:13 UTC (rev 22206)
+++ public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java 2007-01-26 14:36:47 UTC (rev 22207)
@@ -28,6 +28,7 @@
import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
import org.wyona.yanel.core.util.PathUtil;
+import org.wyona.yarep.core.Node;
import org.wyona.yarep.core.Repository;
import org.wyona.yarep.core.RepositoryFactory;
import org.wyona.yarep.util.RepoPath;
@@ -35,6 +36,7 @@
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
@@ -68,7 +70,7 @@
public View getView(String viewId) throws Exception {
View defaultView = new View();
- defaultView.setInputStream(getRealm().getRepository().getInputStream(new Path(getPath())));
+ defaultView.setInputStream(getRealm().getRepository().getNode(getPath()).getInputStream());
defaultView.setMimeType(getMimeType(viewId));
return defaultView;
@@ -141,14 +143,14 @@
*
*/
public Reader getReader() throws Exception {
- return getRealm().getRepository().getReader(new Path(getPath()));
+ return new InputStreamReader(getInputStream(), "UTF-8");
}
/**
*
*/
public InputStream getInputStream() throws Exception {
- return getRealm().getRepository().getInputStream(new Path(getPath()));
+ return getRealm().getRepository().getNode(getPath()).getInputStream();
}
/**
@@ -163,7 +165,7 @@
*
*/
public OutputStream getOutputStream() throws Exception {
- return getRealm().getRepository().getOutputStream(new Path(getPath()));
+ return getRealm().getRepository().getNode(getPath()).getOutputStream();
}
/**
@@ -177,21 +179,32 @@
*
*/
public long getLastModified() throws Exception {
- return getRealm().getRepository().getLastModified(new Path(getPath()));
- }
+ Node node = getRealm().getRepository().getNode(getPath());
+ long lastModified;
+ if (node.isResource()) {
+ lastModified = node.getLastModified();
+ } else {
+ lastModified = 0;
+ }
+ return lastModified;
+ }
+
/**
* Delete data of node resource
*/
public boolean delete() throws Exception {
- return getRealm().getRepository().delete(new Path(getPath()));
+ getRealm().getRepository().getNode(getPath()).remove();
+ return true;
}
/**
*
*/
public String[] getRevisions() throws Exception {
- return getRealm().getRepository().getRevisions(new Path(getPath()));
+ log.warn("Not implemented yet!");
+ return null;
+ //return getRealm().getRepository().getRevisions(new Path(getPath()));
}
public boolean exists() throws Exception {
@@ -203,7 +216,14 @@
*
*/
public long getSize() throws Exception {
- return getRealm().getRepository().getSize(new Path(getPath()));
+ Node node = getRealm().getRepository().getNode(getPath());
+ long size;
+ if (node.isResource()) {
+ size = node.getSize();
+ } else {
+ size = 0;
+ }
+ return size;
}
/**
Modified: public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
===================================================================
--- public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java 2007-01-26 14:26:13 UTC (rev 22206)
+++ public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java 2007-01-26 14:36:47 UTC (rev 22207)
@@ -32,6 +32,7 @@
import org.wyona.yanel.core.util.PathUtil;
import org.wyona.yanel.core.util.ResourceAttributeHelper;
+import org.wyona.yarep.core.Node;
import org.wyona.yarep.core.Repository;
import org.wyona.yarep.core.RepositoryFactory;
import org.wyona.yarep.util.RepoPath;
@@ -51,6 +52,7 @@
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
@@ -98,7 +100,7 @@
if (xsltPath != null) {
TransformerFactory tf = TransformerFactory.newInstance();
//tf.setURIResolver(null);
- Transformer transformer = tf.newTransformer(new StreamSource(repo.getInputStream(new Path(xsltPath))));
+ Transformer transformer = tf.newTransformer(new StreamSource(repo.getNode(xsltPath).getInputStream()));
transformer.setParameter("yanel.path.name", PathUtil.getName(getPath()));
transformer.setParameter("yanel.path", getPath());
//TODO: There seems to be a bug re back2context ...
@@ -180,7 +182,7 @@
}
}
- return repo.getInputStream(new Path(getPath()));
+ return repo.getNode(getPath()).getInputStream();
}
/**
@@ -213,14 +215,14 @@
*
*/
public Reader getReader() throws Exception {
- return getRealm().getRepository().getReader(new Path(getPath()));
+ return new InputStreamReader(getInputStream(), "UTF-8");
}
/**
*
*/
public InputStream getInputStream() throws Exception {
- return getRealm().getRepository().getInputStream(new Path(getPath()));
+ return getRealm().getRepository().getNode(getPath()).getInputStream();
}
/**
@@ -235,7 +237,7 @@
*
*/
public OutputStream getOutputStream() throws Exception {
- return getRealm().getRepository().getOutputStream(new Path(getPath()));
+ return getRealm().getRepository().getNode(getPath()).getOutputStream();
}
/**
@@ -249,7 +251,15 @@
*
*/
public long getLastModified() throws Exception {
- return getRealm().getRepository().getLastModified(new Path(getPath()));
+ Node node = getRealm().getRepository().getNode(getPath());
+ long lastModified;
+ if (node.isResource()) {
+ lastModified = node.getLastModified();
+ } else {
+ lastModified = 0;
+ }
+
+ return lastModified;
}
/**
@@ -285,11 +295,14 @@
*
*/
public boolean delete() throws Exception {
- return getRealm().getRepository().delete(new Path(getPath()));
+ getRealm().getRepository().getNode(getPath()).remove();
+ return true;
}
public String[] getRevisions() throws Exception {
- return getRealm().getRepository().getRevisions(new Path(getPath()));
+ //return getRealm().getRepository().getRevisions(getPath());
+ log.warn("Not implemented yet!");
+ return null;
}
public boolean exists() throws Exception {
@@ -301,7 +314,14 @@
* Get size of generated page
*/
public long getSize() throws Exception {
- return getRealm().getRepository().getSize(new Path(getPath()));
+ Node node = getRealm().getRepository().getNode(getPath());
+ long size;
+ if (node.isResource()) {
+ size = node.getSize();
+ } else {
+ size = 0;
+ }
+ return size;
}
/**
More information about the Yanel-commits
mailing list