Juan Carlos Picado Herrera avatar Juan Carlos Picado Herrera committed caca1e4

In progress ENCUESTAME-517

Comments (0)

Files changed (18)

enme-core/src/main/java/org/encuestame/core/service/AbstractSecurityContext.java

             if (log.isDebugEnabled()) {
                 log.debug("info logged user account: "+account);
                 if (account != null) {
-                    log.debug("info logged user account: "+account.getUserEmail());
-                    log.debug("info logged user account: "+account.getUsername());
-                    log.debug("info logged user account: "+account.getUid());
+                    log.debug("info logged user account: "+ account.getUserEmail());
+                    log.debug("info logged user account: "+ account.getUsername());
+                    log.debug("info logged user account: "+ account.getUid());
                 }
             }
         }
             final UserAccount account,
             final String password,
             final Boolean socialSignIn){
-         log.info("Register login user: "+account.getUsername());
+         log.info("Register login user: "+ account.getUsername());
          //building granted authorities
          final Collection<GrantedAuthority> authorities = ConvertDomainsToSecurityContext.convertEnMePermission(account.getSecUserPermissions());
          //create user detail based on user account.
      * @return the secCtx
      */
     public SecurityContext getSecCtx() {
+        //log.debug("SecurityContextHolder.getContext();" + SecurityContextHolder.getContext());
         return this.securityContext = SecurityContextHolder.getContext();
     }
 
     public EnMeUserAccountDetails getSecurityDetails(){
         EnMeUserAccountDetails details = null;
         log.trace("Authentication Object:{"+getSecCtx().getAuthentication());
-        if(getSecCtx().getAuthentication() != null){
+        if (getSecCtx().getAuthentication() != null) {
             if(getSecCtx().getAuthentication().getPrincipal() instanceof EnMeUserAccountDetails){
                 details =  (EnMeUserAccountDetails) getSecCtx().getAuthentication().getPrincipal();
             }
         <dependency>
             <groupId>org.encuestame</groupId>
             <artifactId>enme-model</artifactId>
-        </dependency>   
+        </dependency>
         <dependency>
             <groupId>org.encuestame</groupId>
             <artifactId>enme-dao</artifactId>
         </dependency>
         <dependency>
             <groupId>org.cometd.java</groupId>
+            <artifactId>cometd-websocket-jetty</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.cometd.java</groupId>
+                    <artifactId>cometd-java-client</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.cometd.java</groupId>
             <artifactId>cometd-java-server</artifactId>
         </dependency>
         <dependency>

enme-mvc/src/main/java/org/encuestame/comet/server/CometBayeuxInitializer.java

 import javax.inject.Inject;
 import javax.servlet.ServletContext;
 
+import org.apache.log4j.Logger;
 import org.cometd.annotation.ServerAnnotationProcessor;
 import org.cometd.bayeux.server.BayeuxServer;
 import org.cometd.server.BayeuxServerImpl;
 import org.cometd.server.ext.AcknowledgedMessagesExtension;
+import org.cometd.server.transport.JSONPTransport;
+import org.cometd.server.transport.JSONTransport;
+import org.cometd.websocket.server.WebSocketTransport;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
 import org.springframework.context.annotation.Bean;
 public class CometBayeuxInitializer implements DestructionAwareBeanPostProcessor,
         ServletContextAware {
 
-    /**
-     * Bayeux Server.
+    /*
+     * Log.
      */
-    private BayeuxServer bayeuxServer;
+    private Logger log = Logger.getLogger(this.getClass());
 
-    /**
-     * Server Annotation Procesor.
-     */
+    private BayeuxServer bayeuxServer;
     private ServerAnnotationProcessor processor;
 
-    /**
-     * Set {@link BayeuxServer}.
-     * @param bayeuxServer
-     */
-    @SuppressWarnings("unused")
     @Inject
-    private void setBayeuxServer(BayeuxServer bayeuxServer) {
+    private void setBayeuxServer(BayeuxServer bayeuxServer)
+    {
         this.bayeuxServer = bayeuxServer;
     }
 
-    /**
-     * Post Construct method.
-     */
-    @SuppressWarnings("unused")
     @PostConstruct
-    private void init() {
+    private void init()
+    {
         this.processor = new ServerAnnotationProcessor(bayeuxServer);
     }
 
-    /**
-     * Destroy bean.
-     */
-    @SuppressWarnings("unused")
     @PreDestroy
-    private void destroy() {
+    private void destroy()
+    {
     }
 
-    /**
-     * Post process before initialization.
-     */
-    public Object postProcessBeforeInitialization(Object bean, String name)
-            throws BeansException {
+    public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException
+    {
         processor.processDependencies(bean);
         processor.processConfigurations(bean);
         processor.processCallbacks(bean);
         return bean;
     }
 
-    /**
-     * Post process after initialization.
-     */
-    public Object postProcessAfterInitialization(Object bean, String name)
-            throws BeansException {
+    public Object postProcessAfterInitialization(Object bean, String name) throws BeansException
+    {
         return bean;
     }
 
-    /**
-     * Post process before destruction.
-     */
-    public void postProcessBeforeDestruction(Object bean, String name)
-            throws BeansException {
+    public void postProcessBeforeDestruction(Object bean, String name) throws BeansException
+    {
         processor.deprocessCallbacks(bean);
     }
 
      * Bayeux Server.
      * @return {@link BayeuxServer}.
      */
-    @Bean(initMethod = "start", destroyMethod = "stop", name="bayeux")
+    @Bean(initMethod = "start", destroyMethod = "stop")
     public BayeuxServer bayeuxServer() {
         BayeuxServerImpl bean = new BayeuxServerImpl();
         bean.setOption(BayeuxServerImpl.LOG_LEVEL, "0");
         //http://cometdaily.com/2009/03/27/cometd-acknowledged-message-extension/
         bean.addExtension(new AcknowledgedMessagesExtension());
         return bean;
+//         log.debug("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+//         log.debug("&&&&&&&&&&&&   COMET SERVER INITIALIZED &&&&&&&&&&&&&&&&&&&&");
+//         BayeuxServerImpl bean = new BayeuxServerImpl();
+//         bean.setTransports(new WebSocketTransport(bean), new JSONTransport(bean), new JSONPTransport(bean));
+//         log.debug("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");
+         //return bean;
     }
 
     /**

enme-mvc/src/main/java/org/encuestame/comet/services/HelloService.java

+package org.encuestame.comet.services;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.cometd.bayeux.server.BayeuxServer;
+import org.cometd.bayeux.server.ServerMessage;
+import org.cometd.bayeux.server.ServerSession;
+import org.cometd.annotation.Listener;
+import org.cometd.annotation.Service;
+import org.cometd.annotation.Session;
+
+@Named
+@Singleton
+@Service("helloService")
+public class HelloService
+{
+    @Inject
+    private BayeuxServer bayeux;
+    @Session
+    private ServerSession serverSession;
+
+    @PostConstruct
+    public void init()
+    {
+    }
+
+    @Listener("/service/hello")
+    public void processHello(ServerSession remote, ServerMessage.Mutable message)
+    {
+        Map<String, Object> input = message.getDataAsMap();
+        String name = (String)input.get("name");
+
+        Map<String, Object> output = new HashMap<String, Object>();
+        output.put("greeting", "Hello, " + name);
+        remote.deliver(serverSession, "/hello", output, null);
+    }
+}

enme-mvc/src/main/java/org/encuestame/comet/services/NotificationCometService.java

 import org.cometd.bayeux.server.ServerMessage;
 import org.cometd.bayeux.server.ServerSession;
 import org.encuestame.persistence.domain.security.UserAccount;
+import org.encuestame.persistence.exception.EnMeExpcetion;
 import org.encuestame.persistence.exception.EnMeNoResultsFoundException;
 
 /**
 
     /**
      * Notification services response.
-     * @param remote
+     * @param service
      * @param message
      */
     @Listener("/service/notification/status")
-    public void processNotification(final ServerSession remote, final ServerMessage.Mutable message) {
+    public void processNotification(final ServerSession service, final ServerMessage.Mutable message) {
         final Map<String, Object> input = message.getDataAsMap();
         //log.debug("Notification Input "+input);
         final Map<String, Object> output = new HashMap<String, Object>();
         UserAccount userAccount;
         try {
-            userAccount = getByUsername(getUserPrincipalUsername());
-            if (userAccount != null) {
-                final Long totalNot = getNotificationDao().retrieveTotalNotificationStatus(userAccount.getAccount());
-                log.debug("totalNot "+totalNot);
-                final Long totalNewNot = getNotificationDao().retrieveTotalNotReadedNotificationStatus(userAccount.getAccount());
-                log.debug("totalNewNot "+totalNewNot);
-                output.put("totalNot", totalNot);
-                output.put("totalNewNot", totalNewNot);
-                log.debug(totalNewNot + " NEW of "+totalNot+" total not");
+            final String username = getUserPrincipalUsername();
+            //log.debug("User get by getUserPrincipalUsername ---> " + getUserPrincipalUsername());
+            if(!username.isEmpty()) {
+                userAccount = getByUsername(username);
+                if (userAccount != null) {
+                    final Long totalNot = getNotificationDao().retrieveTotalNotificationStatus(userAccount.getAccount());
+                    log.debug("totalNot "+totalNot);
+                    final Long totalNewNot = getNotificationDao().retrieveTotalNotReadedNotificationStatus(userAccount.getAccount());
+                    log.debug("totalNewNot "+totalNewNot);
+                    output.put("totalNot", totalNot);
+                    output.put("totalNewNot", totalNewNot);
+                    log.debug(totalNewNot + " NEW of "+totalNot+" total not");
+                } else {
+                    output.put("totalNot", 0);
+                    output.put("totalNewNot", 0);
+                }
             } else {
-                output.put("totalNot", 0);
-                output.put("totalNewNot", 0);
+                throw new EnMeExpcetion("Auth object is not valid");
             }
-        } catch (EnMeNoResultsFoundException e) {
+        } catch (EnMeExpcetion e) {
              output.put("totalNot", 0);
              output.put("totalNewNot", 0);
              log.fatal("cometd: username invalid");
         }
-        remote.deliver(getServerSession(), message.getChannel(), output, null);
+        service.deliver(getServerSession(), message.getChannel(), output, null);
     }
 }

enme-mvc/src/main/java/org/encuestame/comet/services/TweetPollCometService.java

  */
 @Named
 @Singleton
-@Service("tweetPollCometService")
+//@Service("tweetPollCometService")
+@Deprecated
 public class TweetPollCometService extends AbstractCometService {
 
     /**

enme-persistence/enme-dao/src/main/java/org/encuestame/persistence/dao/imp/NotificationDao.java

      * @param secUser
      * @return
      */
-    public final Long retrieveTotalNotificationStatus(final Account secUser){
-        return retrieveCountNotification(secUser, "select count(*) from Notification "
-                +" WHERE account = :secUser");
+    public final Long retrieveTotalNotificationStatus(final Account secUser) {
+        return retrieveCountNotification(secUser, "select count(*) from Notification WHERE account = :secUser");
     }
 
     /**
      * @return
      */
     @SuppressWarnings("unchecked")
-    private Long retrieveCountNotification(final Account account, final String query){
+    private Long retrieveCountNotification(final Account account, final String query) {
         Long resultsSize = 0L;
         final List<Object> list =  getHibernateTemplate().findByNamedParam("select count(*) from Notification "
                 +" WHERE account =:user", "user", account);
-        if (list.get(0) instanceof Long){
+        if (list.get(0) instanceof Long) {
             resultsSize = (Long) list.get(0);
         }
         return resultsSize;
        <dependency>
             <groupId>org.cometd.java</groupId>
             <artifactId>bayeux-api</artifactId>
-        </dependency><!--
+        </dependency>
+        <dependency>
+            <groupId>org.cometd.java</groupId>
+            <artifactId>cometd-websocket-jetty</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.cometd.java</groupId>
+                    <artifactId>cometd-java-client</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <!--
         <dependency>
             <groupId>org.cometd.javascript</groupId>
             <artifactId>cometd-javascript-dojo</artifactId>

enme-war/src/main/resources/log4j.xml

         <level value="warn" />
     </logger>
 
+    <logger name="org.cometd">
+        <level value="warn" />
+    </logger>
+
     <!-- Root Logger -->
     <root>
         <priority value="warn" />

enme-war/src/main/webapp/WEB-INF/jsp/includes/javascript.jsp

     "dojo/_base/declare",
     "dojo/parser",
     "dojo/ready",
+    'me/activity/Activity',
     "me/core/enme",
-], function(declare, parser, ready, _ENME) {
+], function(declare, parser, ready, Activity, _ENME) {
     console.log("Initialize the ENME");
     ready(function(){
         // Call the parser manually so it runs after our widget is defined, and page has finished loading
             suggest_limit : 10,
             delay : 1800000,
             message_delay : 5000,
-            activity_levelDebug : "<%=EnMePlaceHolderConfigurer.getProperty("not.main.activity.levelDebug")%>",
-            activity_maxConnections : <%=EnMePlaceHolderConfigurer.getProperty("not.main.activity.maxConnections")%>,
-            activity_maxNetworkDelay : <%=EnMePlaceHolderConfigurer.getProperty("not.main.activity.maxNetworkDelay")%>,
-            notification_delay : <%=EnMePlaceHolderConfigurer.getProperty("not.main.delay")%>,
-            notification_limit : <%=EnMePlaceHolderConfigurer.getProperty("not.main.limit")%>,
+            activity : {
+                url : "<%=WidgetUtil.getDomain(request)%>/activity",
+                logLevel : "<%=EnMePlaceHolderConfigurer.getProperty("not.main.activity.levelDebug")%>",
+                maxConnections : <%=EnMePlaceHolderConfigurer.getProperty("not.main.activity.maxConnections")%>,
+                maxNetworkDelay : <%=EnMePlaceHolderConfigurer.getProperty("not.main.activity.maxNetworkDelay")%>,
+                delay : <%=EnMePlaceHolderConfigurer.getProperty("not.main.delay")%>,
+                limit : <%=EnMePlaceHolderConfigurer.getProperty("not.main.limit")%>
+            },
             tp_a : <%=EnMePlaceHolderConfigurer.getProperty("tp.min.answer.allowed")%>,
             tp_hr : <%=EnMePlaceHolderConfigurer.getProperty("tp.min.answer.hr")%>,
             tp_minsoa : <%=EnMePlaceHolderConfigurer.getProperty("tp.min.answer.minsoa")%>
         });
         //parse all widgets.
         parser.parse();
+        // initialize the activity support
+        var _E = _ENME.config('activity');
+        var  activity = new Activity(_E, Modernizr.websockets);
+        activity.connect();
+        _ENME.setActivity(activity);
     });
 });
 </script>

enme-war/src/main/webapp/WEB-INF/spring/encuestame-security-context.xml

         <security:intercept-url pattern="/user/signup/create" access="permitAll" />
         <security:intercept-url pattern="/user/confirm/**" access="permitAll" />
         <security:intercept-url pattern="/user/forgot/**" access="permitAll" />
-        <security:intercept-url pattern="/activity/**" access="hasRole('ENCUESTAME_USER')"  />
+        <security:intercept-url pattern="/activity/**" access="permitAll"  />
         <security:intercept-url pattern="/user/logout" access="hasRole('ENCUESTAME_USER')"  />
         <security:intercept-url pattern="/admon/**/*"  access="hasRole('ENCUESTAME_OWNER')" />
         <security:intercept-url pattern="/settings/**/*" access="hasRole('ENCUESTAME_USER')" />

enme-war/src/main/webapp/WEB-INF/web.xml

     <servlet>
         <servlet-name>cometd</servlet-name>
         <servlet-class>org.cometd.server.CometdServlet</servlet-class>
+        <init-param>
+            <param-name>transports</param-name>
+            <param-value>org.cometd.websocket.server.WebSocketTransport</param-value>
+        </init-param>
     </servlet>
     <servlet-mapping>
         <servlet-name>cometd</servlet-name>
         <error-code>500</error-code>
         <location>/500page.jsp</location>
     </error-page> -->
-    
+
 <!--     <error-page>
         <exception-type>java.lang.Exception</exception-type>
         <location>error.jsp</location>
     <welcome-file-list>
         <welcome-file>home</welcome-file>
     </welcome-file-list>
-    
+
     <session-config>
 		<session-timeout>180</session-timeout>
 	</session-config>

enme-war/src/main/webapp/resource/js/me/activity/Activity.js

-require(['dojo/dom', 'dojo/_base/unload', 'dojox/cometd', 'dojo/domReady!'],
-function(dom, unloader, cometd)
-{
-    function _connectionEstablished()
-    {
-        dom.byId('body').innerHTML += '<div>CometD Connection Established</div>';
-    }
+/*
+ * Copyright 2013 encuestame
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 
-    function _connectionBroken()
-    {
-        dom.byId('body').innerHTML += '<div>CometD Connection Broken</div>';
-    }
+/***
+ *  @author juanpicado19D0Tgm@ilDOTcom
+ *  @version 1.146
+ *  @module Activity
+ *  @namespace Notifications
+ *  @class Activity
+ */
 
-    function _connectionClosed()
-    {
-        dom.byId('body').innerHTML += '<div>CometD Connection Closed</div>';
-    }
+//require(["dojo/parser", "ready!"], function(AuthoredDialog, parser) {
+//    // Parse the page
+//    parser.parse();
+//
+//});
+define(["dojo",
+        "dojo/dom",
+        'dojo/_base/unload',
+        'dojox/cometd',
+         "me/core/enme",
+        'dojo/domReady!'], function(
+            dojo,
+            dom,
+            unloader,
+            cometd,
+            _ENME) {
 
-    // Function that manages the connection status with the Bayeux server
-    var _connected = false;
-    function _metaConnect(message)
-    {
-        if (cometd.isDisconnected())
-        {
-            _connected = false;
-            _connectionClosed();
-            return;
-        }
-
-        var wasConnected = _connected;
-        _connected = message.successful === true;
-        if (!wasConnected && _connected)
-        {
-            _connectionEstablished();
-        }
-        else if (wasConnected && !_connected)
-        {
-            _connectionBroken();
-        }
-    }
+        // Disconnect when the page unloads
+        unloader.addOnUnload(function() {
+            cometd.disconnect(true);
+        });
 
-    // Function invoked when first contacting the server and
-    // when the server has lost the state of this client
-    function _metaHandshake(handshake)
-    {
-        if (handshake.successful === true)
-        {
-            cometd.batch(function()
-            {
-                cometd.subscribe('/hello', function(message)
-                {
-                    dom.byId('body').innerHTML += '<div>Server Says: ' + message.data.greeting + '</div>';
-                });
-                // Publish on a service channel since the message is for the server only
-                cometd.publish('/service/hello', { name: 'World' });
+        /**
+         * Create a Activity Object
+         * @param _options a list of options to customize the connection with cometd server
+         * @param wekbsocketSupport enable the websocket support
+         * @constructor Activity
+         */
+        var Activity = function (_options, wekbsocketSupport) {
+            this.options = _options;
+            this.options.websocket = wekbsocketSupport || false;
+            this.cometd = cometd;
+            this._connected = false;
+        };
+
+
+        /**
+         * Connect
+         * @method
+         */
+        Activity.prototype.connect = function () {
+            var parent = this;
+            this.cometd.websocketEnabled = this.options.websocket;
+            this.cometd .configure({
+                    url: this.options.url,
+                    logLevel: this.options.logLevel,
+                    maxConnections : this.options.maxConnections,
+                    maxNetworkDelay : this.options.maxNetworkDelay
             });
-        }
+
+            /**
+             * Function that manages the connection status with the Bayeux server
+             * @method _metaConnect
+             */
+            var _metaConnect = function(message) {
+                // check if the cometd server is disconected
+                if (parent.cometd.isDisconnected()) {
+                    parent._connected = false;
+                    parent._connectionClosed();
+                    return;
+                }
+
+                var wasConnected = parent._connected;
+                parent._connected = message.successful === true;
+                if (!wasConnected && parent._connected) {
+                     parent._connectionEstablished();
+                } else if (wasConnected && !parent._connected) {
+                     parent._connectionBroken();
+                }
+            };
+
+
+            /**
+             * Function invoked when first contacting the server and when the server has lost the state of this client
+             * @method _metaHandshake
+             */
+            var _metaHandshake = function(handshake) {
+                console.warn("_metaHandshake =====");
+                if (handshake.successful === true)
+                {
+                    cometd.batch(function()
+                    {
+                        cometd.subscribe('/service/notification/status', function(message)
+                        {
+                           console.info("****************************** /service/notification/status", message);
+                        });
+                        // Publish on a service channel since the message is for the server only
+                        cometd.publish('/service/notification/status', { name: 'World' });
+                    });
+                }
+            };
+            this.cometd .addListener('/meta/handshake', _metaHandshake);
+            this.cometd .addListener('/meta/connect', _metaConnect);
+            this.cometd .handshake();
+        };
+
+        /**
+         * This method is triggered when the connection with cometd server re established
+         * @method _connectionEstablished
+         */
+        Activity.prototype._connectionEstablished = function () {
+                _ENME.log('CometD Connection Established');
+                dojo.publish('/activity/connection/established');
+        };
+
+        /**
+         * This method is triggered when the connection with cometd server is broken
+         * @method _connectionBroken
+         */
+        Activity.prototype._connectionBroken = function () {
+                _ENME.log('CometD Connection Broken');
+                dojo.publish('/activity/connection/broken');
+        };
+
+        /**
+         * This method is triggered when the connection with cometd server is closed
+         * @method _connectionClosed
+         */
+        Activity.prototype._connectionClosed = function() {
+                _ENME.log('<div>CometD Connection Closed');
+                dojo.publish('/activity/connection/closed');
+        };
+
+        return Activity;
     }
+);
+
 
-    // Disconnect when the page unloads
-    unloader.addOnUnload(function()
-    {
-        cometd.disconnect(true);
-    });
+// require(['dojo/dom', 'dojo/_base/unload', 'dojox/cometd', 'dojo/domReady!'], function(dom, unloader, cometd) {
 
-    var cometURL = location.protocol + "//" + location.host + config.contextPath + "/cometd";
-    cometd.configure({
-        url: cometURL,
-        logLevel: 'debug'
-    });
 
-    cometd.addListener('/meta/handshake', _metaHandshake);
-    cometd.addListener('/meta/connect', _metaConnect);
 
-    cometd.handshake();
-});
+// });
 
 
 ///*
Add a comment to this file

enme-war/src/main/webapp/resource/js/me/activity/ActivityJSON.js

Empty file added.

enme-war/src/main/webapp/resource/js/me/core/enme.js

     //Define if is initialize.
     var isInitialised = false,
 
+    activity = null,
+
     // to store the default configuration
     _config = {};
 
               selector: "date",
               datePattern: fmt
           });
+    },
+
+    /**
+     * Save the current activity object
+     * @param _activity the activity object
+     * @method  setActivity
+     */
+    setActivity : function(_activity) {
+      activity = _activity;
+    },
+
+    /**
+     * Get the current activity object
+     * @method  getActivity
+     */
+    getActivity : function () {
+       return activity;
     }
-    };
+  };
 });
 
 //	var ENME = (function() {

enme-war/src/main/webapp/resource/js/me/main.js

      * require just `dojo/domReady`, it would load that module just like any other module, without the special
      * plugin functionality.
      */
-    //'me/activity/Activity'
+    //
     require([
               'dojo',
               "dojo/dom",
+              "me/core/enme",
               "me/core/ui/Loading",
+              //'me/activity/Activity',
               "dojo/dom-construct"], function (
                       dojo,
                       dom,
+                      _ENME,
                       Loading,
+                      //Activity,
                       domConstruct) {
        var _dom = dom.byId('loading');
        if (_dom) {

enme-war/src/main/webapp/resource/js/me/web/widget/notifications/Notification.js

 dojo.require('dojox.timing');
 
 define([
+         "dojo",
          "dojo/_base/declare",
          "dijit/_WidgetBase",
          "dijit/_TemplatedMixin",
          "me/core/enme",
          "dojo/text!me/web/widget/notifications/template/notification.html" ],
         function(
+                dojo,
                 declare,
                 _WidgetBase,
                 _TemplatedMixin,
           *
           */
          postCreate: function() {
-             //load from cookie.
-             this._count.innerHTML = encuestame.session.activity.cookie().n;
-             //loadin notification subscription.
-             var subscriptionNotification;
-//             dojo.addOnLoad(dojo.hitch(this, function() {
-//                 this.loadStatus();
-//                 this.loadTimer();
-//             dojo.subscribe("/encuestame/notifications/update/status", this, "_updateStatus");
-//             subscriptionNotification  = encuestame.activity.cometd.subscribe('/service/notification/status',
-//                 dojo.hitch(this, function(message) {
-//                     this._updateStatus(message.data.totalNewNot, message.data.totalNot);
-//               }));
-//             }));
-//             dojo.addOnUnload(function() {
-//                 if (subscriptionNotification != null) {
-//                     encuestame.activity.cometd.unsubscribe(subscriptionNotification);
-//                 }
-//             });
-             this._originalTitle = document.title;
+             this.activity = _ENME.getActivity();
+             console.log("NOTIFICATION", this.activity.cometd);
+             var parent = this;
+
+             var jota = function () {
+                console.log("enviando jota /service/notification/status");
+                parent.activity.cometd.publish('/service/notification/status', { name: 'World' });
+             };
+
+              window.setInterval(jota, 20000);
+
+            //  load from cookie.
+            //  this._count.innerHTML = encuestame.session.activity.cookie().n;
+            //  //loadin notification subscription.
+            //  var subscriptionNotification;
+             dojo.addOnLoad(dojo.hitch(this, function() {
+                  //this.loadStatus();
+                  //this.loadTimer();
+                  dojo.subscribe("/encuestame/notifications/update/status", this, "_updateStatus");
+                  subscriptionNotification  = parent.activity.cometd.subscribe('/service/notification/status',
+                      dojo.hitch(this, function(message) {
+                          this._updateStatus(message.data.totalNewNot, message.data.totalNot);
+                  }));
+              }));
+              dojo.addOnUnload(function() {
+                if (subscriptionNotification !== null) {
+                    parent.activity.cometd.unsubscribe(subscriptionNotification);
+                }
+            });
+            this._originalTitle = document.title;
          },
 
          /*
     <version>1.146-SNAPSHOT</version>
     <name>encuestame</name>
     <description>
-     Encuestame is an open source project based on Java 6 technology. You can use to create different 
-     types of surveys. Encuestame provides a full featured Survey Managed System. 
-     It's integrated with the most popular social networks (Facebook, Twitter, etc) and 
+     Encuestame is an open source project based on Java 6 technology. You can use to create different
+     types of surveys. Encuestame provides a full featured Survey Managed System.
+     It's integrated with the most popular social networks (Facebook, Twitter, etc) and
      the capable to distribute your content with diferent ways.
   </description>
     <url>http://www.encuestame.org</url>
         <!-- encuestame version -->
         <encuestame.version>${project.version}</encuestame.version>
         <!-- Spring Version <spring.version>3.1.0.BUILD-SNAPSHOT</spring.version> -->
-        <spring.version>3.1.1.RELEASE</spring.version>
+        <spring.version>3.1.3.RELEASE</spring.version>
         <env>development</env>
         <javascript.minimize>false</javascript.minimize>
-        <spring.webflow.version>2.3.0.RELEASE</spring.webflow.version>
-        <spring.security.version>3.1.0.RELEASE</spring.security.version>
+        <spring.webflow.version>2.3.1.RELEASE</spring.webflow.version>
+        <spring.security.version>3.1.3.RELEASE</spring.security.version>
         <!-- 3.1.0.CI-SNAPSHOT once compatible with OAuth -->
         <spring-integration-core>2.1.0.RELEASE</spring-integration-core>
         <spring-oauth.version>1.0.0.M6</spring-oauth.version>
         <!-- Site Path -->
         <apache>file:///var/www/encuestame</apache>
         <!-- Jetty -->
-        <jetty.default.port>8080</jetty.default.port>
+        <jetty.default.port>8084</jetty.default.port>
         <jetty.default.ssl.port>8443</jetty.default.ssl.port>
         <!-- -->
         <taglibs.version>1.1.2</taglibs.version>
         <dojo.version>1.6.1</dojo.version>
         <webresources.javascript.location>encuestame-war/src/main/webapp/js</webresources.javascript.location>
         <!--CometD -->
-        <comet.version>2.5.0</comet.version>
+        <comet.version>2.5.1</comet.version>
         <!-- Plugin Version -->
         <surefire.version>2.12.4</surefire.version>
-        <!-- 
-        	Clover 2 Needed install on local host 
+        <!--
+        	Clover 2 Needed install on local host
         	http://confluence.atlassian.com/display/CLOVER/Clover+for+Maven+2+and+3+Developer+Guide
         -->
         <maven-clover2-plugin>3.0.5</maven-clover2-plugin>
         <taglist-maven-plugin>2.4</taglist-maven-plugin>
         <maven-checkstyle-plugin>2.5</maven-checkstyle-plugin>
         <site.version>2.3</site.version>
-        <jetty7.version>7.2.2.v20101205</jetty7.version>
+        <jetty7.version>7.6.8.v20121106</jetty7.version>
         <jetty-plugin-version>${jetty7.version}</jetty-plugin-version>
         <jetty.ssl>7.0.0.pre5</jetty.ssl>
         <keytool.maven.plugin>1.0</keytool.maven.plugin>
         <dojo.version>1.8.0</dojo.version>
     </properties>
 
-    <modules>            
+    <modules>
         <module>enme-css</module>
-        <module>enme-js</module>        
+        <module>enme-js</module>
         <module>enme-utils</module>
         <module>enme-core</module>
         <module>enme-social</module>
         <module>enme-oauth</module>
         <module>enme-persistence</module>
         <module>enme-business</module>
-        <module>enme-mvc</module>                    
+        <module>enme-mvc</module>
         <module>enme-war</module>
     </modules>
 
                     <artifactId>maven-surefire-plugin</artifactId>
                     <configuration>
                         <testFailureIgnore>${surefire.failures.ignore}</testFailureIgnore>
-                        <argLine>-Xmx1024m</argLine> 
+                        <argLine>-Xmx1024m</argLine>
                         <groups>org.encuestame.utils.categories.test.DefaultTest</groups>
                     </configuration>
                     <version>${surefire.version}</version>
                 <artifactId>enme-model</artifactId>
                 <version>${encuestame.version}</version>
                 <type>jar</type>
-            </dependency> 
+            </dependency>
             <dependency>
                 <groupId>org.encuestame</groupId>
                 <artifactId>enme-dao</artifactId>
                 <version>${encuestame.version}</version>
                 <type>jar</type>
-            </dependency>             
+            </dependency>
             <dependency> <!-- reuse src/test/java code from encuestame-core! -->
                 <groupId>org.encuestame</groupId>
                 <artifactId>enme-dao</artifactId>
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-orm</artifactId>
-                <version>${spring.orm}</version>
+                <version>${spring.version}</version>
             </dependency>
             <dependency>
                 <groupId>commons-httpclient</groupId>
                 <artifactId>cometd-java-annotations</artifactId>
                 <version>${comet.version}</version>
             </dependency>
+             <dependency>
+            <groupId>org.cometd.java</groupId>
+            <artifactId>cometd-websocket-jetty</artifactId>
+            <version>${comet.version}</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.cometd.java</groupId>
+                    <artifactId>cometd-java-client</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
             <dependency>
                 <groupId>org.cometd.java</groupId>
                 <artifactId>cometd-java-oort</artifactId>
 				<groupId>net.sf.opencsv</groupId>
 				<artifactId>opencsv</artifactId>
 				<version>${opencsv.version}</version>
-			</dependency>            
+			</dependency>
        <!-- <dependency>
                 <groupId>org.apache.cactus</groupId>
                 <artifactId>cactus.core.framework</artifactId>
                 <artifactId>dojo-war</artifactId>
                 <version>${dojo.version}</version>
                 <type>war</type>
-            </dependency>            
+            </dependency>
         </dependencies>
     </dependencyManagement>
 </project>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.