[Yanel-commits] rev 21489 - in public/yanel/trunk/src: contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources core/java/org/wyona/yanel/servlet

michi at wyona.com michi at wyona.com
Mon Jan 8 00:14:18 CET 2007


Author: michi
Date: 2007-01-08 00:14:17 +0100 (Mon, 08 Jan 2007)
New Revision: 21489

Modified:
   public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java
   public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java
   public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/CreateUsecaseHelper.java
Log:
RTI creation generalized

Modified: public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java
===================================================================
--- public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java	2007-01-07 11:28:47 UTC (rev 21488)
+++ public/yanel/trunk/src/contributions/resources/calendar/src/java/org/wyona/yanel/impl/resources/CalendarResource.java	2007-01-07 23:14:17 UTC (rev 21489)
@@ -235,25 +235,8 @@
      *
      */
     public void create(HttpServletRequest request) {
-        // TODO: Move the major part of the following code into Yanel Core
-        // Create RTI ...
         org.wyona.yanel.core.Path newPath = getPath();
         log.error("DEBUG: New path: " + newPath);
-
-        try {
-            org.wyona.yarep.core.Repository rtiRepo = getRealm().getRTIRepository();
-
-            StringBuffer content = new StringBuffer("<{http://www.wyona.org/yanel/resource/1.0}calendar/>\n");
-            content.append("events-path: /new-calendar\n");
-            content.append("categories: none\n");
-            content.append("class: none\n");
-            content.append("user-ids: none\n");
-            java.io.Writer writer = rtiRepo.getWriter(new org.wyona.yarep.core.Path(newPath.getRTIPath().toString()));
-            writer.write(content.toString());
-            writer.close();
-        } catch(Exception e) {
-            log.error(e.getMessage(), e);
-        }
     }
 
     /**

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	2007-01-07 11:28:47 UTC (rev 21488)
+++ public/yanel/trunk/src/contributions/resources/wiki/src/java/org/wyona/yanel/impl/resources/WikiResource.java	2007-01-07 23:14:17 UTC (rev 21489)
@@ -323,8 +323,6 @@
     public void create(HttpServletRequest request){
         String title = request.getParameter("title");
         writeContentAndIntrospection(getEmptyWiki(title), title);
-
-        writeRti();
     }
  
     /**
@@ -357,34 +355,12 @@
      *
      */
     public HashMap createRTIProperties(HttpServletRequest request) {
-        return null;
-    }
+        HashMap map = new HashMap();
+        // TODO: Do not hardcode xslt ...
+        map.put("#xslt", "/xslt/global.xsl");
 
-    /**
-     *
-     */
-    public void writeRti() {
-        //TODO: Move the major part of the following code into Yanel core
-        try {
-            org.wyona.yarep.core.Path newPath = getPath();
-
-            String content = "<{http://www.wyona.org/yanel/resource/1.0}wiki/>";
-
-            // TODO: Do not hardcode xslt ...
-            //content = content + "\nxslt: /xslt/global.xsl";
-
-            // TODO: Make mime-type configurable (depending on global XSLT) ...
-            content = content + "\nmime-type: application/xhtml+xml";
-
-            Repository rtiRepo = getRealm().getRTIRepository();
-            log.info("Writing content to repository " + rtiRepo.getName() + " with content:\n" + content + "\nto path: " + newPath);
-
-            Writer writer = rtiRepo.getWriter(new org.wyona.yarep.core.Path(new Path(newPath.toString()).getRTIPath().toString()));
-            writer.write(content);
-            writer.close();
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-        }
+        // TODO: Make mime-type configurable (depending on global XSLT) ...
+        map.put("mime-type", "application/xhtml+xml");
+        return map;
     }
-            
 }

Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/CreateUsecaseHelper.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/CreateUsecaseHelper.java	2007-01-07 11:28:47 UTC (rev 21488)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/servlet/CreateUsecaseHelper.java	2007-01-07 23:14:17 UTC (rev 21489)
@@ -211,12 +211,26 @@
                     PropertyNames = ((CreatableV2) newResource).getPropertyNames();
 
                     ((CreatableV2) newResource).create(request);
+
+                    // Create RTI
+                    StringBuffer rtiContent = new StringBuffer(newResource.getResourceTypeUniversalName() + "\n");
                     java.util.HashMap rtiProperties = ((CreatableV2) newResource).createRTIProperties(request);
                     if (rtiProperties != null) {
                         log.error("DEBUG: " + rtiProperties + " " + newResource.getPath().getRTIPath());
+                        java.util.Iterator iterator = rtiProperties.keySet().iterator();
+                        while (iterator.hasNext()) {
+                            String property = (String) iterator.next();
+                            String value = (String) rtiProperties.get(property);
+                            rtiContent.append(property + ": " + value + "\n");
+                            log.error("DEBUG: " + property + ", " + value);
+                        }
                     } else {
                         log.warn("No RTI properties: " + newResource.getPath());
                     }
+                    java.io.Writer writer = newResource.getRealm().getRTIRepository().getWriter(new org.wyona.yarep.core.Path(newResource.getPath().getRTIPath().toString()));
+                    writer.write(rtiContent.toString());
+                    writer.close();
+
                         
                     //response after creation, better would be a redirect to the fresh created resource
                     StringBuffer form = new StringBuffer();




More information about the Yanel-commits mailing list