Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.XmlBlasterException


      this.pluginInfo = pluginInfo;
      this.glob = glob;
      this.ME = getType();
      org.xmlBlaster.engine.ServerScope engineGlob = (org.xmlBlaster.engine.ServerScope)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 ?");

      // For JMX instanceName may not contain ","
      String vers = ("1.0".equals(getVersion())) ? "" : getVersion();
      this.contextNode = new ContextNode(ContextNode.SERVICE_MARKER_TAG,
            "SocketDriver[" + getType() + vers + "]", glob.getContextNode());
      this.mbeanHandle = this.glob.registerMBean(this.contextNode, this);

      try {
         this.authenticate = engineGlob.getAuthenticate();
         if (this.authenticate == null) {
            throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".init", "authenticate object is null");
         }
         I_XmlBlaster xmlBlasterImpl = this.authenticate.getXmlBlaster();
         if (xmlBlasterImpl == null) {
            throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".init", "xmlBlasterImpl object is null");
         }

         init(glob, new AddressServer(glob, getType(), glob.getId(), pluginInfo.getParameters()), this.authenticate, xmlBlasterImpl);

         this.useUdpForOneway = this.addressServer.getEnv("useUdpForOneway", this.useUdpForOneway).getValue();
         this.startUdpListener = this.addressServer.getEnv("startUdpListener", this.startUdpListener).getValue();

         // Now we have logging ...
         if (log.isLoggable(Level.FINE)) log.fine("Using pluginInfo=" + this.pluginInfo.toString() + ", startUdpListener=" + this.startUdpListener + ", useUdpForOneway=" + this.useUdpForOneway);

         activate();
      }
      catch (XmlBlasterException ex) {
         throw ex;
      }
      catch (Throwable ex) {
         throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".init", "init. Could'nt initialize the driver.", ex);
      }
   }
View Full Code Here



   protected void connect(String ME, Logger log, HttpSession session, String qos, HttpServletRequest req, HttpServletResponse res)
      throws XmlBlasterException, IOException, ServletException {
      if (qos == null || qos.length() < 1)
         throw new XmlBlasterException(this.initialGlobal, 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.");

      Global glob = this.initialGlobal.getClone(null);
      ConnectQos connectQos;
      boolean warnAuth = false;
      if (qos.toLowerCase().indexOf("securityservice") >= 0) {
View Full Code Here

      if (log.isLoggable(Level.FINER)) log.finer("Entering doGet() ... " + Global.getMemoryStatistic());

      if (actionType.equalsIgnoreCase("NONE")) {
         String str = "Please call servlet with some ActionType";
         log.severe(str);
         XmlBlasterException x = new XmlBlasterException(this.initialGlobal, ErrorCode.USER_CONFIGURATION, ME, str);
         writeResponse(res, I_XmlBlasterAccessRaw.EXCEPTION_NAME, x.getMessage());
         return;
      }

      // for logging only:
      HttpSession oldSession = req.getSession(false);
      String oldSessionId = (oldSession == null) ? "no-session-id" : oldSession.getId();

      HttpSession session = req.getSession(true);
      if (actionType.equals(I_XmlBlasterAccessRaw.CREATE_SESSIONID_NAME) || // Initial dummy request to create a http-sessionId and bounce it back to the applet/browser
          actionType.equals(I_XmlBlasterAccessRaw.CONNECT_NAME)) { // "connect" TODO: !!! Reconnect to old session
         boolean invalidate = getParameter(req, "xmlBlaster/invalidate", false);
         if (invalidate == true) {
            log.info("Entering servlet doGet("+I_XmlBlasterAccessRaw.CONNECT_NAME+"), forcing a new sessionId");
            session.invalidate();   // force a new sessionId
         }
         session = req.getSession(true);
      }
     
      String sessionId = session.getId();

      ME += "-" + sessionId;
      if (log.isLoggable(Level.FINE)) log.fine("Entering servlet doGet(oldSessionId="+oldSessionId+") ...");

      if (false) {
         // HttpServletResponse.addCookie(javax.servlet.http.Cookie)
         javax.servlet.http.Cookie[] cookies = req.getCookies();
         if (cookies != null) {
            for (int i=0; i<cookies.length; i++) {
               log.info("Receiving cookie name=" + cookies[i].getName() + ", domain=" + cookies[i].getDomain() + ", path=" + cookies[i].getPath());
            }
         }
      }

      if (sessionId == null) {
         String str = "Sorry, your sessionId is invalid";
         //XmlBlasterException x = new XmlBlasterException(this.initialGlobal, ErrorCode.USER_CONFIGURATION, ME, str);
         writeResponse(res, I_XmlBlasterAccessRaw.EXCEPTION_NAME, str);
         return;
      }

      try {
         if (actionType.equals(I_XmlBlasterAccessRaw.CONNECT_NAME)) {
            // Here we NEVER return to hold the persistent http connection for callbacks to the applet
            String qos = getParameter(req, "xmlBlaster.connectQos", (String)null);
            // if the binary protocol is used ...
            if (msgHolder != null) qos = msgHolder.getQos();
            connect(ME, log, session, qos, req, res);
         }
         else if (actionType.equals(I_XmlBlasterAccessRaw.CREATE_SESSIONID_NAME)) {
            //------------------ first request from applet --------------------------
            if (log.isLoggable(Level.FINE)) log.fine("doGet: dummyToCreateASessionId");
            writeResponse(res, I_XmlBlasterAccessRaw.CREATE_SESSIONID_NAME, "OK-"+System.currentTimeMillis());
            return;
         }
         else if (actionType.equals(I_XmlBlasterAccessRaw.PONG_NAME)){
            //------------------ answer of a ping -----------------------------------------------
            // The PushHandler adds 'ping' which
            // pings the applet to hold the http connection.
            // The applet responses with 'pong', to allow the servlet to
            // detect if the applet is alive.
            try {
               PushHandler pushHandler = getPushHandler(req);
               pushHandler.pong();
               if (log.isLoggable(Level.FINE)) log.fine("Received pong");
               writeResponse(res, I_XmlBlasterAccessRaw.PONG_NAME, "OK-"+System.currentTimeMillis());
               return;
            }
            catch (XmlBlasterException e) {
               log.severe("Caught XmlBlaster Exception for actionType '" + actionType + "': " + e.getMessage());
               return;
            }
         }
         else if (actionType.equals(I_XmlBlasterAccessRaw.DISCONNECT_NAME)) { // "disconnect"
            log.info("Logout arrived ...");
            try {
               PushHandler pc = getPushHandler(req);
               pc.cleanup();
            } catch(XmlBlasterException e) {
               log.severe(e.toString());
            }
            writeResponse(res, I_XmlBlasterAccessRaw.DISCONNECT_NAME, "<qos/>");
         }
         else {
            String text = "Unknown ActionType '" + actionType + "', request for permanent http connection ignored";
            throw new XmlBlasterException(this.initialGlobal, ErrorCode.USER_CONFIGURATION, ME, text);
         }
      } catch (XmlBlasterException e) {
         log.warning("Caught XmlBlaster Exception: " + e.getMessage());
         writeResponse(res, I_XmlBlasterAccessRaw.EXCEPTION_NAME, e.getMessage());
      } catch (Exception e) {
View Full Code Here

               if (log.isLoggable(Level.FINE)) log.fine("Subscribed to " + key + ": SubscriptionId=" + ret.getSubscriptionId() + " qos=" + qos + " returnObject=" + returnObject.getClass().getName());
            }
            else {
               String str = "Please call servlet with some 'key.oid=...' or 'key=<key ...' when subscribing";
               log.warning(str);
               throw new XmlBlasterException(this.initialGlobal, ErrorCode.USER_CONFIGURATION, ME, str);
            }
         }

         else if (actionType.equals(I_XmlBlasterAccessRaw.UNSUBSCRIBE_NAME)) { // "unSubscribe"
            if (log.isLoggable(Level.FINE)) log.fine("unSubscribe arrived ...");
            UnSubscribeReturnQos[] ret;

            if (oid != null) {
               UnSubscribeKey xmlKey = new UnSubscribeKey(glob, oid);
               ret = xmlBlaster.unSubscribe(xmlKey.toXml(), qos);
            }
            else if (key != null) {
               ret = xmlBlaster.unSubscribe(key, qos);
            }
            else {
               String str = "Please call servlet with some 'key.oid=...' or 'key=<key ...' when unsubscribing";
               log.warning(str);
               throw new XmlBlasterException(this.initialGlobal, ErrorCode.USER_CONFIGURATION, ME, str);
            }
            Vector arr = new Vector();
            for (int ii=0; ii<ret.length; ii++) {
               arr.add(ret[ii].getData().toJXPath());
               if (log.isLoggable(Level.FINE)) log.fine("UnSubscribed " + ret[ii].getSubscriptionId());
            }
            returnObject = (Hashtable[])arr.toArray(new Hashtable[arr.size()]);
         }

         else if (actionType.equals(I_XmlBlasterAccessRaw.GET_NAME)) { // "get"
            if (log.isLoggable(Level.FINE)) log.fine("get arrived ...");
            MsgUnit[] msgUnitArr = xmlBlaster.get(key, qos);
            Vector list = new Vector(msgUnitArr.length*3);
            for (int i=0; i<msgUnitArr.length; i++) {
               list.add(((MsgQosData)msgUnitArr[i].getQosData()).toJXPath());
               list.add(((MsgKeyData)msgUnitArr[i].getKeyData()).toJXPath());
               list.add(msgUnitArr[i].getContent());
            }
            returnObject = list;
         }

         else if (actionType.equals(I_XmlBlasterAccessRaw.PUBLISH_NAME)) { // "publish"
            if (log.isLoggable(Level.FINE)) log.fine("publish arrived ...");
            if (key == null) {
               String str = "Please call servlet with some key when publishing";
               log.warning(str);
               XmlBlasterException x = new XmlBlasterException(this.initialGlobal, ErrorCode.USER_ILLEGALARGUMENT, ME, str);
               writeResponse(res, I_XmlBlasterAccessRaw.EXCEPTION_NAME, x.getMessage());
               return;
            }
            if (log.isLoggable(Level.FINE)) log.fine("Publishing '" + key + "'");
            MsgUnit msgUnit = new MsgUnit(glob, key, content, qos);
            try {
               PublishReturnQos prq = xmlBlaster.publish(msgUnit);
               returnObject = prq.getData().toJXPath();
               if (log.isLoggable(Level.FINE)) log.fine("Success: Publishing done, returned oid=" + prq.getKeyOid());
            } catch(XmlBlasterException e) {
               log.warning("XmlBlasterException: " + e.getMessage());
            }
         }

         else if (actionType.equals(I_XmlBlasterAccessRaw.ERASE_NAME)) { // "erase"
            if (log.isLoggable(Level.FINE)) log.fine("erase arrived ...");
            EraseReturnQos[] ret;

            if (oid != null) {
               EraseKey ek = new EraseKey(glob, oid);
               ret = xmlBlaster.erase(ek.toXml(), qos);
            }
            else if (key != null) {
               ret = xmlBlaster.erase(key, qos);
            }
            else {
               String str = "Please call servlet with some 'key.oid=...' or 'key=<key ...' when subscribing";
               log.warning(str);
               throw new XmlBlasterException(this.initialGlobal, ErrorCode.USER_CONFIGURATION, ME, str);
            }
            Vector arr = new Vector();
            for (int ii=0; ii<ret.length; ii++) {
               arr.add(ret[ii].getData().toJXPath());
               if (log.isLoggable(Level.FINE)) log.fine("Erased " + ret[ii].getKeyOid());
            }
            returnObject = (Hashtable[])arr.toArray(new Hashtable[arr.size()]);
         }

         // TODO: not yet tested
         else if (actionType.equals("xmlScript")) {
            // Send xml encoded requests to the xmlBlaster server.
            // http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.script.html
            java.io.Reader reader = new java.io.StringReader(xmlRequest);
            java.io.OutputStream outStream = new java.io.ByteArrayOutputStream();
            XmlScriptClient interpreter =
                new XmlScriptClient(glob, xmlBlaster, pushHandler, null, outStream);
            interpreter.parse(reader);
            returnObject = outStream.toString();
         }

         else {
            String str = "Unknown or missing 'ActionType=" + actionType + "' please choose 'subscribe' 'unSubscribe' 'erase' etc.";
            log.warning(str);
            throw new XmlBlasterException(this.initialGlobal, ErrorCode.USER_CONFIGURATION, ME, str);
         }

         writeResponse(res, actionType, returnObject);
      } catch (XmlBlasterException e) {
         log.warning("Caught XmlBlaster Exception: " + e.getMessage());
View Full Code Here

      throws XmlBlasterException {
      this.pluginInfo = pluginInfo;
      this.glob = glob;
      org.xmlBlaster.engine.ServerScope engineGlob = (org.xmlBlaster.engine.ServerScope)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 ?");

      // For JMX instanceName may not contain ","
      super.contextNode = new ContextNode(ContextNode.SERVICE_MARKER_TAG,
            "EmailDriver[" + getType() + "]",
            glob.getContextNode());
      super.mbeanHandle = this.glob.registerMBean(super.contextNode, this);
     
      engineGlob.getRequestBroker().getAuthenticate(null).addClientListener(this);

      try {
         this.authenticate = engineGlob.getAuthenticate();
         if (this.authenticate == null) {
            throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".init", "authenticate object is null");
         }
         I_XmlBlaster xmlBlasterImpl = this.authenticate.getXmlBlaster();
         if (xmlBlasterImpl == null) {
            throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".init", "xmlBlasterImpl object is null");
         }

         init(glob, new AddressServer(glob, getType(), glob.getId(), pluginInfo.getParameters()), this.authenticate, xmlBlasterImpl);

         activate();
      }
      catch (XmlBlasterException ex) {
         throw ex;
      }
      catch (Throwable ex) {
         throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".init", "init. Could'nt initialize the driver.", ex);
      }
   }
View Full Code Here

    * @exception If no PushHandler exists
    */
   private PushHandler getPushHandler(HttpServletRequest req) throws XmlBlasterException {
      HttpSession session = req.getSession(false);
      if (session == null) {
         throw new XmlBlasterException(this.initialGlobal, ErrorCode.USER_SECURITY_AUTHENTICATION_ACCESSDENIED, "No servlet session available");
      }
      String key = "PushHandler"+getParameter(req, "appletInstanceCount", "0");
      PushHandler pushHandler = (PushHandler)session.getAttribute(key);
      if (pushHandler == null) {
         throw new XmlBlasterException(this.initialGlobal, ErrorCode.USER_SECURITY_AUTHENTICATION_ACCESSDENIED, "The PushHandler is missing in the session scope");
      }
      return pushHandler;
   }
View Full Code Here

         this.cb = BlasterCallbackHelper.narrow(this.orb.string_to_object(callbackIOR));
         if (log.isLoggable(Level.FINE)) log.fine("Accessing client callback reference using given IOR string");
      }
      catch (Throwable e) {
         log.severe("The given callback IOR ='" + callbackIOR + "' is invalid: " + e.toString());
         throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION_ADDRESS, "Corba-CallbackHandleInvalid", "The given callback IOR is invalid: " + e.toString());
      }
   }
View Full Code Here

    * @exception e.id="CallbackFailed", should be caught and handled appropriate
    */
   public final String[] sendUpdate(MsgUnitRaw[] msgArr) throws XmlBlasterException {
      if (msgArr == null || msgArr.length < 1 || msgArr[0] == null) {
         Thread.dumpStack();
         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME, "Illegal sendUpdate() argument");
      }

      org.xmlBlaster.protocol.corba.serverIdl.MessageUnit[] updateArr = new org.xmlBlaster.protocol.corba.serverIdl.MessageUnit[msgArr.length];
      for (int ii=0; ii<msgArr.length; ii++) {
         updateArr[ii] = convert(msgArr[ii]);
      }

      try {
         return this.cb.update(callbackAddress.getSecretSessionId(), updateArr);
      } catch (org.xmlBlaster.protocol.corba.serverIdl.XmlBlasterException ex) {
         XmlBlasterException xmlBlasterException = OrbInstanceFactory.convert(glob, ex);
         throw XmlBlasterException.tranformCallbackException(xmlBlasterException);
         /*
         // WE ONLY ACCEPT ErrorCode.USER... FROM CLIENTS !
         if (xmlBlasterException.isUser())
            throw xmlBlasterException;

         if (callbackAddress == null) {
            throw new XmlBlasterException(glob, ErrorCode.USER_UPDATE_ERROR, ME,
                   "CORBA Callback of " + msgArr.length + " messages failed",
                   xmlBlasterException);
         }
         else {
            throw new XmlBlasterException(glob, ErrorCode.USER_UPDATE_ERROR, ME,
                   "CORBA Callback of " + msgArr.length + " messages to client [" +
                   callbackAddress.getSecretSessionId() + "] failed.", xmlBlasterException);
         }
         */
      } catch (Throwable e) {
         if (callbackAddress == null)
            throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME,
                "CORBA Callback of " + msgArr.length + " messages failed", e);
         else
            throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME,
                "CORBA Callback of " + msgArr.length + " messages to client ["
                 + callbackAddress.getSecretSessionId() + "] failed", e);
      }
   }
View Full Code Here

    * @exception XmlBlasterException Is never from the client (oneway).
    */
   public final 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.getRawAddress());
      //log.info(ME, "xmlBlaster.updateOneway(" + msgArr.length + ")");

      org.xmlBlaster.protocol.corba.serverIdl.MessageUnit[] updateArr = new org.xmlBlaster.protocol.corba.serverIdl.MessageUnit[msgArr.length];
      for (int ii=0; ii<msgArr.length; ii++) {
         updateArr[ii] = convert(msgArr[ii]);
      }

      try {
         this.cb.updateOneway(callbackAddress.getSecretSessionId(), updateArr);
      } catch (Throwable e) {
         throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME,
               "CORBA oneway callback of " + msgArr.length + " messages to client [" +
               callbackAddress.getSecretSessionId() + "] failed", e);
      }
   }
View Full Code Here

      try {
         BlasterCallback bcb = this.cb; // can be null during startup from persistence
         if (bcb != null)
            return bcb.ping(qos);
         else
            throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME,
                  "CORBA callback ping failed, no callback handle is available");
      } catch (Throwable e) {
         throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME,
                     "CORBA callback ping failed", e);
      }
   }
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.