[Yanel-commits] rev 21812 - in public/yanel/trunk/src/resources/file: . src/java/org/wyona/yanel/impl/resources

michi at wyona.com michi at wyona.com
Tue Jan 16 23:41:19 CET 2007


Author: michi
Date: 2007-01-16 23:41:18 +0100 (Tue, 16 Jan 2007)
New Revision: 21812

Added:
   public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java
Removed:
   public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/FileResource.java
Modified:
   public/yanel/trunk/src/resources/file/resource.xml
Log:
class renamed

Modified: public/yanel/trunk/src/resources/file/resource.xml
===================================================================
--- public/yanel/trunk/src/resources/file/resource.xml	2007-01-16 22:39:21 UTC (rev 21811)
+++ public/yanel/trunk/src/resources/file/resource.xml	2007-01-16 22:41:18 UTC (rev 21812)
@@ -3,9 +3,9 @@
 <resource xmlns="http://www.wyona.org/yanel/1.0"
   name="file"
   namespace="http://www.wyona.org/yanel/resource/1.0"
-  class="org.wyona.yanel.impl.resources.FileResource"
+  class="org.wyona.yanel.impl.resources.NodeResource"
   >
 <description>
-File
+Generic node resource
 </description>
 </resource>

Deleted: public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/FileResource.java
===================================================================
--- public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/FileResource.java	2007-01-16 22:39:21 UTC (rev 21811)
+++ public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/FileResource.java	2007-01-16 22:41:18 UTC (rev 21812)
@@ -1,197 +0,0 @@
-/*
- * Copyright 2006 Wyona
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.wyona.org/licenses/APACHE-LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-package org.wyona.yanel.impl.resources;
-
-import org.wyona.yanel.core.Path;
-import org.wyona.yanel.core.Resource;
-import org.wyona.yanel.core.Topic;
-import org.wyona.yanel.core.api.attributes.ModifiableV2;
-import org.wyona.yanel.core.api.attributes.VersionableV2;
-import org.wyona.yanel.core.api.attributes.ViewableV2;
-import org.wyona.yanel.core.attributes.viewable.View;
-import org.wyona.yanel.core.attributes.viewable.ViewDescriptor;
-
-import org.wyona.yarep.core.Repository;
-import org.wyona.yarep.core.RepositoryFactory;
-import org.wyona.yarep.util.RepoPath;
-
-import javax.servlet.http.HttpServletRequest;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-
-import org.apache.log4j.Category;
-
-/**
- * Generic Node Resource
- */
-public class FileResource extends Resource implements ViewableV2, ModifiableV2, VersionableV2 {
-
-    private static Category log = Category.getInstance(FileResource.class);
-
-    /**
-     *
-     */
-    public FileResource() {
-    }
-
-    /**
-     *
-     */
-    public ViewDescriptor[] getViewDescriptors() {
-        return null;
-    }
-
-    /**
-     *
-     */
-    public View getView(String viewId) throws Exception {
-        View defaultView = new View();
-        
-        defaultView.setInputStream(getRealm().getRepository().getInputStream(getPath()));
-        defaultView.setMimeType(getMimeType(viewId));
-
-        return defaultView;
-    }
-
-    /**
-     *
-     */
-    private String getMimeType(String viewId) throws Exception {
-        
-        String mimeType = getRTI().getProperty("mime-type");
-        
-        if (mimeType != null) return mimeType;
-
-        // TODO: Load config mime.types ...
-        String suffix = getPath().getSuffix();
-        if (suffix != null) {
-            log.debug("SUFFIX: " + suffix);
-            if (suffix.equals("html")) {
-                mimeType = "text/html";
-            } else if (suffix.equals("htm")) {
-                mimeType = "text/html";
-            } else if (suffix.equals("xhtml")) {
-                mimeType = "application/xhtml+xml";
-            } else if (suffix.equals("xml")) {
-                mimeType = "application/xml";
-            } else if (suffix.equals("css")) {
-                mimeType = "text/css";
-            } else if (suffix.equals("js")) {
-                mimeType = "application/x-javascript";
-            } else if (suffix.equals("png")) {
-                mimeType = "image/png";
-            } else if (suffix.equals("jpg")) {
-                mimeType = "image/jpeg";
-	    } else if (suffix.equals("gif")) {
-                mimeType = "image/gif";
-	    } else if (suffix.equals("pdf")) {
-                mimeType = "application/pdf";
-	    } else if (suffix.equals("doc")) {
-                mimeType = "application/msword";
-	    } else if (suffix.equals("odt")) {
-                mimeType = "application/vnd.oasis.opendocument.text";
-	    } else if (suffix.equals("sxc")) {
-                mimeType = "application/vnd.sun.xml.calc";
-	    } else if (suffix.equals("xpi")) {
-                mimeType = "application/x-xpinstall";
-	    } else if (suffix.equals("txt")) {
-                mimeType = "text/plain";
-	    } else if (suffix.equals("mov")) {
-                mimeType = "video/quicktime";
-            } else {
-                log.warn("Could not determine mime-type from suffix (suffix: " + suffix + ")!");
-                mimeType = "application/octet-stream";
-            }
-        } else {
-            log.warn("mime-type will be set to application/octet-stream, because no suffix for " + getPath());
-            mimeType = "application/octet-stream";
-        }
-        return mimeType;
-    }
-
-    /**
-     *
-     */
-    public Reader getReader() throws Exception {
-        return getRealm().getRepository().getReader(getPath());
-    }
-
-    /**
-     *
-     */
-    public InputStream getInputStream() throws Exception {
-        return getRealm().getRepository().getInputStream(getPath());
-    }
-
-    /**
-     *
-     */
-    public Writer getWriter() throws Exception {
-        log.error("Not implemented yet!");
-        return null;
-    }
-
-    /**
-     *
-     */
-    public OutputStream getOutputStream() throws Exception {
-        return getRealm().getRepository().getOutputStream(getPath());
-    }
-
-    /**
-     *
-     */
-    public void write(InputStream in) throws Exception {
-        log.warn("Not implemented yet!");
-    }
-
-    /**
-     *
-     */
-    public long getLastModified() throws Exception {
-        return getRealm().getRepository().getLastModified(getPath());
-    }
-
-    /**
-     * Delete data of node resource
-     */
-    public boolean delete() throws Exception {
-        return getRealm().getRepository().delete(getPath());
-    }
-    
-    /**
-     *
-     */
-    public String[] getRevisions() throws Exception {
-        return getRealm().getRepository().getRevisions(getPath());
-    }
-    
-    public boolean exists() throws Exception {
-        log.warn("Not implemented yet!");
-        return true; 
-    }
-
-    /**
-     * 
-     */
-     public long getSize() throws Exception {
-         return getRealm().getRepository().getSize(getPath());
-     }    
-}

Copied: public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/NodeResource.java (from rev 21809, public/yanel/trunk/src/resources/file/src/java/org/wyona/yanel/impl/resources/FileResource.java)




More information about the Yanel-commits mailing list