Package org.xmlBlaster.util.def

Examples of org.xmlBlaster.util.def.MethodName


         return;
      }

      try {
         String actionType = Util.getParameter(req, "ActionType", "NONE");
         MethodName action;
         try {
            action = MethodName.toMethodName(actionType);
         }
         catch (IllegalArgumentException ie) {
            throw new Exception("Unknown or missing 'ActionType=" + actionType + "' please choose 'subscribe' 'unSubscribe' 'erase' etc.");
         }

         // Extract the message data
         String oid = Util.getParameter(req, "key.oid", null);
         if (oid != null) oid = Global.decode(oid, ENCODING);

         String key = Util.getParameter(req, "key", null);
         if (key != null) {
            key = Global.decode(key, ENCODING);
            if (log.isLoggable(Level.FINEST)) log.finest("key=\n'" + key + "'");
         }
        
         String content = Util.getParameter(req, "content", null);
         if (content != null) {
            content = Global.decode(content, ENCODING);
         }
         else
            content = "";
         if (log.isLoggable(Level.FINEST)) log.finest("content=\n'" + content + "'");

         String qos = Util.getParameter(req, "qos", null);
         if (qos != null) {
            qos = Global.decode(qos, ENCODING);
         }
         else
            qos = "";
         if (log.isLoggable(Level.FINEST)) log.finest("qos=\n'" + qos + "'");

         if (action.equals(MethodName.SUBSCRIBE)) { // "subscribe"
            log.fine("subscribe arrived ...");
           
            if (oid != null) {
               SubscribeKey xmlKey = new SubscribeKey(glob, oid);
               SubscribeReturnQos ret = xmlBlaster.subscribe(xmlKey.toXml(), qos);
               log.info("Subscribed to simple key.oid=" + oid + ": " + ret.getSubscriptionId());
            }
            else if (key != null) {
               SubscribeReturnQos ret = xmlBlaster.subscribe(key, qos);
               log.info("Subscribed to " + key + ": SubscriptionId=" + ret.getSubscriptionId() + " qos=" + qos);
            }
            else {
               String str = "Please call servlet with some 'key.oid=...' or 'key=<key ...' when subscribing";
               log.severe(str);
               htmlOutput(str, res);
               return;
            }
         }

         else if (action.equals(MethodName.UNSUBSCRIBE)) { // "unSubscribe"
            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.severe(str);
               htmlOutput(str, res);
               return;
            }
         }

         else if (action.equals(MethodName.GET)) { // "get"
            throw new Exception("Synchronous ActionType=get is not supported");
         }

         else if (action.equals(MethodName.PUBLISH)) { // "publish"
            log.fine("publish arrived ...");
            if (key == null) {
               String str = "Please call servlet with some key when publishing";
               log.severe(str);
               htmlOutput(str, res);
               return;
            }
            if (content == null)
               content = "";

            log.info("Publishing '" + key + "'");
            MsgUnit msgUnit = new MsgUnit(glob, key, content.getBytes(), qos);
            try {
               PublishReturnQos prq = xmlBlaster.publish(msgUnit);
               log.fine("Success: Publishing done, returned oid=" + prq.getKeyOid());
            } catch(XmlBlasterException e) {
               log.warning("XmlBlasterException: " + e.getMessage());
            }
         }

         else if (action.equals(MethodName.ERASE)) { // "erase"
            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.severe(str);
               htmlOutput(str, res);
               return;
            }
         }

         else if (action.equals(MethodName.PING)) { // "ping"
            log.fine("ping arrived, doing nothing ...");
            //String ret = xmlBlaster.ping(qos);
         }

         else {
View Full Code Here


      try {
         MsgInfo[] msgInfoArr = parser.parse(is);
         if (msgInfoArr != null) {
            for (int i=0; i < msgInfoArr.length; i++) {
               MsgInfo msgInfo = msgInfoArr[i];
               MethodName method = msgInfo.getMethodName();
               String sessionId = msgInfo.getSecretSessionId();
               MsgUnitRaw[] msgUnitRawArr = msgInfo.getMessageArr();
               String key = null;
               MsgUnitRaw msgUnitRaw = null;
              
               if (msgUnitRawArr != null && msgUnitRawArr.length > 0) {
                  msgUnitRaw = msgUnitRawArr[0];
                  key = msgUnitRaw.getKey();
               }
               String qos = msgInfo.getQos();
              
               if (method.isConnect()) {
                 
               }
               else if (method.isDisconnect()) {
                 
               }
               else if (method.isErase()) {
                  return erase(sessionId, key, qos);
               }
               else if (method.isGet()) {
                  final String asString = "true";
                  return get(sessionId, key, qos, asString);
               }
               else if (method.isPublish()) {
                  byte[] content = null;
                  if (msgUnitRaw != null)
                     content = msgUnitRaw.getContent();
                  return publish(sessionId, key, content, qos);
               }
               else if (method.isPublishArray()) {
                  String[] strArr = blasterNative.publishArr(addressServer, sessionId, msgUnitRawArr);
                  return ProtoConverter.stringArray2Vector(strArr);
               }
               else if (method.isPublishOnway()) {
                  blasterNative.publishOneway(addressServer, sessionId, msgUnitRawArr);
                  return "";
               }
               else if (method.isSubscribe()) {
                  return subscribe(sessionId, key, qos);
               }
               else if (method.isUnSubscribe()) {
                  return unSubscribe(sessionId, key, qos);
               }
               else { // how to handle pings !!!!!!
                  // log.warning("The method '" + method.getMethodName() + "' is not implemented");
                  return "OK";
View Full Code Here

         if (msgInfoArr != null) {
            for (int i=0; i < msgInfoArr.length; i++) {
               MsgInfo msgInfo = msgInfoArr[i];
               String sessionId = msgInfo.getSecretSessionId();
               String qos = msgInfo.getQos();
               MethodName method = msgInfo.getMethodName();
               if (method.isConnect()) {
                  return connect(qos);
               }
               else if (method.isDisconnect()) {
                  return disconnect(sessionId, qos);
               }
               else { // how to handle pings !!!!!!
                  return ping(qos);
               }
View Full Code Here

                              }
                           }
                           name = name.substring(0, start);
                        }
                        try {
                           MethodName methodName = MethodName.toMethodName(name);
                           container.allowedMethodNames.put(methodName, set);
                        }
                        catch (IllegalArgumentException e) {
                           log.severe("Ignoring authorization method name, please check your configuration in '" + htpasswdFilename + "': " + e.toString());
                        }
                     }
                  }
                  else {
                     MethodName[] all = MethodName.getAll();
                     HashSet set = new HashSet();
                     for (int k=0; k<all.length; k++) container.allowedMethodNames.put(all[k], set);
                     String[] nameArr = org.xmlBlaster.util.StringPairTokenizer.parseLine(methodNames.substring(1), ',');
                     for (int j=0; j<nameArr.length; j++) {
                        try {
                           MethodName methodName = MethodName.toMethodName(nameArr[j].trim());
                           container.allowedMethodNames.remove(methodName);
                        }
                        catch (IllegalArgumentException e) {
                           log.severe("Ignoring authorization method name, please check your configuration in '" + htpasswdFilename + "': " + e.toString());
                        }
View Full Code Here

      if (authenticated == false) {
         log.warning("Authentication of user " + getName() + " failed");
         return false;
      }
     
      MethodName action = dataHolder.getAction();
      String key = dataHolder.getKeyOid();

      log.warning("No authorization check for action='" + action + "' on key='" +key + "' is implemented, access generously granted.");
      return true;
   }
View Full Code Here

    * Convenience method to access PtP destination
    * @return null if no PtP publish message
    */
   public Destination getDestination() {
      final QosData qosData = getQosData();
      final MethodName m = qosData.getMethod();
      if (MethodName.PUBLISH.equals(m) || MethodName.PUBLISH_ARR.equals(m) || MethodName.PUBLISH_ONEWAY.equals(m)
       || MethodName.UPDATE.equals(m) || MethodName.UPDATE_ONEWAY.equals(m)) {
         if (qosData instanceof MsgQosData) {
            MsgQosData msgQosData = (MsgQosData)qosData;
            return (msgQosData.getDestinationArr().length > 0) ? msgQosData
View Full Code Here

      String xmlKey = "<key oid='" + oid + "'/>";
      // String qos = "<qos/>";

      MsgUnitRaw[] msgUnitArrRaw = xmlBlaster.get(addressServer, sessionId, xmlKey, "<qos/>");//cmd.getQueryQosData().toXml());
      MsgUnit[] msgUnits = new MsgUnit[msgUnitArrRaw.length];
      MethodName method = MethodName.GET; // cmd.getMethod();
      for (int i=0; i < msgUnits.length; i++) {
         msgUnits[i] = new MsgUnit(this.glob, msgUnitArrRaw[i], method);
      }
      log.info(cmd.getCommand() + " returned " + msgUnitArrRaw.length + " messages");
View Full Code Here

      */

      Hashtable map = new Hashtable();
      map.put("/qos/rcvTimestamp/@nanos", ""+getRcvTimestamp());
      map.put("/qos/rcvTimestamp/text()", ""+getRcvTime());
      MethodName methodName = getMethod();
      if (methodName != null) map.put("/qos/methodName/text()", methodName.toString());
      map.put("/qos/persistent/text()", ""+isPersistent());

      Map pMap = getClientProperties();
      Iterator it = pMap.keySet().iterator();
      while (it.hasNext()) {
View Full Code Here

    */
   public I_Entry createEntry(int priority, long timestamp, String type,
                  boolean persistent, long sizeInBytes, InputStream is, StorageId storageId)
      throws XmlBlasterException {

      MethodName methodName = MethodName.toMethodName(type);

      try {
         ObjectInputStream objStream = new ObjectInputStream(is);
         Object[] obj = (Object[])objStream.readObject();

View Full Code Here

  
  
   public I_Entry createEntry(XBStore store, XBMeat meat, XBRef ref) throws XmlBlasterException {
      String type = ref.getMethodName();
      StorageId storageId = getStorageId(store);
      MethodName methodName = MethodName.toMethodName(type);
      String key = meat.getKey();
      String qos = meat.getQos();
      byte[] content = meat.getContent();
      long timestamp = ref.getId();
      int priority = ref.getPrio();
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.def.MethodName

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.