Package org.apache.shindig.gadgets.spec

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


    return getLockedDomainPrefix(gadget) + suffix;
  }

  private String getLockedDomainParticipants(Gadget gadget) throws GadgetException {
    Map<String, Feature> features = gadget.getSpec().getModulePrefs().getFeatures();
    Feature ldFeature = features.get("locked-domain");

    // This gadget is always a participant.
    Set<String> filtered = new TreeSet<String>();
    filtered.add(gadget.getSpec().getUrl().toString().toLowerCase());

    if (ldFeature != null) {
      Collection<String> participants = ldFeature.getParamCollection("participant");
      for (String participant : participants) {
        // be picky, this should be a valid uri
        try {
          Uri.parse(participant);
        } catch (UriException e) {
View Full Code Here


  }

  public void rewrite(Gadget gadget, MutableContent content) throws RewritingException {
    Map<String, Feature> directFeatures = gadget.getViewFeatures();

    Feature feature = directFeatures.get(TEMPLATES_FEATURE_NAME);
    if (feature == null && directFeatures.containsKey(OSML_FEATURE_NAME)) {
      feature = directFeatures.get(OSML_FEATURE_NAME);
    }

    if (feature != null && isServerTemplatingEnabled(feature)) {
View Full Code Here

   */
  public ContentRewriterFeature(GadgetSpec spec, String defaultInclude,
                                String defaultExclude,
                                String defaultExpires,
      Set<String> defaultTags) {
    Feature f = null;
    if (spec != null) {
      f = spec.getModulePrefs().getFeatures().get("content-rewrite");
    }
    String includeRegex = normalizeParam(defaultInclude, null);
    String excludeRegex = normalizeParam(defaultExclude, null);

    this.includeTags = ImmutableSortedSet.copyOf(defaultTags);

    List<String> expiresOptions = Lists.newArrayListWithCapacity(3);
    if (f != null) {
      if (f.getParams().containsKey(INCLUDE_URLS)) {
        includeRegex = normalizeParam(f.getParams().get(INCLUDE_URLS), includeRegex);
      }

      // Note use of default for exclude as null here to allow clearing value in the
      // presence of a container default.
      if (f.getParams().containsKey(EXCLUDE_URLS)) {
        excludeRegex = normalizeParam(f.getParams().get(EXCLUDE_URLS), null);
      }
      String includeTagList = f.getParams().get(INCLUDE_TAGS);
      if (includeTagList != null) {
        Set<String> tags = Sets.newTreeSet();
        for (String tag : includeTagList.split(",")) {
          if (tag != null) {
            tags.add(tag.trim().toLowerCase());
          }
        }
        includeTags = tags;
      }

      if (f.getParams().containsKey(EXPIRES)) {
        expiresOptions.add(normalizeParam(f.getParams().get(EXPIRES), null));
      }
    }

    expiresOptions.add(defaultExpires);
    expiresOptions.add(EXPIRES_DEFAULT);
View Full Code Here

      }
    };

    Gadget gadget = makeGadgetWithSpec(gadgetXml).setContext(context);
    reset(gadgetAdminStore);
    Feature denied = mock(Feature.class);
    expect(denied.getName()).andReturn("hello");
    expect(gadgetAdminStore.checkFeatureAdminInfo(isA(Gadget.class))).andReturn(true);
    expect(gadgetAdminStore.isAllowedFeature(eq(denied), isA(Gadget.class))).andReturn(false);
    replay();

    FeatureResource fooResource = inline("foo-content", "foo-debug");
View Full Code Here

  public void rewrite(Gadget gadget, MutableContent content) throws RewritingException {
    Map<String, Feature> directFeatures = gadget.getSpec().getModulePrefs()
        .getFeatures();

    Feature feature = directFeatures.get(TEMPLATES_FEATURE_NAME);
    if (feature == null && directFeatures.containsKey(OSML_FEATURE_NAME)) {
      feature = directFeatures.get(OSML_FEATURE_NAME);
    }
   
    if (feature != null && isServerTemplatingEnabled(feature)) {
View Full Code Here

    }
   
    Config(GadgetSpec spec, Config defaultConfig) {
      this.onlyAllowExcludes = defaultConfig.onlyAllowExcludes;
     
      Feature f = spec.getModulePrefs().getFeatures().get("content-rewrite");
     
      // Include overrides.
      // Note: Shindig originally supported the plural versions with regular
      // expressions. But the OpenSocial specification v0.9 allows for singular
      // spellings, with multiple values. Plus they are case insensitive substrings.
      // For backward compatibility, if the singular versions are present they
      // will override the plural versions. 10/6/09
      String includeRegex = defaultConfig.includes.param;
      Collection<String> includeUrls = Lists.newArrayList();
      if (f != null && !onlyAllowExcludes) {
        if (f.getParams().containsKey(INCLUDE_URLS)) {
          includeRegex = f.getParam(INCLUDE_URLS);
        }
        Collection<String> paramUrls = f.getParamCollection(INCLUDE_URL);
        for (String url : paramUrls) {
          includeUrls.add(url.trim().toLowerCase());
        }
      }
      this.includes = getMatchBundle(includeRegex, includeUrls);
     
      // Exclude overrides. Only use the exclude regex specified by the
      // gadget spec if !onlyAllowExcludes.
      String excludeRegex = defaultConfig.excludes.param;
      Collection<String> excludeUrls = Lists.newArrayList();
      if (f != null) {
        if (f.getParams().containsKey(EXCLUDE_URLS)) {
          excludeRegex = f.getParam(EXCLUDE_URLS);
        }
        Collection<String> eParamUrls = f.getParamCollection(EXCLUDE_URL);
        for (String url : eParamUrls) {
          excludeUrls.add(url.trim().toLowerCase());
        }
      }
      this.excludes = getMatchBundle(excludeRegex, excludeUrls);
     
      // Spec-specified include tags.
      Set<String> tagsVal = null;
      if (f != null && f.getParams().containsKey(INCLUDE_TAGS)) {
        tagsVal = Sets.newTreeSet();
        for (String tag : StringUtils.split(f.getParam(INCLUDE_TAGS), ',')) {
          if (!StringUtils.isEmpty(tag)) {
            tagsVal.add(tag.trim().toLowerCase());
          }
        }
        if (onlyAllowExcludes) {
          // Only excludes are allowed. Keep only subset of
          // specified tags that are in the defaults.
          tagsVal.retainAll(defaultConfig.includeTags);
        }
      } else {
        tagsVal = ImmutableSortedSet.copyOf(defaultConfig.includeTags);
      }
      this.includeTags = tagsVal;

      // Let spec/feature override if present and smaller than default.
      int expiresVal = defaultConfig.expires;
      if (f != null && f.getParams().containsKey(EXPIRES)) {
        try {
          int overrideVal = Integer.parseInt(f.getParam(EXPIRES));
          expiresVal = Math.min(overrideVal, expiresVal);
        } catch (NumberFormatException e) {
          // Falls through to default.
          if ("HTTP".equalsIgnoreCase(f.getParam(EXPIRES).trim())) {
            expiresVal = EXPIRES_DEFAULT;
          }
        }
      }
      this.expires = expiresVal;
View Full Code Here

TOP

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

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.