diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/ParticipantUpdatingRoomListener.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/ParticipantUpdatingRoomListener.java
index f44ba380cd1e3ce1c69610f0546c84c393ed6158..423a396c1036a5c95130ae1e1ef3a794389f058d 100755
--- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/ParticipantUpdatingRoomListener.java
+++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/ParticipantUpdatingRoomListener.java
@@ -22,7 +22,7 @@ package org.bigbluebutton.conference;
 import java.util.HashMap;
 
 import org.bigbluebutton.conference.service.messaging.MessagingConstants;
-import org.bigbluebutton.conference.service.messaging.RedisPublisher;
+import org.bigbluebutton.conference.service.messaging.MessagingService;
 import org.red5.logging.Red5LoggerFactory;
 import org.slf4j.Logger;
 
@@ -33,12 +33,12 @@ public class ParticipantUpdatingRoomListener implements IRoomListener{
 
 	private static Logger log = Red5LoggerFactory.getLogger(ParticipantUpdatingRoomListener.class, "bigbluebutton");
 	
-	RedisPublisher publisher;
+	MessagingService messagingService;
 	private Room room;
 	
-	public ParticipantUpdatingRoomListener(Room room, RedisPublisher publisher) {
+	public ParticipantUpdatingRoomListener(Room room, MessagingService messagingService) {
 		this.room = room;
-		this.publisher=publisher;
+		this.messagingService=messagingService;
 	}
 	
 	public String getName() {
@@ -46,7 +46,7 @@ public class ParticipantUpdatingRoomListener implements IRoomListener{
 	}
 	
 	public void participantStatusChange(Long userid, String status, Object value){
-		if (publisher != null) {
+		if (messagingService != null) {
 			HashMap<String,String> map= new HashMap<String, String>();
 			map.put("meetingId", this.room.getName());
 			map.put("messageId", MessagingConstants.USER_STATUS_CHANGE_EVENT);
@@ -55,13 +55,13 @@ public class ParticipantUpdatingRoomListener implements IRoomListener{
 			map.put("value", value.toString());
 			
 			Gson gson= new Gson();
-			publisher.publish(MessagingConstants.PARTICIPANTS_CHANNEL, gson.toJson(map));
+			messagingService.send(MessagingConstants.PARTICIPANTS_CHANNEL, gson.toJson(map));
 			log.debug("Publishing a status change in:{}",this.room.getName());
 		}
 	}
 	
 	public void participantJoined(Participant p) {
-		if (publisher != null) {
+		if (messagingService != null) {
 			HashMap<String,String> map= new HashMap<String, String>();
 			map.put("meetingId", this.room.getName());
 			map.put("messageId", MessagingConstants.USER_JOINED_EVENT);
@@ -70,20 +70,20 @@ public class ParticipantUpdatingRoomListener implements IRoomListener{
 			map.put("role", p.getRole());
 			
 			Gson gson= new Gson();
-			publisher.publish(MessagingConstants.PARTICIPANTS_CHANNEL, gson.toJson(map));
+			messagingService.send(MessagingConstants.PARTICIPANTS_CHANNEL, gson.toJson(map));
 			log.debug("Publishing message participant joined in {}",this.room.getName());
 		}
 	}
 	
 	public void participantLeft(Long userid) {		
-		if (publisher != null) {
+		if (messagingService != null) {
 			HashMap<String,String> map= new HashMap<String, String>();
 			map.put("meetingId", this.room.getName());
 			map.put("messageId", MessagingConstants.USER_LEFT_EVENT);
 			map.put("userid", userid.toString());
 			
 			Gson gson= new Gson();
-			publisher.publish(MessagingConstants.PARTICIPANTS_CHANNEL, gson.toJson(map));
+			messagingService.send(MessagingConstants.PARTICIPANTS_CHANNEL, gson.toJson(map));
 			log.debug("Publishing message participant left in {}",this.room.getName());
 		}
 	}
diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/RoomsManager.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/RoomsManager.java
index 872167ea840c5085c0163694d92036d8500e0eef..9249762e6506bd5d9c7c0453981b84687db9c82a 100755
--- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/RoomsManager.java
+++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/RoomsManager.java
@@ -19,8 +19,10 @@
 package org.bigbluebutton.conference;
 
 import org.slf4j.Logger;
+import org.bigbluebutton.conference.service.messaging.MessageListener;
 import org.bigbluebutton.conference.service.messaging.MessagingConstants;
-import org.bigbluebutton.conference.service.messaging.RedisPublisher;
+import org.bigbluebutton.conference.service.messaging.MessagingService;
+import org.bigbluebutton.conference.service.presentation.ConversionUpdatesMessageListener;
 import org.red5.logging.Red5LoggerFactory;
 import com.google.gson.Gson;
 import net.jcip.annotations.ThreadSafe;
@@ -37,7 +39,8 @@ public class RoomsManager {
 	
 	private final Map <String, Room> rooms;
 
-	RedisPublisher publisher;
+	MessagingService messagingService;
+	ConversionUpdatesMessageListener conversionUpdatesMessageListener;
 	
 	public RoomsManager() {
 		rooms = new ConcurrentHashMap<String, Room>();		
@@ -45,7 +48,7 @@ public class RoomsManager {
 	
 	public void addRoom(Room room) {
 		log.debug("Adding room {}", room.getName());
-		room.addRoomListener(new ParticipantUpdatingRoomListener(room,publisher)); 	
+		room.addRoomListener(new ParticipantUpdatingRoomListener(room,messagingService)); 	
 		
 		if (checkPublisher()) {
 			HashMap<String,String> map = new HashMap<String,String>();
@@ -53,7 +56,7 @@ public class RoomsManager {
 			map.put("messageId", MessagingConstants.MEETING_STARTED_EVENT);
 			
 			Gson gson = new Gson();
-			publisher.publish(MessagingConstants.SYSTEM_CHANNEL, gson.toJson(map));
+			messagingService.send(MessagingConstants.SYSTEM_CHANNEL, gson.toJson(map));
 			
 			log.debug("Notified event listener of conference start");
 		}
@@ -70,7 +73,7 @@ public class RoomsManager {
 			map.put("messageId", MessagingConstants.MEETING_ENDED_EVENT);
 			
 			Gson gson = new Gson();
-			publisher.publish(MessagingConstants.SYSTEM_CHANNEL, gson.toJson(map));
+			messagingService.send(MessagingConstants.SYSTEM_CHANNEL, gson.toJson(map));
 			
 			log.debug("Notified event listener of conference end");
 		}
@@ -84,7 +87,7 @@ public class RoomsManager {
 	}
 	
 	private boolean checkPublisher() {
-		return publisher != null;
+		return messagingService != null;
 	}
 
 		
@@ -96,16 +99,6 @@ public class RoomsManager {
 		return rooms.size();
 	}
 	
-	// this method is called by incoming JMS requests (Spring integration)
-	public void endMeetingRequest(String roomname) {
-		log.debug("End meeting request for room: {} ", roomname);
-		Room room = getRoom(roomname); // must do this because the room coming in is serialized (no transient values are present)
-		if (room != null)
-			room.endAndKickAll();
-		else
-			log.debug("Could not find room {}", roomname);
-	}
-	
 	/**
 	 * Keeping getRoom private so that all access to Room goes through here.
 	 */
@@ -193,13 +186,32 @@ public class RoomsManager {
 		log.warn("Changing participant status on a non-existing room {}", roomName);
 	}
 
-	public RedisPublisher getPublisher() {
-		return publisher;
+	public void setMessagingService(MessagingService messagingService) {
+		this.messagingService = messagingService;
+		this.messagingService.addListener(new RoomsManagerListener());
+		this.messagingService.start();
 	}
-
-	public void setPublisher(RedisPublisher publisher) {
-		this.publisher = publisher;
+	public void setConversionUpdatesMessageListener(ConversionUpdatesMessageListener conversionUpdatesMessageListener) {
+		this.conversionUpdatesMessageListener = conversionUpdatesMessageListener;
 	}
 	
+	private class RoomsManagerListener implements MessageListener{
+
+		@Override
+		public void endMeetingRequest(String meetingId) {
+			log.debug("End meeting request for room: {} ", meetingId);
+			Room room = getRoom(meetingId); // must do this because the room coming in is serialized (no transient values are present)
+			if (room != null)
+				room.endAndKickAll();
+			else
+				log.debug("Could not find room {}", meetingId);
+		}
+		
+		@Override
+		public void presentationUpdates(HashMap<String, String> map) {
+			conversionUpdatesMessageListener.handleReceivedMessage(map);
+		}
+		
+	}
 	
 }
diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessageListener.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessageListener.java
new file mode 100755
index 0000000000000000000000000000000000000000..77a79266cdef91ee30f3b65490804671c3008453
--- /dev/null
+++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessageListener.java
@@ -0,0 +1,8 @@
+package org.bigbluebutton.conference.service.messaging;
+
+import java.util.HashMap;
+
+public interface MessageListener {
+	void endMeetingRequest(String meetingId);
+	void presentationUpdates(HashMap<String,String> map);
+}
diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessagingService.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessagingService.java
new file mode 100755
index 0000000000000000000000000000000000000000..df4120a3c64c264bb9957223d149e4067bceb4bc
--- /dev/null
+++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessagingService.java
@@ -0,0 +1,9 @@
+package org.bigbluebutton.conference.service.messaging;
+
+public interface MessagingService {
+	public void start();
+	public void stop();
+	public void send(String channel, String message);
+	public void addListener(MessageListener listener);
+	public void removeListener(MessageListener listener);
+}
diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RedisListener.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RedisListener.java
deleted file mode 100755
index 13f07de8bbcd4cef1ea2fa427fe07b63b00ce6fd..0000000000000000000000000000000000000000
--- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RedisListener.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package org.bigbluebutton.conference.service.messaging;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.bigbluebutton.conference.RoomsManager;
-import org.bigbluebutton.conference.service.presentation.ConversionUpdatesMessageListener;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-
-import redis.clients.jedis.Jedis;
-import redis.clients.jedis.JedisPool;
-import redis.clients.jedis.JedisPubSub;
-
-
-public class RedisListener{
-	private static Logger log = Red5LoggerFactory.getLogger(RedisListener.class, "bigbluebutton");
-	
-	String host;
-	int port;
-	
-	JedisPool redisPool;
-	RoomsManager roomsManager;
-	ConversionUpdatesMessageListener messageListener;
-	
-	public RedisListener(String host, int port) {
-		super();
-		this.host=host;
-		this.port=port;
-	}
-	
-	public void init(){
-		Jedis jedis = new Jedis(host,port);//redisPool.getResource();
-		//subscribe(jedis);
-		//redisPool.returnResource(jedis);
-		log.debug("subscribing to the channels...");
-		try {
-			jedis.connect();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		subscribe(jedis);
-	}
-
-	public void subscribe(final Jedis jedis){
-		log.debug("subscribe init...");
-		Thread t= new Thread(new Runnable() {
-			@Override
-			public void run() {
-				jedis.psubscribe(new JedisPubSub() {
-					@Override
-					public void onUnsubscribe(String arg0, int arg1) {
-						// TODO Auto-generated method stub
-						
-					}
-					
-					@Override
-					public void onSubscribe(String arg0, int arg1) {
-						// TODO Auto-generated method stub
-						
-					}
-					
-					@Override
-					public void onPUnsubscribe(String arg0, int arg1) {
-						// TODO Auto-generated method stub
-						
-					}
-					
-					@Override
-					public void onPSubscribe(String arg0, int arg1) {
-						log.debug("subscribe to: "+arg0+" "+arg1);
-					}
-					
-					@Override
-					public void onPMessage(String pattern, String channel, String message) {
-						log.debug("messsage " + pattern + channel + message);
-						if(channel.equalsIgnoreCase(MessagingConstants.SYSTEM_CHANNEL)){
-							Gson gson = new Gson();
-							HashMap<String,String> map = gson.fromJson(message, new TypeToken<Map<String, String>>() {}.getType());
-							
-							String meetingId = map.get("meetingId");
-							String messageId = map.get("messageId");
-							if(messageId != null){
-								if(MessagingConstants.END_MEETING_REQUEST_EVENT.equalsIgnoreCase(messageId)){
-									roomsManager.endMeetingRequest(meetingId);
-								}
-							}
-						}
-						else if(channel.equalsIgnoreCase(MessagingConstants.PRESENTATION_CHANNEL)){
-							log.debug("receiving message " + message);
-							Gson gson = new Gson();
-							
-							HashMap<String,String> map = gson.fromJson(message, new TypeToken<Map<String, String>>() {}.getType());
-							messageListener.handleReceivedMessage(map);
-						}						
-					}
-					
-					@Override
-					public void onMessage(String channel, String message) {
-
-					}
-				}, MessagingConstants.BIGBLUEBUTTON_PATTERN);
-			}
-		});
-		t.start();
-	}
-
-	public JedisPool getRedisPool() {
-		return redisPool;
-	}
-
-	public void setRedisPool(JedisPool redisPool) {
-		this.redisPool = redisPool;
-	}
-
-	public RoomsManager getRoomsManager() {
-		return roomsManager;
-	}
-
-	public void setRoomsManager(RoomsManager roomsManager) {
-		this.roomsManager = roomsManager;
-	}
-
-	public ConversionUpdatesMessageListener getMessageListener() {
-		return messageListener;
-	}
-
-	public void setMessageListener(ConversionUpdatesMessageListener messageListener) {
-		this.messageListener = messageListener;
-	}
-	
-	
-}
diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RedisMessagingService.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RedisMessagingService.java
new file mode 100755
index 0000000000000000000000000000000000000000..b909fd43efa647838a914ad0475fb9d84b292c68
--- /dev/null
+++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RedisMessagingService.java
@@ -0,0 +1,147 @@
+package org.bigbluebutton.conference.service.messaging;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.JedisPubSub;
+
+public class RedisMessagingService implements MessagingService{
+
+	private static Logger log = Red5LoggerFactory.getLogger(RedisMessagingService.class, "bigbluebutton");
+	
+	private int port;
+	private String host;
+	
+	private JedisPool redisPool;
+	private final Executor exec = Executors.newSingleThreadExecutor();
+	private Runnable pubsubListener;
+	
+	private final Set<MessageListener> listeners = new HashSet<MessageListener>();
+
+	public RedisMessagingService(String host, int port) {
+		this.host = host;
+		this.port = port;
+	}
+	
+	@Override
+	public void start() {
+		log.debug("Starting redis pubsub...");		
+		//Currently, the pool gets blocked for publish if a resource subscribe to a channel
+		final Jedis jedis = new Jedis(this.host,this.port);
+		try {
+			jedis.connect();
+			pubsubListener = new Runnable() {
+			    public void run() {
+			    	jedis.psubscribe(new PubSubListener(), MessagingConstants.BIGBLUEBUTTON_PATTERN);       			
+			    }
+			};
+			exec.execute(pubsubListener);
+		} catch (Exception e) {
+			log.error("Cannot connect to [" + host + ":" + port + "]");
+		}
+	}
+
+	@Override
+	public void stop() {
+		try {
+			redisPool.destroy();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	@Override
+	public void send(String channel, String message) {
+		Jedis jedis = redisPool.getResource();
+		try {
+			jedis.publish(channel, message);
+		} catch(Exception e){
+			log.warn("Cannot publish the message to redis",e);
+		}finally{
+			redisPool.returnResource(jedis);
+		}
+	}
+
+	@Override
+	public void addListener(MessageListener listener) {
+		listeners.add(listener);
+	}
+
+	@Override
+	public void removeListener(MessageListener listener) {
+		listeners.remove(listener);
+	}
+	
+	public void setRedisPool(JedisPool redisPool){
+		this.redisPool=redisPool;
+	}
+
+	private class PubSubListener extends JedisPubSub {
+		
+		public PubSubListener() {
+			super();			
+		}
+
+		@Override
+		public void onMessage(String channel, String message) {
+			// Not used.
+		}
+
+		@Override
+		public void onPMessage(String pattern, String channel, String message) {
+			log.debug("Message Received in channel: " + channel);
+			Gson gson = new Gson();
+			HashMap<String,String> map = gson.fromJson(message, new TypeToken<Map<String, String>>() {}.getType());
+			
+			if(channel.equalsIgnoreCase(MessagingConstants.SYSTEM_CHANNEL)){
+				String meetingId = map.get("meetingId");
+				String messageId = map.get("messageId");
+				if(messageId != null){
+					if(MessagingConstants.END_MEETING_REQUEST_EVENT.equalsIgnoreCase(messageId)){
+						for (MessageListener listener : listeners) {
+							listener.endMeetingRequest(meetingId);
+						}
+					}
+				}
+			}
+			else if(channel.equalsIgnoreCase(MessagingConstants.PRESENTATION_CHANNEL)){
+				for (MessageListener listener : listeners) {
+					listener.presentationUpdates(map);
+				}
+			}
+			
+		}
+
+		@Override
+		public void onPSubscribe(String pattern, int subscribedChannels) {
+			log.debug("Subscribed to the pattern:"+pattern);
+		}
+
+		@Override
+		public void onPUnsubscribe(String pattern, int subscribedChannels) {
+			// Not used.
+		}
+
+		@Override
+		public void onSubscribe(String channel, int subscribedChannels) {
+			// Not used.
+		}
+
+		@Override
+		public void onUnsubscribe(String channel, int subscribedChannels) {
+			// Not used.
+		}		
+	}
+}
diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RedisPublisher.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RedisPublisher.java
deleted file mode 100755
index f0cb88f3435aa7d8e66438c8caddee5c0066930f..0000000000000000000000000000000000000000
--- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RedisPublisher.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.bigbluebutton.conference.service.messaging;
-
-import redis.clients.jedis.Jedis;
-import redis.clients.jedis.JedisPool;
-
-public class RedisPublisher{
-	
-	JedisPool redisPool;
-
-	public RedisPublisher(){
-		super();
-	}
-	
-	public void publish(String channel, String message){
-		Jedis jedis = redisPool.getResource();
-		try {
-			jedis.publish(channel, message);
-		} finally {
-			redisPool.returnResource(jedis);
-		}
-	}
-	
-	public JedisPool getRedisPool() {
-		return redisPool;
-	}
-
-	public void setRedisPool(JedisPool redisPool) {
-		this.redisPool = redisPool;
-	}
-	
-}
diff --git a/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-apps.xml b/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-apps.xml
index f77dbc128f6821ba81d08b1c78f401872d220e07..5f99af8cac638074434af37c2542de825b7dd8d8 100755
--- a/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-apps.xml
+++ b/bigbluebutton-apps/src/main/webapp/WEB-INF/bbb-apps.xml
@@ -18,7 +18,8 @@
 			">
 	
 	<bean id="roomsManager" class="org.bigbluebutton.conference.RoomsManager">
-		<property name="publisher" ref="redisPublisher"></property>
+		<property name="messagingService" ref="messagingService"></property>
+		<property name="conversionUpdatesMessageListener" ref="conversionUpdatesMessageListener"></property>
 	</bean>
 			
 	<bean id="participantsHandler" class="org.bigbluebutton.conference.service.participants.ParticipantsHandler">
@@ -46,7 +47,7 @@
 			<ref local="recorderApplication"/>
 		</property>
 		<property name="conversionUpdatesMessageListener"> 
-			<ref local="messageListener"/>
+			<ref local="conversionUpdatesMessageListener" />
 		</property>
 	</bean>
 	
@@ -65,7 +66,7 @@
 		<property name="presentationApplication"> <ref local="presentationApplication"/></property>
 	</bean>
 
-	<bean id="messageListener" class="org.bigbluebutton.conference.service.presentation.ConversionUpdatesMessageListener">
+	<bean id="conversionUpdatesMessageListener" class="org.bigbluebutton.conference.service.presentation.ConversionUpdatesMessageListener">
 		<property name="conversionUpdatesProcessor" ref="conversionUpdatesProcessor" />
 	</bean>
 
@@ -113,17 +114,11 @@
         <property name="redisPool"><ref local="redisPool" /> </property>
     </bean>
 	
-	<bean id="redisListener" class="org.bigbluebutton.conference.service.messaging.RedisListener" init-method="init">
-		<constructor-arg index="0" value="${redis.host}"/>
-        <constructor-arg index="1" value="${redis.port}"/>
-	    <property name="redisPool"><ref local="redisPool" /> </property>
-	    <property name="roomsManager"> <ref local="roomsManager"/></property>
-	    <property name="messageListener"> <ref local="messageListener"/></property>
-	</bean>
-	
-	<bean id="redisPublisher" class="org.bigbluebutton.conference.service.messaging.RedisPublisher">
-        <property name="redisPool"><ref local="redisPool" /> </property>
-    </bean>
+    <bean id="messagingService" class="org.bigbluebutton.conference.service.messaging.RedisMessagingService">
+    	<constructor-arg index="0" value="${redis.host}"/>
+    	<constructor-arg index="1" value="${redis.port}"/>
+    	<property name="redisPool" ref="redisPool"/>
+  	</bean>
     
     <bean id="redisPool" class="redis.clients.jedis.JedisPool">
         <constructor-arg index="0" value="${redis.host}"/>
diff --git a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy
index 81473a79875bac15606c30eba57364ba27433e05..dabfa98959cb57be621c694fbbabf9bb1a591e04 100755
--- a/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy
+++ b/bigbluebutton-web/grails-app/controllers/org/bigbluebutton/web/controllers/ApiController.groovy
@@ -1,1236 +1,1236 @@
-/* BigBlueButton - http://www.bigbluebutton.org
- * 
- * 
- * Copyright (c) 2008-2009 by respective authors (see below). All rights reserved.
- * 
- * BigBlueButton is free software; you can redistribute it and/or modify it under the 
- * terms of the GNU Lesser General Public License as published by the Free Software 
- * Foundation; either version 3 of the License, or (at your option) any later 
- * version. 
- * 
- * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public License along 
- * with BigBlueButton; if not, If not, see <http://www.gnu.org/licenses/>.
- *
- * @author Jeremy Thomerson <jthomerson@genericconf.com>
- * @version $Id: $
- */
-package org.bigbluebutton.web.controllers
-
-
-import java.text.MessageFormat;
-import java.util.Collections;
-import org.apache.commons.codec.binary.Hex;
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang.RandomStringUtils;
-import org.apache.commons.lang.StringUtils;
-import org.bigbluebutton.api.domain.Meeting;
-import org.bigbluebutton.api.MeetingService;
-import org.bigbluebutton.api.domain.Recording;
-import org.bigbluebutton.web.services.PresentationService
-import org.bigbluebutton.presentation.UploadedPresentation
-//import org.codehaus.groovy.grails.commons.ConfigurationHolder;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-//import grails.converters.XML;
-import org.bigbluebutton.api.ApiErrors;
-import org.bigbluebutton.api.ParamsProcessorUtil;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.ArrayList;
-
-class ApiController {
-  private static final Integer SESSION_TIMEOUT = 10800  // 3 hours    
-  private static final String CONTROLLER_NAME = 'ApiController'		
-  private static final String RESP_CODE_SUCCESS = 'SUCCESS'
-  private static final String RESP_CODE_FAILED = 'FAILED'
-  private static final String ROLE_MODERATOR = "MODERATOR";
-  private static final String ROLE_ATTENDEE = "VIEWER";
-  private static final String SECURITY_SALT = '639259d4-9dd8-4b25-bf01-95f9567eaf4b'
-  private static final String API_VERSION = '0.8'
-    
-  MeetingService meetingService;
-  PresentationService presentationService
-  ParamsProcessorUtil paramsProcessorUtil
-  
-  /* general methods */
-  def index = {
-    log.debug CONTROLLER_NAME + "#index"
-    response.addHeader("Cache-Control", "no-cache")
-    withFormat {	
-      xml {
-        render(contentType:"text/xml") {
-          response() {
-            returncode(RESP_CODE_SUCCESS)
-            version(paramsProcessorUtil.getApiVersion())
-          }
-        }
-      }
-    }
-  }
- 
-        
-  /*********************************** 
-   * CREATE (API) 
-   ***********************************/
-  def create = {
-    String API_CALL = 'create'
-    log.debug CONTROLLER_NAME + "#${API_CALL}"
-  	
-	// BEGIN - backward compatibility
-	if (StringUtils.isEmpty(params.checksum)) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-
-	if (StringUtils.isEmpty(params.name)) {
-		invalid("missingParamName", "You must specify a name for the meeting.");
-		return
-	}
-
-	if (StringUtils.isEmpty(params.meetingID)) {
-		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
-		return
-	}
-	
-	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-	// END - backward compatibility
-	
-	ApiErrors errors = new ApiErrors();
-	paramsProcessorUtil.processRequiredCreateParams(params, errors);
-
-    if (errors.hasErrors()) {
-    	respondWithErrors(errors)
-    	return
-    }
-            
-    // Do we agree with the checksum? If not, complain.
-    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-      errors.checksumError()
-    	respondWithErrors(errors)
-    	return
-    }
-    
-    
-    // Translate the external meeting id into an internal meeting id.
-    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(params.meetingID);		
-    Meeting existing = meetingService.getMeeting(internalMeetingId);
-    if (existing != null) {
-      log.debug "Existing conference found"
-      Map<String, Object> updateParams = paramsProcessorUtil.processUpdateCreateParams(params);
-      if (existing.getViewerPassword().equals(params.get("attendeePW")) && existing.getModeratorPassword().equals(params.get("moderatorPW"))) {
-        paramsProcessorUtil.updateMeeting(updateParams, existing);
-        // trying to create a conference a second time, return success, but give extra info
-        // Ignore pre-uploaded presentations. We only allow uploading of presentation once.
-        //uploadDocuments(existing);
-        respondWithConference(existing, "duplicateWarning", "This conference was already in existence and may currently be in progress.");
-      } else {
-	  	// BEGIN - backward compatibility
-	  	invalid("idNotUnique", "A meeting already exists with that meeting ID.  Please use a different meeting ID.");
-		return;
-	  	// END - backward compatibility
-	  
-        // enforce meetingID unique-ness
-        errors.nonUniqueMeetingIdError()
-        respondWithErrors(errors)
-      } 
-      
-      return;    
-    }
-     
-    Meeting newMeeting = paramsProcessorUtil.processCreateParams(params);            
-    meetingService.createMeeting(newMeeting);
-    
-    // See if the request came with pre-uploading of presentation.
-    uploadDocuments(newMeeting);
-    
-    respondWithConference(newMeeting, null, null)
-  }
-
-  /**********************************************
-   * JOIN API
-   *********************************************/
-  def join = {
-    String API_CALL = 'join'
-    log.debug CONTROLLER_NAME + "#${API_CALL}"
-  	ApiErrors errors = new ApiErrors()
-  	  
-	// BEGIN - backward compatibility
-    if (StringUtils.isEmpty(params.checksum)) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-
-	if (StringUtils.isEmpty(params.fullName)) {
-		invalid("missingParamFullName", "You must specify a name for the attendee who will be joining the meeting.");
-		return
-	}
-	
-	if (StringUtils.isEmpty(params.meetingID)) {
-		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
-		return
-	}
-	
-	if (StringUtils.isEmpty(params.password)) {
-		invalid("invalidPassword","You either did not supply a password or the password supplied is neither the attendee or moderator password for this conference.");
-		return
-	}
-	
-	if (!paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-	// END - backward compatibility
-  
-    // Do we have a checksum? If none, complain.
-    if (StringUtils.isEmpty(params.checksum)) {
-      errors.missingParamError("checksum");
-    }
-
-    // Do we have a name for the user joining? If none, complain.
-    String fullName = params.fullName
-    if (StringUtils.isEmpty(fullName)) {
-      errors.missingParamError("fullName");
-    }
-
-    // Do we have a meeting id? If none, complain.
-    String externalMeetingId = params.meetingID
-    if (StringUtils.isEmpty(externalMeetingId)) {
-      errors.missingParamError("meetingID");
-    }
-
-    // Do we have a password? If not, complain.
-    String attPW = params.password
-    if (StringUtils.isEmpty(attPW)) {
-      errors.missingParamError("password");
-    }
-    
-    if (errors.hasErrors()) {
-    	respondWithErrors(errors)
-    	return
-    }
-        
-    // Do we agree on the checksum? If not, complain.		
-    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-      	errors.checksumError()
-    	respondWithErrors(errors)
-    	return
-    }
-
-    // Everything is good so far. Translate the external meeting id to an internal meeting id. If
-    // we can't find the meeting, complain.					        
-    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingId);
-    log.info("Retrieving meeting ${internalMeetingId}")		
-    Meeting meeting = meetingService.getMeeting(internalMeetingId);
-    if (meeting == null) {
-		// BEGIN - backward compatibility
-		invalid("invalidMeetingIdentifier", "The meeting ID that you supplied did not match any existing meetings");
-		return;
-		// END - backward compatibility
-		
-	   errors.invalidMeetingIdError();
-	   respondWithErrors(errors)
-	   return;
-    }
-
-	// the createTime mismatch with meeting's createTime, complain
-	// In the future, the createTime param will be required
-	if (params.createTime != null){
-		long createTime = 0;
-		try{
-			createTime=Long.parseLong(params.createTime);
-		}catch(Exception e){
-			log.warn("could not parse createTime param");
-			createTime = -1;
-		}
-		if(createTime != meeting.getCreateTime()){
-			errors.mismatchCreateTimeParam();
-			respondWithErrors(errors);
-			return;
-		}
-	}
-    
-    // Is this user joining a meeting that has been ended. If so, complain.
-    if (meeting.isForciblyEnded()) {
-		// BEGIN - backward compatibility
-		invalid("meetingForciblyEnded", "You can not re-join a meeting that has already been forcibly ended.  However, once the meeting is removed from memory (according to the timeout configured on this server, you will be able to once again create a meeting with the same meeting ID");
-		return;
-		// END - backward compatibility
-		
-      errors.meetingForciblyEndedError();
-      respondWithErrors(errors)
-      return;
-    }
-
-    // Now determine if this user is a moderator or a viewer.
-    String role = null;
-    if (meeting.getModeratorPassword().equals(attPW)) {
-      role = ROLE_MODERATOR;
-    } else if (meeting.getViewerPassword().equals(attPW)) {
-      role = ROLE_ATTENDEE;
-    }
-    
-    if (role == null) {
-		// BEGIN - backward compatibility
-		invalid("invalidPassword","You either did not supply a password or the password supplied is neither the attendee or moderator password for this conference.");
-		return
-		// END - backward compatibility
-		
-    	errors.invalidPasswordError()
-	    respondWithErrors(errors)
-	    return;
-    }
-        
-    String webVoice = StringUtils.isEmpty(params.webVoiceConf) ? meeting.getTelVoice() : params.webVoiceConf
-
-    boolean redirectImm = parseBoolean(params.redirectImmediately)
-    
-    String externUserID = params.userID
-    if (StringUtils.isEmpty(externUserID)) {
-      externUserID = RandomStringUtils.randomAlphanumeric(12).toLowerCase()
-    }
-    
-    session["conferencename"] = meeting.getName()
-    session["meetingID"] = meeting.getInternalId()
-    session["externUserID"] = externUserID
-    session["fullname"] = fullName 
-    session["role"] = role
-    session["conference"] = meeting.getInternalId()
-    session["room"] = meeting.getInternalId()
-    session["voicebridge"] = meeting.getTelVoice()
-    session["webvoiceconf"] = meeting.getWebVoice()
-    session["mode"] = "LIVE"
-    session["record"] = meeting.isRecord()
-    session['welcome'] = meeting.getWelcomeMessage()
-    
-    session.setMaxInactiveInterval(SESSION_TIMEOUT);
-    
-    log.info("Successfully joined. Redirecting to ${paramsProcessorUtil.getDefaultClientUrl()}"); 		
-    redirect(url: paramsProcessorUtil.getDefaultClientUrl())
-  }
-
-  /*******************************************
-   * IS_MEETING_RUNNING API
-   *******************************************/
-  def isMeetingRunning = {
-    String API_CALL = 'isMeetingRunning'
-    log.debug CONTROLLER_NAME + "#${API_CALL}"
-
-	// BEGIN - backward compatibility
-	if (StringUtils.isEmpty(params.checksum)) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-
-	if (StringUtils.isEmpty(params.meetingID)) {
-		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
-		return
-	}
-	
-	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-	// END - backward compatibility
-	
-  	ApiErrors errors = new ApiErrors()
-  	
-    // Do we have a checksum? If none, complain.
-    if (StringUtils.isEmpty(params.checksum)) {
-      errors.missingParamError("checksum");
-    }
-
-    // Do we have a meeting id? If none, complain.
-    String externalMeetingId = params.meetingID
-    if (StringUtils.isEmpty(externalMeetingId)) {
-      errors.missingParamError("meetingID");
-    }
-
-    if (errors.hasErrors()) {
-    	respondWithErrors(errors)
-    	return
-    }
-    
-    // Do we agree on the checksum? If not, complain.		
-    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-      	errors.checksumError()
-    	respondWithErrors(errors)
-    	return
-    }
-            
-    // Everything is good so far. Translate the external meeting id to an internal meeting id. If
-    // we can't find the meeting, complain.					        
-    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingId);
-    log.info("Retrieving meeting ${internalMeetingId}")		
-    Meeting meeting = meetingService.getMeeting(internalMeetingId);
-    if (meeting == null) {
-		// BEGIN - backward compatibility
-		invalid("invalidMeetingIdentifier", "The meeting ID that you supplied did not match any existing meetings");
-		return;
-		// END - backward compatibility
-		
-	   errors.invalidMeetingIdError();
-	   respondWithErrors(errors)
-	   return;
-    }
-    
-    response.addHeader("Cache-Control", "no-cache")
-    withFormat {	
-      xml {
-        render(contentType:"text/xml") {
-          response() {
-            returncode(RESP_CODE_SUCCESS)
-            running(meeting.isRunning() ? "true" : "false")
-          }
-        }
-      }
-    }
-  }
-
-  /************************************
-   * END API
-   ************************************/
-  def end = {
-    String API_CALL = "end"
-    
-    log.debug CONTROLLER_NAME + "#${API_CALL}"    
-	
-	// BEGIN - backward compatibility
-	if (StringUtils.isEmpty(params.checksum)) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-
-	if (StringUtils.isEmpty(params.meetingID)) {
-		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
-		return
-	}
-	
-	if (StringUtils.isEmpty(params.password)) {
-		invalid("invalidPassword","You must supply the moderator password for this call.");
-		return
-	}
-	
-	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-	// END - backward compatibility
-	
-    ApiErrors errors = new ApiErrors()
-    
-    // Do we have a checksum? If none, complain.
-    if (StringUtils.isEmpty(params.checksum)) {
-      errors.missingParamError("checksum");
-    }
-
-    // Do we have a meeting id? If none, complain.
-    String externalMeetingId = params.meetingID
-    if (StringUtils.isEmpty(externalMeetingId)) {
-      errors.missingParamError("meetingID");
-    }
-
-    // Do we have a password? If not, complain.
-    String modPW = params.password
-    if (StringUtils.isEmpty(modPW)) {
-      errors.missingParamError("password");
-    }
-
-    if (errors.hasErrors()) {
-    	respondWithErrors(errors)
-    	return
-    }
-    
-    // Do we agree on the checksum? If not, complain.		
-    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-      	errors.checksumError()
-    	respondWithErrors(errors)
-    	return
-    }
-            
-    // Everything is good so far. Translate the external meeting id to an internal meeting id. If
-    // we can't find the meeting, complain.					        
-    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingId);
-    log.info("Retrieving meeting ${internalMeetingId}")		
-    Meeting meeting = meetingService.getMeeting(internalMeetingId);
-    if (meeting == null) {
-		// BEGIN - backward compatibility
-		invalid("notFound", "We could not find a meeting with that meeting ID - perhaps the meeting is not yet running?");
-		return;
-		// END - backward compatibility
-		
-	   errors.invalidMeetingIdError();
-	   respondWithErrors(errors)
-	   return;
-    }
-    
-    if (meeting.getModeratorPassword().equals(modPW) == false) {
-		// BEGIN - backward compatibility
-		invalid("invalidPassword","You must supply the moderator password for this call.");
-		return;
-		// END - backward compatibility
-		
-	   errors.invalidPasswordError();
-	   respondWithErrors(errors)
-	   return;
-    }
-       
-    meetingService.endMeeting(meeting.getInternalId());
-    
-    response.addHeader("Cache-Control", "no-cache")
-    withFormat {	
-      xml {
-        render(contentType:"text/xml") {
-          response() {
-            returncode(RESP_CODE_SUCCESS)
-            messageKey("sentEndMeetingRequest")
-            message("A request to end the meeting was sent.  Please wait a few seconds, and then use the getMeetingInfo or isMeetingRunning API calls to verify that it was ended.")
-          }
-        }
-      }
-    }
-  }
-
-  /*****************************************
-   * GETMEETINGINFO API
-   *****************************************/
-  def getMeetingInfo = {
-    String API_CALL = "getMeetingInfo"
-    log.debug CONTROLLER_NAME + "#${API_CALL}"
-    
-	// BEGIN - backward compatibility
-	if (StringUtils.isEmpty(params.checksum)) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-
-	if (StringUtils.isEmpty(params.meetingID)) {
-		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
-		return
-	}
-	
-	if (StringUtils.isEmpty(params.password)) {
-		invalid("invalidPassword","You must supply the moderator password for this call.");
-		return
-	}
-	
-	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-	// END - backward compatibility
-	
-    ApiErrors errors = new ApiErrors()
-        
-    // Do we have a checksum? If none, complain.
-    if (StringUtils.isEmpty(params.checksum)) {
-      errors.missingParamError("checksum");
-    }
-
-    // Do we have a meeting id? If none, complain.
-    String externalMeetingId = params.meetingID
-    if (StringUtils.isEmpty(externalMeetingId)) {
-      errors.missingParamError("meetingID");
-    }
-
-    // Do we have a password? If not, complain.
-    String modPW = params.password
-    if (StringUtils.isEmpty(modPW)) {
-      errors.missingParamError("password");
-    }
-
-    if (errors.hasErrors()) {
-    	respondWithErrors(errors)
-    	return
-    }
-    
-    // Do we agree on the checksum? If not, complain.		
-    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-      	errors.checksumError()
-    	respondWithErrors(errors)
-    	return
-    }
-    
-    // Everything is good so far. Translate the external meeting id to an internal meeting id. If
-    // we can't find the meeting, complain.					        
-    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingId);
-    log.info("Retrieving meeting ${internalMeetingId}")		
-    Meeting meeting = meetingService.getMeeting(internalMeetingId);
-    if (meeting == null) {
-		// BEGIN - backward compatibility
-		invalid("notFound", "We could not find a meeting with that meeting ID");
-		return;
-		// END - backward compatibility
-		
-	   errors.invalidMeetingIdError();
-	   respondWithErrors(errors)
-	   return;
-    }
-    
-    if (meeting.getModeratorPassword().equals(modPW) == false) {
-		// BEGIN - backward compatibility
-		invalid("invalidPassword","You must supply the moderator password for this call."); 
-		return;
-		// END - backward compatibility
-		
-	   errors.invalidPasswordError();
-	   respondWithErrors(errors)
-	   return;
-    }
-    
-    respondWithConferenceDetails(meeting, null, null, null);
-  }
-  
-  /************************************
-   *	GETMEETINGS API
-   ************************************/
-  def getMeetings = {
-    String API_CALL = "getMeetings"
-    log.debug CONTROLLER_NAME + "#${API_CALL}"
-    
-	// BEGIN - backward compatibility
-	if (StringUtils.isEmpty(params.checksum)) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-	
-	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-	// END - backward compatibility
-	
-    ApiErrors errors = new ApiErrors()
-        
-    // Do we have a checksum? If none, complain.
-    if (StringUtils.isEmpty(params.checksum)) {
-      errors.missingParamError("checksum");
-    }
-
-    if (errors.hasErrors()) {
-    	respondWithErrors(errors)
-    	return
-    }
-    
-    // Do we agree on the checksum? If not, complain.		
-    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-      	errors.checksumError()
-    	respondWithErrors(errors)
-    	return
-    }
-        
-    Collection<Meeting> mtgs = meetingService.getMeetings();
-    
-    if (mtgs == null || mtgs.isEmpty()) {
-      response.addHeader("Cache-Control", "no-cache")
-      withFormat {	
-        xml {
-          render(contentType:"text/xml") {
-            response() {
-              returncode(RESP_CODE_SUCCESS)
-              meetings(null)
-              messageKey("noMeetings")
-              message("no meetings were found on this server")
-            }
-          }
-        }
-      }
-      return;
-    }
-    
-    response.addHeader("Cache-Control", "no-cache")
-    withFormat {	
-      xml {
-        render(contentType:"text/xml") {
-          response() {
-            returncode(RESP_CODE_SUCCESS)
-            meetings() {
-              mtgs.each { m ->
-                meeting() {
-                  meetingID(m.getExternalId())
-				  meetingName(m.getName())
-				  createTime(m.getCreateTime())
-                  attendeePW(m.getViewerPassword())
-                  moderatorPW(m.getModeratorPassword())
-                  hasBeenForciblyEnded(m.isForciblyEnded() ? "true" : "false")
-                  running(m.isRunning() ? "true" : "false")
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  }
-
-  /***********************************************
-   * ENTER API
-   ***********************************************/
-  def enter = {
-    def fname = session["fullname"]
-    def rl = session["role"]
-    def cnf = session["conference"]
-    def rm = session["room"]
-    def vb = session["voicebridge"] 
-    def wbv = session["webvoiceconf"]  
-    def rec = session["record"]
-    def md = session["mode"]
-    def confName = session["conferencename"]
-    def welcomeMsg = session['welcome']
-    def meetID = session["meetingID"] 
-    def externUID = session["externUserID"] 
-        
-    if (!rm) {
-      println "Could not find conference"
-      response.addHeader("Cache-Control", "no-cache")
-      withFormat {				
-        xml {
-          render(contentType:"text/xml") {
-            response() {
-              returncode("FAILED")
-              message("Could not find conference ${params.conference}.")
-            }
-          }
-        }
-      }
-      } else {	
-        println "Found conference"
-        response.addHeader("Cache-Control", "no-cache")
-        withFormat {				
-        xml {
-          render(contentType:"text/xml") {
-            response() {
-              returncode("SUCCESS")
-              fullname("$fname")
-              confname("$confName")
-              meetingID("$meetID")
-              externUserID("$externUID")
-              role("$rl")
-              conference("$cnf")
-              room("$rm")
-              voicebridge("${vb}")
-              webvoiceconf("${wbv}")
-              mode("$md")
-              record("$rec")
-              welcome("$welcomeMsg")
-            }
-          }
-        }
-      }
-      }  
-  }
-  
-  /*************************************************
-   * SIGNOUT API
-   *************************************************/
-  def signOut = {        
-  	String meetingId = session["conference"]
-  	Meeting meeting = meetingService.getMeeting(meetingId);
-  	String logoutUrl = paramsProcessorUtil.getDefaultLogoutUrl()
-                  
-  	// Log the user out of the application.
-  	session.invalidate()
-  
-  	if (meeting != null) {
-  	  log.debug("Logging out from [" + meeting.getInternalId() + "]");
-  		logoutUrl = meeting.getLogoutUrl();
-  	} else {
-  		log.warn("Signing out from a non-existing meeting [" + meetingId + "]");	
-  	}      
-   
-  	log.debug("Signing out. Redirecting to " + logoutUrl)
-  	redirect(url: logoutUrl)
-  }
- 
-  /******************************************************
-   * GET_RECORDINGS API
-   ******************************************************/
-  def getRecordings = {
-    String API_CALL = "getRecordings"
-    log.debug CONTROLLER_NAME + "#${API_CALL}"
-    
-	// BEGIN - backward compatibility
-	if (StringUtils.isEmpty(params.checksum)) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-	
-	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		invalid("checksumError", "You did not pass the checksum security check")
-		return
-	}
-	// END - backward compatibility
-	
-    ApiErrors errors = new ApiErrors()
-        
-    // Do we have a checksum? If none, complain.
-    if (StringUtils.isEmpty(params.checksum)) {
-      errors.missingParamError("checksum");
-	  respondWithErrors(errors)
-	  return
-    }
-	
-    // Do we agree on the checksum? If not, complain.   
-    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-        errors.checksumError()
-      respondWithErrors(errors)
-      return
-    }
-	
-	ArrayList<String> externalMeetingIds = new ArrayList<String>();
-	if (!StringUtils.isEmpty(params.meetingID)) {
-		externalMeetingIds=paramsProcessorUtil.decodeIds(params.meetingID);
-	}
-    
-    // Everything is good so far. Translate the external meeting ids to an internal meeting ids.             
-    ArrayList<String> internalMeetingIds = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingIds);        
-	HashMap<String,Recording> recs = meetingService.getRecordings(internalMeetingIds);
-	
-    if (recs.isEmpty()) {
-      response.addHeader("Cache-Control", "no-cache")
-      withFormat {  
-        xml {
-          render(contentType:"text/xml") {
-            response() {
-              returncode(RESP_CODE_SUCCESS)
-              recordings(null)
-              messageKey("noRecordings")
-              message("There are not recordings for the meetings")
-            }
-          }
-        }
-      }
-      return;
-    }
-    withFormat {  
-      xml {
-        render(contentType:"text/xml") {
-          response() {
-           returncode(RESP_CODE_SUCCESS)
-            recordings() {
-              recs.values().each { r ->
-				  recording() {
-                  recordID(r.getId())
-				  meetingID(r.getMeetingID())
-				  name(''){
-					  mkp.yieldUnescaped("<![CDATA["+r.getName()+"]]>")
-				  }
-                  published(r.isPublished())
-                  startTime(r.getStartTime())
+/* BigBlueButton - http://www.bigbluebutton.org
+ * 
+ * 
+ * Copyright (c) 2008-2009 by respective authors (see below). All rights reserved.
+ * 
+ * BigBlueButton is free software; you can redistribute it and/or modify it under the 
+ * terms of the GNU Lesser General Public License as published by the Free Software 
+ * Foundation; either version 3 of the License, or (at your option) any later 
+ * version. 
+ * 
+ * BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License along 
+ * with BigBlueButton; if not, If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @author Jeremy Thomerson <jthomerson@genericconf.com>
+ * @version $Id: $
+ */
+package org.bigbluebutton.web.controllers
+
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang.StringUtils;
+import org.bigbluebutton.api.domain.Meeting;
+import org.bigbluebutton.api.MeetingService;
+import org.bigbluebutton.api.domain.Recording;
+import org.bigbluebutton.web.services.PresentationService
+import org.bigbluebutton.presentation.UploadedPresentation
+//import org.codehaus.groovy.grails.commons.ConfigurationHolder;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+//import grails.converters.XML;
+import org.bigbluebutton.api.ApiErrors;
+import org.bigbluebutton.api.ParamsProcessorUtil;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.ArrayList;
+
+class ApiController {
+  private static final Integer SESSION_TIMEOUT = 10800  // 3 hours    
+  private static final String CONTROLLER_NAME = 'ApiController'		
+  private static final String RESP_CODE_SUCCESS = 'SUCCESS'
+  private static final String RESP_CODE_FAILED = 'FAILED'
+  private static final String ROLE_MODERATOR = "MODERATOR";
+  private static final String ROLE_ATTENDEE = "VIEWER";
+  private static final String SECURITY_SALT = '639259d4-9dd8-4b25-bf01-95f9567eaf4b'
+  private static final String API_VERSION = '0.8'
+    
+  MeetingService meetingService;
+  PresentationService presentationService
+  ParamsProcessorUtil paramsProcessorUtil
+  
+  /* general methods */
+  def index = {
+    log.debug CONTROLLER_NAME + "#index"
+    response.addHeader("Cache-Control", "no-cache")
+    withFormat {	
+      xml {
+        render(contentType:"text/xml") {
+          response() {
+            returncode(RESP_CODE_SUCCESS)
+            version(paramsProcessorUtil.getApiVersion())
+          }
+        }
+      }
+    }
+  }
+ 
+        
+  /*********************************** 
+   * CREATE (API) 
+   ***********************************/
+  def create = {
+    String API_CALL = 'create'
+    log.debug CONTROLLER_NAME + "#${API_CALL}"
+  	
+	// BEGIN - backward compatibility
+	if (StringUtils.isEmpty(params.checksum)) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+
+	if (StringUtils.isEmpty(params.name)) {
+		invalid("missingParamName", "You must specify a name for the meeting.");
+		return
+	}
+
+	if (StringUtils.isEmpty(params.meetingID)) {
+		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
+		return
+	}
+	
+	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+	// END - backward compatibility
+	
+	ApiErrors errors = new ApiErrors();
+	paramsProcessorUtil.processRequiredCreateParams(params, errors);
+
+    if (errors.hasErrors()) {
+    	respondWithErrors(errors)
+    	return
+    }
+            
+    // Do we agree with the checksum? If not, complain.
+    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+      errors.checksumError()
+    	respondWithErrors(errors)
+    	return
+    }
+    
+    
+    // Translate the external meeting id into an internal meeting id.
+    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(params.meetingID);		
+    Meeting existing = meetingService.getMeeting(internalMeetingId);
+    if (existing != null) {
+      log.debug "Existing conference found"
+      Map<String, Object> updateParams = paramsProcessorUtil.processUpdateCreateParams(params);
+      if (existing.getViewerPassword().equals(params.get("attendeePW")) && existing.getModeratorPassword().equals(params.get("moderatorPW"))) {
+        paramsProcessorUtil.updateMeeting(updateParams, existing);
+        // trying to create a conference a second time, return success, but give extra info
+        // Ignore pre-uploaded presentations. We only allow uploading of presentation once.
+        //uploadDocuments(existing);
+        respondWithConference(existing, "duplicateWarning", "This conference was already in existence and may currently be in progress.");
+      } else {
+	  	// BEGIN - backward compatibility
+	  	invalid("idNotUnique", "A meeting already exists with that meeting ID.  Please use a different meeting ID.");
+		return;
+	  	// END - backward compatibility
+	  
+        // enforce meetingID unique-ness
+        errors.nonUniqueMeetingIdError()
+        respondWithErrors(errors)
+      } 
+      
+      return;    
+    }
+     
+    Meeting newMeeting = paramsProcessorUtil.processCreateParams(params);            
+    meetingService.createMeeting(newMeeting);
+    
+    // See if the request came with pre-uploading of presentation.
+    uploadDocuments(newMeeting);
+    
+    respondWithConference(newMeeting, null, null)
+  }
+
+  /**********************************************
+   * JOIN API
+   *********************************************/
+  def join = {
+    String API_CALL = 'join'
+    log.debug CONTROLLER_NAME + "#${API_CALL}"
+  	ApiErrors errors = new ApiErrors()
+  	  
+	// BEGIN - backward compatibility
+    if (StringUtils.isEmpty(params.checksum)) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+
+	if (StringUtils.isEmpty(params.fullName)) {
+		invalid("missingParamFullName", "You must specify a name for the attendee who will be joining the meeting.");
+		return
+	}
+	
+	if (StringUtils.isEmpty(params.meetingID)) {
+		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
+		return
+	}
+	
+	if (StringUtils.isEmpty(params.password)) {
+		invalid("invalidPassword","You either did not supply a password or the password supplied is neither the attendee or moderator password for this conference.");
+		return
+	}
+	
+	if (!paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+	// END - backward compatibility
+  
+    // Do we have a checksum? If none, complain.
+    if (StringUtils.isEmpty(params.checksum)) {
+      errors.missingParamError("checksum");
+    }
+
+    // Do we have a name for the user joining? If none, complain.
+    String fullName = params.fullName
+    if (StringUtils.isEmpty(fullName)) {
+      errors.missingParamError("fullName");
+    }
+
+    // Do we have a meeting id? If none, complain.
+    String externalMeetingId = params.meetingID
+    if (StringUtils.isEmpty(externalMeetingId)) {
+      errors.missingParamError("meetingID");
+    }
+
+    // Do we have a password? If not, complain.
+    String attPW = params.password
+    if (StringUtils.isEmpty(attPW)) {
+      errors.missingParamError("password");
+    }
+    
+    if (errors.hasErrors()) {
+    	respondWithErrors(errors)
+    	return
+    }
+        
+    // Do we agree on the checksum? If not, complain.		
+    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+      	errors.checksumError()
+    	respondWithErrors(errors)
+    	return
+    }
+
+    // Everything is good so far. Translate the external meeting id to an internal meeting id. If
+    // we can't find the meeting, complain.					        
+    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingId);
+    log.info("Retrieving meeting ${internalMeetingId}")		
+    Meeting meeting = meetingService.getMeeting(internalMeetingId);
+    if (meeting == null) {
+		// BEGIN - backward compatibility
+		invalid("invalidMeetingIdentifier", "The meeting ID that you supplied did not match any existing meetings");
+		return;
+		// END - backward compatibility
+		
+	   errors.invalidMeetingIdError();
+	   respondWithErrors(errors)
+	   return;
+    }
+
+	// the createTime mismatch with meeting's createTime, complain
+	// In the future, the createTime param will be required
+	if (params.createTime != null){
+		long createTime = 0;
+		try{
+			createTime=Long.parseLong(params.createTime);
+		}catch(Exception e){
+			log.warn("could not parse createTime param");
+			createTime = -1;
+		}
+		if(createTime != meeting.getCreateTime()){
+			errors.mismatchCreateTimeParam();
+			respondWithErrors(errors);
+			return;
+		}
+	}
+    
+    // Is this user joining a meeting that has been ended. If so, complain.
+    if (meeting.isForciblyEnded()) {
+		// BEGIN - backward compatibility
+		invalid("meetingForciblyEnded", "You can not re-join a meeting that has already been forcibly ended.  However, once the meeting is removed from memory (according to the timeout configured on this server, you will be able to once again create a meeting with the same meeting ID");
+		return;
+		// END - backward compatibility
+		
+      errors.meetingForciblyEndedError();
+      respondWithErrors(errors)
+      return;
+    }
+
+    // Now determine if this user is a moderator or a viewer.
+    String role = null;
+    if (meeting.getModeratorPassword().equals(attPW)) {
+      role = ROLE_MODERATOR;
+    } else if (meeting.getViewerPassword().equals(attPW)) {
+      role = ROLE_ATTENDEE;
+    }
+    
+    if (role == null) {
+		// BEGIN - backward compatibility
+		invalid("invalidPassword","You either did not supply a password or the password supplied is neither the attendee or moderator password for this conference.");
+		return
+		// END - backward compatibility
+		
+    	errors.invalidPasswordError()
+	    respondWithErrors(errors)
+	    return;
+    }
+        
+    String webVoice = StringUtils.isEmpty(params.webVoiceConf) ? meeting.getTelVoice() : params.webVoiceConf
+
+    boolean redirectImm = parseBoolean(params.redirectImmediately)
+    
+    String externUserID = params.userID
+    if (StringUtils.isEmpty(externUserID)) {
+      externUserID = RandomStringUtils.randomAlphanumeric(12).toLowerCase()
+    }
+    
+    session["conferencename"] = meeting.getName()
+    session["meetingID"] = meeting.getInternalId()
+    session["externUserID"] = externUserID
+    session["fullname"] = fullName 
+    session["role"] = role
+    session["conference"] = meeting.getInternalId()
+    session["room"] = meeting.getInternalId()
+    session["voicebridge"] = meeting.getTelVoice()
+    session["webvoiceconf"] = meeting.getWebVoice()
+    session["mode"] = "LIVE"
+    session["record"] = meeting.isRecord()
+    session['welcome'] = meeting.getWelcomeMessage()
+    
+    session.setMaxInactiveInterval(SESSION_TIMEOUT);
+    
+    log.info("Successfully joined. Redirecting to ${paramsProcessorUtil.getDefaultClientUrl()}"); 		
+    redirect(url: paramsProcessorUtil.getDefaultClientUrl())
+  }
+
+  /*******************************************
+   * IS_MEETING_RUNNING API
+   *******************************************/
+  def isMeetingRunning = {
+    String API_CALL = 'isMeetingRunning'
+    log.debug CONTROLLER_NAME + "#${API_CALL}"
+
+	// BEGIN - backward compatibility
+	if (StringUtils.isEmpty(params.checksum)) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+
+	if (StringUtils.isEmpty(params.meetingID)) {
+		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
+		return
+	}
+	
+	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+	// END - backward compatibility
+	
+  	ApiErrors errors = new ApiErrors()
+  	
+    // Do we have a checksum? If none, complain.
+    if (StringUtils.isEmpty(params.checksum)) {
+      errors.missingParamError("checksum");
+    }
+
+    // Do we have a meeting id? If none, complain.
+    String externalMeetingId = params.meetingID
+    if (StringUtils.isEmpty(externalMeetingId)) {
+      errors.missingParamError("meetingID");
+    }
+
+    if (errors.hasErrors()) {
+    	respondWithErrors(errors)
+    	return
+    }
+    
+    // Do we agree on the checksum? If not, complain.		
+    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+      	errors.checksumError()
+    	respondWithErrors(errors)
+    	return
+    }
+            
+    // Everything is good so far. Translate the external meeting id to an internal meeting id. If
+    // we can't find the meeting, complain.					        
+    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingId);
+    log.info("Retrieving meeting ${internalMeetingId}")		
+    Meeting meeting = meetingService.getMeeting(internalMeetingId);
+    if (meeting == null) {
+		// BEGIN - backward compatibility
+		invalid("invalidMeetingIdentifier", "The meeting ID that you supplied did not match any existing meetings");
+		return;
+		// END - backward compatibility
+		
+	   errors.invalidMeetingIdError();
+	   respondWithErrors(errors)
+	   return;
+    }
+    
+    response.addHeader("Cache-Control", "no-cache")
+    withFormat {	
+      xml {
+        render(contentType:"text/xml") {
+          response() {
+            returncode(RESP_CODE_SUCCESS)
+            running(meeting.isRunning() ? "true" : "false")
+          }
+        }
+      }
+    }
+  }
+
+  /************************************
+   * END API
+   ************************************/
+  def end = {
+    String API_CALL = "end"
+    
+    log.debug CONTROLLER_NAME + "#${API_CALL}"    
+	
+	// BEGIN - backward compatibility
+	if (StringUtils.isEmpty(params.checksum)) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+
+	if (StringUtils.isEmpty(params.meetingID)) {
+		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
+		return
+	}
+	
+	if (StringUtils.isEmpty(params.password)) {
+		invalid("invalidPassword","You must supply the moderator password for this call.");
+		return
+	}
+	
+	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+	// END - backward compatibility
+	
+    ApiErrors errors = new ApiErrors()
+    
+    // Do we have a checksum? If none, complain.
+    if (StringUtils.isEmpty(params.checksum)) {
+      errors.missingParamError("checksum");
+    }
+
+    // Do we have a meeting id? If none, complain.
+    String externalMeetingId = params.meetingID
+    if (StringUtils.isEmpty(externalMeetingId)) {
+      errors.missingParamError("meetingID");
+    }
+
+    // Do we have a password? If not, complain.
+    String modPW = params.password
+    if (StringUtils.isEmpty(modPW)) {
+      errors.missingParamError("password");
+    }
+
+    if (errors.hasErrors()) {
+    	respondWithErrors(errors)
+    	return
+    }
+    
+    // Do we agree on the checksum? If not, complain.		
+    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+      	errors.checksumError()
+    	respondWithErrors(errors)
+    	return
+    }
+            
+    // Everything is good so far. Translate the external meeting id to an internal meeting id. If
+    // we can't find the meeting, complain.					        
+    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingId);
+    log.info("Retrieving meeting ${internalMeetingId}")		
+    Meeting meeting = meetingService.getMeeting(internalMeetingId);
+    if (meeting == null) {
+		// BEGIN - backward compatibility
+		invalid("notFound", "We could not find a meeting with that meeting ID - perhaps the meeting is not yet running?");
+		return;
+		// END - backward compatibility
+		
+	   errors.invalidMeetingIdError();
+	   respondWithErrors(errors)
+	   return;
+    }
+    
+    if (meeting.getModeratorPassword().equals(modPW) == false) {
+		// BEGIN - backward compatibility
+		invalid("invalidPassword","You must supply the moderator password for this call.");
+		return;
+		// END - backward compatibility
+		
+	   errors.invalidPasswordError();
+	   respondWithErrors(errors)
+	   return;
+    }
+       
+    meetingService.endMeeting(meeting.getInternalId());
+    
+    response.addHeader("Cache-Control", "no-cache")
+    withFormat {	
+      xml {
+        render(contentType:"text/xml") {
+          response() {
+            returncode(RESP_CODE_SUCCESS)
+            messageKey("sentEndMeetingRequest")
+            message("A request to end the meeting was sent.  Please wait a few seconds, and then use the getMeetingInfo or isMeetingRunning API calls to verify that it was ended.")
+          }
+        }
+      }
+    }
+  }
+
+  /*****************************************
+   * GETMEETINGINFO API
+   *****************************************/
+  def getMeetingInfo = {
+    String API_CALL = "getMeetingInfo"
+    log.debug CONTROLLER_NAME + "#${API_CALL}"
+    
+	// BEGIN - backward compatibility
+	if (StringUtils.isEmpty(params.checksum)) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+
+	if (StringUtils.isEmpty(params.meetingID)) {
+		invalid("missingParamMeetingID", "You must specify a meeting ID for the meeting.");
+		return
+	}
+	
+	if (StringUtils.isEmpty(params.password)) {
+		invalid("invalidPassword","You must supply the moderator password for this call.");
+		return
+	}
+	
+	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+	// END - backward compatibility
+	
+    ApiErrors errors = new ApiErrors()
+        
+    // Do we have a checksum? If none, complain.
+    if (StringUtils.isEmpty(params.checksum)) {
+      errors.missingParamError("checksum");
+    }
+
+    // Do we have a meeting id? If none, complain.
+    String externalMeetingId = params.meetingID
+    if (StringUtils.isEmpty(externalMeetingId)) {
+      errors.missingParamError("meetingID");
+    }
+
+    // Do we have a password? If not, complain.
+    String modPW = params.password
+    if (StringUtils.isEmpty(modPW)) {
+      errors.missingParamError("password");
+    }
+
+    if (errors.hasErrors()) {
+    	respondWithErrors(errors)
+    	return
+    }
+    
+    // Do we agree on the checksum? If not, complain.		
+    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+      	errors.checksumError()
+    	respondWithErrors(errors)
+    	return
+    }
+    
+    // Everything is good so far. Translate the external meeting id to an internal meeting id. If
+    // we can't find the meeting, complain.					        
+    String internalMeetingId = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingId);
+    log.info("Retrieving meeting ${internalMeetingId}")		
+    Meeting meeting = meetingService.getMeeting(internalMeetingId);
+    if (meeting == null) {
+		// BEGIN - backward compatibility
+		invalid("notFound", "We could not find a meeting with that meeting ID");
+		return;
+		// END - backward compatibility
+		
+	   errors.invalidMeetingIdError();
+	   respondWithErrors(errors)
+	   return;
+    }
+    
+    if (meeting.getModeratorPassword().equals(modPW) == false) {
+		// BEGIN - backward compatibility
+		invalid("invalidPassword","You must supply the moderator password for this call."); 
+		return;
+		// END - backward compatibility
+		
+	   errors.invalidPasswordError();
+	   respondWithErrors(errors)
+	   return;
+    }
+    
+    respondWithConferenceDetails(meeting, null, null, null);
+  }
+  
+  /************************************
+   *	GETMEETINGS API
+   ************************************/
+  def getMeetings = {
+    String API_CALL = "getMeetings"
+    log.debug CONTROLLER_NAME + "#${API_CALL}"
+    
+	// BEGIN - backward compatibility
+	if (StringUtils.isEmpty(params.checksum)) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+	
+	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+	// END - backward compatibility
+	
+    ApiErrors errors = new ApiErrors()
+        
+    // Do we have a checksum? If none, complain.
+    if (StringUtils.isEmpty(params.checksum)) {
+      errors.missingParamError("checksum");
+    }
+
+    if (errors.hasErrors()) {
+    	respondWithErrors(errors)
+    	return
+    }
+    
+    // Do we agree on the checksum? If not, complain.		
+    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+      	errors.checksumError()
+    	respondWithErrors(errors)
+    	return
+    }
+        
+    Collection<Meeting> mtgs = meetingService.getMeetings();
+    
+    if (mtgs == null || mtgs.isEmpty()) {
+      response.addHeader("Cache-Control", "no-cache")
+      withFormat {	
+        xml {
+          render(contentType:"text/xml") {
+            response() {
+              returncode(RESP_CODE_SUCCESS)
+              meetings(null)
+              messageKey("noMeetings")
+              message("no meetings were found on this server")
+            }
+          }
+        }
+      }
+      return;
+    }
+    
+    response.addHeader("Cache-Control", "no-cache")
+    withFormat {	
+      xml {
+        render(contentType:"text/xml") {
+          response() {
+            returncode(RESP_CODE_SUCCESS)
+            meetings() {
+              mtgs.each { m ->
+                meeting() {
+                  meetingID(m.getExternalId())
+				  meetingName(m.getName())
+				  createTime(m.getCreateTime())
+                  attendeePW(m.getViewerPassword())
+                  moderatorPW(m.getModeratorPassword())
+                  hasBeenForciblyEnded(m.isForciblyEnded() ? "true" : "false")
+                  running(m.isRunning() ? "true" : "false")
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
+  /***********************************************
+   * ENTER API
+   ***********************************************/
+  def enter = {
+    def fname = session["fullname"]
+    def rl = session["role"]
+    def cnf = session["conference"]
+    def rm = session["room"]
+    def vb = session["voicebridge"] 
+    def wbv = session["webvoiceconf"]  
+    def rec = session["record"]
+    def md = session["mode"]
+    def confName = session["conferencename"]
+    def welcomeMsg = session['welcome']
+    def meetID = session["meetingID"] 
+    def externUID = session["externUserID"] 
+        
+    if (!rm) {
+      println "Could not find conference"
+      response.addHeader("Cache-Control", "no-cache")
+      withFormat {				
+        xml {
+          render(contentType:"text/xml") {
+            response() {
+              returncode("FAILED")
+              message("Could not find conference ${params.conference}.")
+            }
+          }
+        }
+      }
+      } else {	
+        println "Found conference"
+        response.addHeader("Cache-Control", "no-cache")
+        withFormat {				
+        xml {
+          render(contentType:"text/xml") {
+            response() {
+              returncode("SUCCESS")
+              fullname("$fname")
+              confname("$confName")
+              meetingID("$meetID")
+              externUserID("$externUID")
+              role("$rl")
+              conference("$cnf")
+              room("$rm")
+              voicebridge("${vb}")
+              webvoiceconf("${wbv}")
+              mode("$md")
+              record("$rec")
+              welcome("$welcomeMsg")
+            }
+          }
+        }
+      }
+      }  
+  }
+  
+  /*************************************************
+   * SIGNOUT API
+   *************************************************/
+  def signOut = {        
+  	String meetingId = session["conference"]
+  	Meeting meeting = meetingService.getMeeting(meetingId);
+  	String logoutUrl = paramsProcessorUtil.getDefaultLogoutUrl()
+                  
+  	// Log the user out of the application.
+  	session.invalidate()
+  
+  	if (meeting != null) {
+  	  log.debug("Logging out from [" + meeting.getInternalId() + "]");
+  		logoutUrl = meeting.getLogoutUrl();
+  	} else {
+  		log.warn("Signing out from a non-existing meeting [" + meetingId + "]");	
+  	}      
+   
+  	log.debug("Signing out. Redirecting to " + logoutUrl)
+  	redirect(url: logoutUrl)
+  }
+ 
+  /******************************************************
+   * GET_RECORDINGS API
+   ******************************************************/
+  def getRecordings = {
+    String API_CALL = "getRecordings"
+    log.debug CONTROLLER_NAME + "#${API_CALL}"
+    
+	// BEGIN - backward compatibility
+	if (StringUtils.isEmpty(params.checksum)) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+	
+	if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		invalid("checksumError", "You did not pass the checksum security check")
+		return
+	}
+	// END - backward compatibility
+	
+    ApiErrors errors = new ApiErrors()
+        
+    // Do we have a checksum? If none, complain.
+    if (StringUtils.isEmpty(params.checksum)) {
+      errors.missingParamError("checksum");
+	  respondWithErrors(errors)
+	  return
+    }
+	
+    // Do we agree on the checksum? If not, complain.   
+    if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+        errors.checksumError()
+      respondWithErrors(errors)
+      return
+    }
+	
+	ArrayList<String> externalMeetingIds = new ArrayList<String>();
+	if (!StringUtils.isEmpty(params.meetingID)) {
+		externalMeetingIds=paramsProcessorUtil.decodeIds(params.meetingID);
+	}
+    
+    // Everything is good so far. Translate the external meeting ids to an internal meeting ids.             
+    ArrayList<String> internalMeetingIds = paramsProcessorUtil.convertToInternalMeetingId(externalMeetingIds);        
+	HashMap<String,Recording> recs = meetingService.getRecordings(internalMeetingIds);
+	
+    if (recs.isEmpty()) {
+      response.addHeader("Cache-Control", "no-cache")
+      withFormat {  
+        xml {
+          render(contentType:"text/xml") {
+            response() {
+              returncode(RESP_CODE_SUCCESS)
+              recordings(null)
+              messageKey("noRecordings")
+              message("There are not recordings for the meetings")
+            }
+          }
+        }
+      }
+      return;
+    }
+    withFormat {  
+      xml {
+        render(contentType:"text/xml") {
+          response() {
+           returncode(RESP_CODE_SUCCESS)
+            recordings() {
+              recs.values().each { r ->
+				  recording() {
+                  recordID(r.getId())
+				  meetingID(r.getMeetingID())
+				  name(''){
+					  mkp.yieldUnescaped("<![CDATA["+r.getName()+"]]>")
+				  }
+                  published(r.isPublished())
+                  startTime(r.getStartTime())
                   endTime(r.getEndTime())
-				  metadata() {
-					 r.getMetadata().each { k,v ->
-						 "$k"(''){ 
-							 mkp.yieldUnescaped("<![CDATA[$v]]>") 
-						 }
-					 }
-				  }
-				  playback() {
-					  r.getPlaybacks().each { item ->
-						  format{
-							  type(item.getFormat())
-							  url(item.getUrl())
-							  length(item.getLength())
-						  }
+				  metadata() {
+					 r.getMetadata().each { k,v ->
+						 "$k"(''){ 
+							 mkp.yieldUnescaped("<![CDATA[$v]]>") 
+						 }
+					 }
+				  }
+				  playback() {
+					  r.getPlaybacks().each { item ->
+						  format{
+							  type(item.getFormat())
+							  url(item.getUrl())
+							  length(item.getLength())
+						  }
 					  }
-                  }
-                  
-                }
-              }
-            }
-          }
-        }
-      }
-    }
-  } 
-  
-  /******************************************************
-  * PUBLISH_RECORDINGS API
-  ******************************************************/
-  
-  def publishRecordings = {
-	  String API_CALL = "publishRecordings"
-	  log.debug CONTROLLER_NAME + "#${API_CALL}"
-	  
-	  // BEGIN - backward compatibility
-	  if (StringUtils.isEmpty(params.checksum)) {
-		  invalid("checksumError", "You did not pass the checksum security check")
-		  return
-	  }
-	  
-	  if (StringUtils.isEmpty(params.recordID)) {
-		  invalid("missingParamRecordID", "You must specify a recordID.");
-		  return
-	  }
-	  
-	  if (StringUtils.isEmpty(params.publish)) {
-		  invalid("missingParamPublish", "You must specify a publish value true or false.");
-		  return
-	  }
-	  
-	  if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		  invalid("checksumError", "You did not pass the checksum security check")
-		  return
-	  }
-	  // END - backward compatibility
-	  
-	  ApiErrors errors = new ApiErrors()
-	  
-	  // Do we have a checksum? If none, complain.
-	  if (StringUtils.isEmpty(params.checksum)) {
-		errors.missingParamError("checksum");
-	  }
-	
-	  // Do we have a recording id? If none, complain.
-	  String recordId = params.recordID
-	  if (StringUtils.isEmpty(recordId)) {
-		errors.missingParamError("recordID");
-	  }
-	  // Do we have a publish status? If none, complain.
-	  String publish = params.publish
-	  if (StringUtils.isEmpty(publish)) {
-		errors.missingParamError("publish");
-	  }
-	
-	  if (errors.hasErrors()) {
-		  respondWithErrors(errors)
-		  return
-	  }
-  
-	  // Do we agree on the checksum? If not, complain.
-	  if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		  errors.checksumError()
-		  respondWithErrors(errors)
-		  return
-	  }
-	  
-	  ArrayList<String> recordIdList = new ArrayList<String>();
-	  if (!StringUtils.isEmpty(recordId)) {
-		  recordIdList=paramsProcessorUtil.decodeIds(recordId);
-	  }
-	  
-	  if(!meetingService.existsAnyRecording(recordIdList)){
-		  // BEGIN - backward compatibility
-		  invalid("notFound", "We could not find recordings");
-		  return;
-		  // END - backward compatibility
-		  
-		  errors.recordingNotFound();
-		  respondWithErrors(errors);
-		  return;
-	  }
-	  
-	  meetingService.setPublishRecording(recordIdList,publish.toBoolean());
-	  withFormat {
-		  xml {
-			render(contentType:"text/xml") {
-			  response() {
-				  returncode(RESP_CODE_SUCCESS)
-				  published(publish)
-			  }
-			}
-		  }
-		}
-  }
-  
-  /******************************************************
-  * DELETE_RECORDINGS API
-  ******************************************************/
-  def deleteRecordings = {
-	  String API_CALL = "deleteRecordings"
-	  log.debug CONTROLLER_NAME + "#${API_CALL}"
-	  
-	  // BEGIN - backward compatibility
-	  if (StringUtils.isEmpty(params.checksum)) {
-		  invalid("checksumError", "You did not pass the checksum security check")
-		  return
-	  }
-	  
-	  if (StringUtils.isEmpty(params.recordID)) {
-		  invalid("missingParamRecordID", "You must specify a recordID.");
-		  return
-	  }
-	  
-	  if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		  invalid("checksumError", "You did not pass the checksum security check")
-		  return
-	  }
-	  // END - backward compatibility
-	  
-	  ApiErrors errors = new ApiErrors()
-	  
-	  // Do we have a checksum? If none, complain.
-	  if (StringUtils.isEmpty(params.checksum)) {
-		errors.missingParamError("checksum");
-	  }
-	
-	  // Do we have a recording id? If none, complain.
-	  String recordId = params.recordID
-	  if (StringUtils.isEmpty(recordId)) {
-		errors.missingParamError("recordID");
-	  }
-	
-	  if (errors.hasErrors()) {
-		  respondWithErrors(errors)
-		  return
-	  }
-  
-	  // Do we agree on the checksum? If not, complain.
-	  if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
-		  errors.checksumError()
-		  respondWithErrors(errors)
-		  return
-	  }
-	  
-	  ArrayList<String> recordIdList = new ArrayList<String>();
-	  if (!StringUtils.isEmpty(recordId)) {
-		  recordIdList=paramsProcessorUtil.decodeIds(recordId);
-	  }
-	  
-	  if(recordIdList.isEmpty()){
-		  // BEGIN - backward compatibility
-		  invalid("notFound", "We could not find recordings");
-		  return;
-		  // END - backward compatibility
-		  
-		  errors.recordingNotFound();
-		  respondWithErrors(errors);
-		  return;
-	  }
-	  
-	  meetingService.deleteRecordings(recordIdList);
-	  withFormat {
-		  xml {
-			render(contentType:"text/xml") {
-			  response() {
-				  returncode(RESP_CODE_SUCCESS)
-				  deleted(true)
-			  }
-			}
-		  }
-		}
-  }
-  
-  def uploadDocuments(conf) { 
-    log.debug("ApiController#uploadDocuments(${conf.getInternalId()})");
-
-    String requestBody = request.inputStream == null ? null : request.inputStream.text;
-    requestBody = StringUtils.isEmpty(requestBody) ? null : requestBody;
-
-    if (requestBody == null) {
-      return;
-    }
-        
-    log.debug "Request body: \n" + requestBody;
-
-    def xml = new XmlSlurper().parseText(requestBody);
-    xml.children().each { module ->
-      log.debug("module config found: [${module.@name}]");
-      if ("presentation".equals(module.@name.toString())) {
-        // need to iterate over presentation files and process them
-        module.children().each { document -> 
-          if (!StringUtils.isEmpty(document.@url.toString())) {
-            downloadAndProcessDocument(document.@url.toString(), conf);
-          } else if (!StringUtils.isEmpty(document.@name.toString())) {
-            def b64 = new Base64()
-            def decodedBytes = b64.decode(document.text().getBytes())
-            processDocumentFromRawBytes(decodedBytes, document.@name.toString(), conf);
-          } else {
-            log.debug("presentation module config found, but it did not contain url or name attributes");
-          }
-        }
-      }
-    }
-  }
-
-
-
-  def cleanFilename(filename) {
-    def notValidCharsRegExp = /[^0-9a-zA-Z_\.]/
-    return filename.replaceAll(notValidCharsRegExp, '-')
-  }
-  
-  def processDocumentFromRawBytes(bytes, filename, conf) {
-    def cleanName = cleanFilename(filename);
-
-    File uploadDir = presentationService.uploadedPresentationDirectory(conf.getInternalId(), conf.getInternalId(), cleanName);
-    def pres = new File(uploadDir.absolutePath + File.separatorChar + cleanName);
-    
-    FileOutputStream fos = new java.io.FileOutputStream(pres)
-    fos.write(bytes)
-    fos.flush()
-    fos.close()
-    
-    processUploadedFile(cleanName, pres, conf);
-  }
-    
-  def downloadAndProcessDocument(address, conf) {
-    log.debug("ApiController#downloadAndProcessDocument({$address}, ${conf.getInternalId()})");
-    String name = cleanFilename(address.tokenize("/")[-1]);
-    log.debug("Uploading presentation: ${name} from ${address} [starting download]");
-    
-    def out;
-    def pres;
-    try {
-      File uploadDir = presentationService.uploadedPresentationDirectory(conf.getInternalId(), conf.getInternalId(), name);
-      pres = new File(uploadDir.absolutePath + File.separatorChar + name);
-      out = new BufferedOutputStream(new FileOutputStream(pres))
-      out << new URL(address).openStream()
-    } finally {
-      if (out != null) {
-        out.close()
-      }
-    }
-
-    processUploadedFile(name, pres, conf);
-  }
-  
-  def processUploadedFile(name, pres, conf) {
-    UploadedPresentation uploadedPres = new UploadedPresentation(conf.getInternalId(), conf.getInternalId(), name);
-    uploadedPres.setUploadedFile(pres);
-    presentationService.processUploadedPresentation(uploadedPres);
-  }
-  
-  def beforeInterceptor = {
-    if (paramsProcessorUtil.isServiceEnabled() == false) {
-      log.info("apiNotEnabled: The API service and/or controller is not enabled on this server.  To use it, you must first enable it.")
-      // TODO: this doesn't stop the request - so it generates invalid XML
-      //			since the request continues and renders a second response
-      invalid("apiNotEnabled", "The API service and/or controller is not enabled on this server.  To use it, you must first enable it.")
-    }
-  }
-
-  def respondWithConferenceDetails(meeting, room, msgKey, msg) {
-    response.addHeader("Cache-Control", "no-cache")
-    withFormat {				
-      xml {
-        render(contentType:"text/xml") {
-          response() {
-            returncode(RESP_CODE_SUCCESS)
-			meetingName(meeting.getName())
-            meetingID(meeting.getExternalId())
-			createTime(meeting.getCreateTime())
-            attendeePW(meeting.getViewerPassword())
-            moderatorPW(meeting.getModeratorPassword())
-            running(meeting.isRunning() ? "true" : "false")
-			recording(meeting.isRecord() ? "true" : "false")
-            hasBeenForciblyEnded(meeting.isForciblyEnded() ? "true" : "false")
-            startTime(meeting.getStartTime())
-            endTime(meeting.getEndTime())
-            participantCount(meeting.getNumUsers())
-            maxUsers(meeting.getMaxUsers())
-            moderatorCount(meeting.getNumModerators())
-            attendees() {
-              meeting.getUsers().each { att ->
-                attendee() {
-                  userID("${att.userid}")
-                  fullName("${att.fullname}")
-                  role("${att.role}")
-                }
-              }
-            }
-			metadata(){
-				meeting.getMetadata().each{ k,v ->
-					"$k"("$v")
-				}
-			}
-            messageKey(msgKey == null ? "" : msgKey)
-            message(msg == null ? "" : msg)
-          }
-        }
-      }
-    }			 
-  }
-  
-  def respondWithConference(meeting, msgKey, msg) {
-    response.addHeader("Cache-Control", "no-cache")
-    withFormat {	
-      xml {
-        log.debug "Rendering as xml"
-        render(contentType:"text/xml") {
-          response() {
-            returncode(RESP_CODE_SUCCESS)
-            meetingID(meeting.getExternalId())
-            attendeePW(meeting.getViewerPassword())
-            moderatorPW(meeting.getModeratorPassword())
-            createTime(meeting.getCreateTime())
-            hasBeenForciblyEnded(meeting.isForciblyEnded() ? "true" : "false")
-            messageKey(msgKey == null ? "" : msgKey)
-            message(msg == null ? "" : msg)
-          }
-        }
-      }
-    }
-  }
-  
-  def respondWithErrors(errorList) {
-    log.debug CONTROLLER_NAME + "#invalid"
-    response.addHeader("Cache-Control", "no-cache")
-    withFormat {				
-      xml {
-        render(contentType:"text/xml") {
-          response() {
-            returncode(RESP_CODE_FAILED)
-            errors() {
-              ArrayList errs = errorList.getErrors();
-              Iterator itr = errs.iterator();
-              while (itr.hasNext()){
-                String[] er = (String[]) itr.next();
-                log.debug CONTROLLER_NAME + "#invalid" + er[0]
-                error(key: er[0], message: er[1])
-              }          
-            }
-          }
-        }
-      }
-      json {
-        log.debug "Rendering as json"
-        render(contentType:"text/json") {
-            returncode(RESP_CODE_FAILED)
-            messageKey(key)
-            message(msg)
-        }
-      }
-    }  
-  }
-  //TODO: method added for backward compability, it will be removed in next versions after 0.8
-  def invalid(key, msg) {
-	  String deprecatedMsg=" Note: This xml scheme will be DEPRECATED."
-	  log.debug CONTROLLER_NAME + "#invalid"
-	  response.addHeader("Cache-Control", "no-cache")
-	  withFormat {
-		  xml {
-			  render(contentType:"text/xml") {
-				  response() {
-					  returncode(RESP_CODE_FAILED)
-					  messageKey(key)
-					  message(msg+deprecatedMsg)
-				  }
-			  }
-		  }
-		  json {
-			  log.debug "Rendering as json"
-			  render(contentType:"text/json") {
-					  returncode(RESP_CODE_FAILED)
-					  messageKey(key)
-					  message(msg+deprecatedMsg)
-			  }
-		  }
-	  }
-  }
-  
-  def parseBoolean(obj) {
-		if (obj instanceof Number) {
-			return ((Number) obj).intValue() == 1;
-		}
-		return false
-  }  
-}
+                  }
+                  
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  } 
+  
+  /******************************************************
+  * PUBLISH_RECORDINGS API
+  ******************************************************/
+  
+  def publishRecordings = {
+	  String API_CALL = "publishRecordings"
+	  log.debug CONTROLLER_NAME + "#${API_CALL}"
+	  
+	  // BEGIN - backward compatibility
+	  if (StringUtils.isEmpty(params.checksum)) {
+		  invalid("checksumError", "You did not pass the checksum security check")
+		  return
+	  }
+	  
+	  if (StringUtils.isEmpty(params.recordID)) {
+		  invalid("missingParamRecordID", "You must specify a recordID.");
+		  return
+	  }
+	  
+	  if (StringUtils.isEmpty(params.publish)) {
+		  invalid("missingParamPublish", "You must specify a publish value true or false.");
+		  return
+	  }
+	  
+	  if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		  invalid("checksumError", "You did not pass the checksum security check")
+		  return
+	  }
+	  // END - backward compatibility
+	  
+	  ApiErrors errors = new ApiErrors()
+	  
+	  // Do we have a checksum? If none, complain.
+	  if (StringUtils.isEmpty(params.checksum)) {
+		errors.missingParamError("checksum");
+	  }
+	
+	  // Do we have a recording id? If none, complain.
+	  String recordId = params.recordID
+	  if (StringUtils.isEmpty(recordId)) {
+		errors.missingParamError("recordID");
+	  }
+	  // Do we have a publish status? If none, complain.
+	  String publish = params.publish
+	  if (StringUtils.isEmpty(publish)) {
+		errors.missingParamError("publish");
+	  }
+	
+	  if (errors.hasErrors()) {
+		  respondWithErrors(errors)
+		  return
+	  }
+  
+	  // Do we agree on the checksum? If not, complain.
+	  if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		  errors.checksumError()
+		  respondWithErrors(errors)
+		  return
+	  }
+	  
+	  ArrayList<String> recordIdList = new ArrayList<String>();
+	  if (!StringUtils.isEmpty(recordId)) {
+		  recordIdList=paramsProcessorUtil.decodeIds(recordId);
+	  }
+	  
+	  if(!meetingService.existsAnyRecording(recordIdList)){
+		  // BEGIN - backward compatibility
+		  invalid("notFound", "We could not find recordings");
+		  return;
+		  // END - backward compatibility
+		  
+		  errors.recordingNotFound();
+		  respondWithErrors(errors);
+		  return;
+	  }
+	  
+	  meetingService.setPublishRecording(recordIdList,publish.toBoolean());
+	  withFormat {
+		  xml {
+			render(contentType:"text/xml") {
+			  response() {
+				  returncode(RESP_CODE_SUCCESS)
+				  published(publish)
+			  }
+			}
+		  }
+		}
+  }
+  
+  /******************************************************
+  * DELETE_RECORDINGS API
+  ******************************************************/
+  def deleteRecordings = {
+	  String API_CALL = "deleteRecordings"
+	  log.debug CONTROLLER_NAME + "#${API_CALL}"
+	  
+	  // BEGIN - backward compatibility
+	  if (StringUtils.isEmpty(params.checksum)) {
+		  invalid("checksumError", "You did not pass the checksum security check")
+		  return
+	  }
+	  
+	  if (StringUtils.isEmpty(params.recordID)) {
+		  invalid("missingParamRecordID", "You must specify a recordID.");
+		  return
+	  }
+	  
+	  if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		  invalid("checksumError", "You did not pass the checksum security check")
+		  return
+	  }
+	  // END - backward compatibility
+	  
+	  ApiErrors errors = new ApiErrors()
+	  
+	  // Do we have a checksum? If none, complain.
+	  if (StringUtils.isEmpty(params.checksum)) {
+		errors.missingParamError("checksum");
+	  }
+	
+	  // Do we have a recording id? If none, complain.
+	  String recordId = params.recordID
+	  if (StringUtils.isEmpty(recordId)) {
+		errors.missingParamError("recordID");
+	  }
+	
+	  if (errors.hasErrors()) {
+		  respondWithErrors(errors)
+		  return
+	  }
+  
+	  // Do we agree on the checksum? If not, complain.
+	  if (! paramsProcessorUtil.isChecksumSame(API_CALL, params.checksum, request.getQueryString())) {
+		  errors.checksumError()
+		  respondWithErrors(errors)
+		  return
+	  }
+	  
+	  ArrayList<String> recordIdList = new ArrayList<String>();
+	  if (!StringUtils.isEmpty(recordId)) {
+		  recordIdList=paramsProcessorUtil.decodeIds(recordId);
+	  }
+	  
+	  if(recordIdList.isEmpty()){
+		  // BEGIN - backward compatibility
+		  invalid("notFound", "We could not find recordings");
+		  return;
+		  // END - backward compatibility
+		  
+		  errors.recordingNotFound();
+		  respondWithErrors(errors);
+		  return;
+	  }
+	  
+	  meetingService.deleteRecordings(recordIdList);
+	  withFormat {
+		  xml {
+			render(contentType:"text/xml") {
+			  response() {
+				  returncode(RESP_CODE_SUCCESS)
+				  deleted(true)
+			  }
+			}
+		  }
+		}
+  }
+  
+  def uploadDocuments(conf) { 
+    log.debug("ApiController#uploadDocuments(${conf.getInternalId()})");
+
+    String requestBody = request.inputStream == null ? null : request.inputStream.text;
+    requestBody = StringUtils.isEmpty(requestBody) ? null : requestBody;
+
+    if (requestBody == null) {
+      return;
+    }
+        
+    log.debug "Request body: \n" + requestBody;
+
+    def xml = new XmlSlurper().parseText(requestBody);
+    xml.children().each { module ->
+      log.debug("module config found: [${module.@name}]");
+      if ("presentation".equals(module.@name.toString())) {
+        // need to iterate over presentation files and process them
+        module.children().each { document -> 
+          if (!StringUtils.isEmpty(document.@url.toString())) {
+            downloadAndProcessDocument(document.@url.toString(), conf);
+          } else if (!StringUtils.isEmpty(document.@name.toString())) {
+            def b64 = new Base64()
+            def decodedBytes = b64.decode(document.text().getBytes())
+            processDocumentFromRawBytes(decodedBytes, document.@name.toString(), conf);
+          } else {
+            log.debug("presentation module config found, but it did not contain url or name attributes");
+          }
+        }
+      }
+    }
+  }
+
+
+
+  def cleanFilename(filename) {
+    def notValidCharsRegExp = /[^0-9a-zA-Z_\.]/
+    return filename.replaceAll(notValidCharsRegExp, '-')
+  }
+  
+  def processDocumentFromRawBytes(bytes, filename, conf) {
+    def cleanName = cleanFilename(filename);
+
+    File uploadDir = presentationService.uploadedPresentationDirectory(conf.getInternalId(), conf.getInternalId(), cleanName);
+    def pres = new File(uploadDir.absolutePath + File.separatorChar + cleanName);
+    
+    FileOutputStream fos = new java.io.FileOutputStream(pres)
+    fos.write(bytes)
+    fos.flush()
+    fos.close()
+    
+    processUploadedFile(cleanName, pres, conf);
+  }
+    
+  def downloadAndProcessDocument(address, conf) {
+    log.debug("ApiController#downloadAndProcessDocument({$address}, ${conf.getInternalId()})");
+    String name = cleanFilename(address.tokenize("/")[-1]);
+    log.debug("Uploading presentation: ${name} from ${address} [starting download]");
+    
+    def out;
+    def pres;
+    try {
+      File uploadDir = presentationService.uploadedPresentationDirectory(conf.getInternalId(), conf.getInternalId(), name);
+      pres = new File(uploadDir.absolutePath + File.separatorChar + name);
+      out = new BufferedOutputStream(new FileOutputStream(pres))
+      out << new URL(address).openStream()
+    } finally {
+      if (out != null) {
+        out.close()
+      }
+    }
+
+    processUploadedFile(name, pres, conf);
+  }
+  
+  def processUploadedFile(name, pres, conf) {
+    UploadedPresentation uploadedPres = new UploadedPresentation(conf.getInternalId(), conf.getInternalId(), name);
+    uploadedPres.setUploadedFile(pres);
+    presentationService.processUploadedPresentation(uploadedPres);
+  }
+  
+  def beforeInterceptor = {
+    if (paramsProcessorUtil.isServiceEnabled() == false) {
+      log.info("apiNotEnabled: The API service and/or controller is not enabled on this server.  To use it, you must first enable it.")
+      // TODO: this doesn't stop the request - so it generates invalid XML
+      //			since the request continues and renders a second response
+      invalid("apiNotEnabled", "The API service and/or controller is not enabled on this server.  To use it, you must first enable it.")
+    }
+  }
+
+  def respondWithConferenceDetails(meeting, room, msgKey, msg) {
+    response.addHeader("Cache-Control", "no-cache")
+    withFormat {				
+      xml {
+        render(contentType:"text/xml") {
+          response() {
+            returncode(RESP_CODE_SUCCESS)
+			meetingName(meeting.getName())
+            meetingID(meeting.getExternalId())
+			createTime(meeting.getCreateTime())
+            attendeePW(meeting.getViewerPassword())
+            moderatorPW(meeting.getModeratorPassword())
+            running(meeting.isRunning() ? "true" : "false")
+			recording(meeting.isRecord() ? "true" : "false")
+            hasBeenForciblyEnded(meeting.isForciblyEnded() ? "true" : "false")
+            startTime(meeting.getStartTime())
+            endTime(meeting.getEndTime())
+            participantCount(meeting.getNumUsers())
+            maxUsers(meeting.getMaxUsers())
+            moderatorCount(meeting.getNumModerators())
+            attendees() {
+              meeting.getUsers().each { att ->
+                attendee() {
+                  userID("${att.userid}")
+                  fullName("${att.fullname}")
+                  role("${att.role}")
+                }
+              }
+            }
+			metadata(){
+				meeting.getMetadata().each{ k,v ->
+					"$k"("$v")
+				}
+			}
+            messageKey(msgKey == null ? "" : msgKey)
+            message(msg == null ? "" : msg)
+          }
+        }
+      }
+    }			 
+  }
+  
+  def respondWithConference(meeting, msgKey, msg) {
+    response.addHeader("Cache-Control", "no-cache")
+    withFormat {	
+      xml {
+        log.debug "Rendering as xml"
+        render(contentType:"text/xml") {
+          response() {
+            returncode(RESP_CODE_SUCCESS)
+            meetingID(meeting.getExternalId())
+            attendeePW(meeting.getViewerPassword())
+            moderatorPW(meeting.getModeratorPassword())
+            createTime(meeting.getCreateTime())
+            hasBeenForciblyEnded(meeting.isForciblyEnded() ? "true" : "false")
+            messageKey(msgKey == null ? "" : msgKey)
+            message(msg == null ? "" : msg)
+          }
+        }
+      }
+    }
+  }
+  
+  def respondWithErrors(errorList) {
+    log.debug CONTROLLER_NAME + "#invalid"
+    response.addHeader("Cache-Control", "no-cache")
+    withFormat {				
+      xml {
+        render(contentType:"text/xml") {
+          response() {
+            returncode(RESP_CODE_FAILED)
+            errors() {
+              ArrayList errs = errorList.getErrors();
+              Iterator itr = errs.iterator();
+              while (itr.hasNext()){
+                String[] er = (String[]) itr.next();
+                log.debug CONTROLLER_NAME + "#invalid" + er[0]
+                error(key: er[0], message: er[1])
+              }          
+            }
+          }
+        }
+      }
+      json {
+        log.debug "Rendering as json"
+        render(contentType:"text/json") {
+            returncode(RESP_CODE_FAILED)
+            messageKey(key)
+            message(msg)
+        }
+      }
+    }  
+  }
+  //TODO: method added for backward compability, it will be removed in next versions after 0.8
+  def invalid(key, msg) {
+	  String deprecatedMsg=" Note: This xml scheme will be DEPRECATED."
+	  log.debug CONTROLLER_NAME + "#invalid"
+	  response.addHeader("Cache-Control", "no-cache")
+	  withFormat {
+		  xml {
+			  render(contentType:"text/xml") {
+				  response() {
+					  returncode(RESP_CODE_FAILED)
+					  messageKey(key)
+					  message(msg)
+				  }
+			  }
+		  }
+		  json {
+			  log.debug "Rendering as json"
+			  render(contentType:"text/json") {
+					  returncode(RESP_CODE_FAILED)
+					  messageKey(key)
+					  message(msg)
+			  }
+		  }
+	  }
+  }
+  
+  def parseBoolean(obj) {
+		if (obj instanceof Number) {
+			return ((Number) obj).intValue() == 1;
+		}
+		return false
+  }  
+}
diff --git a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/RedisMessagingService.java b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/RedisMessagingService.java
index 19c95dd6e05f2908983db774a4a4ceb0d6ab9650..d102c98e02d384cc2c6b390b572f5fe1d76b69f6 100755
--- a/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/RedisMessagingService.java
+++ b/bigbluebutton-web/src/java/org/bigbluebutton/api/messaging/RedisMessagingService.java
@@ -66,7 +66,6 @@ public class RedisMessagingService implements MessagingService {
 	public void send(String channel, String message) {
 		Jedis jedis = redisPool.getResource();
 		try {
-			System.out.println("Sending " + message + " to " + channel);
 			jedis.publish(channel, message);
 		} catch(Exception e){
 			log.warn("Cannot publish the message to redis",e);
diff --git a/record-and-playback/slides/playback/slides/css/bbb.playback.css b/record-and-playback/slides/playback/slides/css/bbb.playback.css
index a270e6e3c7208850e46a791443713a2d4fd50b2c..a3825397d7e2b51d6c518d6cb01fa11ac6e75353 100755
--- a/record-and-playback/slides/playback/slides/css/bbb.playback.css
+++ b/record-and-playback/slides/playback/slides/css/bbb.playback.css
@@ -1,5 +1,9 @@
+html{
+	height:100%;
+}
 body {
-	
+	font-family: Verdana;
+	height:100%;
 }
 h1 {
 	text-align:center
@@ -10,7 +14,7 @@ br{
 
 #playbackArea{
 	width: 800px;
-	height: 600px;
+	height: 700px;
 	margin-left: auto;
 	margin-right: auto;
 }
@@ -28,11 +32,11 @@ br{
 
 .chatcontainer{
 	width:420px;
-	height:350px;
+	height:600px;
 	margin-left: auto;
-        margin-right: auto;
+    margin-right: auto;
 	position: relative;
-	top:-500px;
+	top:-650px;
 	left:610px;
 }
 #chat{
@@ -51,8 +55,8 @@ br{
 #big {display:none}
 #mid {display:none}
 
-.chattitle{
-	position:relative;
-	top:20px;
-	left:145px
-}
+#footer{
+	position: absolute;
+	bottom: 0;
+	left: 40%;
+}
\ No newline at end of file
diff --git a/record-and-playback/slides/playback/slides/lib/popcorn.timeline.js b/record-and-playback/slides/playback/slides/lib/popcorn.timeline.js
index f2ce31255a848daae6c480e4923d63d9597d965f..ad820ba33c75a280773ecb1e822536a0eb79ea2c 100755
--- a/record-and-playback/slides/playback/slides/lib/popcorn.timeline.js
+++ b/record-and-playback/slides/playback/slides/lib/popcorn.timeline.js
@@ -41,7 +41,7 @@
         newdiv = document.createElement( "div" );
 
     target.style.width = "380px";
-    target.style.height = "180px";
+    target.style.height = "600px";
     target.style.overflow = "auto";
 
     newdiv.style.display = "none";
diff --git a/record-and-playback/slides/playback/slides/playback.html b/record-and-playback/slides/playback/slides/playback.html
index 469424f58531b3bb91f8d8782552c346020a5f50..31e483a7802ab1d09ea7ef399148d8ae13237432 100755
--- a/record-and-playback/slides/playback/slides/playback.html
+++ b/record-and-playback/slides/playback/slides/playback.html
@@ -37,15 +37,13 @@
   <script src="lib/popcorn.timeline.js"></script>
 </head>
 <body>
-
-  <div id="playbackArea">
-    <div style="width:800px; height:650px;" id="slide"> </div> 
-    <audio id="audioRecording" controls > You must use an HTML5 capable browser to view this page.</audio>
-    <div class="chatcontainer">
-            <h4 class="chattitle"></h4>	
-	    <div id="chat"></div>	
-    </div>
-  </div>
-
+	<div id="playbackArea">
+		<div style="width:800px; height:650px;" id="slide"></div> 
+		<audio id="audioRecording" controls > You must use an HTML5 capable browser to view this page.</audio>
+		<div class="chatcontainer">
+			<div id="chat"></div>			
+		</div>
+	</div>
+	<p id="footer">Recorded with <a href="http://bigbluebutton.org/">BigBlueButton</a>.  Playback using <a href="http://popcornjs.org/">popcorn.js</a>.</p>
 </body>
 </html>