Package org.apache.shindig.gadgets

Examples of org.apache.shindig.gadgets.GadgetException


        if (shouldCache) {
          parsedCssCache.addElement(key, parsedCss);
        }
      } catch (ParseException pe) {
        // Bad input; not server's fault.
        throw new GadgetException(GadgetException.Code.CSS_PARSE_ERROR, pe,
            HttpResponse.SC_BAD_REQUEST);
      }
    }
    if (shouldCache) {
      return (CssTree.StyleSheet)parsedCss.clone();
View Full Code Here


        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

    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

          builder.append(token.text);
        }
      }
      parsedCss.add(builder.toString());
    } catch (ParseException pe) {
      throw new GadgetException(GadgetException.Code.CSS_PARSE_ERROR, pe,
          HttpResponse.SC_BAD_REQUEST);
    }
    return parsedCss;
  }
View Full Code Here

      // 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,
          HttpResponse.SC_BAD_REQUEST);
    }

    HttpRequest rcr = buildHttpRequest(request, URL_PARAM);
    if (rcr == null) {
      throw new GadgetException(GadgetException.Code.INVALID_PARAMETER,
          "No url paramater in request", HttpResponse.SC_BAD_REQUEST);     
    }
    HttpResponse results = requestPipeline.execute(rcr);
   
    if (results.isError()) {
      // Error: try the fallback. Particularly useful for proxied images.
      HttpRequest fallbackRcr = buildHttpRequest(request, FALLBACK_URL_PARAM);
      if (fallbackRcr != null) {
        results = requestPipeline.execute(fallbackRcr);
      }
    }
   
    if (contentRewriterRegistry != null) {
      try {
        results = contentRewriterRegistry.rewriteHttpResponse(rcr, results);
      } catch (RewritingException e) {
        throw new GadgetException(GadgetException.Code.INTERNAL_SERVER_ERROR, e,
            e.getHttpStatusCode());
      }
    }

    for (Map.Entry<String, String> entry : results.getHeaders().entries()) {
View Full Code Here

      connectDependencyGraph();
     
      // Clear caches.
      cache.clear();
    } catch (IOException e) {
      throw new GadgetException(GadgetException.Code.INVALID_PATH, e);
    }
  }
View Full Code Here

      StringBuilder sb = new StringBuilder();
      sb.append("Problems found processing features:\n");
      for (String problem : problems) {
        sb.append(problem).append('\n');
      }
      throw new GadgetException(GadgetException.Code.INVALID_CONFIG, sb.toString());
    }
  }
View Full Code Here

        String content = getResourceContent(resource);
        Uri parent = new UriBuilder().setScheme(RESOURCE_SCHEME).setPath(resource).toUri();
        loadFeature(parent, content);
      }
    } catch (IOException e) {
      throw new GadgetException(GadgetException.Code.INVALID_PATH, e);
    }
  }
View Full Code Here

    }
  }

  private void loadFile(File file) throws GadgetException, IOException {
    if (!file.exists() || !file.canRead()) {
      throw new GadgetException(GadgetException.Code.INVALID_CONFIG,
          "Feature file '" + file.getPath() + "' doesn't exist or can't be read");
    }
   
    File[] toLoad = null;
    if (file.isDirectory()) {
View Full Code Here

     
      while (!toTraverse.isEmpty()) {
        Pair<FeatureNode, Pair<Integer, String>> next = toTraverse.poll();
        String debug = next.two.two + (next.two.one > 0 ? " -> " : "") + next.one.name;
        if (next.one == this && next.two.one != 0) {
          throw new GadgetException(GadgetException.Code.INVALID_CONFIG,
              "Feature dep loop detected: " + debug);
        }
        // Breadth-first list of dependencies.
        this.transitiveDeps.add(next.one);
        this.nodeDepth = Math.max(this.nodeDepth, next.two.one);
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.GadgetException

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.