Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.MsgUnit


    * <p />
    * @param   oid   The message oid (key oid="...")
    * @return the MsgUnit, which is persistent.
    */
   public MsgUnit fetch(String oid, long timestamp) throws XmlBlasterException {
      MsgUnit msgUnit = null;
      String fileName = createFileName(oid, timestamp);

      String xmlKey_literal = FileLocator.readAsciiFile(this.path, fileName + this.XMLKEY_TOKEN);
      byte[] content = FileLocator.readFile(this.path, fileName);
      String xmlQos_literal = FileLocator.readAsciiFile(this.path, fileName + this.XMLQOS_TOKEN);

      msgUnit = new MsgUnit(glob, xmlKey_literal, content, xmlQos_literal);

      if (log.isLoggable(Level.FINE)) log.fine("Successfully fetched message " + fileName);
      if (log.isLoggable(Level.FINEST)) log.finest("Successfully fetched message\n" + msgUnit.toXml());

      return msgUnit;
   }
View Full Code Here


            }
            xml = FileLocator.readAsciiFile(inFile);
         }
         String content = (!isQos) ? xml : "";
         String qos = (isQos) ? xml : "<qos/>";
         MsgUnit msgUnit = new MsgUnit("<key oid='Hello'/>", content, qos);
         msgUnit.getQosData().setRcvTimestamp(new Timestamp());
         SessionInfo sessionInfo = null;

         PluginInfo info = new PluginInfo(glob, null, "XPathFilter", "1.0");
         info.getParameters().put(MATCH_AGAINST_QOS, ""+isQos);
         if (xslFile != null)
            info.getParameters().put(XSL_CONTENT_TRANSFORMER_FILE_NAME, xslFile);
         filter.init(glob, info);
        
         BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        
         System.out.println("The XML to query is");
         System.out.println("==================================");
         System.out.println(xml);
         System.out.println("==================================");
         System.out.println("Enter your xpath like '//a' or type 'q' to quit");
         String line = "";
         while (true) {
            System.out.println("");
            line = ""; // Nice to have: showing old query, this does not work - use jline
            System.out.print("xpath> " + line);
            line = in.readLine(); // Blocking in I/O
            if (line == null) continue;
            line = line.trim();
            if (line.length() < 1) continue;
            Query query = new Query(glob, line);
            if (line.toLowerCase().equals("q") || line.toLowerCase().equals("quit")) {
               System.out.println("Bye");
               System.exit(0);
            }
            try {
               boolean ret = filter.match(sessionInfo, msgUnit, query);
               //System.out.println("Query: " + query.getQuery());
               System.out.println("Match: " + ret);
               if (ret == true && xslFile != null) {
                  System.out.println("Transformed content: " + msgUnit.getContentStr());
               }
            }
            catch (Exception e) { // javap org.jaxen.XPathSyntaxException
               System.out.println(e.toString());
               e.printStackTrace();
View Full Code Here

   /**
    * TODO? make sender persistent?
    * @return can be null
    */
   public final SessionName getSender() {
      MsgUnit msgUnit = getMsgUnitOrNull();
      if (msgUnit == null) return null;
      return msgUnit.getQosData().getSender();
   }
View Full Code Here

      Object[] obj = { this.keyOid, new Long(this.msgUnitWrapperUniqueId) };
      return obj;
   }

   public final void embeddedObjectToXml(java.io.OutputStream out, java.util.Properties props) throws java.io.IOException {
      MsgUnit msgUnit = getMsgUnitOrNull();
      if (msgUnit != null) // TODO: Messages with no meat can't be loaded again by ServerEntryFactory
         msgUnit.toXml(out, props);
   }
View Full Code Here

      sent =  info_.get("filewatcher.sent", null);
      discarded =  info_.get("filewatcher.discarded", null);
      lockExtention =  info_.get("filewatcher.lockExtention", null);
    
      // this would throw an exception and act as a validation if something is not OK in configuration
      new MsgUnit(this.publishKey, (byte[])null, this.publishQos);
      this.filterType = info_.get("filewatcher.filterType", "simple");
      this.copyOnMove = info_.getBoolean("filewatcher.copyOnMove", true);

      // replPrefixGroup = info_.get(ReplicationConstants.REPL_PREFIX_GROUP_KEY, null);
      // replVersion = info_.get(ReplicationConstants.REPLICATION_VERSION, null);
View Full Code Here

               log.severe(ME+": doPublish: sizes bigger than '" + Integer.MAX_VALUE + "' are currently not implemented");
            }
            else {
               byte[] content = directoryManager.getContent(infos[i]);
               String pubQos = preparePubQos(this.publishQos);
               MsgUnit msgUnit = new MsgUnit(this.publishKey, content, pubQos);
               msgUnit.getQosData().addClientProperty(ContribConstants.FILENAME_ATTR, infos[i].getRelativeName());
               msgUnit.getQosData().addClientProperty(ContribConstants.FILE_DATE, infos[i].getTimestamp());
               String subDir = directoryManager.getSubDir();
               if (subDir != null)
                  msgUnit.getQosData().addClientProperty(ContribConstants.SUBDIR_ATTR, subDir);
               this.access.publish(msgUnit);
               if (log.isLoggable(Level.FINE))
                  log.fine(ME+": Successfully published file " + infos[i].getRelativeName() + " with size=" +infos[i].getSize());
            }
View Full Code Here

      try {
         // authentication security check
         SessionInfo sessionInfo = authenticate.check(sessionId);

         // import and authorize message
         MsgUnit msgUnit = importAndAuthorize(sessionInfo, addressServer,
                                       new MsgUnitRaw(xmlKey_literal, EMPTY_BYTEARR, qos_literal),
                                       MethodName.SUBSCRIBE);

         SubscribeQosServer subscribeQos = new SubscribeQosServer(glob, (QueryQosData)msgUnit.getQosData());

         // Invoke xmlBlaster
         String ret = requestBroker.subscribe(sessionInfo, (QueryKeyData)msgUnit.getKeyData(), subscribeQos);


         sessionInfo.getDispatchStatistic().incrNumSubscribe(1);

         // export (encrypt) return value
View Full Code Here

      try {
         // authentication and authorization security checks
         SessionInfo sessionInfo = authenticate.check(sessionId);

         // import and authorize message
         MsgUnit msgUnit = importAndAuthorize(sessionInfo, addressServer,
                                       new MsgUnitRaw(xmlKey_literal, EMPTY_BYTEARR, qos_literal),
                                       MethodName.UNSUBSCRIBE);

         UnSubscribeQosServer unSubscribeQosServer = new UnSubscribeQosServer(glob, (QueryQosData)msgUnit.getQosData());

         // Invoke xmlBlaster
         String [] retArr = requestBroker.unSubscribe(sessionInfo, (QueryKeyData)msgUnit.getKeyData(), unSubscribeQosServer);

         sessionInfo.getDispatchStatistic().incrNumUnSubscribe(1);

         // export (encrypt) return value
         I_Session sec = sessionInfo.getSecuritySession();
View Full Code Here

      }
      else {
        currentContent = (this.contentData == null) ? new byte[0] : this.contentData.getBlobValue();
      }

      MsgUnit msgUnit = new MsgUnit(this.key.toString(),
         currentContent, this.qos.toString());
      return msgUnit;
   }
View Full Code Here

      StringBuffer sb = new StringBuffer(1024+(msgUnitArr.length*256));
      sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
      sb.append("\n<").append(rootTag).append(">");
      if (comment != null && comment.length() > 0) sb.append("\n<!-- " + comment + " -->");
      for (int i=0; i<msgUnitArr.length; i++) {
         MsgUnit msgUnit = msgUnitArr[i];
         String xml = msgUnit.toXml((String)null, (Properties)null);
         sb.append("\n <").append(msgUnit.getMethodName().toString()).append(">");
         sb.append(xml);
         sb.append("\n </").append(msgUnit.getMethodName().toString()).append(">");
      }
      sb.append("\n</").append(rootTag).append(">");
      return sb.toString();
   }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.MsgUnit

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.