public void deserialize(
     PropertyContext propertyContext,
     ConnectionResult connectionResult,
     XFormsModelSubmission.SubmissionParameters p,
     XFormsModelSubmission.SecondPassParameters p2)
     throws Exception {
   // Deserialize here so it can run in parallel
   if (XMLUtils.isXMLMediatype(connectionResult.getResponseMediaType())) {
     // XML media type
     final IndentedLogger detailsLogger = getDetailsLogger(p, p2);
     resultingDocument =
         deserializeInstance(
             propertyContext, detailsLogger, p2.isReadonly, p2.isHandleXInclude, connectionResult);
   } else {
     // Other media type is not allowed
     throw new XFormsSubmissionException(
         submission,
         "Body received with non-XML media type for replace=\"instance\": "
             + connectionResult.getResponseMediaType(),
         "processing instance replacement",
         new XFormsSubmitErrorEvent(
             containingDocument,
             propertyContext,
             submission,
             XFormsSubmitErrorEvent.ErrorType.RESOURCE_ERROR,
             connectionResult));
   }
 }
Esempio n. 2
0
  /**
   * Return the charset associated with a text/* Content-Type header. If a charset is present,
   * return it. Otherwise, guess depending on whether the mediatype is text/xml or not.
   *
   * @param contentType Content-Type header value
   * @return charset
   */
  public static String getTextCharsetFromContentType(String contentType) {
    final String charset;
    final String connectionCharset = getContentTypeCharset(contentType);
    if (connectionCharset != null) {
      charset = connectionCharset;
    } else {

      // RFC 3023: "Conformant with [RFC2046], if a text/xml entity is
      // received with the charset parameter omitted, MIME processors and
      // XML processors MUST use the default charset value of
      // "us-ascii"[ASCII]. In cases where the XML MIME entity is
      // transmitted via HTTP, the default charset value is still
      // "us-ascii". (Note: There is an inconsistency between this
      // specification and HTTP/1.1, which uses ISO-8859-1[ISO8859] as the
      // default for a historical reason. Since XML is a new format, a new
      // default should be chosen for better I18N. US-ASCII was chosen,
      // since it is the intersection of UTF-8 and ISO-8859-1 and since it
      // is already used by MIME.)"

      if (XMLUtils.isXMLMediatype(contentType)) charset = DEFAULT_TEXT_XML_READING_ENCODING;
      else charset = DEFAULT_HTTP_TEXT_READING_ENCODING;
    }
    return charset;
  }