Package org.apache.shindig.gadgets.spec

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


  }

  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


    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

    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

      }
    };

    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

    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

  private void mockModulePrefs(List<Feature> features) {
    EasyMock.expect(mockPrefs.getAllFeatures()).andReturn(features).anyTimes();
  }

  private Feature createMockFeature(String name, boolean required) {
    Feature feature = mock(Feature.class);
    EasyMock.expect(feature.getName()).andReturn(name).anyTimes();
    EasyMock.expect(feature.getRequired()).andReturn(required).anyTimes();
    return feature;
  }
View Full Code Here

  }

  @Test
  public void testIsAllowedFeature() throws Exception {
    mockGadget(ImmutableList.<Feature> of(), DEFAULT, TODO);
    Feature denied = createMockFeature("setprefs", true);
    Feature allowed = createMockFeature("foo", true);
    replay();
    assertFalse(enabledStore.isAllowedFeature(denied, mockGadget));
    assertTrue(enabledStore.isAllowedFeature(allowed, mockGadget));
    assertTrue(disabledStore.isAllowedFeature(denied, mockGadget));
    assertTrue(disabledStore.isAllowedFeature(allowed, mockGadget));
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

      }
    };

    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

    }

    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;
      if (f != null && f.getParams().containsKey(INCLUDE_TAGS)) {
        tagsVal = Sets.newTreeSet();
        for (String tag : Splitter.on(',').trimResults().omitEmptyStrings().split(f.getParam(INCLUDE_TAGS))) {
          tagsVal.add(tag.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 = (expiresVal == EXPIRES_HTTP || overrideVal < expiresVal) ?
              overrideVal : expiresVal;
        } catch (NumberFormatException e) {
          // Falls through to default.
          if ("HTTP".equalsIgnoreCase(f.getParam(EXPIRES).trim())) {
            expiresVal = EXPIRES_HTTP;
          }
        }
      }
      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.