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

    GadgetsHandlerApi.RenderingType type = GadgetsHandlerApi.RenderingType.DEFAULT;
    if (value != null) {
      try {
        type = GadgetsHandlerApi.RenderingType.valueOf(value.toUpperCase());
      } catch (IllegalArgumentException e) {
        throw new ProcessingException("Error parsing rendering type parameter",
            HttpServletResponse.SC_BAD_REQUEST);
      }
    }
    return type;
  }
View Full Code Here

    public AbstractRequest(String url, BaseRequestItem request, List<String> defaultFields)
        throws ProcessingException {
      try {
        this.uri = (url != null ? Uri.parse(url) : null);
      } catch (UriException e) {
        throw new ProcessingException("Bad url - " + url, HttpServletResponse.SC_BAD_REQUEST);
      }
      this.request = request;
      this.container = request.getParameter(Param.CONTAINER.getName());
      this.fields = processFields(request, defaultFields);
    }
View Full Code Here

      Integer intVal = null;
      if (val != null) {
        try {
          intVal = Integer.valueOf(val);
        } catch (NumberFormatException e) {
          throw new ProcessingException("Error parsing " + field + " parameter",
              HttpServletResponse.SC_BAD_REQUEST);
        }
      }
      return intVal;
    }
View Full Code Here

  public void testBadGadget() throws Exception {
    HttpRequest request = new HttpRequest(DEST_URL);
    request.setSecurityToken(securityToken);
    request.setOAuthArguments(new OAuthArguments());
    expect(processor.process(eqContext(securityToken, request.getOAuthArguments())))
        .andThrow(new ProcessingException("doh", HttpServletResponse.SC_BAD_REQUEST));

    control.replay();

    try {
      getGenerator().generateCallback(fetcherConfig, "base", request, responseParams);
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

        .put(createGadget(SPEC_URL2.toString(), 1, null));
    JSONObject input = new JSONObject()
        .put("context", createContext("en", "US"))
        .put("gadgets", gadgets);

    processor.exceptions.put(SPEC_URL2.toJavaUri(), new ProcessingException("broken"));

    JSONObject response = jsonRpcHandler.process(input);

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

    assertEquals(TYPE_URL_HREF, results.getRedirect());
  }

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

      super(null, null, null, null);
    }

    @Override
    public Gadget process(GadgetContext context) throws ProcessingException {
      ProcessingException exception = exceptions.get(context.getUrl());
      if (exception != null) {
        throw exception;
      }

      try {
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.