Examples of GadgetException


Examples of org.apache.shindig.gadgets.GadgetException

      refreshInterval = 0;
    } else if (request.getParameter(REFRESH_PARAM) != null) {
      try {
        refreshInterval =  Integer.valueOf(request.getParameter(REFRESH_PARAM));
      } catch (NumberFormatException nfe) {
        throw new GadgetException(GadgetException.Code.INVALID_PARAMETER,
            "refresh parameter is not a number");
      }
    } else {
      refreshInterval = Math.max(60 * 60, (int)(results.getCacheTtl() / 1000L));
    }
View Full Code Here

Examples of org.apache.shindig.gadgets.GadgetException

    // Rewrite the response
    if (contentRewriterRegistry != null) {
      try {
        results = contentRewriterRegistry.rewriteHttpResponse(rcr, results);
      } catch (RewritingException e) {
        throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e);
      }
    }

    // Serialize the response
    String output = convertResponseToJson(rcr.getSecurityToken(), request, results);
View Full Code Here

Examples of org.apache.shindig.gadgets.GadgetException

    if (headerData.length() > 0) {
      String[] headerList = headerData.split("&");
      for (String header : headerList) {
        String[] parts = header.split("=");
        if (parts.length != 2) {
          throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR,
              "Malformed header specified,");
        }
        String headerName = Utf8UrlCoder.decode(parts[0]);
        if (!HttpRequestHandler.BAD_HEADERS.contains(headerName.toUpperCase())) {
          req.addHeader(headerName, Utf8UrlCoder.decode(parts[1]));
View Full Code Here

Examples of org.apache.shindig.gadgets.GadgetException

   * @return A valid token for the given input.
   */
  private SecurityToken extractAndValidateToken(HttpServletRequest request) throws GadgetException {
    SecurityToken token = new AuthInfo(request).getSecurityToken();
    if (token == null) {
      throw new GadgetException(GadgetException.Code.INVALID_SECURITY_TOKEN);
    }
    return token;
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.GadgetException

  @Override
  public Document parseDomImpl(String source) throws GadgetException {
    try {
      return parseDomInternal(source);
    } catch (Exception e) {
      throw new GadgetException(GadgetException.Code.HTML_PARSE_ERROR, e);
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.GadgetException

      parser.setFeature("http://apache.org/xml/features/scanner/notify-char-refs", true);
      parser.setFeature("http://cyberneko.org/html/features/scanner/notify-builtin-refs", true);
      parser.parse(input, fragment);
      return fragment;
    } catch (Exception e) {
      throw new GadgetException(GadgetException.Code.HTML_PARSE_ERROR, e);
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.GadgetException

      // Force embedded images and the like to their own domain to avoid XSS
      // in gadget domains.
      String msg = "Embed request for url " + getParameter(request, URL_PARAM, "") +
          " made to wrong domain " + host;
      logger.info(msg);
      throw new GadgetException(GadgetException.Code.INVALID_PARAMETER, msg);
    }

    HttpRequest rcr = buildHttpRequest(request);
    HttpResponse results = requestPipeline.execute(rcr);
    if (contentRewriterRegistry != null) {
      try {
        results = contentRewriterRegistry.rewriteHttpResponse(rcr, results);
      } catch (RewritingException e) {
        throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e);
      }
    }

    setResponseHeaders(request, response, results);
View Full Code Here

Examples of org.apache.shindig.gadgets.GadgetException

        URI gadgetUri = new URI(url);
        JSONObject oauthConfig = oauthConfigs.getJSONObject(url);
        storeConsumerInfos(gadgetUri, oauthConfig);
      }
    } catch (JSONException e) {
      throw new GadgetException(GadgetException.Code.OAUTH_STORAGE_ERROR, e);
    } catch (URISyntaxException e) {
      throw new GadgetException(GadgetException.Code.OAUTH_STORAGE_ERROR, e);
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.GadgetException

    BasicOAuthStoreConsumerKeyAndSecret cks = consumerInfos.get(pk);
    if (cks == null) {
      cks = defaultKey;
    }
    if (cks == null) {
      throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR,
          "No key for gadget " + securityToken.getAppUrl() + " and service " + serviceName);
    }
    OAuthConsumer consumer = null;
    if (cks.getKeyType() == KeyType.RSA_PRIVATE) {
      consumer = new OAuthConsumer(null, cks.getConsumerKey(), null, provider);
View Full Code Here

Examples of org.apache.shindig.gadgets.GadgetException

        parsedCss = parseImpl(content);
        if (shouldCache) {
          parsedCssCache.addElement(key, parsedCss);
        }
      } catch (ParseException pe) {
        throw new GadgetException(GadgetException.Code.CSS_PARSE_ERROR, pe);
      }
    }
    if (shouldCache) {
      try {
        return (CssTree.StyleSheet)parsedCss.clone();
      } catch (RuntimeException re) {
        // TODO - FIXME ASAP!
        log.log(Level.INFO,
            "Workaround for Caja bug http://code.google.com/p/google-caja/issues/detail?id=985&start=200\n" + re.getMessage());
        try {
          return parseImpl(content);
        } catch (ParseException pe) {
          throw new GadgetException(GadgetException.Code.CSS_PARSE_ERROR, pe);
        }
      }
    }
    return parsedCss;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.