public static CougarValidationException exceptionDuringDeserialisation(
      ParameterType paramType, String paramName, Exception e, boolean client) {
    StringBuilder logBuffer = new StringBuilder();
    logBuffer.append("Unable to convert data in request to ");
    logBuffer.append(paramType.getType().name());
    logBuffer.append(" for parameter: ");
    logBuffer.append(paramName);
    String message = logBuffer.toString();

    logger.log(Level.FINER, message, e);
    throw CougarMarshallingException.unmarshallingException("xml", message, e, client);
  }
  private Object readObject(ParameterType paramType, OMElement node, boolean client)
      throws Exception {
    switch (paramType.getType()) {
      case BOOLEAN:
      case DOUBLE:
      case FLOAT:
      case INT:
      case LONG:
      case STRING:
      case ENUM:
      case DATE:
      case BYTE:
        return node == null
            ? null
            : readSimpleObject(paramType, node.getLocalName(), node.getText(), client);
      case OBJECT:
        // descend - note possibly two levels if inside a collection recursion
        OMElement _copy = this.currentNode;
        currentNode = node;

        Transcribable t = (Transcribable) paramType.getImplementationClass().newInstance();
        t.transcribe(this, TranscribableParams.getAll(), client);

        // ascend
        this.currentNode = _copy;
        return t;
      case MAP:
        Map map = new HashMap();
        for (Iterator i = node.getChildElements(); i.hasNext(); ) {
          OMElement element = (OMElement) i.next();
          Object key =
              readSimpleObject(
                  paramType.getComponentTypes()[0],
                  node.getLocalName(),
                  element.getAttributeValue(keyAttName),
                  client);
          map.put(
              key,
              readObject(
                  paramType.getComponentTypes()[1],
                  (OMElement) element.getChildElements().next(),
                  client));
        }
        return map;
      case LIST:
        if (paramType.getComponentTypes()[0].getType() == ParameterType.Type.BYTE) {
          try {
            return Base64Utils.decode(node.getText());
          } catch (Exception e) {
            String message = "Unable to parse " + node.getText() + " as type " + paramType;
            logger.log(Level.FINER, message, e);
            throw CougarMarshallingException.unmarshallingException("soap", message, e, client);
          }
        } else {
          List list = new ArrayList();
          for (Iterator i = node.getChildElements(); i.hasNext(); ) {
            list.add(readObject(paramType.getComponentTypes()[0], (OMElement) i.next(), client));
          }
          return list;
        }
      case SET:
        Set set = new HashSet();
        for (Iterator i = node.getChildElements(); i.hasNext(); ) {
          set.add(readObject(paramType.getComponentTypes()[0], (OMElement) i.next(), client));
        }
        return set;
    }
    return null;
  }