Package org.apache.shindig.gadgets.spec

Examples of org.apache.shindig.gadgets.spec.GadgetSpec


      LOG.info("Attempted to render blacklisted gadget: " + context.getUrl());
      throw new ProcessingException("The requested gadget is unavailable");
    }

    try {
      GadgetSpec spec = gadgetSpecFactory.getGadgetSpec(context);
      spec = substituter.substitute(context, spec);

      return new Gadget()
          .setContext(context)
          .setGadgetFeatureRegistry(gadgetFeatureRegistry)
View Full Code Here


    if (rawxml != null) {
      // Set URI to a fixed, safe value (localhost), preventing a gadget rendered
      // via raw XML (eg. via POST) to be rendered on a locked domain of any other
      // gadget whose spec is hosted non-locally.
      try {
        return new GadgetSpec(RAW_GADGET_URI, XmlUtil.parse(rawxml), rawxml);
      } catch (XmlException e) {
        throw new SpecParserException(e);
      }
    }
View Full Code Here

      String content = response.getResponseAsString();
      Element element = XmlUtil.parse(content);
      if (ApplicationManifest.NAMESPACE.equals(element.getNamespaceURI())) {
        return new ApplicationManifest(uri, element);
      }
      return new GadgetSpec(uri, element, content);
    } catch (XmlException e) {
      throw new SpecParserException(e);
    }
  }
View Full Code Here

    return buf.toString();
  }

  public String getIframeUrl(Gadget gadget) {
    GadgetContext context = gadget.getContext();
    GadgetSpec spec = gadget.getSpec();
    String url = context.getUrl().toString();
    View view = gadget.getCurrentView();
    View.ContentType type;
    type = (view == null) ? View.ContentType.HTML : view.getType();

    UriBuilder uri;
    switch (type) {
      case URL:
        uri = new UriBuilder(view.getHref());
        break;
      case HTML:
      case HTML_SANITIZED:
      default:
        Uri iframeBaseUri = iframeBaseUris.get(context.getContainer());
        uri = iframeBaseUri != null ? new UriBuilder(iframeBaseUri) : new UriBuilder();
        String host = lockedDomainService.getLockedDomainForGadget(gadget, context.getContainer());
        if (host != null) {
          uri.setAuthority(host);
        }
        break;
    }

    uri.addQueryParameter("container", context.getContainer());
    if (context.getModuleId() != 0) {
      uri.addQueryParameter("mid", Integer.toString(context.getModuleId()));
    }
    if (context.getIgnoreCache()) {
      uri.addQueryParameter("nocache", "1");
    } else {
      uri.addQueryParameter("v", spec.getChecksum());
    }

    uri.addQueryParameter("lang", context.getLocale().getLanguage());
    uri.addQueryParameter("country", context.getLocale().getCountry());
    uri.addQueryParameter("view", context.getView());
View Full Code Here

    return contentRewriters.get(container);
   }

  public ContentRewriterFeature get(HttpRequest request) {
    final Uri gadgetUri = request.getGadget();
    GadgetSpec spec;
    if (gadgetUri != null) {
      try {
        GadgetContext context = new GadgetContext() {
          @Override
          public Uri getUrl() {
View Full Code Here

   * Lookup information contained in the gadget spec.
   */
  private OAuthServiceProvider lookupSpecInfo(SecurityToken securityToken, OAuthArguments arguments,
      AccessorInfoBuilder accessorBuilder, OAuthResponseParams responseParams)
      throws OAuthRequestException {
    GadgetSpec spec = findSpec(securityToken, arguments, responseParams);
    OAuthSpec oauthSpec = spec.getModulePrefs().getOAuthSpec();
    if (oauthSpec == null) {
      throw responseParams.oauthRequestException(OAuthError.BAD_OAUTH_CONFIGURATION,
          "Failed to retrieve OAuth URLs, spec for gadget " +
          securityToken.getAppUrl() + " does not contain OAuth element.");
    }
View Full Code Here

  public GadgetSpec getGadgetSpec(GadgetContext context) throws GadgetException {
    Uri gadgetUri = getGadgetUri(context);
    if (RAW_GADGET_URI.equals(gadgetUri)) {
      try {
        String rawxml = context.getParameter(RAW_GADGETSPEC_XML_PARAM_NAME);
        return new GadgetSpec(gadgetUri, XmlUtil.parse(rawxml), rawxml);
      } catch (XmlException e) {
        throw new SpecParserException(e);
      }
    }
View Full Code Here

    if (content.length() >= BOM_ENTITY.length() &&
        content.substring(0, BOM_ENTITY.length()).equalsIgnoreCase(BOM_ENTITY)) {
      content = content.substring(BOM_ENTITY.length());
    }
    Element element = XmlUtil.parse(content);
    return new GadgetSpec(query.getSpecUri(), element, content);
  }
View Full Code Here

    Injector injector = Guice.createInjector(new ParseModule(), new PropertiesModule());
    parser = injector.getInstance(GadgetHtmlParser.class);
  }

  private Gadget makeGadgetWithSpec(String gadgetXml) throws GadgetException {
    GadgetSpec spec = new GadgetSpec(SPEC_URL, gadgetXml);
    Gadget gadget = new Gadget()
        .setContext(context)
        .setPreloads(ImmutableList.<PreloadedData>of())
        .setSpec(spec)
        .setCurrentView(spec.getView(GadgetSpec.DEFAULT_VIEW))
        .setGadgetFeatureRegistry(featureRegistry);

    // Convenience: by default expect no features requested, by gadget or extern.
    // expectFeatureCalls(...) resets featureRegistry if called again.
    expectFeatureCalls(gadget,
View Full Code Here

  @Override
  public void setUp() throws Exception {
    super.setUp();
   
    gadget = new Gadget().setContext(unsanitaryGadgetContext);
    gadget.setSpec(new GadgetSpec(Uri.parse("www.example.org/gadget.xml"),
        "<Module><ModulePrefs title=''/><Content type='x-html-sanitized'/></Module>"));
    gadget.setCurrentView(gadget.getSpec().getViews().values().iterator().next());
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.spec.GadgetSpec

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.