Example usage for org.apache.http.entity ContentType TEXT_HTML

List of usage examples for org.apache.http.entity ContentType TEXT_HTML

Introduction

In this page you can find the example usage for org.apache.http.entity ContentType TEXT_HTML.

Prototype

ContentType TEXT_HTML

To view the source code for org.apache.http.entity ContentType TEXT_HTML.

Click Source Link

Usage

From source file:eu.matejkormuth.crawler2.Document.java

static Document create(String contentType, String contentEncoding, long contentLength, InputStream content) {
    if (ContentType.TEXT_HTML.getMimeType().equalsIgnoreCase(contentType)) {
        return createHtmlDocument(contentType, contentEncoding, contentLength, content);
    } else {/*from   w  ww.  j  av  a2  s.c  om*/
        return createBinaryDocument(contentType, contentEncoding, contentLength, content);
    }
}

From source file:eu.matejkormuth.crawler2.documents.HtmlDocument.java

@Override
public ContentType getContentType() {
    return ContentType.TEXT_HTML;
}

From source file:com.epam.reportportal.service.ReportPortalErrorHandlerTest.java

@Test(expected = InternalReportPortalClientException.class)
public void handle_not_json() throws Exception {
    //  given:/*from   ww w. j av  a 2s  .  c o  m*/
    LinkedListMultimap<String, String> invalidHeaders = LinkedListMultimap.create();
    invalidHeaders.put(HttpHeaders.CONTENT_TYPE, ContentType.TEXT_HTML.getMimeType());

    Response<ByteSource> invalidResponse = createFakeResponse(200, invalidHeaders);

    //  when:
    reportPortalErrorHandler.handle(invalidResponse);
}

From source file:com.android.tools.swing.ui.NavigationComponent.java

public NavigationComponent() {
    setEditable(false);//from w ww.j a v  a2  s. c  om
    setContentType(ContentType.TEXT_HTML.getMimeType());
    putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);

    // Disable links decoration.
    ((HTMLDocument) getDocument()).getStyleSheet().addRule("a { text-decoration:none; }");

    addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
                return;
            }

            int idx = Integer.parseInt(e.getDescription());
            final T item = myItemStack.get(idx);

            for (final ItemListener<T> listener : myItemListeners) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        listener.itemSelected(item);
                    }
                });
            }
        }
    });
}

From source file:com.braffdev.server.core.http.environment.operator.SendStatusOperator.java

/**
 * @param code//w  w w  .ja  va2  s. c  o m
 * @param args
 */
public void sendStatus(int code, String... args) {
    if (code != HttpStatus.SC_NO_CONTENT) {
        String text = this.statusMessageBuilder.build(code, args);
        StringEntity entity = new StringEntity(text, ContentType.TEXT_HTML);
        this.response.setEntity(entity);
    }
}

From source file:onl.area51.httpd.action.Actions.java

static HttpEntity errorEntity(Request req, int sc, String message) {
    req.getHttpResponse().setStatusCode(sc);
    return new StringEntity("<html><body><div style=\"align:center;\"><img src=\"/." + sc + ".png\"/><p>"
            + message + "</p></div></body></html>", ContentType.TEXT_HTML);
}

From source file:com.difference.historybook.importer.indexer.Indexer.java

/**
 * Uploads the given HistoryRecord to the search index service
 * //from   www. j  av  a 2  s  .  c o  m
 * @param record HistoryRecord to send to index. Should have a body.
 */
public void index(HistoryRecord record) {
    try {
        if (record.getBody() != null) {
            String url = baseUrl + "/collections/" + collection + "/"
                    + URLEncoder.encode(record.getUrl(), Charsets.UTF_8.name());
            if (record.getTimestamp() != null) {
                url = url + "/" + URLEncoder.encode(record.getTimestamp(), Charsets.UTF_8.name());
            }
            Request.Post(url).bodyString(record.getBody(), ContentType.TEXT_HTML).execute();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:org.ambraproject.wombat.service.FreemarkerMailServiceImpl.java

@Override
public Multipart createContent(Site site, String templateFilename, Model context)
        throws IOException, MessagingException {
    Template textTemplate = getEmailTemplate(site, "txt", templateFilename);
    Template htmlTemplate = getEmailTemplate(site, "html", templateFilename);

    // Create a "text" Multipart message
    Multipart mp = createPartForMultipart(textTemplate, context, "alternative", ContentType.TEXT_PLAIN);

    // Create a "HTML" Multipart message
    Multipart htmlContent = createPartForMultipart(htmlTemplate, context, "related", ContentType.TEXT_HTML);

    BodyPart htmlPart = new MimeBodyPart();
    htmlPart.setContent(htmlContent);//from   w  w  w  .  j av a  2  s  .  c o m
    mp.addBodyPart(htmlPart);

    return mp;
}