Package org.apache.shindig.gadgets.spec

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


  private GadgetSpec findSpec(final SecurityToken securityToken, final OAuth2Arguments arguments,
      final Uri gadgetUri) throws OAuth2RequestException {
    final String method = "findSpec";
    log.entering(CLASS, method, new Object[] { arguments, gadgetUri });

    GadgetSpec ret;

    try {
      final GadgetContext context = new OAuth2GadgetContext(securityToken, arguments, gadgetUri);
      ret = this.specFactory.getGadgetSpec(context);
    } catch (final GadgetException e) {
View Full Code Here


    public static class GadgetSpecValidator implements Validator, Serializable {

        public void validate(UIFormInput uiInput) throws Exception {
            try {
                new GadgetSpec(Uri.parse("http://exoplatform.org"), (String) uiInput.getValue());
            } catch (Exception se) {
                throw new MessageException(new ApplicationMessage("UIGadgetEditor.msg.invalidSpec", null,
                        ApplicationMessage.WARNING));
            }
        }
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

    return UrlValidationStatus.VALID_UNVERSIONED;
  }

  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 defaultFeature;
  }

  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

    }

    public JSONObject call() throws RpcException {
      try {
        Gadget gadget = processor.process(context);
        GadgetSpec spec = gadget.getSpec();
        return getGadgetJson(gadget,spec);
      } catch (Exception e) {
        throw new RpcException(context, e);
      }
    }
View Full Code Here

                Uri uri = RAW_GADGET_URI;
                // For accelerate page, pass in page url instead of fake one:
                if (HtmlAccelServlet.isAccel(context)) {
                    uri = context.getUrl();
                }
                return new GadgetSpec(uri, XmlUtil.parse(rawxml), rawxml);
            } catch (XmlException e) {
                throw new SpecParserException(e);
            }
        }
View Full Code Here

    }

    @Override
    protected GadgetSpec parse(String content, Query query) throws XmlException, GadgetException {
        Element element = XmlUtil.parse(content);
        return new GadgetSpec(query.getSpecUri(), element, content);
    }
View Full Code Here

        "</Module>";
  private GadgetSpec spec;

  @Before
  public void setUp() throws Exception {
    spec = new GadgetSpec(Uri.parse("#"), DEFAULT_XML);
  }
View Full Code Here

  private final CaptureRewriter captureRewriter = new CaptureRewriter();
  private final CaptureRewriter accelRewriter = new CaptureRewriter();
  private HtmlRenderer renderer;

  private Gadget makeGadget(String content) throws GadgetException {
    GadgetSpec spec = new GadgetSpec(SPEC_URL,
        "<Module><ModulePrefs title=''/><Content><![CDATA[" + content + "]]></Content></Module>");

    return new Gadget()
        .setSpec(spec)
        .setContext(CONTEXT)
        .setCurrentView(spec.getView("default"));
  }
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.