Package org.apache.shindig.gadgets

Examples of org.apache.shindig.gadgets.UserPrefs


    if (context.getCajoled()) {
      addParam(uri, Param.CAJOLE.getKey(), "1", useTpl, false);
    }

    // Add all UserPrefs
    UserPrefs prefs = context.getUserPrefs();
    for (UserPref up : gadget.getSpec().getUserPrefs().values()) {
      String name = up.getName();
      String data = prefs.getPref(name);
      if (data == null) {
        data = up.getDefaultValue();
      }

      boolean upInFragment = !view.needsUserPrefSubstitution();
View Full Code Here


    Iterator i = prefs.keys();
    while (i.hasNext()) {
      String key = (String)i.next();
      p.put(key, prefs.getString(key));
    }
    return new UserPrefs(p);
  }
View Full Code Here

      if (paramName.startsWith(USERPREF_PARAM_PREFIX)) {
        String prefName = paramName.substring(USERPREF_PARAM_PREFIX.length());
        prefs.put(prefName, req.getParameter(paramName));
      }
    }
    return new UserPrefs(prefs);
  }
View Full Code Here

    spec = new GadgetSpec(Uri.parse("#"), DEFAULT_XML);
  }

  public void testSubstitutions() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, USER_VALUE, OVERRIDE_NAME, OVERRIDE_VALUE);
    UserPrefs prefs = new UserPrefs(map);
    UserPrefSubstituter.addSubstitutions(substituter, spec, prefs);

    assertEquals(DEFAULT_VALUE,
        substituter.getSubstitution(Type.USER_PREF, DEFAULT_NAME));
    assertEquals(USER_VALUE,
View Full Code Here

        substituter.getSubstitution(Type.USER_PREF, OVERRIDE_NAME));
  }

  public void testEscaping() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, UNESCAPED_USER_VALUE);
    UserPrefs prefs = new UserPrefs(map);
    UserPrefSubstituter.addSubstitutions(substituter, spec, prefs);
    assertEquals(ESCAPED_USER_VALUE,
        substituter.getSubstitution(Type.USER_PREF, USER_NAME));
  }
View Full Code Here

                 "</Module>";
    GadgetSpec spec = new GadgetSpec(Uri.parse("#"), xml);
    GadgetContext context = new GadgetContext() {
      @Override
      public UserPrefs getUserPrefs() {
        return new UserPrefs(ImmutableMap.of("foo", "shindig"));
      }
    };

    spec = substituter.substitute(context, spec);
View Full Code Here

    addParam(uri, Param.COUNTRY.getKey(), context.getLocale().getCountry(), useTpl, false);
    addParam(uri, Param.DEBUG.getKey(), context.getDebug() ? "1" : "0", useTpl, false);
    addParam(uri, Param.NO_CACHE.getKey(), context.getIgnoreCache() ? "1" : "0", useTpl, false);
   
    // Add all UserPrefs
    UserPrefs prefs = context.getUserPrefs();
    for (UserPref up : gadget.getSpec().getUserPrefs()) {
      String name = up.getName();
      String data = prefs.getPref(name);
      if (data == null) {
        data = up.getDefaultValue();
      }
     
      boolean upInFragment = !view.needsUserPrefSubstitution();
View Full Code Here

        Iterator i = prefs.keys();
        while (i.hasNext()) {
            String key = (String) i.next();
            p.put(key, prefs.getString(key));
        }
        return new UserPrefs(p);
    }
View Full Code Here

  }

  @Test
  public void testSubstitutions() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, USER_VALUE, OVERRIDE_NAME, OVERRIDE_VALUE);
    UserPrefs prefs = new UserPrefs(map);
    UserPrefSubstituter.addSubstitutions(substituter, spec, prefs);

    assertEquals(DEFAULT_VALUE,
        substituter.getSubstitution(Type.USER_PREF, DEFAULT_NAME));
    assertEquals(USER_VALUE,
View Full Code Here

  }

  @Test
  public void testEscaping() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, UNESCAPED_USER_VALUE);
    UserPrefs prefs = new UserPrefs(map);
    UserPrefSubstituter.addSubstitutions(substituter, spec, prefs);
    assertEquals(ESCAPED_USER_VALUE,
        substituter.getSubstitution(Type.USER_PREF, USER_NAME));
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.UserPrefs

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.