[kune-commits] r1793 - in trunk: . src/main/java/cc/kune/core/client/actions/xml src/main/java/cc/kune/core/server/content

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Mon Mar 26 02:54:08 CEST 2012


Author: vjrj_
Date: 2012-03-26 02:54:07 +0200 (Mon, 26 Mar 2012)
New Revision: 1793

Modified:
   trunk/INSTALL
   trunk/src/main/java/cc/kune/core/client/actions/xml/XMLActionsParser.java
   trunk/src/main/java/cc/kune/core/server/content/XMLActionReader.java
Log:
debian package (work in progress)

Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL	2012-03-26 00:53:30 UTC (rev 1792)
+++ trunk/INSTALL	2012-03-26 00:54:07 UTC (rev 1793)
@@ -191,6 +191,7 @@
 - src/main/resources/wave-server.properties
 - src/main/resources/log4j.properties
 - src/main/webapp/ws.html 
+- src/main/webapp/others/kune-client-actions.xml (extensions definitions)
 - src/main/webapp/ in general
 
 The best way to configure kune is to copy that files (for instance in /etc/kune/), to create a custom directory for ws.html and other of your custom html stuff (for instance in /var/www/kune/), and configure that directory to resources_base in wave-server.properties, for instance:

Modified: trunk/src/main/java/cc/kune/core/client/actions/xml/XMLActionsParser.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/actions/xml/XMLActionsParser.java	2012-03-26 00:53:30 UTC (rev 1792)
+++ trunk/src/main/java/cc/kune/core/client/actions/xml/XMLActionsParser.java	2012-03-26 00:54:07 UTC (rev 1793)
@@ -49,7 +49,8 @@
 
 public class XMLActionsParser {
 
-  public static final String ACTIONS_XML_LOCATION = "/others/kune-client-actions.xml";
+  public static final String ACTIONS_XML_LOCATION_FILE = "kune-client-actions.xml";
+  public static final String ACTIONS_XML_LOCATION_PATH_ABS = "/others/" + ACTIONS_XML_LOCATION_FILE;
 
   private static final String SEP = "»";
 
@@ -80,7 +81,8 @@
 
     // Based on:
     // http://www.roseindia.net/tutorials/gwt/retrieving-xml-data.shtml
-    final RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, ACTIONS_XML_LOCATION);
+    final RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET,
+        ACTIONS_XML_LOCATION_PATH_ABS);
     try {
       requestBuilder.sendRequest(null, new RequestCallback() {
         @Override

Modified: trunk/src/main/java/cc/kune/core/server/content/XMLActionReader.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/content/XMLActionReader.java	2012-03-26 00:53:30 UTC (rev 1792)
+++ trunk/src/main/java/cc/kune/core/server/content/XMLActionReader.java	2012-03-26 00:54:07 UTC (rev 1793)
@@ -26,6 +26,12 @@
 import java.nio.channels.FileChannel;
 import java.nio.charset.Charset;
 
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import cc.kune.core.client.actions.xml.XMLActionsParser;
 import cc.kune.core.client.actions.xml.XMLKuneClientActions;
 
@@ -33,24 +39,46 @@
 import com.google.inject.Singleton;
 
 @Singleton
-public class XMLActionReader {
-
+public class XMLActionReader implements ServletContextListener {
+  public static final Log LOG = LogFactory.getLog(XMLActionReader.class);
   private XMLKuneClientActions actions;
 
   public XMLActionReader() throws IOException {
-    final File xmlFile = new File("src/main/webapp/" + XMLActionsParser.ACTIONS_XML_LOCATION);
+  }
 
+  @Override
+  public void contextDestroyed(final ServletContextEvent sce) {
+  }
+
+  @Override
+  public void contextInitialized(final ServletContextEvent sce) {
+    final File xmlFile = new File(sce.getServletContext().getRealPath(
+        XMLActionsParser.ACTIONS_XML_LOCATION_PATH_ABS));
     // Inspired in:
-    // http://stackoverflow.com/questions/326390/how-to-create-a-java-string-from-the-contents-of-a-file
-    final FileInputStream stream = new FileInputStream(xmlFile);
+    //
+    // stackoverflow.com/questions/326390/how-to-create-a-java-string-from-the-contents-of-a-file
+    FileInputStream stream;
     try {
+      stream = new FileInputStream(xmlFile);
       final FileChannel fc = stream.getChannel();
       final MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
       final String xml = Charset.forName("UTF-8").decode(bb).toString();
       actions = new XMLKuneClientActions(new ServicesTester(), xml);
-    } finally {
       stream.close();
+    } catch (final IOException e) {
+      LOG.error("Error reading extension actions", e);
     }
+
+    // Other option:
+
+    // final InputStream iStream =
+    // this.getClass().getClassLoader().getResourceAsStream(
+    // XMLActionsParser.ACTIONS_XML_LOCATION_FILE);
+    // final StringWriter writer = new StringWriter();
+    // IOUtils.copy(iStream, writer, "UTF-8");
+    // final String xml = writer.toString();
+    // actions = new XMLKuneClientActions(new ServicesTester(), xml);
+
   }
 
   public XMLKuneClientActions getActions() {




More information about the kune-commits mailing list