Examples of XmlRpcException


Examples of de.timroes.axmlrpc.XMLRPCException

   * @throws XMLRPCException Will be thrown whenever an error occurs.
   */
  public Object deserialize(Element element) throws XMLRPCException {

    if(!XMLRPCClient.VALUE.equals(element.getNodeName())) {
      throw new XMLRPCException("Value tag is missing around value.");
    }
   
    if(!XMLUtil.hasChildElement(element.getChildNodes())) {
      // Value element doesn't contain a child element
      if((flags & XMLRPCClient.FLAGS_DEFAULT_TYPE_STRING) != 0) {
        return string.deserialize(element);
      } else {
        throw new XMLRPCException("Missing type element inside of value element.");
      }
    }
     
    // Grep type element from inside value element
    element = XMLUtil.getOnlyChildElement(element.getChildNodes());

    Serializer s = null;

    String type;

    // If FLAGS_IGNORE_NAMESPACE has been set, only use local name.
    if((flags & XMLRPCClient.FLAGS_IGNORE_NAMESPACES) != 0) {
      type = element.getLocalName() == null ? element.getNodeName() : element.getLocalName();
    } else {
      type = element.getNodeName();
    }

    if((flags & XMLRPCClient.FLAGS_NIL) != 0 && TYPE_NULL.equals(type)) {
      s = nil;
    } else if(TYPE_STRING.equals(type)) {
      s = string;
    } else if(TYPE_BOOLEAN.equals(type)) {
      s = bool;
    } else if(TYPE_DOUBLE.equals(type)) {
      s = floating;
    } else if (TYPE_INT.equals(type) || TYPE_INT2.equals(type)) {
      s = integer;
    } else if(TYPE_DATETIME.equals(type)) {
      s = datetime;
    } else if (TYPE_LONG.equals(type)) {
      if((flags & XMLRPCClient.FLAGS_8BYTE_INT) != 0) {
        s = long8;
      } else {
        throw new XMLRPCException("8 byte integer is not in the specification. "
            + "You must use FLAGS_8BYTE_INT to enable the i8 tag.");
      }
    } else if(TYPE_STRUCT.equals(type)) {
      s = struct;
    } else if(TYPE_ARRAY.equals(type)) {
      s = array;
    } else if(TYPE_BASE64.equals(type)) {
      s = base64;
    } else {
      throw new XMLRPCException("No deserializer found for type '" + type + "'.");
    }

    return s.deserialize(element);

  }
View Full Code Here

Examples of de.timroes.axmlrpc.XMLRPCException

        s = long8;
      } else {
        // Allow long values as long as their fit within the 4 byte integer range.
        long l = (Long)object;
        if(l > Integer.MAX_VALUE || l < Integer.MIN_VALUE) {
          throw new XMLRPCException("FLAGS_8BYTE_INT must be set, if values "
              + "outside the 4 byte integer range should be transfered.");
        } else {
          s = integer;
        }
      }
    } else if(object instanceof Date) {
      s = datetime;
    } else if(object instanceof Calendar) {
      object = ((Calendar)object).getTime();
      s = datetime;
    } else if (object instanceof Map) {
      s = struct;
    } else if(object instanceof byte[]) {
      byte[] old = (byte[])object;
      Byte[] boxed = new Byte[old.length];
      for(int i = 0; i < boxed.length; i++) {
        boxed[i] = new Byte(old[i]);
      }
      object = boxed;
      s = base64;
    } else if(object instanceof Byte[]) {
      s = base64;
    } else if(object instanceof Iterable<?> || object instanceof Object[]) {
      s = array;
    } else {
      throw new XMLRPCException("No serializer found for type '"
          + object.getClass().getName() + "'.");
    }

    return s.serialize(object);
View Full Code Here

Examples of de.timroes.axmlrpc.XMLRPCException

          || n.getNodeType() == Node.COMMENT_NODE)
        continue;

      if(n.getNodeType() != Node.ELEMENT_NODE
          || !STRUCT_MEMBER.equals(n.getNodeName())) {
        throw new XMLRPCException("Only struct members allowed within a struct.");
      }

      // Grep name and value from member
      s = null; o = null;
      for(int j = 0; j < n.getChildNodes().getLength(); j++) {
        m = n.getChildNodes().item(j);
       
        // Strip only whitespace text elements and comments
        if((m.getNodeType() == Node.TEXT_NODE
              && m.getNodeValue().trim().length() <= 0)
            || m.getNodeType() == Node.COMMENT_NODE)
          continue;

        if(STRUCT_NAME.equals(m.getNodeName())) {
          if(s != null) {
            throw new XMLRPCException("Name of a struct member cannot be set twice.");
          } else {
            s = XMLUtil.getOnlyTextContent(m.getChildNodes());
          }
        } else if(m.getNodeType() == Node.ELEMENT_NODE && STRUCT_VALUE.equals(m.getNodeName())) {
          if(o != null) {
            throw new XMLRPCException("Value of a struct member cannot be set twice.");
          } else {
            o = SerializerHandler.getDefault().deserialize((Element)m);
          }
        } else {
          throw new XMLRPCException("A struct member must only contain one name and one value.");
        }

      }

      map.put(s, o);
View Full Code Here

Examples of de.timroes.axmlrpc.XMLRPCException

    List<Object> list = new ArrayList<Object>();

    Element data = XMLUtil.getOnlyChildElement(content.getChildNodes());

    if(!ARRAY_DATA.equals(data.getNodeName())) {
      throw new XMLRPCException("The array must contain one data tag.");
    }

    // Deserialize every array element
    Node value;
    for(int i = 0; i < data.getChildNodes().getLength(); i++) {

      value = data.getChildNodes().item(i);

      // Strip only whitespace text elements and comments
      if(value == null || (value.getNodeType() == Node.TEXT_NODE
            && value.getNodeValue().trim().length() <= 0)
          || value.getNodeType() == Node.COMMENT_NODE)
        continue;

      if(value.getNodeType() != Node.ELEMENT_NODE) {
        throw new XMLRPCException("Wrong element inside of array.");
      }

      list.add(SerializerHandler.getDefault().deserialize((Element)value));

    }
View Full Code Here

Examples of de.timroes.axmlrpc.XMLRPCException

  public Object deserialize(Element content) throws XMLRPCException {
    try {
      return DATE_FORMATER.parse(XMLUtil.getOnlyTextContent(content.getChildNodes()));
    } catch (ParseException ex) {
      throw new XMLRPCException("Unable to parse given date.", ex);
    }
  }
View Full Code Here

Examples of org.apache.xmlrpc.XmlRpcException

                        break;
                     buf.append(line).append("\n");
                  }
                  errStr.close();
                  if (buf.length() > 0) {
                     throw new XmlRpcException(errUrl.getResponseCode(), buf.toString(), e);
                  }
               }
            }
            catch (IOException ex) {
               ex.printStackTrace();
            }
         }
        
         throw new XmlRpcException("Failed to create input stream: " + e.getMessage(), e);
      }
   }
View Full Code Here

Examples of org.apache.xmlrpc.XmlRpcException

    log.debug(":: getXmlWriter ::");
   
    try {
      xw.setWriter(new BufferedWriter(new OutputStreamWriter(pStream, enc)));
    } catch (UnsupportedEncodingException e) {
      throw new XmlRpcException(0, "Unsupported encoding: " + enc + e);
    }
    return xw;
  }
View Full Code Here

Examples of org.apache.xmlrpc.XmlRpcException

    log.debug(":: getXmlWriter ::");
   
    try {
      xw.setWriter(new BufferedWriter(new OutputStreamWriter(pStream, enc)));
    } catch (UnsupportedEncodingException e) {
      throw new XmlRpcException(0, "Unsupported encoding: " + enc + e);
    }
    return xw;
  }
View Full Code Here

Examples of org.apache.xmlrpc.XmlRpcException

       
        Method method = lookupMethod( delegate, methodName, xmlRpcSignature );
       
        if( method.getDeclaringClass() == Object.class )
        {
            throw new XmlRpcException( 0, "Can't call methods defined in java.lang.Object" );
        }
       
        MethodSignature methodSig = MethodSignature.createFromMethod( method );
        Object[] adaptedParameters = adaptParameters( methodSig, args );
       
       
        Object result = method.invoke( delegate, adaptedParameters );
       
        //convert result back to a XML-RPC compliant representation
        result = getTypeConverter().convertToXmlRpcRepresentation( methodSig.getReturnParameter(), result );
       
        if (result == null && !methodSig.getReturnParameter().getApiRepresentationClass().equals( void.class ))
        {
            throw( new XmlRpcException( 0, "Method '" + method + "' must not return <null>" ) );
        }
       
        return( result );
    }
View Full Code Here

Examples of org.apache.xmlrpc.XmlRpcException

            AuthorizationResult result = authorize( session, method, username );
           
            return result.isAuthorized();
        }

        throw new XmlRpcException( "Unsupported transport (must be http)" );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.