Example usage for com.google.common.net MediaType APPLICATION_XML_UTF_8

List of usage examples for com.google.common.net MediaType APPLICATION_XML_UTF_8

Introduction

In this page you can find the example usage for com.google.common.net MediaType APPLICATION_XML_UTF_8.

Prototype

MediaType APPLICATION_XML_UTF_8

To view the source code for com.google.common.net MediaType APPLICATION_XML_UTF_8.

Click Source Link

Document

As described in <a href="http://www.ietf.org/rfc/rfc3023.txt">RFC 3023</a>, this constant ( application/xml ) is used for XML documents that are "unreadable by casual users."

Usage

From source file:org.apache.nifi.processors.evtx.ResultProcessor.java

public void process(ProcessSession session, ComponentLog logger, FlowFile updated, Exception exception,
        String name) {//from   w  w w. jav a 2s  .co m
    updated = session.putAttribute(updated, CoreAttributes.FILENAME.key(), name);
    updated = session.putAttribute(updated, CoreAttributes.MIME_TYPE.key(),
            MediaType.APPLICATION_XML_UTF_8.toString());
    if (exception == null) {
        session.transfer(updated, successRelationship);
    } else {
        logger.error(UNABLE_TO_PROCESS_DUE_TO, new Object[] { name, exception }, exception);
        session.transfer(updated, failureRelationship);
    }
}

From source file:com.github.avarabyeu.restendpoint.serializer.StringSerializer.java

/**
 * Checks whether mime types is supported by this serializer implementation
 *///from w w  w . j  a v a  2s.  c om
@Override
public boolean canRead(@Nonnull MediaType mimeType, Class<?> resultType) {
    MediaType type = mimeType.withoutParameters();
    return (type.is(MediaType.ANY_TEXT_TYPE) || MediaType.APPLICATION_XML_UTF_8.withoutParameters().is(type)
            || MediaType.JSON_UTF_8.withoutParameters().is(type)) && String.class.equals(resultType);
}

From source file:com.github.avarabyeu.restendpoint.serializer.StringSerializer.java

/**
 * Checks whether mime types is supported by this serializer implementation
 *///from  w w  w.ja  va  2  s .co  m
@Override
public boolean canRead(@Nonnull MediaType mimeType, Type resultType) {
    MediaType type = mimeType.withoutParameters();
    return (type.is(MediaType.ANY_TEXT_TYPE) || MediaType.APPLICATION_XML_UTF_8.withoutParameters().is(type)
            || MediaType.JSON_UTF_8.withoutParameters().is(type))
            && String.class.equals(TypeToken.of(resultType).getRawType());
}

From source file:lu.list.itis.dkd.assess.cloze.util.KodaAnnotation.java

/**
 * Returns all annotations KODA annotiates for the sentence.
 * @param sentence/*from  w w  w.ja va  2  s.c  om*/
 * @return
 * @throws IOException
 */
public static List<String> getAnnotations(String sentence, Language language) {
    //Choose ontology
    String ontology = "&ontology=";
    switch (language) {
    case DE:
        ontology += "DBPEDIA_EN_DE";
        break;
    case FR:
        ontology += "DBPEDIA_EN_FR";
        break;
    default:
        ontology += "DBPEDIA_EN_EN";
        break;
    }

    //Connect to Koda
    String encodedSentence = sentence;
    try {
        encodedSentence = URLEncoder.encode(sentence, java.nio.charset.StandardCharsets.UTF_8.toString());
    } catch (UnsupportedEncodingException e) {
        logger.log(Level.WARNING, "UTF-8 encoding failed!");
        e.printStackTrace();
    }
    String url = properties.getProperty("koda.url") + "text=" + encodedSentence + ontology;
    String source = UrlHelper.getSource(url, MediaType.APPLICATION_XML_UTF_8);
    //        String source = UrlHelper.getSource(url, MediaType.JSON_UTF_8); alternative

    return retrieveAnnotations(source, language);
}

From source file:com.github.avarabyeu.restendpoint.serializer.xml.JaxbSerializer.java

@Override
public String getMimeType() {
    return MediaType.APPLICATION_XML_UTF_8.toString();
}

From source file:com.github.avarabyeu.restendpoint.serializer.xml.JaxbSerializer.java

@Override
public boolean canRead(MediaType mimeType, Type resultType) {
    return mimeType.withoutParameters().is(MediaType.APPLICATION_XML_UTF_8.withoutParameters());
}

From source file:com.cognifide.aet.rest.XUnitServlet.java

private void generateXUnitAndRespondWithIt(DBKey dbKey, HttpServletResponse response, Suite suite)
        throws IOException {
    final MetadataToXUnitConverter converter = new MetadataToXUnitConverter(suite);

    try (InputStream result = generateXML(converter.convert())) {
        response.setContentType(MediaType.APPLICATION_XML_UTF_8.toString());
        response.getWriter().write(IOUtils.toString(result));
    } catch (IOException | JAXBException e) {
        LOGGER.error("Fatal exception while generating xUnit xml", e);
        response.setStatus(HttpURLConnection.HTTP_BAD_REQUEST);
        response.getWriter().write(responseAsJson("Unable to get xUnit for %s", dbKey.toString()));
    }//from  w w w. j  av  a 2  s  . c  o  m
}

From source file:org.opennms.smoketest.RequisitionUtils.java

public OnmsNodeList getNodesInDatabase(final String foreignSource) {
    try (HttpClientWrapper httpClient = HttpClientWrapper.create()) {
        httpClient.addBasicCredentials(OpenNMSSeleniumTestCase.BASIC_AUTH_USERNAME,
                OpenNMSSeleniumTestCase.BASIC_AUTH_PASSWORD);
        httpClient.usePreemptiveAuth();/*from  ww w. ja  v  a2 s  .  c om*/
        HttpGet request = new HttpGet(OpenNMSSeleniumTestCase.BASE_URL + "/opennms/rest/nodes");
        request.setHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML_UTF_8.toString());

        try (CloseableHttpResponse response = httpClient.execute(request)) {
            try (Reader reader = new InputStreamReader(response.getEntity().getContent())) {
                return JaxbUtils.unmarshal(OnmsNodeList.class, reader);
            }
        }
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}

From source file:org.geoserver.security.iride.service.util.builder.http.HttpPostBuilder.java

/**
 *
 * @param requestXml/*from   w w w  . jav  a2 s . co  m*/
 * @return
 * @throws IOException
 */
private RequestEntity createRequestEntity() throws IOException {
    return new StringRequestEntity(this.getContent(), MediaType.APPLICATION_XML_UTF_8.toString(),
            StandardCharsets.UTF_8.name());
}

From source file:org.geoserver.security.iride.service.policy.handler.IridePolicyRequestHandler.java

/**
 *
 * @param requestXml//  w  ww. j  a v  a2 s.c om
 * @return
 * @throws IOException
 */
private RequestEntity createPolicyRequestEntity(String requestXml) throws IOException {
    return new StringRequestEntity(requestXml, MediaType.APPLICATION_XML_UTF_8.toString(),
            StandardCharsets.UTF_8.name());
}