[kune-commits] r1821 - in trunk: . debian script src/main/java/cc/kune/core/client/rpcservices src/main/java/cc/kune/core/server src/main/java/cc/kune/core/server/auth src/main/java/cc/kune/core/server/rack/filters/gwts src/main/java/cc/kune/core/server/rpc

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Mon Apr 2 22:21:42 CEST 2012


Author: vjrj_
Date: 2012-04-02 22:21:41 +0200 (Mon, 02 Apr 2012)
New Revision: 1821

Added:
   trunk/script/kune server via mvn with debug.launch
Removed:
   trunk/src/main/java/cc/kune/core/server/auth/openfire/
Modified:
   trunk/.classpath
   trunk/TODO
   trunk/debian/files
   trunk/debian/kune.default
   trunk/debian/kune.dirs
   trunk/debian/kune.init
   trunk/debian/rules
   trunk/pom.xml
   trunk/script/server.sh
   trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
   trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java
   trunk/src/main/java/cc/kune/core/server/UserSessionManager.java
   trunk/src/main/java/cc/kune/core/server/rack/filters/gwts/DelegatedRemoteServlet.java
   trunk/src/main/java/cc/kune/core/server/rack/filters/gwts/GWTServiceFilter.java
   trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
Log:
Init start/stop fixed
Better method for openfire auth provider

Modified: trunk/.classpath
===================================================================
--- trunk/.classpath	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/.classpath	2012-04-02 20:21:41 UTC (rev 1821)
@@ -77,6 +77,7 @@
   <classpathentry kind="var" path="M2_REPO/com/gwtplatform/gwtp-processors/0.5/gwtp-processors-0.5.jar" sourcepath="M2_REPO/com/gwtplatform/gwtp-processors/0.5/gwtp-processors-0.5-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/com/gwtplatform/gwtp-tester/0.5/gwtp-tester-0.5.jar" sourcepath="M2_REPO/com/gwtplatform/gwtp-tester/0.5/gwtp-tester-0.5-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/com/googlecode/gwtquery/gwtquery/1.1.0/gwtquery-1.1.0-2.1.0.jar" sourcepath="M2_REPO/com/googlecode/gwtquery/gwtquery/1.1.0/gwtquery-1.1.0-2.1.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/googlecode/gwtrpccommlayer/0.0.1-SNAPSHOT/gwtrpccommlayer-0.0.1-SNAPSHOT.jar"/>
   <classpathentry kind="var" path="M2_REPO/com/googlecode/gwtupload/gwtupload/0.6.3-compat/gwtupload-0.6.3-compat.jar" sourcepath="M2_REPO/com/googlecode/gwtupload/gwtupload/0.6.3-compat/gwtupload-0.6.3-compat-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/com/extjs/gxt/2.2.1/gxt-2.2.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/com/h2database/h2/1.0.20070617/h2-1.0.20070617.jar"/>

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/TODO	2012-04-02 20:21:41 UTC (rev 1821)
@@ -63,7 +63,6 @@
 |------------+--------+---------+---------+-----------|
 
 
-
 ** setui/root/port 80
    [ ] http://wiki.eclipse.org/Jetty/Howto/Port80#Configuring_Jetty.27s_SetUID_Feature
    [ ] https://github.com/disconnect/apache-websocket

Modified: trunk/debian/files
===================================================================
--- trunk/debian/files	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/debian/files	2012-04-02 20:21:41 UTC (rev 1821)
@@ -1 +1 @@
-kune_0.1.0+b5_all.deb java optional
+kune_0.1.0+b6_all.deb java optional

Modified: trunk/debian/kune.default
===================================================================
--- trunk/debian/kune.default	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/debian/kune.default	2012-04-02 20:21:41 UTC (rev 1821)
@@ -10,4 +10,13 @@
 START=no
 
 # Additional options that are passed to the Daemon.
-DAEMON_OPTS=""
+# Options:
+# -l LOGLEVEL : IGNORE|DEBUG|INFO|WARN
+# -x: -Xmx memory value
+# -m: -Xms memory value
+# Debug Options:
+# -d: debug
+# -u: Suspend the start (useful for debug the boot)
+# -p: port of debugger
+KUNE_DEFAULT_ARGS="-l INFO"
+

Modified: trunk/debian/kune.dirs
===================================================================
--- trunk/debian/kune.dirs	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/debian/kune.dirs	2012-04-02 20:21:41 UTC (rev 1821)
@@ -1,6 +1,5 @@
 /etc/kune/
 /usr/share/kune/
-/usr/share/kune/bin/
 /usr/share/kune/lib/
 /usr/share/kune/custom/
 /usr/share/kune/webapp/

Modified: trunk/debian/kune.init
===================================================================
--- trunk/debian/kune.init	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/debian/kune.init	2012-04-02 20:21:41 UTC (rev 1821)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 ### BEGIN INIT INFO
 # Provides:          kune
 # Required-Start:    $local_fs $remote_fs $network $syslog $named openfire
@@ -13,9 +13,6 @@
 DESC="kune server"
 NAME=kune             
 USER=kune
-DAEMON=/usr/share/kune/bin/server.sh
-# Arguments to run the daemon with (see server.sh -h)
-DAEMON_ARGS="-j /usr/share/kune/lib/kune-complete.jar -a"
 PIDFILE=/var/run/$NAME.pid
 SCRIPTNAME=/etc/init.d/$NAME
 
@@ -32,6 +29,119 @@
 # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
 . /lib/lsb/init-functions
 
+usage() {
+    echo "Set KUNE_DEFAULT_ARGS in /etc/default/kune
+    KUNE_DEFAULT_ARGS=[-k <kune-config>] [-w <wave-config>] [-s <jaas config>] [Debug options] [other options]
+    Example: KUNE_DEFAULT_ARGS=-l IGNORE -d -p -u 20000
+
+Options:
+-l LOGLEVEL : IGNORE|DEBUG|INFO|WARN
+-x: -Xmx memory value
+-m: -Xms memory value
+
+Debug Options:
+-d: debug
+-u: Suspend the start (useful for debug the boot)
+-p: port of debugger
+"
+}
+
+init_kune_vars() {
+    if [ -z $KUNE_HOME ]
+    then
+	KUNE_HOME=/etc/kune
+    fi
+
+    # See src/main/resources/kune.properties in svn
+    KUNE_CONFIG=$KUNE_HOME/kune.properties 
+    # See src/main/resources/wave-server.properties in svn
+    WAVE_CONFIG=$KUNE_HOME/wave-server.properties
+    # See src/main/resources/jaas.config in svn
+    JAAS_CONFIG=$KUNE_HOME/jaas.config
+    # See src/main/resources/log4j.properties in svn
+    LOGJ4_CONFIG=file://$KUNE_HOME/log4j.properties
+
+    JAR=/usr/share/kune/lib/kune-complete.jar
+    LOGFILE=/var/log/kune/kune.log
+
+    # Attempt to locate JAVA_HOME, code borrowed from jabref package
+    if [ -z $JAVA_HOME ]
+    then
+        t=/usr/lib/jvm/java-1.6.0-openjdk && test -d $t && JAVA_HOME=$t
+        t=/usr/lib/jvm/java-6-sun && test -d $t && JAVA_HOME=$t
+	t=/usr/lib/jvm/java-1.7.0-openjdk && test -d $t && JAVA_HOME=$t
+    fi
+
+    PATH=$PATH:${JAVA_HOME}/bin
+    JAVA=${JAVA_HOME}/bin/java
+    DAEMON=$JAVA
+    
+    while getopts “hm:x:k:w:s:up:l:d” OPTION $KUNE_DEFAULT_ARGS
+    do
+	case $OPTION in
+	    h)
+		usage
+		exit 1
+		;;
+	    k)
+		KUNE_CONFIG=$OPTARG
+		;;
+	    w)
+		WAVE_CONFIG=$OPTARG
+		;;
+	    s)
+		JAAS_CONFIG=$OPTARG
+		;;
+	    x)
+		MX="-Xmx"$OPTARG
+		;;
+	    m)
+		MS="-Xms"$OPTARG
+		;;
+	    p)
+                # Debug port
+		PORT=$OPTARG
+		if ! [[ $PORT =~ ^[0-9]+$ ]] 
+		then
+		    usage
+		    exit 1
+		fi
+		DEBUG_PORT=",address=$PORT"
+		;;
+	    u)
+		SUSPEND="y"
+		;;
+	    l)
+		LOG_LEVEL=$OPTARG
+		;;
+	    d)
+		DEBUG="y"
+		;;
+	    ?)
+		usage
+		exit
+		;;
+	esac
+    done	
+
+    if [[ $LOG_LEVEL != "IGNORE" && $LOG_LEVEL != "DEBUG" && $LOG_LEVEL != "INFO" && $LOG_LEVEL != "WARN" ]]
+    then
+	usage
+	exit 1
+    fi
+
+    DAEMON_ARGS="$DEBUG_FLAGS \
+	    -Dorg.eclipse.jetty.util.log.$LOG_LEVEL=true \
+	    -Djava.security.auth.login.config=$JAAS_CONFIG \
+	    -Dlog4j.configuration=$LOGJ4_CONFIG \
+	    -Dkune.server.config=$KUNE_CONFIG \
+	    -Dwave.server.config=$WAVE_CONFIG \
+            $MS \
+	    $MX \
+	    -jar $JAR >> $LOGFILE 2>&1"
+
+}
+
 # check if param is true/yes/0
 is_true() {
     if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then
@@ -46,23 +156,26 @@
 #
 do_start()
 {
-        if is_true "$START" ; then       
+    if is_true "$START" ; then       
+	init_kune_vars
+	# FIXME This should go in limits.conf
+	ulimit -n 65000    
         log_daemon_msg "Starting kune"
 	# Return
 	#   0 if daemon has been started
 	#   1 if daemon was already running
 	#   2 if daemon could not be started
-	start-stop-daemon --start --quiet --pidfile $PIDFILE -d /usr/share/kune/ -c $USER:$USER -b --exec $DAEMON --test > /dev/null \
-		|| return 1
-	start-stop-daemon --start --quiet --pidfile $PIDFILE -d /usr/share/kune/ -c $USER:$USER -b --exec $DAEMON -- \
-		$DAEMON_ARGS \
-		|| return 2
+	start-stop-daemon --start -b -m --quiet --pidfile $PIDFILE -d /usr/share/kune/ -c $USER:$USER --exec $DAEMON --test > /dev/null \
+	    || return 1
+	start-stop-daemon --start -b -m --quiet --pidfile $PIDFILE -d /usr/share/kune/ -c $USER:$USER --exec $DAEMON -- \
+	    $DAEMON_ARGS \
+	    || return 2
 	# Add code here, if necessary, that waits for the process to be ready
 	# to handle requests from services started subsequently which depend
 	# on this one.  As a last resort, sleep for some time.
-        else
-           log_daemon_msg "Skipping start of kune (see /etc/default/kune)"
-        fi
+    else
+        log_daemon_msg "Skipping start of kune (see /etc/default/kune)"
+    fi
 }
 
 #
@@ -70,65 +183,65 @@
 #
 do_stop()
 {
-	# Return
-	#   0 if daemon has been stopped
-	#   1 if daemon was already stopped
-	#   2 if daemon could not be stopped
-	#   other if a failure occurred
-        log_daemon_msg "Stopping kune"
-	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
-	RETVAL="$?"
-	[ "$RETVAL" = 2 ] && return 2
-	# Wait for children to finish too if this is a daemon that forks
-	# and if the daemon is only ever run from this initscript.
-	# If the above conditions are not satisfied then add some other code
-	# that waits for the process to drop all resources that could be
-	# needed by services started subsequently.  A last resort is to
-	# sleep for some time.
-	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE
-	[ "$?" = 2 ] && return 2
-	# Many daemons don't delete their pidfiles when they exit.
-	rm -f $PIDFILE
-	return "$RETVAL"
+    # Return
+    #   0 if daemon has been stopped
+    #   1 if daemon was already stopped
+    #   2 if daemon could not be stopped
+    #   other if a failure occurred
+    log_daemon_msg "Stopping kune"
+    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+    RETVAL="$?"
+    [ "$RETVAL" = 2 ] && return 2
+    # Wait for children to finish too if this is a daemon that forks
+    # and if the daemon is only ever run from this initscript.
+    # If the above conditions are not satisfied then add some other code
+    # that waits for the process to drop all resources that could be
+    # needed by services started subsequently.  A last resort is to
+    # sleep for some time.
+    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --pidfile $PIDFILE
+    [ "$?" = 2 ] && return 2
+    # Many daemons don't delete their pidfiles when they exit.
+    rm -f $PIDFILE
+    return "$RETVAL"
 }
 
 #
 # Function that sends a SIGHUP to the daemon/service
 #
 do_reload() {
-	#
-	# If the daemon can reload its configuration without
-	# restarting (for example, when it is sent a SIGHUP),
-	# then implement that here.
-	#
-        log_daemon_msg "Reloading kune"
-	# Seems that dont works if the user/group is not the same:
-	# http://stackoverflow.com/questions/4147288/how-to-trap-a-signal-in-a-java-application-initialized-using-a-bash-script
-	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --user $USER --group $USER --name $NAME
-	return 0
+    #
+    # If the daemon can reload its configuration without
+    # restarting (for example, when it is sent a SIGHUP),
+    # then implement that here.
+    #
+    log_daemon_msg "Reloading kune"
+    # Seems that dont works if the user/group is not the same:
+    # http://stackoverflow.com/questions/4147288/how-to-trap-a-signal-in-a-java-application-initialized-using-a-bash-script
+    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --user $USER --group $USER --name $NAME
+    return 0
 }
 
 case "$1" in
-  start)
-    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
-    do_start
-    case "$?" in
-		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
-		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+    start)
+	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
+	do_start
+	case "$?" in
+	    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+	    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 	esac
-  ;;
-  stop)
+	;;
+    stop)
 	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
 	do_stop
 	case "$?" in
-		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
-		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+	    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
 	esac
 	;;
-  status)
-       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
-       ;;
-  reload|force-reload)
+    status)
+	status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+	;;
+    reload|force-reload)
 	#
 	# If do_reload() is not implemented then leave this commented out
 	# and leave 'force-reload' as an alias for 'restart'.
@@ -136,7 +249,7 @@
 	do_reload
 	log_end_msg $?
 	;;
-  restart|force-reload)
+    restart|force-reload)
 	#
 	# If the "reload" option is implemented then remove the
 	# 'force-reload' alias
@@ -144,21 +257,21 @@
 	log_daemon_msg "Restarting $DESC" "$NAME"
 	do_stop
 	case "$?" in
-	  0|1)
+	    0|1)
 		do_start
 		case "$?" in
-			0) log_end_msg 0 ;;
-			1) log_end_msg 1 ;; # Old process is still running
-			*) log_end_msg 1 ;; # Failed to start
+		    0) log_end_msg 0 ;;
+		    1) log_end_msg 1 ;; # Old process is still running
+		    *) log_end_msg 1 ;; # Failed to start
 		esac
 		;;
-	  *)
+	    *)
 	  	# Failed to stop
 		log_end_msg 1
 		;;
 	esac
 	;;
-  *)
+    *)
 	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
 	exit 3
 	;;

Modified: trunk/debian/rules
===================================================================
--- trunk/debian/rules	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/debian/rules	2012-04-02 20:21:41 UTC (rev 1821)
@@ -41,7 +41,6 @@
 install/kune::
 
 # FIXME make this via http://www.debian.org/doc/manuals/maint-guide/dother.en.html#conffiles
-	cp $(CURDIR)/script/server.sh $(KUNE)/bin/
 	cp $(TARGET)/kune-0.1.0-SNAPSHOT-complete.jar $(KUNE)/lib/kune-complete.jar
 	cp $(RESOURCES)/wave-server-production.properties $(ETCDIR)/wave-server.properties
 	cp $(RESOURCES)/server.federation.config.example $(ETCDIR)

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/pom.xml	2012-04-02 20:21:41 UTC (rev 1821)
@@ -78,17 +78,6 @@
       <url>http://gwt-maven-rewraps.googlecode.com/hg/</url>
     </repository>
     <!-- cc -->
-    <!-- <repository> -->
-    <!-- <id>dyndns-repo</id> -->
-    <!-- <url>http://maven.dyndns.org/2</url> -->
-    <!-- </repository> -->
-    <!-- seems that these are not working/neccesary now: -->
-    <!-- <repository> <id>google-maven-snapshot-repository</id> <name>Google 
-      Maven Snapshot Repository</name> <url>https://oss.sonatype.org/content/repositories/google-snapshots/ 
-      </url> <snapshots> <enabled>true</enabled> </snapshots> </repository> <repository> 
-      <id>gwtplatform.snapshot.repo</id> <name>Gwtplatform snapshot repository</name> 
-      <url>https://oss.sonatype.org/content/repositories/snapshots/ </url> <layout>default</layout> 
-      </repository> -->
     <repository>
       <id>openqa.org</id>
       <name>Openqa Release Repository</name>
@@ -253,9 +242,6 @@
       <scope>provided</scope>
       <version>r464</version>
     </dependency>
-    <!-- <dependency> <groupId>com.jhickman.web.gwt</groupId> <artifactId>gwt-customuibinder</artifactId> 
-      <version>0.1</version> </dependency> <dependency> <groupId>com.jhickman.web.gwt</groupId> 
-      <artifactId>gxt-uibinder</artifactId> <version>0.6</version> </dependency> -->
     <!-- cc -->
     <dependency>
       <groupId>com.allen_sauer.gwt.log.gwt-log</groupId>
@@ -510,14 +496,7 @@
       <version>3.3.5</version>
       <!-- <scope>test</scope> -->
     </dependency>
-    <!-- If you want to start a selenium server, you will need the following 
-      dependency: -->
-    <!-- <dependency> -->
-    <!-- <groupId>org.seleniumhq.selenium</groupId> -->
-    <!-- <artifactId>selenium-server</artifactId> -->
-    <!-- <version>2.0a4</version> -->
-    <!-- </dependency> -->
-
+  
     <!-- public side -->
     <dependency>
       <groupId>org.jruby.rack</groupId>
@@ -729,101 +708,12 @@
       <classifier>2.1.0</classifier>
       <scope>provided</scope>
     </dependency>
-    <!-- openfire auth integration -->
-    <!-- <dependency> -->
-    <!-- <groupId>org.igniterealtime</groupId> -->
-    <!-- <artifactId>openfire</artifactId> -->
-    <!-- <version>3.7.0</version> -->
-    <!-- <scope>provided</scope> -->
-    <!-- <exclusions> -->
-    <!-- <exclusion> -->
-    <!-- <groupId>org.eclipse.jetty</groupId> -->
-    <!-- <artifactId>hibernate</artifactId> -->
-    <!-- </exclusion> -->
-    <!-- <exclusion> -->
-    <!-- <groupId>org.slf4j</groupId> -->
-    <!-- <artifactId>spi</artifactId> -->
-    <!-- </exclusion> -->
-    <!-- <exclusion> -->
-    <!-- <groupId>org.slf4j</groupId> -->
-    <!-- <artifactId>slf4j-api</artifactId> -->
-    <!-- </exclusion> -->
-    <!-- <exclusion> -->
-    <!-- <groupId>org.slf4j</groupId> -->
-    <!-- <artifactId>jcl-over-slf4j</artifactId> -->
-    <!-- </exclusion> -->
-    <!-- <exclusion> -->
-    <!-- <groupId>org.slf4j</groupId> -->
-    <!-- <artifactId>jcl-over-slf4j</artifactId> -->
-    <!-- </exclusion> -->
-    <!-- <exclusion> -->
-    <!-- <groupId>org.apache</groupId> -->
-    <!-- <artifactId>commons</artifactId> -->
-    <!-- </exclusion> -->
-    <!-- <exclusion> -->
-    <!-- <groupId>org.apache.commons</groupId> -->
-    <!-- <artifactId>logging</artifactId> -->
-    <!-- </exclusion> -->
-    <!-- </exclusions> -->
-    <!-- </dependency> -->
+    <dependency>
+      <groupId>com.googlecode</groupId>
+      <artifactId>gwtrpccommlayer</artifactId>
+      <version>0.0.1-SNAPSHOT</version>
+   </dependency>
   </dependencies>
-  <!-- <dependency> -->
-  <!-- <groupId>dom4j</groupId> -->
-  <!-- <artifactId>dom4j</artifactId> -->
-  <!-- <version>1.6.1</version> -->
-  <!-- <type>jar</type> -->
-  <!-- </dependency> -->
-  <!-- <dependency> -->
-  <!-- <groupId>com.google.code.guice</groupId> -->
-  <!-- <artifactId>guice-assistedinject</artifactId> -->
-  <!-- <version>2.0</version> -->
-  <!-- </dependency> -->
-  <!-- <dependency> -->
-  <!-- <groupId>jline<!/groupId> -->
-  <!-- <artifactId>jline</artifactId> -->
-  <!-- <version>0.9.94</version> -->
-  <!-- <type>jar</type> -->
-  <!-- </dependency> -->
-  <!-- <dependency> -->
-  <!-- <groupId>org.gnu.inet</groupId> -->
-  <!-- <artifactId>libidn</artifactId> -->
-  <!-- <version>1.15</version> -->
-  <!-- <type>jar</type> -->
-  <!-- </dependency> -->
-  <!-- <dependency> -->
-  <!-- <groupId>com.google.protobuf</groupId> -->
-  <!-- <artifactId>protobuf-java</artifactId> -->
-  <!-- <version>2.3.0</version> -->
-  <!-- <type>jar</type> -->
-  <!-- </dependency> -->
-  <!-- <dependency> -->
-  <!-- <groupId>xpp3</groupId> -->
-  <!-- <artifactId>xpp3</artifactId> -->
-  <!-- <version>1.1.4c</version> -->
-  <!-- <type>jar</type> -->
-  <!-- </dependency> -->
-  <!-- <dependency> -->
-  <!-- <groupId>xpp3</groupId> -->
-  <!-- <artifactId>xpp3_xpath</artifactId> -->
-  <!-- <version>1.1.4c</version> -->
-  <!-- <type>jar</type> -->
-  <!-- </dependency> -->
-  <!-- <dependency> -->
-  <!-- <groupId>aopalliance</groupId> -->
-  <!-- <artifactId>aopalliance</artifactId> -->
-  <!-- <version>1.0</version> -->
-  <!-- <type>jar</type> -->
-  <!-- </dependency> -->
-  <!-- <dependency> -->
-  <!-- <groupId>org.wave-protocol</groupId> -->
-  <!-- <artifactId>xmpp</artifactId> -->
-  <!-- <version>1.0.0</version> -->
-  <!-- </dependency> -->
-  <!-- <dependency> -->
-  <!-- <groupId>org.wave-protocol</groupId> -->
-  <!-- <artifactId>whack</artifactId> -->
-  <!-- <version>1.0.0</version> -->
-  <!-- </dependency> -->
   <distributionManagement>
     <repository>
       <id>kune.ourproject.org</id>
@@ -1177,7 +1067,8 @@
               </modules>
               <copyWebapp>true</copyWebapp>
               <compileReport>false</compileReport>
-              <localWorkers>1</localWorkers><!-- Using all workers can temporarily 
+              <localWorkers>2</localWorkers>
+              <!-- <localWorkers>1</localWorkers> Using all workers can temporarily 
                 hang the mouse and isn't much faster -->
               <extraJvmArgs>-Xmx1024m</extraJvmArgs>
             </configuration>
@@ -1266,7 +1157,6 @@
               </dependency>
             </dependencies>
           </plugin>
-
         </plugins>
       </build>
     </profile>

Added: trunk/script/kune server via mvn with debug.launch
===================================================================
--- trunk/script/kune server via mvn with debug.launch	                        (rev 0)
+++ trunk/script/kune server via mvn with debug.launch	2012-04-02 20:21:41 UTC (rev 1821)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
+<mapAttribute key="org.eclipse.debug.core.environmentVariables">
+<mapEntry key="MAVEN_OPTS" value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001"/>
+</mapAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="/usr/bin/mvn"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="exec:java"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/kune}"/>
+</launchConfiguration>

Modified: trunk/script/server.sh
===================================================================
--- trunk/script/server.sh	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/script/server.sh	2012-04-02 20:21:41 UTC (rev 1821)
@@ -89,7 +89,6 @@
 	    DAEMON="y"	    
 	    ;;
 	l)
-            # TODO: use/configure src/main/resources/log4j.properties
 	    LOG_LEVEL=$OPTARG
 	    ;;
 	d)
@@ -116,7 +115,7 @@
 USER=`id -u -n`
 if [[ -n $DAEMON && USER -ne "root" ]]
 then 
-    echo "Error: Only root user can run kune as a deamon"
+    echo "Error: Only root user can run kune as a daemon"
     usage
     exit 1
 fi

Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java	2012-04-02 20:21:41 UTC (rev 1821)
@@ -46,6 +46,8 @@
 
   void changePasswd(String userHash, String oldPassword, String newPassword) throws DefaultException;
 
+  void checkUserAndHash(String username, String userHash);
+
   void createUser(UserDTO user, boolean wantPersonalHomepage) throws DefaultException;
 
   String getUserAvatarBaser64(String userHash, StateToken userToken) throws DefaultException;

Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java	2012-04-02 20:21:41 UTC (rev 1821)
@@ -37,6 +37,8 @@
 
   void changePasswd(String userHash, String oldPassword, String newPassword, AsyncCallback<Void> callback);
 
+  void checkUserAndHash(String username, String userHash, AsyncCallback<Void> callback);
+
   void createUser(UserDTO user, boolean wantPersonalHomepage, AsyncCallback<Void> asyncCallback);
 
   void getUserAvatarBaser64(String userHash, StateToken userToken, AsyncCallback<String> asyncCallback);

Modified: trunk/src/main/java/cc/kune/core/server/UserSessionManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/UserSessionManager.java	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/src/main/java/cc/kune/core/server/UserSessionManager.java	2012-04-02 20:21:41 UTC (rev 1821)
@@ -46,6 +46,7 @@
     this.userSessionProv = userSessionProv;
     final HashSessionManager hSessionManager = (HashSessionManager) jettySessionManager;
     hSessionManager.setMaxInactiveInterval(-1);
+    // this prevent saving the session??
     hSessionManager.setUsingCookies(true);
     hSessionManager.setSavePeriod(5);
     // For now the implementation of this can be very inaccurate (if we

Modified: trunk/src/main/java/cc/kune/core/server/rack/filters/gwts/DelegatedRemoteServlet.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rack/filters/gwts/DelegatedRemoteServlet.java	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/src/main/java/cc/kune/core/server/rack/filters/gwts/DelegatedRemoteServlet.java	2012-04-02 20:21:41 UTC (rev 1821)
@@ -19,46 +19,86 @@
  */
 package cc.kune.core.server.rack.filters.gwts;
 
+import java.lang.reflect.Method;
+import java.util.LinkedList;
+
 import javax.servlet.ServletContext;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException;
 import com.google.gwt.user.client.rpc.RemoteService;
 import com.google.gwt.user.client.rpc.SerializationException;
 import com.google.gwt.user.server.rpc.RPC;
 import com.google.gwt.user.server.rpc.RPCRequest;
-import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+import com.googlecode.gwtrpccommlayer.server.GwtRpcCommLayerServlet;
+import com.googlecode.gwtrpccommlayer.shared.GwtRpcCommLayerPojoRequest;
 
-public class DelegatedRemoteServlet extends RemoteServiceServlet {
-    private static final long serialVersionUID = -7646054921925214953L;
-    private transient RemoteService service;
-    private ServletContext servletContext;
+public class DelegatedRemoteServlet extends GwtRpcCommLayerServlet {
+  public static final Log LOG = LogFactory.getLog(DelegatedRemoteServlet.class);
+  private static final long serialVersionUID = -7646054921925214953L;
+  private transient RemoteService service;
 
-    @Override
-    public ServletContext getServletContext() {
-        return servletContext;
-    }
+  private ServletContext servletContext;
 
-    @Override
-    public String processCall(final String payload) throws SerializationException {
-        try {
-            final RPCRequest rpcRequest = RPC.decodeRequest(payload, service.getClass());
-            return RPC.invokeAndEncodeResponse(service, rpcRequest.getMethod(), rpcRequest.getParameters());
-        } catch (IncompatibleRemoteServiceException ex) {
-            return RPC.encodeResponseForFailure(null, ex);
-        }
-    }
+  public DelegatedRemoteServlet(final Object servlet) {
+    super(servlet);
+  }
 
-    public void setService(final RemoteService service) {
-        this.service = service;
+  @Override
+  protected void doUnexpectedFailure(final Throwable except) {
+    except.printStackTrace();
+    super.doUnexpectedFailure(except);
+  }
+
+  @Override
+  protected Method getMethod(final GwtRpcCommLayerPojoRequest stressTestRequest)
+      throws NoSuchMethodException, ClassNotFoundException {
+    final int count = 0;
+    final Class<?> paramClasses[] = new Class[stressTestRequest.getMethodParameters().size()];
+
+    final LinkedList<Class<?>> lstParameterClasses = new LinkedList<Class<?>>();
+    for (final String methodName : stressTestRequest.getParameterClassNames()) {
+      lstParameterClasses.add(Class.forName(methodName));
     }
 
-    public void setServletContext(final ServletContext servletContext) {
-        this.servletContext = servletContext;
+    final Class[] arrParameterClasses = lstParameterClasses.toArray(new Class[0]);
+    return service.getClass().getMethod(stressTestRequest.getMethodName(), arrParameterClasses);
+  }
+
+  @Override
+  public ServletContext getServletContext() {
+    return servletContext;
+  }
+
+  @Override
+  public void log(final String message) {
+    super.log(message);
+    LOG.info(message);
+  }
+
+  @Override
+  public void log(final String message, final Throwable t) {
+    super.log(message, t);
+    LOG.info(message, t);
+  }
+
+  @Override
+  public String processCall(final String payload) throws SerializationException {
+    try {
+      final RPCRequest rpcRequest = RPC.decodeRequest(payload, service.getClass());
+      return RPC.invokeAndEncodeResponse(service, rpcRequest.getMethod(), rpcRequest.getParameters());
+    } catch (final IncompatibleRemoteServiceException ex) {
+      return RPC.encodeResponseForFailure(null, ex);
     }
+  }
 
-    @Override
-    protected void doUnexpectedFailure(final Throwable except) {
-        except.printStackTrace();
-        super.doUnexpectedFailure(except);
-    }
+  public void setService(final RemoteService service) {
+    this.service = service;
+  }
+
+  public void setServletContext(final ServletContext servletContext) {
+    this.servletContext = servletContext;
+  }
 }
\ No newline at end of file

Modified: trunk/src/main/java/cc/kune/core/server/rack/filters/gwts/GWTServiceFilter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rack/filters/gwts/GWTServiceFilter.java	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/src/main/java/cc/kune/core/server/rack/filters/gwts/GWTServiceFilter.java	2012-04-02 20:21:41 UTC (rev 1821)
@@ -26,8 +26,6 @@
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -38,33 +36,36 @@
 import com.google.gwt.user.client.rpc.RemoteService;
 
 public class GWTServiceFilter extends AbstractInjectedFilter {
-    public static final Log LOG = LogFactory.getLog(GWTServiceFilter.class);
+  public static final Log LOG = LogFactory.getLog(GWTServiceFilter.class);
 
-    private final Class<? extends RemoteService> serviceClass;
-    private final DelegatedRemoteServlet servlet;
+  private final Class<? extends RemoteService> serviceClass;
+  private DelegatedRemoteServlet servlet;
 
-    public GWTServiceFilter(final Class<? extends RemoteService> serviceClass) {
-        this.serviceClass = serviceClass;
-        this.servlet = new DelegatedRemoteServlet();
-    }
+  public GWTServiceFilter(final Class<? extends RemoteService> serviceClass) {
+    this.serviceClass = serviceClass;
+  }
 
-    @Override
-    public void destroy() {
-    }
+  @Override
+  public void destroy() {
+  }
 
-    public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
-            throws IOException, ServletException {
-        LOG.info("--------------------------------------------------------------------------------");
-        LOG.debug("SERVICE: " + RackHelper.getURI(request) + " - " + serviceClass.getSimpleName());
-        final RemoteService service = getInstance(serviceClass);
-        servlet.setService(service);
-        servlet.doPost((HttpServletRequest) request, (HttpServletResponse) response);
-    }
+  @Override
+  public void doFilter(final ServletRequest request, final ServletResponse response,
+      final FilterChain chain) throws IOException, ServletException {
+    LOG.info("--------------------------------------------------------------------------------");
+    LOG.debug("SERVICE: " + RackHelper.getURI(request) + " - " + serviceClass.getSimpleName());
+    servlet.service(request, response);
+    // servlet.doPost((HttpServletRequest) request, (HttpServletResponse)
+    // response);
+  }
 
-    @Override
-    public void init(final FilterConfig filterConfig) throws ServletException {
-        super.init(filterConfig);
-        servlet.setServletContext(filterConfig.getServletContext());
-    }
+  @Override
+  public void init(final FilterConfig filterConfig) throws ServletException {
+    super.init(filterConfig);
+    final RemoteService service = getInstance(serviceClass);
+    this.servlet = new DelegatedRemoteServlet(service);
+    servlet.setService(service);
+    servlet.setServletContext(filterConfig.getServletContext());
+  }
 
 }

Modified: trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java	2012-04-02 04:35:24 UTC (rev 1820)
+++ trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java	2012-04-02 20:21:41 UTC (rev 1821)
@@ -25,7 +25,9 @@
 import org.jivesoftware.smack.util.Base64;
 import org.json.JSONObject;
 import org.waveprotocol.box.server.CoreSettings;
+import org.waveprotocol.box.server.account.AccountData;
 import org.waveprotocol.box.server.authentication.SessionManager;
+import org.waveprotocol.wave.model.wave.ParticipantId;
 
 import cc.kune.core.client.errors.AccessViolationException;
 import cc.kune.core.client.errors.DefaultException;
@@ -61,7 +63,9 @@
 import cc.kune.domain.User;
 import cc.kune.domain.finders.UserFinder;
 import cc.kune.wave.server.CustomWaveClientServlet;
+import cc.kune.wave.server.ParticipantUtils;
 
+import com.google.common.base.Preconditions;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.google.inject.name.Named;
@@ -69,7 +73,9 @@
 public class UserRPC implements RPC, UserService {
 
   private final ContentRPC contentRPC;
+
   private final Mapper mapper;
+  private final ParticipantUtils partUtils;
   private final ReservedWordsRegistry reserverdWords;
   private final UserFinder userFinder;
   private final UserInfoService userInfoService;
@@ -85,7 +91,8 @@
       final UserInfoService userInfoService, final Mapper mapper,
       final SessionManager waveSessionManager, final CustomWaveClientServlet waveClientServlet,
       final ReservedWordsRegistry reserverdWords, final ContentRPC contentRPC,
-      final UserSessionManager userSessionManager, final UserFinder userFinder) {
+      final UserSessionManager userSessionManager, final UserFinder userFinder,
+      final ParticipantUtils partUtils) {
     this.userManager = userManager;
     this.useSocketIO = useSocketIO;
     this.userInfoService = userInfoService;
@@ -96,6 +103,7 @@
     this.contentRPC = contentRPC;
     this.userSessionManager = userSessionManager;
     this.userFinder = userFinder;
+    this.partUtils = partUtils;
   }
 
   @Authenticated
@@ -127,6 +135,23 @@
   }
 
   @Override
+  @KuneTransactional
+  public void checkUserAndHash(final String username, final String passwdOrToken) {
+    final User user = userManager.login(username, passwdOrToken);
+    if (user != null) {
+      return;
+    }
+    final HttpSession session = waveSessionManager.getSessionFromToken(passwdOrToken);
+    Preconditions.checkState(session != null, "Session not found for this hash");
+    final AccountData loggedInAccount = waveSessionManager.getLoggedInAccount(session);
+    Preconditions.checkState(loggedInAccount != null, "Not account info for this session");
+    final ParticipantId participant = loggedInAccount.getId();
+    final String participantAddress = partUtils.getAddressName(participant.getAddress());
+    Preconditions.checkState(participantAddress.equals(username),
+        "Session account and hash does not match");
+  }
+
+  @Override
   @KuneTransactional(rollbackOn = DefaultException.class)
   public void createUser(final UserDTO userDTO, final boolean wantPersonalHomepage)
       throws DefaultException {
@@ -152,7 +177,7 @@
     } else {
       throw new DefaultException("Unexpected programatic exception (user has no logo)");
     }
-  }
+  };
 
   @Override
   @Authenticated(mandatory = true)
@@ -161,7 +186,7 @@
     final JSONObject sessionJson = waveClientServlet.getSessionJson(sessionFromToken);
     final JSONObject clientFlags = new JSONObject(); // waveClientServlet.getClientFlags();
     return new WaveClientParams(sessionJson.toString(), clientFlags.toString(), useSocketIO);
-  };
+  }
 
   private UserInfoDTO loadUserInfo(final User user) throws DefaultException {
     final UserInfo userInfo = userInfoService.buildInfo(user, userSessionManager.getHash());
@@ -261,5 +286,4 @@
     final User user = userSessionManager.getUser();
     userManager.verifyPasswordHash(user.getId(), emailReceivedHash, SessionConstants._AN_HOUR);
   }
-
 }




More information about the kune-commits mailing list