Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.XmlBlasterException


         if (actionType.equals("login") || actionType.equals("connect")) {
            ConnectQos connectQos;
            if (actionType.equals("connect")) {
               String qos = Util.getParameter(req, "xmlBlaster.connectQos", null);
               if (qos == null || qos.length() < 1)
                  throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME, "Missing connect QoS. Pass xmlBlaster.connectQos='<qos> ... </qos>' with your URL in your POST in a hidden form field or in your cookie.");
               connectQos = new ConnectQos(glob, glob.getConnectQosFactory().readObject(qos));
            }
            else {
               String loginName = Util.getParameter(req, "xmlBlaster.loginName", null);    // "Joe";
               if (loginName == null || loginName.length() < 1)
                  throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME, "Missing login name. Pass xmlBlaster.loginName=xy with your URL or in your cookie.");
               String passwd = Util.getParameter(req, "xmlBlaster.passwd", null)// "secret";
               if (passwd == null || passwd.length() < 1)
                  throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME, "Missing passwd");
               connectQos = new ConnectQos(glob, loginName, passwd);
            }

            ME  = "BlasterHttpProxyServlet-" + req.getRemoteAddr() + "-" +
                  connectQos.getSessionName().getLoginName() + "-" + sessionId;

            I_XmlBlasterAccess xmlBlasterAccess = glob.getXmlBlasterAccess();
            HttpPushHandler pushHandler = new HttpPushHandler(req, res, sessionId,
                                                     connectQos.getSessionName().getRelativeName(),
                                                     xmlBlasterAccess);

            xmlBlasterAccess.connect(connectQos, pushHandler);
            if (!session.isNew()) {
               pushHandler.startPing();
            }
            else {
               log.info("Login action, browser has not yet joined this sessionId (cookie), so first pings pong may return an invalid sessionId");
               pushHandler.startPing(); // This is too early here, we need to start the ping thread later?
            }

            BlasterHttpProxy.addHttpPushHandler( sessionId, pushHandler );

            // Don't fall out of doGet() to keep the HTTP connection open
            log.info("Waiting forever, permanent HTTP connection from " +
                           req.getRemoteHost() + "/" + req.getRemoteAddr() +
                           ", sessionName=" + connectQos.getSessionName().getRelativeName() + " sessionId=" + sessionId +
                           "', protocol='" + req.getProtocol() +
                           "', agent='" + req.getHeader("User-Agent") +
                           "', referer='" + req.getHeader("Referer") +
                           "'.");

            if (log.isLoggable(Level.FINE)) log.fine("user='" + req.getRemoteUser() +
            "', serverPort='" + req.getServerPort() +
            "', query='" + req.getQueryString() +
            "', pathInfo='" + req.getPathInfo() +
            "', pathTranslated='" + req.getPathTranslated() +
            "', servletPath='" + req.getServletPath() +
            "', documentRoot='" + getServletConfig().getServletContext().getRealPath("/") +
            "', accept='" + req.getHeader("Accept") +
            "', referer='" + req.getHeader("Referer") +
            "', authorization='" + req.getHeader("Authorization") +
            "'.");

            pushHandler.setBrowserIsReady( true );
            pushHandler.ping("loginSucceeded");

            while (!pushHandler.closed()) {
               try {
                  Thread.sleep(10000L);
               }
               catch (InterruptedException i) {
                  log.severe("Error in Thread handling, don't know what to do: "+i.toString());
                  pushHandler.cleanup();
                  break;
               }
            }
            pushHandler = null;
            log.info("Persistent HTTP connection lost, leaving doGet() ....");
            /*
            System.out.println("Currently consumed threads:");
            System.out.println("===========================");
            ThreadLister.listAllThreads(System.out);
            */
         }


         //------------------ first request from applet --------------------------
         else if(actionType.equals("dummyToCreateASessionId")) {  // I_XmlBlasterAccessRaw.CREATE_SESSIONID_NAME
            log.info("doGet: dummyToCreateASessionId");
            PrintWriter out = res.getWriter();
            out.println(header+"<body text='white' bgcolor='white'>Empty response for your ActionType='dummyToCreateASessionId' " +
                        System.currentTimeMillis() + "</body></html>");
            return;
         }
         //------------------ ready, browser processed last message --------------------------
         // The HttpPushHandler adds javascript 'parent.browserReady();' which
         // is invoked after the browser is ready.
         else if(actionType.equals("browserReady")) {
            try {
               HttpPushHandler pushHandler = BlasterHttpProxy.getHttpPushHandler(sessionId);
               if (log.isLoggable(Level.FINE)) log.fine("Received 'browserReady'");
               pushHandler.setBrowserIsReady( true );

               // Otherwise the browser (controlFrame) complains 'document contained no data'
               PrintWriter out = res.getWriter();
               out.println(header+"<body text='white' bgcolor='white'>Empty response for your ActionType='browserReady' " + System.currentTimeMillis() + "</body></html>");
               return;
            }
            catch (XmlBlasterException e) {
               log.severe("Caught XmlBlaster Exception for actionType '" + actionType + "': " + e.getMessage());
               return;
            }
         }
         //------------------ answer of a ping -----------------------------------------------
         // The HttpPushHandler adds javascript 'parent.ping();' which
         // pings the browser to hold the http connection.
         // The browser responses with 'pong', to allow the servlet to
         // detect if the browser is alive.
         // Locally this works fine, but over the internet the second or third pong from the browser
         // was never reaching this servlet. Adding some dynamic content/URL helped a bit,
         // but after some ten pongs, the following pongs where lost.
         // The browserReady request hasn't got this problem, why??
         // So we do a pong on browserReady as well, which solved the problem (see HttpPushHandler.java)
         else if(actionType.equals("pong")) {
            try {
               HttpPushHandler pushHandler = BlasterHttpProxy.getHttpPushHandler(sessionId);
               pushHandler.pong();

               // state is only for debugging and to avoid internet proxies to discard this content (since it has not changed)
               if (log.isLoggable(Level.FINE)) log.fine("Received pong '" + Util.getParameter(req, "state", "noState") + "'");

               // Otherwise the browser (controlFrame) complains 'document contained no data'
               PrintWriter out = res.getWriter();
               out.println(header+"<body text='white' bgcolor='white'>Empty response for your ActionType='pong' " + Util.getParameter(req, "state", "noState") + " " + System.currentTimeMillis() + "</body></html>");
               return;
            }
            catch (XmlBlasterException e) {
               log.severe("Caught XmlBlaster Exception for actionType '" + actionType + "': " + e.getMessage());
               return;
            }
         }

         else if (MethodName.PUBLISH.toString().equalsIgnoreCase(actionType)) { // "publish"
            doPost(req, res);
         }
         else if (MethodName.SUBSCRIBE.toString().equalsIgnoreCase(actionType)) { // "subscribe"
            doPost(req, res);
         }
         else if (MethodName.UNSUBSCRIBE.toString().equalsIgnoreCase(actionType)) { // "unSubscribe"
            doPost(req, res);
         }
         else if (MethodName.GET.toString().equalsIgnoreCase(actionType)) { // "get"
            doPost(req, res);
         }
         else if (MethodName.ERASE.toString().equalsIgnoreCase(actionType)) { // "erase"
            doPost(req, res);
         }
         else if (MethodName.PING.toString().equalsIgnoreCase(actionType)) { // "ping"
            doPost(req, res);
         }

         //------------------ logout ---------------------------------------------------------
         else if (actionType.equals("logout")) {
            log.info("Logout arrived ...");
            try {
               HttpPushHandler pc = BlasterHttpProxy.getHttpPushHandler(sessionId);
               pc.cleanup();
            } catch(XmlBlasterException e) {
               log.severe(e.toString());
            }

            // Otherwise the browser (controlFrame) complains 'document contained no data'
            PrintWriter out = res.getWriter();
            out.println(header+" <body text='white' bgcolor='white'><script language='JavaScript' type='text/javascript'>top.close()</script></body></html>");
         }

         else {
            String text = "Unknown ActionType '" + actionType + "', request for permanent http connection ignored";
            throw new XmlBlasterException(glob, ErrorCode.USER_CONFIGURATION, ME, text);
         }


      } catch (XmlBlasterException e) {
         log.severe("Caught XmlBlaster Exception: " + e.getMessage());
View Full Code Here


      if (this.clusterManager == null) {
         if (!useCluster())
            return null;
         log.severe("Internal problem: please intialize ClusterManager first");
         Thread.dumpStack();
         throw new XmlBlasterException(this, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Internal problem: please intialize ClusterManager first - Please ask on mailing list for support");
      }
      return this.clusterManager;
   }
View Full Code Here

      if (this.commandManager == null) {
         if (!useAdminManager())
            return null;
         log.severe("Internal problem: please intialize CommandManager first");
         Thread.dumpStack();
         throw new XmlBlasterException(this, ErrorCode.INTERNAL_UNKNOWN, ME, "please intialize CommandManager first - Please ask on mailing list for support");
      }
      return this.commandManager;
   }
View Full Code Here

    */
   public final String[] sendUpdate(MsgUnitRaw[] msgArr) throws XmlBlasterException
   {
      try {
         if (msgArr == null || msgArr.length < 1)
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Illegal sendUpdate() argument");

         String id ="JdbcDriver-"+glob.getId();
         JdbcDriver driver = (JdbcDriver)glob.getObjectEntry(id);
         if (driver == null) {
            log.severe("Can't find JdbcDriver instance");
            Thread.currentThread().dumpStack();
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "Internal error, can't find JdbcDriver instance '" + id + "'");
         }
         for (int ii=0; ii<msgArr.length; ii++) {
            MsgQosData msgQosData = (MsgQosData)((MsgUnit)msgArr[ii].getMsgUnit()).getQosData();
            driver.update(msgQosData.getSender().getAbsoluteName(), msgArr[ii].getContent());
         }
         String[] ret = new String[msgArr.length];
         for (int ii=0; ii<ret.length; ii++)
            ret[ii] = Constants.RET_OK;
         return ret;
      }
      catch (XmlBlasterException xmlBlasterException) {

         // WE ONLY ACCEPT ErrorCode.USER... FROM CLIENTS !
         if (xmlBlasterException.isUser())
            throw xmlBlasterException;

         throw new XmlBlasterException(glob, ErrorCode.USER_UPDATE_ERROR, ME,
                   "JDBC processing problem", xmlBlasterException);
      }
      catch (Throwable throwable) {
         throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME,
                   "Internal JDBC processing problem", throwable);
      }
   }
View Full Code Here

    * @exception XmlBlasterException Is never from the client (oneway).
    */
   public void sendUpdateOneway(MsgUnitRaw[] msgArr) throws XmlBlasterException
   {
      if (msgArr == null || msgArr.length < 1)
         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Illegal sendUpdateOneway() argument");

      String id = "JdbcDriver-"+glob.getId();
      JdbcDriver driver = (JdbcDriver)glob.getObjectEntry(id);
      if (driver == null) {
         log.severe("Can't find JdbcDriver instance");
         Thread.currentThread().dumpStack();
         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "Internal error, can't find JdbcDriver instance '" + id + "'");
      }
      for (int ii=0; ii<msgArr.length; ii++) {
         try {
            MsgQosData msgQosData = (MsgQosData)((MsgUnit)msgArr[ii].getMsgUnit()).getQosData();
            driver.update(msgQosData.getSender().getAbsoluteName(), msgArr[ii].getContent());
         } catch (Throwable e) {
            throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME,
               "JDBC Callback of " + ii + "th message to client [" + callbackAddress.getSecretSessionId() + "] failed.", e);
         }
      }
   }
View Full Code Here

         return this.callback;
      synchronized (this) {
         if (this.callback != null)
            return this.callback;
         if (this.callbackAddress == null)
            throw new XmlBlasterException(this.glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "getCallback");
         org.xmlBlaster.engine.ServerScope
            engineGlob = (org.xmlBlaster.engine.ServerScope)this.glob.getObjectEntry(Constants.OBJECT_ENTRY_ServerScope);
         if (engineGlob == null)
            throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".init", "could not retreive the ServerNodeScope. Am I really on the server side ?");
         // "LOCAL:29653342" added by LocalCallbackImpl.initialize()
         // "LOCAL:"+localCallbackImpl.hashCode();
         String raw = getRawAddress();
         this.callback = (I_CallbackExtended) engineGlob.getObjectEntry(raw);
         if (this.callback == null)
            throw new XmlBlasterException(this.glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, "getCallback lookup of '" + getRawAddress() + "' failed");
         return this.callback;
      }
   }
View Full Code Here

    * This sends the update to the client.
    * @exception Exceptions thrown from client are re thrown as ErrorCode.USER*
    */
   public final String[] sendUpdate(MsgUnitRaw[] msgArr) throws XmlBlasterException {
      if (msgArr == null || msgArr.length < 1)
         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Illegal sendUpdate() argument");
      if (log.isLoggable(Level.FINE))
         log.fine("xmlBlaster.update() to " + callbackAddress.getSecretSessionId());
     
      try {
         return getCallback().update(callbackAddress.getSecretSessionId(), msgArr);
View Full Code Here

    * @exception XmlBlasterException Is never from the client (oneway).
    */
   public void sendUpdateOneway(MsgUnitRaw[] msgArr) throws XmlBlasterException
   {
      if (msgArr == null || msgArr.length < 1)
         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Illegal sendUpdateOneway() argument");
     
      if (log.isLoggable(Level.FINE)) log.fine("xmlBlaster.updateOneway() to " + callbackAddress.getSecretSessionId());
     
      try {
         getCallback().updateOneway(callbackAddress.getSecretSessionId(), msgArr);
      }
      catch (XmlBlasterException e) {
         throw XmlBlasterException.tranformCallbackException(e);
      }
      catch (Throwable e) {
         throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME,
               "Local oneway callback of message to client [" + callbackAddress.getSecretSessionId() + "] failed", e);
      }
   }
View Full Code Here

      UnnamedConnectionPool pool = getPool(dbUrl, dbUser, dbPasswd);
      if (pool == null) { // check before as well to increase performance
         synchronized(meetingPoint) {
            pool = getPool(dbUrl, dbUser, dbPasswd);
            if (pool == null) {
               if (dbPasswd == null) throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION, ME+".MissingPasswd", "Please give a password for '" + dbUser + "' when creating a JDBC pool");
               pool = new UnnamedConnectionPool(this, dbUrl, dbUser, dbPasswd, eraseUnusedPoolTimeout, maxInstances, busyToIdle, idleToErase);
               namedPools.put(getKey(dbUrl, dbUser, dbPasswd), pool);
            }
         }
      }
      try {
         Connection con = pool.reserve();
         if (log.isLoggable(Level.FINE)) log.fine("reserve(" + dbUrl + ", " + dbUser + ") con=" + con);
         return con;
      }
      catch(XmlBlasterException e) {
         throw e;
      }
      catch(Throwable e) {
         log.severe("Unexpected exception in connect(" + dbUrl + ", " + dbUser + "): " + e.toString());
         throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION, ME+".NoOpen", "Couldn't open database connection: " + e.toString());
      }
   }
View Full Code Here

            pool.destroy();
         if (log.isLoggable(Level.FINE)) log.fine("All JDBC connections for '" + dbUrl + "' destroyed");
      }
      catch (Exception e) {
         log.severe("System Exception in destroy JDBC connection for '" + dbUrl + "': " + e.toString());
         throw new XmlBlasterException(glob, ErrorCode.RESOURCE_DB_UNKNOWN, ME+".DestroyError", "System Exception in destroy JDBC connection for '" + dbUrl + "': " + e.toString());
      }
   }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.XmlBlasterException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.