Package org.apache.xindice.util

Examples of org.apache.xindice.util.SymbolSerializer


*
*/
public class GetDocument extends RPCDefaultMessage {  
   public Hashtable execute(Hashtable message) throws Exception {
      SymbolSerializer symbolSerializer = null;

      if(!message.containsKey(COLLECTION)) {
         throw new Exception(MISSING_COLLECTION_PARAM);
      }

      if(!message.containsKey(NAME)) {
         throw new Exception(MISSING_NAME_PARAM);
      }

      Collection col = getCollection( (String) message.get(COLLECTION) );

      Document doc = col.getDocument( (String) message.get(NAME) );
      if ( doc == null ) {
         throw new Exception( API_NAME + ": Document not found " +
                              (String) message.get(NAME) );
      }

      Hashtable result = new Hashtable();
      if (message.containsKey(COMPRESSED)) {
         try {
            symbolSerializer = new SymbolSerializer(col.getSymbols());
         }
         catch ( Exception e ) {
            // It's ok (in theory) for a Collection to have no symbol table
         }

         long timestamp = 1;
         /* Time stamp is an optimization and longs are causing problems with XML-RPC
            so we'll try to get everything working without them.
          if ( ! message.containsKey(TIMESTAMP) ) {
            throw new Exception(MISSING_TIMESTAMP_PARAM);
         }

         int timestamp = ((Integer) message.get("timestamp")).intValue();*/
         if ( /*( timestamp != -1) &&*/ ( symbolSerializer != null ) ) {
            result.put(RESULT,
                       symbolSerializer.convertFromDocument(doc, timestamp));
         }
         else {
            result.put(RESULT, TextWriter.toString( doc ));              
         }
      }
View Full Code Here


            // Return empty result
        } else if (obj instanceof byte[]) {
            // Binary resource
            result.put(RESULT, obj);
        } else if (message.containsKey(COMPRESSED)) {
            SymbolSerializer symbolSerializer = null;
            try {
                symbolSerializer = new SymbolSerializer(col.getSymbols());
            } catch (Exception e) {
                // It's ok (in theory) for a Collection to have no symbol table
                if (log.isWarnEnabled()) {
                    log.warn("ignored exception", e);
                }
            }

            long timestamp = 1;
            /* TODO: Timestamp optimization.
               Longs are causing problems with XML-RPC
               so we'll try to get everything working without them.
            if (!message.containsKey(TIMESTAMP)) {
                throw new Exception(MISSING_TIMESTAMP_PARAM);
            }
            int timestamp = ((Integer) message.get("timestamp")).intValue();
            */

            Document doc = (Document)obj;
            if (/*( timestamp != -1) &&*/ (symbolSerializer != null)) {
                result.put(RESULT,
                           symbolSerializer.convertFromDocument(doc, timestamp));
            } else {
                result.put(RESULT, TextWriter.toString(doc));
            }
        } else {
            Document doc = (Document)obj;
View Full Code Here

            // Return empty result
        } else if (obj instanceof byte[]) {
            // Binary resource
            result.put(RESULT, obj);
        } else if (message.containsKey(COMPRESSED)) {
            SymbolSerializer symbolSerializer = null;
            try {
                symbolSerializer = new SymbolSerializer(col.getSymbols());
            } catch (Exception e) {
                // It's ok (in theory) for a Collection to have no symbol table
                if (log.isWarnEnabled()) {
                    log.warn("ignored exception", e);
                }
            }

            long timestamp = 1;
            /* TODO: Timestamp optimization.
               Longs are causing problems with XML-RPC
               so we'll try to get everything working without them.
            if (!message.containsKey(TIMESTAMP)) {
                throw new Exception(MISSING_TIMESTAMP_PARAM);
            }
            int timestamp = ((Integer) message.get("timestamp")).intValue();
            */

            // Document might be compressed (with bytes) or not. In a latter case, convert to string.
            Document doc = (Document) obj;
            if (/*( timestamp != -1) &&*/ symbolSerializer != null && ((CompressedDocument) doc).getDataBytes() != null) {
                result.put(RESULT,
                           symbolSerializer.convertFromDocument(doc, timestamp));
            } else {
                result.put(RESULT, TextWriter.toString(doc));
            }
        } else {
            Document doc = (Document) obj;
View Full Code Here

            // Binary resource
            result.put(RESULT, obj.getValue());

        } else if (message.containsKey(COMPRESSED)) {
            // Compressed XML resource
            SymbolSerializer symbolSerializer = new SymbolSerializer(col.getSymbols());

            long timestamp = 1;
            /* TODO: Timestamp optimization.
               Longs are causing problems with XML-RPC
               so we'll try to get everything working without them.
            if (!message.containsKey(TIMESTAMP)) {
                throw new Exception(MISSING_TIMESTAMP_PARAM);
            }
            int timestamp = ((Integer) message.get("timestamp")).intValue();
            */

            // Document might be compressed (with bytes) or not. In a latter case, convert to string.
            Document doc = (Document) obj.getValue();
            if (/*( timestamp != -1) &&*/ ((CompressedDocument) doc).getDataBytes() != null) {
                result.put(RESULT, symbolSerializer.convertFromDocument(doc, timestamp));
            } else {
                result.put(RESULT, TextWriter.toString(doc));
            }

        } else {
View Full Code Here

            // Return empty result
        } else if (obj instanceof byte[]) {
            // Binary resource
            result.put(RESULT, obj);
        } else if (message.containsKey(COMPRESSED)) {
            SymbolSerializer symbolSerializer = null;
            try {
                symbolSerializer = new SymbolSerializer(col.getSymbols());
            } catch (Exception e) {
                // It's ok (in theory) for a Collection to have no symbol table
                if (log.isWarnEnabled()) {
                    log.warn("ignored exception", e);
                }
            }

            long timestamp = 1;
            /* TODO: Timestamp optimization.
               Longs are causing problems with XML-RPC
               so we'll try to get everything working without them.
            if (!message.containsKey(TIMESTAMP)) {
                throw new Exception(MISSING_TIMESTAMP_PARAM);
            }
            int timestamp = ((Integer) message.get("timestamp")).intValue();
            */

            Document doc = (Document)obj;
            if (/*( timestamp != -1) &&*/ (symbolSerializer != null)) {
                result.put(RESULT,
                           symbolSerializer.convertFromDocument(doc, timestamp));
            } else {
                result.put(RESULT, TextWriter.toString(doc));
            }
        } else {
            Document doc = (Document)obj;
View Full Code Here

TOP

Related Classes of org.apache.xindice.util.SymbolSerializer

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.