/** * Get the mime type of this SOAP version with the passed charset. * * @param aCharset * The charset to be used. May not be <code>null</code>. * @return Never <code>null</code>. */ @Nonnull @ReturnsMutableCopy public MimeType getMimeType (@Nonnull final Charset aCharset) { return new MimeType (m_aMimeType).addParameter (CMimeType.PARAMETER_NAME_CHARSET, aCharset.name ()); }
new MimeType (CMimeType.TEXT_HTML).addParameter (CMimeType.PARAMETER_NAME_CHARSET, aCharset.name ()) .getAsString ());
@Nullable public static IMimeType safeParseMimeType (@Nullable final String sMimeType) { try { return MimeTypeParser.parseMimeType (sMimeType); } catch (final MimeTypeParserException ex) { if ("*".equals (sMimeType)) return new MimeType (EMimeContentType._STAR, "*"); } if (LOGGER.isWarnEnabled ()) LOGGER.warn ("Unparsable MIME type '" + sMimeType + "'"); return null; } }
m_aMimeType = ((MimeType) aMimeType.getClone ()).addParameter (CMimeType.PARAMETER_NAME_CHARSET, aCharset.name ());
final ICommonsList <WSS4JAttachment> aIncomingAttachments = new CommonsArrayList <> (); final IMimeType aPlainContentType = aContentType.getCopyWithoutParameters (); if (aPlainContentType.equals (MT_MULTIPART_RELATED)) LOGGER.info ("Received MIME message"); final String sBoundary = aContentType.getParameterValueWithName ("boundary"); if (StringHelper.hasNoText (sBoundary)) .getCopyWithoutParameters (); LOGGER.info ("Received plain message with Content-Type " + aContentType.getAsString ());
final SoapMimeMultipart aMimeMultipart = new SoapMimeMultipart (eSOAPVersion, aCharset); final EContentTransferEncoding eCTE = EContentTransferEncoding.BINARY; final String sContentType = eSOAPVersion.getMimeType (aCharset).getAsString (); final String s = aBAOS.getAsString (StandardCharsets.UTF_8); if (s.length () > 0) System.out.println (s);
/** * Get the HTML MIME type to use * * @param aRequestScope * The request scope. May be <code>null</code>- * @return Never <code>null</code>. */ @Nonnull public static IMimeType getMimeType (@Nullable final IRequestWebScopeWithoutResponse aRequestScope) { // Add the charset to the MIME type return new MimeType (CMimeType.TEXT_HTML).addParameter (CMimeType.PARAMETER_NAME_CHARSET, HCSettings.getHTMLCharset ().name ()); }
public void xml (@Nullable final String sXML, @Nonnull final Charset aCharset) { setContentAndCharset (StringHelper.getNotNull (sXML), aCharset); setMimeType (new MimeType (CMimeType.APPLICATION_XML).addParameter (CMimeType.PARAMETER_NAME_CHARSET, aCharset.name ())); }
public void json (@Nullable final IJson aValue) { // Ensure it is valid JSON final String sResponse = aValue != null ? aValue.getAsJsonString () : "{}"; final Charset aCharset = StandardCharsets.UTF_8; setContentAndCharset (sResponse, aCharset); setMimeType (new MimeType (CMimeType.APPLICATION_JSON).addParameter (CMimeType.PARAMETER_NAME_CHARSET, aCharset.name ())); }
public void handleRequest (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Status information requested"); // Build data to provide IJsonObject aStatusData; if (SMPServerConfiguration.isStatusEnabled ()) aStatusData = getDefaultStatusData (); else { // Status is disabled in the configuration aStatusData = new JsonObject (); aStatusData.add ("status.enabled", false); } // Put JSON on response aUnifiedResponse.disableCaching (); aUnifiedResponse.setMimeType (new MimeType (CMimeType.APPLICATION_JSON).addParameter (CMimeType.PARAMETER_NAME_CHARSET, CHARSET.name ())); aUnifiedResponse.setContentAndCharset (aStatusData.getAsJsonString (), CHARSET); } }
public void handleRequest (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { if (LOGGER.isDebugEnabled ()) LOGGER.debug ("Status information requested"); // Build data to provide IJsonObject aStatusData; if (SMPServerConfiguration.isStatusEnabled ()) aStatusData = getDefaultStatusData (); else { // Status is disabled in the configuration aStatusData = new JsonObject (); aStatusData.add ("status.enabled", false); } // Put JSON on response aUnifiedResponse.disableCaching (); aUnifiedResponse.setMimeType (new MimeType (CMimeType.APPLICATION_JSON).addParameter (CMimeType.PARAMETER_NAME_CHARSET, CHARSET.name ())); aUnifiedResponse.setContentAndCharset (aStatusData.getAsJsonString (), CHARSET); } }
public void execute (@Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { // Resolve language final String sLanguage = aRequestScope.getAttributeAsString (LANGUAGE_ID); Locale aLanguage = LocaleCache.getLocale (sLanguage); if (aLanguage == null) { // None or invalid locale specified - use default from constructor aLanguage = m_aDefaultLocale; } // Main action final IJsonObject aData = DataTables.createLanguageJson (aLanguage); // Fill HTTP response final Charset aCharset = CHTMLCharset.CHARSET_HTML_OBJ; aUnifiedResponse.setContentAndCharset (aData.getAsString (), aCharset) .setMimeType (new MimeType (CMimeType.APPLICATION_JSON).addParameter (CMimeType.PARAMETER_NAME_CHARSET, aCharset.name ())) .enableCaching (ResponseHelperSettings.getExpirationSeconds ()); } }