Package com.google.caja.lexer

Examples of com.google.caja.lexer.FetchedData$BinaryFetchedData


    servlet = new ProxyServlet(
        new UriFetcher() {
          public FetchedData fetch(ExternalReference ref, String mimeType)
              throws UriFetchException {
            FetchedData data = uriContent.get(ref.getUri());
            if (data == null) {
              throw new UriFetchException(ref, mimeType);
            }
            return data;
          }
View Full Code Here


    if (req.getRequestURI().contains(";")) {
      throw new ServletException("Invalid URL path parameter");
    }

    MessageQueue mq = new SimpleMessageQueue();
    FetchedData result = handle(args, mq);
    if (result == null) {
      closeBadRequest(resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, mq);
      return;
    }

    resp.setStatus(HttpServletResponse.SC_OK);

    String responseContentType = result.getContentType();
    if (result.getCharSet() != null) {
      responseContentType += ";charset=" + result.getCharSet();
    }
    if (containsNewline(responseContentType)) {
      throw new IllegalArgumentException(responseContentType);
    }

    try {
      byte[] content = result.getByteContent();
      resp.setContentType(responseContentType);
      resp.setContentLength(content.length);
      resp.setHeader(UMP.a, UMP.b);
      resp.setHeader("X-Content-Type-Options", "nosniff");
      resp.setHeader("Content-Disposition", "attachment; filename=f.txt");
View Full Code Here

   * @return the output content, or {@code null} if a serious error occurred
   *     that prevented the content from being generated.
   */
  public FetchedData handle(ContentHandlerArgs args,
                            MessageQueue mq) {
    FetchedData result = doHandle(args, mq);
    if (result == null) {
      ByteArrayOutputStream intermediateResponse = new ByteArrayOutputStream();
      Pair<ContentType, String> contentParams =
          getReturnedContentParams(args);
      OutputStreamWriter writer = new OutputStreamWriter(
View Full Code Here

          MessagePart.Factory.valueOf(
              CajaArguments.INPUT_MIME_TYPE.toString()));
      return null;
    }

    FetchedData inputFetchedData;
    try {
      inputFetchedData = uriFetcher.fetch(
          new ExternalReference(inputUri, FilePosition.UNKNOWN),
          expectedInputContentType);
    } catch (UriFetcher.UriFetchException ex) {
      ex.toMessageQueue(mq);
      return null;
    }

    if (!typeCheck.check(
            expectedInputContentType,
            inputFetchedData.getContentType())) {
      mq.addMessage(
          ServiceMessageType.UNEXPECTED_INPUT_MIME_TYPE,
          MessagePart.Factory.valueOf(expectedInputContentType),
          MessagePart.Factory.valueOf(inputFetchedData.getContentType()));
      return null;
    }

    ByteArrayOutputStream intermediateResponse = new ByteArrayOutputStream();
    Pair<String, String> contentInfo;
View Full Code Here

      InputSource is, PluginMeta meta) {
    try {
      if (null == meta) {
        return null;
      }
      FetchedData data = meta.getUriFetcher().fetch(
          new ExternalReference(is.getUri(), FilePosition.UNKNOWN), "*/*");
      return data.getTextualContent();
    } catch (UriFetchException e) {
      e.printStackTrace();
      // Failed heuristic, return null
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
View Full Code Here

   *     that prevented the content from being generated.
   */
  public FetchedData handle(FetchedData inputFetchedData,
                            ContentHandlerArgs args,
                            MessageQueue mq) {
    FetchedData result = doHandle(inputFetchedData, args, mq);
    if (result == null) {
      ByteArrayOutputStream intermediateResponse = new ByteArrayOutputStream();
      Pair<ContentType, String> contentParams =
          AbstractCajolingHandler.getReturnedContentParams(args);
      OutputStreamWriter writer = new OutputStreamWriter(
View Full Code Here

      InputSource is, PluginMeta meta) {
    try {
      if (null == meta) {
        return null;
      }
      FetchedData data = meta.getUriFetcher().fetch(
          new ExternalReference(is.getUri(), FilePosition.UNKNOWN), "*/*");
      return data.getTextualContent();
    } catch (UriFetchException e) {
      e.printStackTrace();
      // Failed heuristic, return null
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
View Full Code Here

   *     that prevented the content from being generated.
   */
  public FetchedData handle(FetchedData inputFetchedData,
                            ContentHandlerArgs args,
                            MessageQueue mq) {
    FetchedData result = doHandle(inputFetchedData, args, mq);
    if (result == null) {
      ByteArrayOutputStream intermediateResponse = new ByteArrayOutputStream();
      Pair<ContentType, String> contentParams =
          AbstractCajolingHandler.getReturnedContentParams(args);
      OutputStreamWriter writer = new OutputStreamWriter(
View Full Code Here

      InputSource is, PluginMeta meta) {
    try {
      if (null == meta) {
        return null;
      }
      FetchedData data = meta.getUriFetcher().fetch(
          new ExternalReference(is.getUri(), FilePosition.UNKNOWN), "*/*");
      return data.getTextualContent();
    } catch (UriFetchException e) {
      e.printStackTrace();
      // Failed heuristic, return null
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
View Full Code Here

      closeBadRequest(resp, HttpServletResponse.SC_BAD_REQUEST,
          "Supplied Content-type is null");
      return;
    }

    FetchedData fetchedData;
    try {
      fetchedData = FetchedData.fromStream(
          req.getInputStream(), req.getContentType(),
          req.getCharacterEncoding(),
          InputSource.UNKNOWN);
View Full Code Here

TOP

Related Classes of com.google.caja.lexer.FetchedData$BinaryFetchedData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.