protected void addDefaultUriParameters(UriBuilder uri, Gadget gadget, View view, boolean useTpl) { GadgetContext context = gadget.getContext(); String container = context.getContainer(); // Add container, whose input derived other components of the URI. uri.addQueryParameter(Param.CONTAINER.getKey(), container); // Add remaining non-url standard parameters, in templated or filled form. addParam(uri, Param.VIEW.getKey(), view.getName(), useTpl, false); addParam(uri, Param.LANG.getKey(), context.getLocale().getLanguage(), useTpl, false); 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); addParam(uri, Param.SANITIZE.getKey(), context.getSanitize() ? "1" : "0", useTpl, false); if (context.getCajoled()) { addParam(uri, Param.CAJOLE.getKey(), "1", useTpl, false); } }
protected void addExtrasForTypeUrl(UriBuilder uri, Gadget gadget, String container) { Set<String> features = gadget.getViewFeatures().keySet(); String jsHost = getReqVal(container, DefaultJsUriManager.JS_HOST_PARAM); String jsPathBase = getReqVal(container, DefaultJsUriManager.JS_PATH_PARAM); UriBuilder jsuri = null; if (features.size() > 0) { // We somewhat cheat in that jsHost may contain protocol/scheme as well. jsuri = new UriBuilder(Uri.parse(jsHost)); // Add JS info to path and set it in URI. StringBuilder builder = new StringBuilder(jsPathBase); if (!jsPathBase.endsWith("/")) { builder.append('/'); } builder.append(DefaultJsUriManager.addJsLibs(features)); builder.append(DefaultJsUriManager.JS_SUFFIX); jsuri.setPath(builder.toString()); } addParam(uri, Param.LIBS.getKey(), jsuri == null ? "" : jsuri.toString(), false, false); }
protected void addAllUserPrefs(UriBuilder uri, Gadget gadget, View view, boolean useTpl) { GadgetContext context = gadget.getContext(); 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(); addParam(uri, UriCommon.USER_PREF_PREFIX + up.getName(), data, useTpl, upInFragment); } }
addParam(uri, Param.VIEW.getKey(), view.getName(), useTpl, false); addParam(uri, Param.LANG.getKey(), context.getLocale().getLanguage(), useTpl, false); 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); addParam(uri, UriCommon.USER_PREF_PREFIX + up.getName(), data, useTpl, upInFragment); addParam(uri, Param.VERSION.getKey(), versioner.version(gadget.getSpec().getUrl(), container), false, false); addParam(uri, Param.SECURITY_TOKEN.getKey(), securityToken, securityToken == null, !securityTokenOnQuery);
addParam(uri, Param.VIEW.getKey(), view.getName(), useTpl, false); addParam(uri, Param.LANG.getKey(), context.getLocale().getLanguage(), useTpl, false); 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); addParam(uri, UriCommon.USER_PREF_PREFIX + up.getName(), data, useTpl, upInFragment); addParam(uri, Param.VERSION.getKey(), versioner.version(gadget.getSpec().getUrl(), container), false, false); addParam(uri, Param.SECURITY_TOKEN.getKey(), securityToken, securityToken == null, !securityTokenOnQuery);