Package org.apache.shindig.common.uri

Examples of org.apache.shindig.common.uri.Uri


    MessageBundle child = null;
    LocaleSpec localeSpec = spec.getModulePrefs().getLocale(locale);
    if (localeSpec == null) {
      return parent == null ? MessageBundle.EMPTY : parent;
    }
    Uri messages = localeSpec.getMessages();
    if (messages == null || messages.toString().length() == 0) {
      child = localeSpec.getMessageBundle();
    } else {
      child = fetchBundle(localeSpec, ignoreCache);
    }
    return new MessageBundle(parent, child);
View Full Code Here


    return getBundle(spec, new Locale(locale.getLanguage(), "ALL"), ignoreCache);
  }

  protected MessageBundle fetchBundle(LocaleSpec locale, boolean ignoreCache)
      throws GadgetException {
    Uri url = locale.getMessages();
    HttpRequest request = new HttpRequest(url).setIgnoreCache(ignoreCache);
    // Since we don't allow any variance in cache time, we should just force the cache time
    // globally. This ensures propagation to shared caches when this is set.
    request.setCacheTtl((int) (refresh / 1000));
View Full Code Here

   * automatically performing variable substitution on the spec for use elsewhere.
   *
   * @throws ProcessingException If there is a problem processing the gadget.
   */
  public Gadget process(GadgetContext context) throws ProcessingException {
    Uri url = context.getUrl();

    if (url == null) {
      throw new ProcessingException("Missing or malformed url parameter");
    }

    if (!"http".equalsIgnoreCase(url.getScheme()) && !"https".equalsIgnoreCase(url.getScheme())) {
      throw new ProcessingException("Unsupported scheme (must be http or https).");
    }

    if (blacklist.isBlacklisted(context.getUrl())) {
      LOG.info("Attempted to render blacklisted gadget: " + context.getUrl());
View Full Code Here

    }
    return ImmutableList.of();
  }

  private Set<String> retrieveServices(String endpoint) {
    Uri url = Uri.parse(endpoint + "?method=" + SYSTEM_LIST_METHODS_METHOD);
    HttpRequest request = new HttpRequest(url);
    try {
      HttpResponse response = fetcher.fetch(request);
      if (response.getHttpStatusCode() == HttpResponse.SC_OK) {
        return getServicesFromJsonResponse(response.getResponseAsString());
View Full Code Here

   * @throws GadgetException
   */
  private static String loadDataFromUrl(String url, HttpFetcher fetcher) throws GadgetException {
    try {
      logger.info("Attempting to load js from: " + url);
      Uri uri = Uri.parse(url);
      HttpRequest request = new HttpRequest(uri);
      HttpResponse response = fetcher.fetch(request);
      if (response.getHttpStatusCode() == HttpResponse.SC_OK) {
        return response.getResponseAsString();
      } else {
View Full Code Here

    OAuthAccessor accessor = accessorInfo.getAccessor();
    if (accessor.consumer.serviceProvider.accessTokenURL == null) {
      throw responseParams.oauthRequestException(OAuthError.BAD_OAUTH_CONFIGURATION,
          "No access token URL specified.");
    }
    Uri accessTokenUri = Uri.parse(accessor.consumer.serviceProvider.accessTokenURL);
    HttpRequest request = new HttpRequest(accessTokenUri);
    request.setMethod(accessorInfo.getHttpMethod().toString());
    if (accessorInfo.getHttpMethod() == HttpMethod.POST) {
      request.setHeader("Content-Type", OAuth.FORM_ENCODED);
    }

    List<Parameter> msgParams = Lists.newArrayList();
    msgParams.add(new Parameter(OAuth.OAUTH_TOKEN, accessor.requestToken));
    if (accessorInfo.getSessionHandle() != null) {
      msgParams.add(new Parameter(OAuthConstants.OAUTH_SESSION_HANDLE,
          accessorInfo.getSessionHandle()));
    }
    String receivedCallback = realRequest.getOAuthArguments().getReceivedCallbackUrl();
    if (!StringUtils.isBlank(receivedCallback)) {
      try {
        Uri parsed = Uri.parse(receivedCallback);
        String verifier = parsed.getQueryParameter(OAuthConstants.OAUTH_VERIFIER);
        if (verifier != null) {
          msgParams.add(new Parameter(OAuthConstants.OAUTH_VERIFIER, verifier));
        }
      } catch (IllegalArgumentException e) {
        throw responseParams.oauthRequestException(OAuthError.INVALID_REQUEST,
View Full Code Here

        throw new GadgetException(GadgetException.Code.INVALID_PARAMETER,
            "Unable to find a suitable version for the given manifest.");
      }
    }

    Uri specUri = manifest.getGadget(version);

    if (specUri == null) {
      throw new GadgetException(GadgetException.Code.INVALID_PARAMETER,
          "No gadget spec available for the given version.");
    }
View Full Code Here

        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);
        }
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
View Full Code Here

  public View(String name, List<Element> elements, Uri base) throws SpecParserException {
    this.name = name;
    this.base = base;

    boolean quirks = true;
    Uri href = null;
    String contentType = null;
    ContentType type = null;
    int preferredHeight = 0;
    int preferredWidth = 0;
    String auth = null;
View Full Code Here

TOP

Related Classes of org.apache.shindig.common.uri.Uri

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.