[Yanel-commits] rev 28466 - in public/yanel/contributions/realms/foaf/src/resources/foaf/src: build java/org/wyona/yanel/impl/resources/foaf

michi at wyona.com michi at wyona.com
Mon Nov 5 09:18:21 CET 2007


Author: michi
Date: 2007-11-05 09:18:20 +0100 (Mon, 05 Nov 2007)
New Revision: 28466

Modified:
   public/yanel/contributions/realms/foaf/src/resources/foaf/src/build/dependencies.xml
   public/yanel/contributions/realms/foaf/src/resources/foaf/src/java/org/wyona/yanel/impl/resources/foaf/FOAFResource.java
Log:
viewable implemented

Modified: public/yanel/contributions/realms/foaf/src/resources/foaf/src/build/dependencies.xml
===================================================================
--- public/yanel/contributions/realms/foaf/src/resources/foaf/src/build/dependencies.xml	2007-11-05 00:10:40 UTC (rev 28465)
+++ public/yanel/contributions/realms/foaf/src/resources/foaf/src/build/dependencies.xml	2007-11-05 08:18:20 UTC (rev 28466)
@@ -7,8 +7,12 @@
 
     <artifact:dependencies pathId="maven2.classpath" filesetId="maven2.fileset">
       <remoteRepository refid="wyona.remote.repository"/>
-      <dependency groupId="wyona-org-yanel" artifactId="yanel-core"
-                  version="${yanel.source.version}"/>
+<!--
+      <dependency groupId="wyona-org-yanel" artifactId="yanel-core" version="${yanel.source.version}"/>
+-->
+      <!-- Hardcoded Yanel dependency in order to be able to compile standalone -->
+      <dependency groupId="wyona-org-yanel" artifactId="yanel-core" version="1.0-dev-rREVISION"/>
+      <dependency groupId="javax.servlet" artifactId="servlet-api" version="2.3"/>
     </artifact:dependencies>
 
     <artifact:dependencies pathId="maven2.resource.classpath" filesetId="maven2.resource.fileset">

Modified: public/yanel/contributions/realms/foaf/src/resources/foaf/src/java/org/wyona/yanel/impl/resources/foaf/FOAFResource.java
===================================================================
--- public/yanel/contributions/realms/foaf/src/resources/foaf/src/java/org/wyona/yanel/impl/resources/foaf/FOAFResource.java	2007-11-05 00:10:40 UTC (rev 28465)
+++ public/yanel/contributions/realms/foaf/src/resources/foaf/src/java/org/wyona/yanel/impl/resources/foaf/FOAFResource.java	2007-11-05 08:18:20 UTC (rev 28466)
@@ -5,15 +5,75 @@
 package org.wyona.yanel.impl.resources.foaf;
 
 import org.wyona.yanel.core.Resource;
+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.apache.log4j.Category;
+
+import java.net.URL;
+
 /**
  *
  */
-public class FOAFResource extends Resource {
+public class FOAFResource extends Resource implements ViewableV2 {
 
+    private static Category log = Category.getInstance(FOAFResource.class);
+
     /**
      *
      */
     public FOAFResource() {
     }
+
+    /**
+     *
+     */
+    public boolean exists() {
+        log.error("Implementation not finished yet! Needs to check existence of local or remote FOAF.");
+        return true;
+    }
+
+    /**
+     *
+     */
+    public String getMimeType(String viewId) {
+        return "application/xml";
+    }
+
+    /**
+     *
+     */
+    public long getSize() {
+        log.error("Implementation not done yet!");
+        return -1;
+    }
+
+    /**
+     *
+     */
+    public View getView(String viewId) {
+        View view = new View();
+        try {
+            URL url = new URL(getRequest().getParameter("href"));
+            view.setInputStream(url.openConnection().getInputStream());
+            view.setMimeType(getMimeType(viewId));
+        } catch (java.io.FileNotFoundException e) {
+            log.error(e);
+            view.setInputStream(new java.io.StringBufferInputStream(new StringBuffer("No such file: " + e.getMessage()).toString()));
+            view.setMimeType("text/plain");
+        } catch (Exception e) {
+            log.error(e);
+            view.setInputStream(new java.io.StringBufferInputStream(new StringBuffer("Exeception: " + e.getMessage()).toString()));
+            view.setMimeType("text/plain");
+        }
+        return view;
+    }
+
+    /**
+     *
+     */
+    public ViewDescriptor[] getViewDescriptors() {
+        return null;
+    }
 }



More information about the Yanel-commits mailing list