Package org.apache.shindig.gadgets.process

Examples of org.apache.shindig.gadgets.process.ProcessingException


  }

  public GadgetsHandlerApi.BaseResponse createErrorResponse(Uri uri, Exception e,
      String defaultMsg) {
    if (e instanceof ProcessingException) {
      ProcessingException processingExc = (ProcessingException) e;
      return createErrorResponse(uri, processingExc.getHttpStatusCode(),
          processingExc.getMessage());
    }
    LOG.log(Level.WARNING, "Error handling request: " + (uri != null ? uri.toString() : ""), e);
    return createErrorResponse(uri, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, defaultMsg);
  }
View Full Code Here


  public void testMetadataMultipleGadgetsWithFailure() throws Exception {
    registerGadgetsHandler(null);
    setupGadgetAdminStore();
    setupMockRegistry(Lists.newArrayList("core"));
    JSONObject request = makeMetadataRequest("en", "US", null, GADGET1_URL, GADGET2_URL);
    processor.exceptions.put(FakeProcessor.SPEC_URL2, new ProcessingException("broken",
            HttpServletResponse.SC_BAD_REQUEST));
    RpcHandler operation = registry.getRpcHandler(request);
    Object responseObj = operation.execute(emptyFormItems, authContext, converter).get();
    JSONObject response = new JSONObject(converter.convertToString(responseObj));
View Full Code Here

    JSONObject input = new JSONObject()
        .put("context", createContext("en", "US"))
        .put("gadgets", gadgets);

    processor.exceptions.put(FakeProcessor.SPEC_URL2,
        new ProcessingException("broken", HttpServletResponse.SC_BAD_REQUEST));

    JSONObject response = jsonRpcHandler.process(input);

    JSONArray outGadgets = response.getJSONArray("gadgets");
View Full Code Here

    assertEquals(HttpServletResponse.SC_BAD_REQUEST, results.getHttpStatusCode());
  }

  @Test
  public void handlesProcessingExceptionGracefully() {
    processor.exception = new ProcessingException("foo", HttpServletResponse.SC_FORBIDDEN);
    RenderingResults results = renderer.render(makeContext("html"));
    assertEquals(RenderingResults.Status.ERROR, results.getStatus());
    assertEquals("foo", results.getErrorMessage());
    assertEquals(HttpServletResponse.SC_FORBIDDEN, results.getHttpStatusCode());
  }
View Full Code Here

            + "}}");
    HttpRequest httpRequest = new HttpRequest(Uri.parse("http://www.example.org/somecontent"));
    httpRequest.setMethod("GET");
    expect(pipeline.execute(eqRequest(httpRequest))).andReturn(builder.create()).anyTimes();
    expect(mockProcessor.process(EasyMock.isA(GadgetContext.class))).andThrow(
            new ProcessingException("error", HttpServletResponse.SC_BAD_REQUEST)).anyTimes();

    replay();
    RpcHandler operation = registry.getRpcHandler(request);

    HttpRequestHandler.HttpApiResponse httpApiResponse =
View Full Code Here

  }

  @Override
  public Gadget process(GadgetContext context) throws ProcessingException {

    ProcessingException exception = exceptions.get(context.getUrl());
    if (exception != null) {
      throw exception;
    }

    try {
View Full Code Here

    Gadget gadget = processor.process(context);

    boolean needIfrUrls = isFieldIncluded(fields, "iframeurls");
    if (needIfrUrls) {
      if(!gadgetAdminStore.checkFeatureAdminInfo(gadget)) {
        throw new ProcessingException("Gadget is not trusted to render in this container.",
              HttpResponse.SC_BAD_REQUEST);
      }
    }
    Map<String, Uri> uris = needIfrUrls ?
            iframeUriManager.makeAllRenderingUris(gadget) : null;
View Full Code Here

    if (isFieldIncluded(fields, "jsContent")) {
      JsResponse response;
      try {
        response = jsPipeline.execute(jsRequestBuilder.build(jsUri, servedUri.getAuthority()));
      } catch (JsException e) {
        throw new ProcessingException(e.getMessage(), e.getStatusCode());
      }
      content = response.toJsString();
      if (response.isProxyCacheable()) {
        expireMs = getDefaultExpiration();
      }
View Full Code Here

      if (isFieldIncluded(fields, "proxyContent")) {
        httpResponse = proxyHandler.fetch(proxyUri);
      }
    } catch (IOException e) {
      LOG.log(Level.INFO, "Failed to fetch resource " + proxyUri.getResource().toString(), e);
      throw new ProcessingException("Error getting response content", HttpResponse.SC_BAD_GATEWAY);
    } catch (GadgetException e) {
      // TODO: Clean this log if it is too spammy
      LOG.log(Level.INFO, "Failed to fetch resource " + proxyUri.getResource().toString(), e);
      throw new ProcessingException("Error getting response content", HttpResponse.SC_BAD_GATEWAY);
    }

    try {
      return createProxyResponse(uris.get(0), httpResponse, fields,
          getProxyExpireMs(proxyUri, httpResponse));
    } catch (IOException e) {
      // Should never happen!
      LOG.log(Level.WARNING, "Error creating proxy response", e);
      throw new ProcessingException("Error getting response content",
          HttpResponse.SC_INTERNAL_SERVER_ERROR);
    }
  }
View Full Code Here

   * Verify request parameter are defined.
   */
  protected void verifyBaseParams(GadgetsHandlerApi.BaseRequest request, boolean checkUrl)
      throws ProcessingException {
    if (checkUrl && request.getUrl() == null) {
      throw new ProcessingException("Missing url parameter", HttpResponse.SC_BAD_REQUEST);
    }
    if (request.getContainer() == null) {
      throw new ProcessingException("Missing container parameter", HttpResponse.SC_BAD_REQUEST);
    }
    if (request.getFields() == null) {
      throw new ProcessingException("Missing fields parameter", HttpResponse.SC_BAD_REQUEST);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.process.ProcessingException

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.